Make Science Videos Start A Science Blog Get Project Help
Make Science Videos Get Project Help

How Robots Work: The Sense-Plan-Act Cycle Explained

Updated July 2026
Every robot, from a simple line-following toy to a surgical system operating inside a human body, works through the same fundamental cycle: sense the environment, plan what to do next, and act on that plan through physical movement. This sense-plan-act loop runs continuously, often hundreds or thousands of times per second, creating the illusion of smooth, intelligent behavior from what is actually a rapid sequence of discrete computational steps.

The Sense-Plan-Act Loop

The sense-plan-act (SPA) architecture is the most intuitive way to understand robot behavior. In the sensing phase, the robot gathers data about itself and its surroundings. In the planning phase, it processes that data and decides what to do. In the acting phase, it sends commands to its motors and actuators to carry out the plan. Then the cycle repeats.

Consider a warehouse robot tasked with picking a box from a shelf. In the sensing phase, cameras capture images of the shelf, a depth sensor measures the distance to each box, and encoders report the current position of every joint in the robot arm. In the planning phase, computer vision algorithms identify which box to pick, a grasp planner calculates the best grip position, and a motion planner computes a collision-free path from the arm's current position to the target. In the acting phase, the controller sends voltage commands to each motor, moving the arm along the planned path, closing the gripper around the box, and lifting it from the shelf.

This entire cycle might take 50 to 500 milliseconds, depending on the complexity of the task and the processing power available. The robot then senses its new state, plans its next move (perhaps carrying the box to a conveyor), and acts again. Thousands of these cycles compose what looks like a single, fluid picking operation.

Sensing: How Robots Perceive the World

Robots use two broad categories of sensors: proprioceptive sensors that measure the robot's own internal state, and exteroceptive sensors that measure the external environment.

Proprioceptive sensors include joint encoders (which report the angle of each revolute joint or the position of each linear joint), motor current sensors (which indicate how much torque each motor is producing), inertial measurement units or IMUs (which track orientation and acceleration), and force/torque sensors (which measure the forces and moments acting on the robot's structure). These sensors tell the robot where its body is and what it is doing.

Exteroceptive sensors include cameras (2D and stereo), LiDAR (which sends out laser pulses and measures how long they take to bounce back, building a 3D point cloud of the environment), ultrasonic sensors (which use sound waves for distance measurement), infrared proximity sensors, tactile sensors (which detect contact and pressure), and microphones. These sensors tell the robot what is happening outside its body.

Raw sensor data is rarely useful on its own. A camera produces millions of pixels; a LiDAR produces hundreds of thousands of 3D points; an IMU produces noisy acceleration readings. The robot's software must process, filter, and interpret this data before it becomes actionable information. This processing step, often called perception, is one of the hardest problems in robotics.

Planning: How Robots Decide What to Do

Planning in robotics happens at multiple levels, from high-level task planning (what sequence of actions to perform) down to low-level trajectory planning (what exact motor commands to send at each millisecond).

Task Planning

Task planning breaks a complex goal into a sequence of achievable steps. If the goal is "make a sandwich," the task planner must determine the steps: open the bread bag, remove two slices, open the peanut butter jar, pick up a knife, spread the peanut butter, and so on. Task planners use techniques from classical AI, including state-space search and hierarchical task networks. More recently, large language models have been used to generate task plans from natural language instructions.

Motion Planning

Motion planning computes a path from the robot's current configuration to a goal configuration while avoiding obstacles. For a robot arm with six joints, the configuration space is six-dimensional, and the planner must find a path through this space that does not result in any part of the arm colliding with anything in the environment. Common algorithms include RRT (Rapidly-exploring Random Trees), which builds a tree of random configurations and connects them to find a path, and PRM (Probabilistic Roadmap), which pre-computes a network of collision-free configurations. These algorithms are implemented in software libraries like MoveIt (for ROS) and OMPL (Open Motion Planning Library).

Trajectory Planning

Once a collision-free path is found, trajectory planning adds timing information: how fast the robot should move along each segment, where it should accelerate and decelerate, and how to coordinate the motion of all joints to produce smooth, efficient movement. Trajectory planning must respect physical constraints including maximum joint velocities, maximum accelerations, and maximum motor torques. A poorly planned trajectory wastes energy, causes vibrations, and can damage the robot or its payload.

Acting: Control Systems and Feedback

The control system is the software and hardware that translates planned trajectories into actual motor commands and continuously corrects for errors. Control is what makes the difference between a robot that moves precisely and one that flails unpredictably.

Open-Loop vs Closed-Loop Control

Open-loop control sends commands to motors without checking whether the desired result was achieved. A simple timer-based motor controller that runs a motor for exactly 2 seconds is open-loop. If something blocks the motor or the load is heavier than expected, the controller has no way to know or adjust.

Closed-loop (feedback) control continuously measures the actual state and adjusts commands to reduce the difference between the desired state and the actual state. Nearly all robots use closed-loop control because real-world conditions are never perfectly predictable. Friction, load variations, temperature changes, and mechanical wear all create discrepancies that only feedback can correct.

PID Control

The PID (Proportional-Integral-Derivative) controller is the workhorse of robot control. It calculates a control signal based on three terms. The proportional term produces a correction proportional to the current error (how far the actual position is from the desired position). The integral term accumulates past errors and corrects for persistent steady-state offset. The derivative term predicts future error based on the rate of change, providing damping that prevents overshooting the target.

A well-tuned PID controller can keep a robot arm's position error below 0.1 millimeters during motion. Tuning involves adjusting three gain parameters (Kp, Ki, Kd) to balance responsiveness against stability. Too much proportional gain causes oscillation. Too much integral gain causes slow, sluggish response. Too much derivative gain amplifies sensor noise. Finding the right balance is both science and art.

Advanced Control Methods

Model Predictive Control (MPC) uses a mathematical model of the robot to predict its future behavior over a short time horizon, then optimizes the control inputs to minimize a cost function (such as position error plus energy consumption). MPC can handle constraints explicitly and is used in advanced mobile robots, walking machines, and autonomous vehicles.

Impedance control regulates the relationship between force and motion rather than controlling position or force alone. A robot under impedance control behaves like a spring-damper system, allowing it to comply with external forces rather than fighting them rigidly. This is essential for tasks involving contact with the environment, such as polishing a surface, inserting a peg into a hole, or interacting safely with humans.

Adaptive control adjusts its parameters in real time to account for changing conditions, such as a robot arm picking up objects of unknown weight. The controller starts with an estimated model and updates it as the robot operates, maintaining performance even when conditions differ from expectations.

Kinematics and Dynamics

Kinematics describes the geometry of motion without considering forces. Forward kinematics calculates where the end effector (gripper, tool) will be given a set of joint angles. If the shoulder is rotated 30 degrees, the elbow is at 45 degrees, and the wrist is at 60 degrees, forward kinematics computes the resulting position and orientation of the gripper in 3D space. This is a straightforward trigonometric calculation.

Inverse kinematics solves the opposite problem: given a desired position and orientation of the end effector, what joint angles are needed to get there? This is much harder because there are often multiple solutions (different arm configurations that reach the same point) or no solution at all (the target is outside the workspace). Inverse kinematics algorithms must choose the best solution based on criteria like minimizing joint motion, avoiding singularities (configurations where the robot loses a degree of freedom), and maintaining smooth trajectories.

Dynamics adds forces and torques to the picture. The dynamic model describes how much force each motor must produce to achieve a desired acceleration at each joint, accounting for gravity, inertia, friction, and the interactions between joints (because accelerating one joint creates forces on all other joints). Accurate dynamic models enable feedforward control, where the controller precomputes the expected motor torques and adds feedback corrections on top, achieving much better performance than feedback alone.

Software Architecture

A working robot requires multiple software components running simultaneously: sensor drivers, perception algorithms, planners, controllers, safety monitors, user interfaces, and communication handlers. Organizing these components into a coherent system is a software architecture challenge.

The Robot Operating System (ROS), despite its name, is not an operating system but a middleware framework. ROS provides a publish-subscribe communication system (called topics) that allows software components (called nodes) to exchange data without being directly coupled to each other. A camera driver node publishes images, a perception node subscribes to those images and publishes detected objects, a planning node subscribes to detected objects and publishes motion plans, and a controller node subscribes to motion plans and sends commands to motors. Each node can be developed, tested, and replaced independently.

ROS also provides standard tools for visualization (RViz), simulation (Gazebo), data recording and playback (rosbag), and coordinate frame management (tf). ROS 2, the current version, adds real-time capabilities, improved security, and support for multi-robot systems. Most robotics research labs and an increasing number of commercial products use ROS as their software backbone.

Key Takeaway

Robots work by continuously cycling through sensing (gathering data), planning (deciding what to do), and acting (moving motors). Feedback control systems correct for real-world imperfections, kinematics translates between joint angles and end-effector positions, and software frameworks like ROS coordinate the dozens of software components that must work together in real time.