Math for Robotics · Lesson 03
Coordinate Systems
Est. 30–40 min
Why
Why “forward” is meaningless without a named frame
This lesson teaches you to draw and name right-handed frames, pick units, and express the same point in two frames that only differ by a shift.
Concept
The big idea: origin + oriented axes = a frame
- A coordinate system (frame) has an origin and oriented axes.
- Right-handed frames: x, y, z follow the right-hand rule (common in robotics).
- 2D lab sketch: +x right, +y up (math). Screens often flip y; many robots use +z up.
- Always name frames: {world}, {base}, {tool}, {camera}.
- Units: metres in serious stacks; hobby code often uses mm — pick one and stick to it.
How it works
How it actually works, step by step
Pick an origin
A nail in the desk, the robot base bolt pattern, the camera optical centre — mark it.
Pick axis directions
Decide +x, then +y (or +z up). Use the right-hand rule so everyone agrees.
Name the frame
Write {base} or {camera} on the sketch. Unnamed arrows cause night-shift bugs.
Express a point
Coordinates are always relative to a frame. “P = (3, 1.5) m in {world}” is complete; “(3, 1.5)” alone is not.
Visual
Visualise it: move and rotate a frame
Move and rotate frame F relative to world. A fixed local point maps to different world coordinates.
Interactive · Coordinate-frame manipulator
Point in world
(95.0, 77.7)
p_world = origin + R(θ) · p_local
Worked example
Worked example: same point, two platforms
Point P is at (3.0, 1.5) m in {world}. Frame {B}’s origin sits at (2.0, 0) m in world, axes parallel. Then in {B}, P is (1.0, 1.5) m.
Code lab
Code lab: map a point between frames
"""Stage 1 L03 — express the same point in world and in a shifted frame."""
# World origin at platform centre. Frame B is 2 m along +x (towards Platform B).
# Point P is at (3.0, 1.5) m in world.
px_w, py_w = 3.0, 1.5
ox_b, oy_b = 2.0, 0.0 # origin of B in world
# If B is only translated (no rotation): p_B = p_W - o_B
px_b = px_w - ox_b
py_b = py_w - oy_b
print("Point P in world: ({:.1f}, {:.1f}) m".format(px_w, py_w))
print("Origin of B in world: ({:.1f}, {:.1f}) m".format(ox_b, oy_b))
print("Same point P in B: ({:.1f}, {:.1f}) m".format(px_b, py_b))
print("Check: world = B_origin + p_B → ({:.1f}, {:.1f})".format(ox_b + px_b, oy_b + py_b))Expected output
Point P in world: (3.0, 1.5) m Origin of B in world: (2.0, 0.0) m Same point P in B: (1.0, 1.5) m Check: world = B_origin + p_B → (3.0, 1.5)
Real world
Frames you will name on a robot

- {world} / map frame on a mobile robot
- {base} bolted to the arm pedestal
- {tool} / {ee} at the gripper
- {camera} at the sensor optical frame
Mistakes
Common mistakes and confusions
Hardware & safety
Hardware lab and safety notes
Build a desk frame you can touch: a sheet of graph paper taped to the table with the origin marked in one corner. This is your {world} for the rest of Stage 1.
- Mark +x along the long edge and +y along the short edge; +z points up (right-hand rule).
- Place a second sheet (frame {B}) 20 cm along x, edges parallel. Put a coin on it and measure it in both frames.
- Write units on every number (cm or m). ROS uses metres (REP 103).
Debugging
Debugging: when it doesn’t work
| Symptom | Likely cause | Fix |
|---|---|---|
| Converted point is off by exactly the frame offset | Added o_B instead of subtracting | p_B = p_W − o_B (axes parallel) |
| Answer is 1000× off | Mixed mm and m | Pick one unit, convert at input |
| z comes out negative when it should be up | Left-handed axes | Use the right-hand rule: x × y = z |
| Two people get different answers | Frame not named or origin not marked | Write {frame} and origin on the page |
Think
Think about it
Think
A coworker says “the object is at x=0.2”. What three clarifying questions should you ask?
Experiment
Try it in the lab: name three frames
Experiment
Name three frames
You will need
- Desk or table
- Notebook
- Optional: sticky notes
Steps
- Pick a desk corner as {world} origin. Draw +x along the long edge, +y along the short edge.
- Place a water bottle. Measure its (x,y) in cm in {world}.
- Define {B} as another corner. Re-express the bottle in {B}.
- Label sticky notes: {world}, {B}, bottle.
Interactive · Coordinate-frame manipulator
Point in world
(95.0, 77.7)
p_world = origin + R(θ) · p_local
The bottle did not move — only the numbers changed with the frame.
Knowledge check
Check your understanding
Knowledge check
1. A coordinate frame needs at least…
2. Right-handed frames are common because…
3. Best habit when writing a point?
4. If {B} is only translated from world by o_B, then p_B = …
Practice quiz
Mini assignment
Hands-on assignment
Mini assignment
Frame legend
Draw a one-page legend for a desk-scale robot cell: {world}, {base}, {tool}, {camera} with origins and axis directions.
Deliverables
- Annotated sketch
- Unit choice stated
Do this, step by step
- Tape graph paper and mark {world}. Place frame {B} with origin at (20, 0) cm, axes parallel.
- Put a coin at any spot. Measure it in {world} and in {B}.
- Check: o_B + p_B should equal p_W. Note any error in mm.
- Edit
frames_map.pywith your numbers and confirm the script agrees.
Stuck? Hints, one at a time
- Hint 1: Measure from the marked origin, not from the paper edge.
- Hint 2: With parallel axes, only subtraction is needed: p_B = p_W − (20, 0).
- Hint 3: An error of 1–2 mm is normal from ruler reading; 20 cm means you used the wrong origin.
Challenges (pick by level)
- 🟢 Easy: Add frame {C} at (0, 15) cm and express the coin in it.
- 🟡 Medium: Repeat with all positions in metres and check the script still agrees.
- 🟠 Hard: Turn {B} by 90° on the desk. Why does subtraction alone now fail? (Lesson 7 fixes this.)
Next step
Next, Lesson 4: 2D Vectors — the arrows between those points. Related: ROS frame conventions in Stage 10 — ROS 2.
Sources
- Wikipedia — Cartesian coordinate system
- Wikipedia — Right-hand rule
- Wikipedia — Frame of reference
- ROS REP 103 — Standard units and coordinate conventions
- Photos: Wikimedia Commons (credits under each image).
Self-attested for now — keep artifacts in your lab notebook.
Complete
Today's goal
0 of 1 done today
Mark this lesson complete when you have worked the experiment, knowledge check, and assignment (even roughly).