intermediate

What a Robot Is: Sensing, Planning and Acting

Understand the loop that every robot runs: sensors that measure, a controller that decides and actuators that act; open and closed loops, degrees of freedom, control rates and latency budgets, the main robot types, and a quick tour of the parts and the tools on a Raspberry Pi or microcontroller used to check them.

60 min

1. The loop every robot runs

A robot is a machine that senses its surroundings or its own state, decides what to do and acts on the world, then repeats. Everything in this course supports that loop:

Stage Parts Examples
Sense Sensors Encoders (wheel position), IMU (tilt and rotation), distance sensors, cameras, current sensors, bump switches
Think Controller and software A microcontroller running a fast control loop, a Raspberry Pi running planning or vision
Act Actuators and drivers DC motors, servos, steppers, pumps, solenoids, grippers
Power and structure Batteries, regulators, frames Wheels, joints, chassis, wiring
Safety Stops, limits, guards Emergency stop, speed limits, current limits

A useful split: a microcontroller handles the fast, timing-critical loops (motor control, encoders, safety), and a Raspberry Pi or computer handles slower, heavier tasks (vision, planning, networking), as in the Pi and microcontroller lessons.

2. Open loop and closed loop

  • Open loop: send a command (run the motor at 50 percent for two seconds) and assume the result. Simple, but errors from load, battery voltage, slippage or friction go uncorrected.
  • Closed loop: measure the result (wheel speed from an encoder), compare it with the target and correct the output. This is the basis of the PID controller covered later.

Most useful robots mix them: open loop for simple actions, closed loop for speed, position and balance.

3. Degrees of freedom and robot types

A degree of freedom (DOF) is an independent way the mechanism can move. A rotating joint or a sliding joint each add one. A robot arm that can place and orient a gripper anywhere in its reach needs 6 DOF. A differential-drive rover moves in a plane with two controlled wheels, and cannot move sideways directly.

Type Example Main challenges
Mobile robots Wheeled rovers, line followers, delivery robots Odometry, obstacle avoidance, navigation, battery
Manipulators Robot arms and grippers Kinematics, torque, accuracy, safety
Legged and aerial Walkers, drones Balance, control rate, power
Mobile manipulators Arm on a rover All of the above together

4. Rates, latency and the time budget

The control rate (in hertz) sets the period: 100 Hz means a cycle every 10 ms. Within each cycle the robot must read sensors, compute, and write outputs. If the work takes longer than the period, the loop slips, and the robot reacts to old data. Write a time budget: for example 2 ms sensing, 3 ms computation, 1 ms output at 100 Hz uses 6 ms of 10 ms, leaving 40 percent margin.

Distances travelled during delays matter too: a robot moving at 500 mm/s with 100 ms of total latency travels 50 mm before the first correction.

5. Look at the hardware

When you build, always check what is connected before you write control code:

Lab: check the hardware before writing control code

Find the motor controller's serial port, scan the I2C bus for sensors, list serial ports and check that the Pi's power is healthy.

Objectives

  • List USB serial devices to find the motor controller board.
  • Scan I2C bus 1 for sensors such as an IMU.
  • List serial ports with descriptions.
  • Check the Pi for under-voltage or throttling before running motors.
Console - student@robot-pi:~$
Practice terminal: it checks the commands you type and shows example output. It is not connected to a real device.
Work through the objectives on the left.
Stuck? Type "?" to see the current objective, or "hint" to reveal the command.
student@robot-pi:~$

(The outputs above are examples of the format. Real output varies by software version and setup.)

6. A sensible way to build

  1. Safety first: add a stop and limits before motion (next lesson).
  2. Move one thing at a time: test the motor, then the sensor, then the loop.
  3. Measure: log sensor values and loop times.
  4. Test slowly, with the wheels off the ground or the arm at low speed.
  5. Document wiring, parameters and results as you go.

7. On your bench

  1. Draw the sense-think-act loop for a robot you want to build and list the part for each box.
  2. Count the degrees of freedom of a toy arm or rover and write what each one does.
  3. Write a time budget for a 100 Hz control loop and measure the real loop time on your board.
  4. Compare open loop and closed loop speed control: run a motor at the same PWM with a light and a heavy load and watch the speed.
  5. Check your hardware with the commands above and write down every device and its address.

8. Hands-on lab: loop rates, budgets and robot basics

Control period, time budget, travel during latency, DOF and loop type — Python 3
WHAT TO DO
control_period_ms(hz): the control loop period in whole milliseconds: 1000 divided by the rate, rounded down. loop_ok(sense_ms, plan_ms, act_ms, period_ms): True when the three stages together take no longer than the period. load_percent(busy_ms, period_ms): the share of the period used, as a whole percent rounded down. travel_mm(speed_mm_s, latency_ms): distance travelled during the latency, in whole millimetres, rounded down. dof(joints_csv): the number of degrees of freedom of a mechanism whose independent joints are listed in a comma separated text such as "rev,rev,prism" (each listed joint adds one). An empty text has 0. loop_type(has_feedback): "closed" when there is feedback, otherwise "open". sensor_for(kind): "distance" -> "ultrasonic or tof", "rotation" -> "encoder", "orientation" -> "imu", "line" -> "reflectance", anything else -> "unknown".
YOUR CODE (edit here, then press Run)
Ctrl/⌘ + Enter
OUTPUT

9. Common mistakes

Mistake Better
Writing control code before checking the hardware Scan buses, check ports and power first
Open loop for everything Close the loop where load and battery vary
A loop that sometimes takes longer than its period Budget and measure the time of every stage
Ignoring latency in fast motion Calculate the distance covered during delays
Doing everything on one computer Fast control on a microcontroller, heavy work on the Pi
Testing at full speed first Wheels off the ground and low speed first
No stop or limits Safety before motion
No logging Log sensor values and loop times

10. Key takeaways

  • A robot senses, thinks and acts in a loop; know the part for each stage.
  • Closed loops use feedback to correct errors; open loops assume the result.
  • DOF counts independent joint motions; a 6 DOF arm can place and orient a tool.
  • The control period is 1/rate; sensing, computing and outputs must fit with margin.
  • Latency times speed is distance travelled blind; check hardware and power before running motors.
A rover at 400 mm/s runs a loop with 80 ms of total latency. How far does it travel before it can react, and why does that matter?

400 mm/s x 0.08 s = 32 mm. If an obstacle appears closer than that plus the stopping distance, the robot hits it. Reduce latency, slow down, or add margin to safe speeds.

Can You Explain It?

Close the lesson and answer these without looking back. The goal isn't the wording — it's whether you've formed a usable mental model.

  • Explain the sense-think-act loop and give a part for each stage.
  • Describe the difference between open and closed loop control with an example.
  • Say how you would write a time budget for a 100 Hz control loop.

🧪 Want to practise this on your own computer? See how to set up your lab →

📝

Knowledge Check

1 of 4

What makes a control loop closed?

Official References

Report a problem

About: /lessons/rob-what-a-robot-is-sensing-planning-and-acting