Question
An extended state machine describing a traffic light at a pedestrian crosswalk is shown above. This is a time triggered machine that assumes it will
An extended state machine describing a traffic light at a pedestrian crosswalk is shown above. This is a time triggered machine that assumes it will react once per second. It starts in the red state and counts 60 seconds with the help of the variable count. It then transitions to green, where it will remain until the pure input pedestrian is present. That input could be generated, for example, by a pedestrian pushing a button to request a walk light. When pedestrian is present, the machine transitions to yellow if it has been in state green for at least 60 seconds. Otherwise, it transitions to pending, where it stays for the remainder of the 60 second interval. This ensures that once the light goes green, it stays green for at least 60 seconds. At the end of 60 seconds, it will transition to yellow, where it will remain for 5 seconds before transitioning back to red. The outputs produced by this machine are sigG to turn on the green light, sigY to change the light to yellow, and sigR to change the light to red.
Please write a simulation in Python using the above formula to simulate the traffic light for 200 seconds with a scenario where a pedestrian is present at 70. second
Your simulation shall have a one second step size.
Your simulation shall log every second (in simulation time) time, inputs. system state and the outputs to console.
Figure 3.10: Extended state machine model of a traffic light controller that keeps track of the passage of time, assuming it reacts at regular intervalsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started