01

Drive the joint

The dashed teal arm is where the command alone assumes the joint is. The solid yellow arm is where the hardware really is. Add load or block the joint, and the two separate. The red arc is the gap between them. Only the state interface tells the truth.

Joint and control loop

Interactive
read()→update()→write()one cycle of the controller manager
- - - command (assumed)—— state (real joint)arc gap between them
COMMAND velocity0.00
STATE velocity0.00
STATE position0.00
GAP (cmd - state)0.00
Command: velocity 1.50 rad/s
Load on the joint 0%
The interactive part has not started yet. If this message stays, the site is blocking or delaying the script in this block.
02

Two lines, one story

The command is a step the controller chooses. The state is what comes back, always a little late, and lower when there is load. Position is the running total of velocity, so a small speed gap becomes a growing position gap.

Last 10 seconds

Live
- - - command / position assumed from command—— state (measured)
03

In the robot description

A joint declares which interfaces it offers. Controllers write command interfaces and read state interfaces. Hover, focus or tap a line and the panel beside it shows who writes that value, who reads it, and its live number.

my_robot.ros2_control.xacro

Hover
<ros2_control name="MyRobot" type="system">  <joint name="joint1">    <command_interface name="velocity"/>    <state_interface name="position"/>    <state_interface name="velocity"/>  </joint></ros2_control>
command_interfacevelocity
Controller → write() Hardware

The controller writes this number every cycle. It is a wish. It says nothing about what the joint is really doing.

now: +1.50 rad/s
state_interfaceposition
Hardware → read() Controller

The hardware reports this after reading its sensors. It is a measurement of where the joint is.

now: 0.00 rad
state_interfacevelocity
Hardware → read() Controller

The measured speed. Same unit as the command, but a different meaning: what is happening, not what was asked.

now: 0.00 rad/s
SideQuestionWho writes, who readsTagHere
Command"What do I want?"Controller writes, hardware reads<command_interface>velocity
State"What is happening?"Hardware writes, controller reads<state_interface>position, velocity
04

Sort it out

Is each item a command or a state?