GLOBAL KNOWLEDGE ARK

Robotics & Mechatronics · Embedded execution and hardware contracts

Read a minimal robot control loop

A small robot loop can be understood as repeated decisions over a record. You do not need to write software to trace its outputs, but you do need to know which value is read, which condition is checked and what state is remembered.

All numerical tables, scenarios and records are original constructed teaching data unless a specific external dataset is named. No physical experiment is claimed. A worked simulation model is distinguished from an executed simulator.

Lesson preparation and course links

Use the local explanations and supplied units, diagrams, tables and examples; advanced chapters build on the named local chapters. External links are point-of-need depth, not a requirement to finish an entire map.

Back to the Robotics chapter

After reading, you can

Introduce locally the variables, branch decisions and repeated update needed to inspect a small robot task; keep a trace-table alternative for learners not yet writing code.

01

Read names as quantities and remembered state

A variable is a named stored value. Here x_mm is a measured position in millimetres, fresh is a validity decision and state is one of READY, MOVE, STOP_REQUESTED or FAULT. A condition chooses a branch. Repeating the update means read inputs again, make the next decision and send the resulting output.

The order matters. Validate required input before comparing it with a threshold. Use the same acquired snapshot for that decision; otherwise the freshness flag and position could describe different messages. A state remembers that a stop has already been requested.

02

Trace a supplied decision loop

This pseudocode is an original teaching state machine, not deployable equipment control. Stop/fault outputs refer to the module’s declared response.

Trace a supplied decision loop
OrderRule
1Read one snapshot: position, acquisition time, reference, quality
2If required snapshot invalid: state ← FAULT; output ← declared fault response
3Else if state=MOVE and x_mm≥70: state ← STOP_REQUESTED; output ← normal stop
4Else if state=MOVE: output ← +20 mm/s
5Else: preserve the defined non-moving/latched state output
6Record snapshot identity, chosen branch, state and output
03

Run the loop on paper

Initial state is MOVE. Later valid values do not clear a latched FAULT.

Run the loop on paper
Input x / mmFresh?Prior stateNext state/output
68YesMOVEMOVE; +20 mm/s
69NoMOVEFAULT; declared fault response
72YesFAULTFAULT remains; no automatic MOVE
70YesMOVE in a separate testSTOP_REQUESTED; normal stop
04

Check the equality and the invalid case

The threshold is inclusive:70 satisfies x≥70. Using x>70 changes the boundary. A missing value must not default to 0 mm and trigger the below-threshold branch. Define numerical range checks and clock/reference validity before using x.

A stopped state must not return to MOVE merely because a later measurement drops below 70. A new task requires its own acceptance path. This small loop illustrates execution semantics; real protective functions and certified controllers have separate design and evidence requirements.

05

Use a trace table as a programming alternative

Cover the output column, predict each row and then compare. Explain the first row where your prediction differs. In a simulation, replay the same snapshots and compare logged branch/state/output with the paper result. Matching this trace establishes the implemented decision for these inputs, not every possible program path.

Keep the input sequence, initial state and reset/new-task rules. A program listing without its initial state can have several legitimate traces.

Repair a plausible-looking loop

An incorrect loop first tests x<70 and sends MOVE, then checks freshness. With stale x=68 it can issue one extra movement command before recording a fault. Reorder validity ahead of the threshold decision and ensure only one final output is committed per update.

For a 20 mm/s ideal segment, one unintended 20 ms update corresponds to 0.4 mm additional command-time travel. Actual response depends on device dynamics and delay; the arithmetic explains why update order can matter.

Try the reasoning

  1. Why does x=70 take the stop branch?

    Show the answer and reasoning

    The supplied condition is x≥70, inclusive of equality.

  2. Why retain state after the threshold?

    Show the answer and reasoning

    It prevents later low/noisy values from automatically restarting the task.

  3. What is a snapshot in this loop?

    Show the answer and reasoning

    A coherent acquired record whose position, time, reference and quality belong together.

  4. Can the paper route establish understanding without writing code?

    Show the answer and reasoning

    Yes. Predicting branches, state and outputs for valid/boundary/fault cases demonstrates the same decision reasoning.

What to carry forward

Read, validate, decide, commit and record. Trace tables expose robot-loop logic without requiring a programming curriculum.

References

Sources supporting this lesson’s explanations and examples.

  1. ros2_control: Hardware Components and hardware interface typesros2_control contributorsOfficial software documentationKilted, displayed October 2026 documentationcontrol.ros.orgRead source
  2. Gazebo Jetty: SensorsGazebo contributorsOfficial simulation tutorialJetty versioned documentationgazebosim.orgRead source