File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ from statemachine import StateMachine , State
2
+
3
+ class Car (StateMachine ):
4
+ # State Machine for the Cooper Union Intelligent Ground Vehicle
5
+ Lane_Following = State ("LF" )
6
+ Lane_Change = State ("LC" )
7
+ # C stop is Controlled, E stop is Emergency
8
+ Cstop = State ("CS" ,initial = True )
9
+ Estop = State ("ES" ,final = True )
10
+
11
+
12
+ Resume = Cstop .to (Lane_Following )
13
+ Obj_Avoidance = Lane_Following .to (Lane_Change )
14
+ Stop_Trigger = Lane_Following .to (Cstop ) | Lane_Change .to (Cstop )
15
+ Emergency_Trigger = (
16
+ Lane_Following .to (Estop )
17
+ | Lane_Change .to (Estop )
18
+ | Cstop .to (Estop )
19
+ )
20
+ Return_To_Follow = Lane_Change .to (Lane_Following )
21
+
22
+ #The Lane Follow State
23
+ @Lane_Following .enter
24
+ def Follow ():
25
+ print ("Following Lanes" )
26
+
27
+
28
+ @Cstop .enter
29
+ def on_CStop ():
30
+ print ("Car is Stopped temporarily" )
31
+
32
+ @Estop .enter
33
+ def on_EStop ():
34
+ print ("UH OH" )
35
+
36
+ if "__name__" == "__main__" :
37
+ test_machin = Car ()
38
+ img_path = "visualizer.png"
39
+ test_machin ._graph ().write_png (img_path )
You can’t perform that action at this time.
0 commit comments