Skip to content

Commit 4ef4e22

Browse files
committed
state machine update
1 parent 7a74c61 commit 4ef4e22

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

MissionPlanning/StateMachine/robot_behavior_case.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
A case study of robot behavior using state machine
3+
4+
author: Wang Zheng (@Aglargil)
5+
"""
6+
17
from state_machine import StateMachine
28

39

MissionPlanning/StateMachine/state_machine.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
State Machine
3+
4+
author: Wang Zheng (@Aglargil)
5+
6+
Ref:
7+
8+
- [State Machine]
9+
(https://en.wikipedia.org/wiki/Finite-state_machine)
10+
"""
11+
112
from collections.abc import Callable
213

314

@@ -47,7 +58,7 @@ def __init__(self, name: str, model=object):
4758
self._events = {}
4859
self._transition_table = {}
4960
self._model = model
50-
self._state: StateMachine = None
61+
self._state: State = None
5162

5263
def _register_event(self, event: str):
5364
self._events[event] = event
@@ -211,8 +222,8 @@ def generate_plantuml(self) -> str:
211222
if self._state is None:
212223
raise ValueError("State machine is not initialized")
213224

214-
plantuml = ["@startuml"]
215-
plantuml.append("[*] --> " + self._state.name)
225+
plant_uml = ["@startuml"]
226+
plant_uml.append("[*] --> " + self._state.name)
216227

217228
# Generate transitions
218229
for (src_state, event), (
@@ -234,7 +245,7 @@ def generate_plantuml(self) -> str:
234245
if conditions:
235246
transition += "\\n" + " ".join(conditions)
236247

237-
plantuml.append(transition)
248+
plant_uml.append(transition)
238249

239-
plantuml.append("@enduml")
240-
return "\n".join(plantuml)
250+
plant_uml.append("@enduml")
251+
return "\n".join(plant_uml)

docs/modules/13_mission_planning/mission_planning_main.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Mission Planning
44
================
55

6-
Mission planning includes tools such as finite state machines and behavior trees used to describe robot behavior.
6+
Mission planning includes tools such as finite state machines and behavior trees used to describe robot behavior and high level task planning.
77

88
.. toctree::
99
:maxdepth: 2

0 commit comments

Comments
 (0)