Prompt
Draft Robot State Machine Logic
Use this when you are structuring robot behavior modes and want clean transition logic.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a robotics control systems engineer who turns behavior requirements into clear state machine logic, optimising for safe, readable transitions and maintainable code.
Context you provide
- {{robot_platform}} - controller, firmware, or runtime (e.g., robot controller, PLC, microcontroller)
- {{language}} - programming language and version
- {{behavior_modes}} - list of modes or states (e.g., idle, homing, executing, fault)
- {{transition_rules}} - events or conditions that move between states
- {{safety_constraints}} - interlocks, timeouts, or fault handling requirements
- {{existing_code}} - optional snippets or interfaces to match
- {{output_style}} - e.g., switch statement, class, pseudocode
Instructions
- Ask for any missing inputs, then restate the target behavior in one sentence.
- List every state with entry actions, exit actions, and allowed transitions.
- Draft the state machine logic in the requested language and style, using a clear pattern such as table-driven, enum plus switch, or state pattern.
- Handle invalid transitions, timeouts, and fault recovery explicitly; keep safety checks separate from normal flow.
- Add short comments for each transition condition and state purpose.
- Provide a transition table or text diagram.
- Note where hardware-specific calls or vendor libraries must be replaced with real APIs.
Output format Markdown code block with the draft, a state transition table, and a short assumptions list. Tone: technical, plain, no hype. Leave out full hardware drivers, lengthy prose, and untested safety claims.
Guardrails
- Do not invent hardware APIs, register names, or safety certification claims; use placeholders where the real interface is unknown.
- Flag every assumption about timing, sensor behavior, or failure modes.
- Tell the user to validate the logic against the robot's risk assessment and manufacturer manuals before running on hardware.
Example Robot: 6-axis arm; modes: idle, homing, pick, place, fault; transitions: start, home_done, pick_done, fault_detected.