Section4.1Introduction to Reactive Control and State Machines
In Chapter 3, we studied global path planning algorithms like A*, which calculate an entire path from start to goal before the robot ever turns its wheels. This global approach works well in static, fully known environments. However, real-world environments are dynamic and unpredictable: a human worker walks across a factory floor, a soccer ball rolls into a VEX competition lane, or a door closes unexpectedly.
Reactive Navigation focuses on rapid, local decision-making. Instead of storing a full map or computing complex paths, a reactive robot reads its real-time sensor data and immediately maps those inputs directly to actuator commands: sensors such as distance and IR readings feed into behavior logic built from if/elif/else rules, which in turn drives the actuators (drive motors) directly, with no map or planner in between.
Real-World Example (Warehouse AGVs & Vacuum Robots): Automated Guided Vehicles (AGVs) in Amazon fulfillment centers use global planners to navigate between aisles. However, if a box falls off a shelf into the robotβs path, a high-frequency reactive loop triggers an instant emergency stop or quick dodge without waiting for the central server to re-calculate a whole new map.
VEX Robotics Example (Over Under / High Stakes Competitions): During the autonomous period, a VEX robot driving toward a scoring zone might detect another robot blocking its path via its VEX Distance Sensor. A reactive behavior allows the VEX robot to pivot or back off instantly to avoid an illegal collision or entanglement penalty, regardless of its original pre-programmed trajectory.
Subsection4.1.2Structuring Reactive Logic: Finite State Machines (FSM)
When writing reactive code, raw if/else statements can quickly turn into disorganized "spaghetti code." To prevent this, roboticists organize reactive control using a Finite State Machine (FSM).
An FSM breaks the robotβs behavior into a set of discrete, mutually exclusive states (e.g., DRIVE_FORWARD, TURN_LEFT, REVERSE). The robot remains in its current state until a specific sensor reading triggers a transition to a new state.
Consider a two-state FSM built from just DRIVE_FORWARD and TURN_LEFT. While in DRIVE_FORWARD, the robot keeps driving forward as long as the front distance reading stays at or above 0.5 meters; the moment that distance drops below 0.5 meters, it transitions to TURN_LEFT. While in TURN_LEFT, the robot keeps turning in place as long as the front distance stays below 0.5 meters; once the distance rises back to 0.5 meters or more, it transitions back to DRIVE_FORWARD.
Isolation: You only need to think about what the robot should do right now in its active state (e.g., while in TURN_LEFT, the motors are set to spin in place).
Predictable Transitions: State changes happen strictly based on explicit conditions (e.g., distance < 0.5m), making troubleshooting simple during VEX lab testing.
Global path planning algorithms calculate paths faster than FSMs.
Incorrect. Global planners are computationally heavier and take longer to re-compute than simple state transitions.
Reactive FSMs respond immediately to immediate sensor changes without needing a full pre-computed map.
Correct! Reactive state machines allow robots to immediately react to unpredictable local changes (like moving obstacles) without needing a pre-built map.
FSMs remember the exact 3D shape of every obstacle they encounter.
Incorrect. FSMs are memoryless reactive loops; they do not construct 3D maps.
FSMs do not require any sensors to make decisions.
Incorrect. Reactive control relies heavily on real-time sensor feedback.