Chapter 02 · Turn the maths into robot motion
Today in the field story
One problem, then the next
The tray check passes, but the Camera-Crane Recovery now spans room, crane base, shoulder, and camera frames. Draw one directed transform per neighboring pair and walk the path with matching labels. Reverse the route using a true rigid inverse, then test a physical point forward and back. This is the diagnostic that distinguishes a valid number from a valid frame-chain result.
- Why now
The camera location depends on several local relationships whose order and direction must be checkable.
- Ignore today
Ignore tf2 APIs and buffering; prove the static chain with paper and arithmetic first.
- Unlocks next
Time-aware transform lookup and robot-model audits in later ROS chapters.
Understand
Build the physical picture first
A frame chain is a route through several local maps. Each transform is one trusted direction between neighbouring maps. Composition walks the route forward; inversion turns one arrow around.
Robots attach coordinate frames to the room, mobile base, arm links, camera, lidar, and tool. A point measured by a camera cannot be used as a map point until the chain between those frames is known. Writing a transform as T_AB means: it converts coordinates described in frame B into coordinates described in frame A. The labels are part of the value, not decoration.
Adjacent frame labels show legal composition. T_AB T_BC = T_AC because the inner B labels meet. With column vectors, the rightmost transform acts first: a C-frame point first enters B, then A. This resembles typed function composition: the output frame of one operation must match the input frame of the next.
The inverse T_BA = T_AB⁻¹ travels backward. For a rotated rigid transform, inversion is not simply negating the translation. The correct inverse rotation is Rᵀ and the inverse translation is -Rᵀt, because the old translation must first be expressed along the reversed axes. A forward-and-back identity test catches many direction errors.
A frame tree gives one parent to each child, which creates one unambiguous path between frames. Real robot transforms are also time-dependent: a mathematically valid base-to-camera relationship at the wrong timestamp can describe a different physical pose. Later tf2 work will combine the same path logic with a time buffer.
Words you need
Name each idea precisely
- Frame tree
A connected hierarchy of coordinate frames with one parent per child.
Physical example:room → rover base → camera mount → camera lens.
- Composition
Combining compatible transforms in order to relate more distant frames.
Physical example:Room-to-rover combined with rover-to-camera gives room-to-camera.
- Inverse transform
The rigid transform that reverses a frame relationship.
Physical example:Camera-to-rover undoes rover-to-camera.
- Identity transform
A transform with no rotation and no translation.
Physical example:Following room→camera→room should return every test point unchanged.
- Timestamp
The physical instant for which a changing transform or measurement is valid.
Physical example:A moving rover's camera pose at 10:00:01 is not its pose at 10:00:03.
Visual model
See the relationship
Math, one line at a time
Work through today’s relationship
Prerequisite rescue · optionalStart at zero: turns, triangles, and pose chains
A joint turn becomes a tool position only after we define the angle, split a link into horizontal and vertical parts, and follow frame order.
- θ
- theta: the amount a joint has turnedUnit: degrees (°) or radians (rad)
- cos θ, sin θ
- horizontal and vertical fractions of a turned unit linkUnit: no unit
- Tᴬ_B
- position and direction of frame B described by frame AUnit: unitless rotation + metres
A full turn is 360° = 2π rad, so 90° × π/180 = π/2 rad. π is about 3.1416.
For a 1 m link at 90°, x = 1 cos 90° = 0 m and y = 1 sin 90° = 1 m.
For several frames, follow the physical path in order. Multiply transforms only when the touching frame names match, then verify by reversing the path.
Like nested UI transforms, each child inherits its parent's transform; unlike UI, the order can move metal into an obstacle.
What are x and y for a 2 m link at 0 rad?
x = 2 cos 0 = 2 m; y = 2 sin 0 = 0 m.
Follow adjacent frame names:
A rigid transform inverse undoes the motion:
For aligned translations, .
Compose and reverse an aligned frame chain
All axes are aligned. The rover base is at (2.0,1.0) m in the room, and the camera is at (0.30,0.20) m in the rover base.
Name the relationships: t_room,base=(2.0,1.0) m and t_base,camera=(0.30,0.20) m.
Check that the chain room→base→camera is continuous.
Because the axes are aligned in this special case, add translations: t_room,camera=(2.30,1.20) m.
A point 0.50 m along camera +x is therefore at (2.80,1.20) m in the room.
Reverse the camera offset: t_camera,base=(-0.30,-0.20) m only because there is no rotation here.
Subtract the full room→camera translation from the room point and recover camera point (0.50,0.00) m.
The camera origin is (2.30,1.20) m in the room, and the test point round trip returns (0.50,0.00) m.
Frame labels determine legal order. Simple translation addition is valid only when axes are aligned; rotated inverses need Rᵀ and -Rᵀt.
Physical examples
Where this appears in real life
Camera on a robot mast
The map tracks the mobile base. A rigid bracket fixes a mast to the base, and a camera is bolted to the mast.
The marker observation must pass camera→mast→base→map; skipping the bracket offset produces a systematic location error.
Gripper holding a barcode scanner
The arm controller knows base→wrist, and calibration gives wrist→scanner. The scanner reports a box face in its own frame.
Compose the full path at the observation time, then verify scanner→base→scanner returns the original box point.
Hands-on exercise
Make the idea observable
Use a toy car or cardboard rectangle, a small paper camera, graph paper, a ruler, and removable tape.
Draw room, car, and camera frames with different coloured axes.
Measure room→car and car→camera translations with all axes initially aligned.
Predict the camera origin and one camera-local point in room coordinates, then measure both.
Rotate the car 90°, redraw the chain, and predict again using rotation before translation.
Apply the inverse chain to the measured room point and calculate the recovered camera-local point.
Swap one transform direction deliberately; record the wrong result and the frame-label mismatch.
The camera bracket stays fixed in the car frame while its room direction changes with the car. The round trip exposes order or inverse mistakes.
Both aligned and rotated cases have named transforms, measured errors, and a forward→inverse residual of at most 2 mm on paper.
Build today
Extend the browser notebook into a two-link arm visualizer with frame composition, forward kinematics, and a bounded numerical IK trace.
Evidence to save
DONE when “Compose and invert transforms through a frame tree” runs from one documented command and the nominal plus boundary outputs are attached.
Common mistakes
Catch the wrong mental model
Multiplying transforms in visual left-to-right reading order without checking frame labels.
Use column-vector semantics and make adjacent inner frame labels match before calculating.
Reversing a rotated transform by changing t to -t.
Use R⁻¹=Rᵀ and t_inverse=-Rᵀt.
Publishing two parents for the same child frame.
Keep the transform graph a tree or define an explicit estimation/fusion boundary.
Combining a sensor measurement with the latest transform instead of the measurement-time transform.
Use the measurement timestamp and reject or handle unavailable/extrapolated transforms explicitly.
Job connection
How this becomes employable evidence
During sensor bring-up, a valid camera detection appears consistently offset on the map. The engineer traces the live frame path, verifies transform direction and timestamp, measures the mount, and proves the fix with a round-trip and a known target.
Relevant target roles
- Robotics Deployment, Integration & Validation Engineer
- Robotics Application / ROS 2 Integration Engineer
- Robotics Software Engineer — ROS 2 / AMR
Chapter 02 interview drill
Interview questions: Compose and invert transforms through a frame tree
Practise a 60–90 second answer: define the idea, connect it to a physical robot, state assumptions, frames, and units when relevant, then finish with the failure signal or evidence you would inspect.
Primary interview scenario
Explain why T_map,base T_camera,base is not a legal map→camera composition, and describe the exact transform or inverse you need instead.
Answer shape: clarify the situation → trace the physical and software path → test the most likely boundaries → name the evidence that would confirm the result.
Technical follow-up questions
Q1What does T_AB do under the convention used here?
It converts coordinates expressed in frame B into coordinates expressed in frame A.
Q2What identity should a transform and its inverse satisfy?
T_AB T_BA = I and T_BA T_AB = I, within numerical tolerance.
Q3Why can a correct frame path still produce a wrong physical point?
The transform may refer to the wrong time, use incorrect calibration, or mix physical units.