Create state machine implementation with states, transitions, events, and lifecycle management for robotics behavior. Use when implementing robot behavior control, finite state machines, state transitions, python-statemachine, or ROS 2 lifecycle integration.
Generate state machine implementation with states, transitions, events, and lifecycle management following robotics behavior patterns.
robot_behavior, motion_controlidle,walking,turning,stopped)cpppythonAt least 2 states. State names: valid identifiers (lowercase, underscores). Initial state in list.
Python: <package>/<package>/<machine_name>_sm.py. C++: src/<machine_name>_sm.cpp, include/<package>/<machine_name>_sm.hpp.
Generate default transitions. Document: states, transitions, events.
Use statemachine library. Define State (initial=True for initial), to() for transitions. on_enter_<state>, on_exit_<state>, before_<transition>, on_<transition>. process_event() maps events to transitions. Reference: packages/runtime/drqp_brain/.
Header: enum State, enum Event, to_string() helpers, StateMachine class with process_event(), callbacks. Implementation: setup_transitions(), execute_transition(), entry/exit callbacks.
Node wrapper: publishers for state, subscribers for events, timer for state publishing. Topics: /<machine_name>/state, /<machine_name>/event.
Test initial state, valid transition, invalid transition, state sequence, entry/exit callbacks.
Add Mermaid diagram to README: stateDiagram-v2, states, transitions.
Include new files in CMakeLists.txt or setup.py.
packages/runtime/drqp_brain/