generated from Tino-FRC-2473/FSMBotTemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Assignment 1: Traffic Light | ||
|
||
The first step is to implement the traffic light cycling from green, to yellow, then to red. | ||
|
||
## Requirements | ||
The traffic light starts with only the green light illuminated. When the crosswalk button is pressed (goes low), the light immediately switches to yellow. Three seconds later, the light turns red. Five seconds after the light turns red, the light resets to green. | ||
|
||
## State Machine | ||
|
||
The provided starter code only cycles between green and red. We need to add in another state for the yellow light. Modify the state diagram below to add in the appropriate state and transitions. Make sure to include the conditions for when transitions happen. See the [Mermaid diagramming language docs](https://mermaid.js.org/syntax/stateDiagram.html) for more details on the syntax. | ||
|
||
```mermaid | ||
--- | ||
title: (EDIT ME) Traffic Light State Diagram | ||
--- | ||
stateDiagram-v2 | ||
state "Green Light" as GREEN_LIGHT_STATE | ||
state "Red Light" as RED_LIGHT_STATE | ||
[*] --> GREEN_LIGHT_STATE | ||
GREEN_LIGHT_STATE --> RED_LIGHT_STATE: Button pressed | ||
RED_LIGHT_STATE --> GREEN_LIGHT_STATE: Timer > 5 seconds | ||
``` | ||
|
||
## Implementation | ||
|
||
Next, modify the code in `TrafficLightSystem.java` to implement your state machine. Run the code in the simulator and verify that the timings are working as expected. When your implementation is working in simulator, demonstrate your code to a mentor on the test board to complete this assignment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Assignment 2: Crosswalk Signal | ||
|
||
Now that we have the main traffic light cycling, it is time to implement the crosswalk walk/don't walk sign. | ||
|
||
## Requirements | ||
* If the main traffic light is yellow or green, the "don't walk" sign must remain lit with an orange light and the "walk" sign must be dark. | ||
* After the main traffic light turns red, turn off the "don't walk" sign and immediately light up the "walk" sign with a white light for three seconds. Then turn off the "walk" sign and start flashing the orange "don't walk" sign every second for the next eight seconds. | ||
* After these eight seconds, the main traffic light turns green. | ||
|
||
See the [Caltrans Manual on Uniform Traffic Control Devices](https://dot.ca.gov/programs/safety-programs/camutcd), Part 4 Section 4E.06: "Pedestrian Intervals and Signal Phases" if you want to see the full requirements for an actual traffic light. | ||
|
||
## State Machine | ||
|
||
Copy in your the state diagram from Exercise 1, then add in the appropriate states and transitions to implement the crosswalk signal. Make sure to include the conditions for when transitions happen, and annotate what lights should be on/off in each state. See the [Mermaid diagramming language docs](https://mermaid.js.org/syntax/stateDiagram.html) for more details on the syntax. | ||
|
||
```mermaid | ||
--- | ||
title: (EDIT ME) Traffic Light with Crosswalk State Diagram | ||
--- | ||
stateDiagram-v2 | ||
state "Green Light" as GREEN_LIGHT_STATE | ||
state "Red Light" as RED_LIGHT_STATE | ||
[*] --> GREEN_LIGHT_STATE | ||
GREEN_LIGHT_STATE --> RED_LIGHT_STATE: Button pressed | ||
RED_LIGHT_STATE --> GREEN_LIGHT_STATE: Timer > 5 seconds | ||
``` | ||
|
||
## Implementation | ||
|
||
Next, modify the code in `TrafficLightSystem.java` to implement your state machine. Run the code in the simulator and verify that the timings are working as expected. When your implementation is working in simulator, demonstrate your code to a mentor on the test board to complete this assignment. |