Spatial AI & Autonomous Robotics Coordinate Frames (ROS 2)

Ask a robotics team what their hardest bugs were, and coordinate frames will be on the list. Not the algorithms — the frames: a yaw sign flipped between conventions, a transform read 100 ms too late, a camera frame confused with a body frame. ROS 2 gives the discipline a standard form (REP-103 and REP-105), but the standard only works if every frame, axis convention and timestamp in the system is explicit. This guide explains the standard frame tree, works a real transform by hand, and catalogs the convention traps that produce the classic "robot turns the wrong way" failures.

The ROS 2 Standard Coordinate Tree

map → odom → base_link → sensor frames

  • map is the world-fixed frame, anchored to geodetic latitude/longitude or a UTM grid. It is the frame of goals, routes and global plans — and it is allowed to jump when localization corrects itself.
  • odom is the continuous local frame built from wheel encoders, IMU and visual/LiDAR odometry. It never jumps, but it drifts — perfect for control over seconds, wrong over kilometers.
  • base_link is the rigid frame at the robot's body center, the frame in which actuators and safety logic think.
  • Sensor frames (each LiDAR, camera, IMU) hang below base_link through calibrated static transforms.

The split between map and odom is the tree's central idea: the map → odom transform absorbs every localization correction, so planners (who want global truth) and controllers (who want smoothness) each get the frame they need, and neither has to compromise.

Worked Example: Transforming a Point from base_link to map

Frame trees exist to answer one concrete question: "the sensor saw something here — where is it in the world?" Suppose the robot's pose in the map frame is position (2.0 m, 1.0 m) with a heading (yaw) of 30°, and its LiDAR reports an obstacle at (1.0 m, 0.0 m) in base_link — one meter straight ahead. Rotating the point by the heading, then translating by the position:

xmap = 2.0 + cos(30°)×1.0 − sin(30°)×0.0 = 2.87 m
ymap = 1.0 + sin(30°)×1.0 + cos(30°)×0.0 = 1.50 m

Every transform in the tree is this same rotate-then-translate operation, composed. Two habits keep it correct in practice: always transform into the frame the consumer expects, and always use the transform stamped closest to the sensor reading's own timestamp — a fast-turning robot with a 100 ms stale transform misplaces points by its turn rate multiplied by that delay. When the robot logs latitude/longitude, the map frame itself is anchored through a local ENU origin; you can check what a logged coordinate pair means in UTM or MGRS with the Coordinate Format Auto-Detector.

Local ENU Navigation: Why Meters, Not Degrees

Robotics algorithms operate in local Cartesian meters using East-North-Up (ENU) orientation rather than spherical degrees, because velocities, distances and path geometry are linear in meters and badly non-linear in degrees: a degree of longitude spans about 111 km at the equator and about 56 km at 60° latitude. The standard pattern is to fix one surveyed origin, build the ENU tangent frame there, do all computation in that frame, and convert to or from geodetic coordinates only at the system boundary — exactly the pattern autonomous vehicles use, as described in our LiDAR SLAM and HD map localization guide.

ENU vs NED: The Convention Trap

ENU (ROS 2) X East Z Up Y North NED (aerospace / PX4) Y East Z Down X North
The same physical directions, two incompatible labelings. Yaw sign and the vertical axis both flip between the conventions.
ConventionAxesUsed By
ENU world + FLU bodyEast-North-Up; body Forward-Left-UpROS 2 (REP-103), most ground robotics
NED world + FRD bodyNorth-East-Down; body Forward-Right-DownAerospace, PX4/ArduPilot, many drone autopilots

Neither is wrong — mixing them silently is. A yaw angle that is positive counter-clockwise in ENU is positive clockwise in NED, and the vertical axis points in opposite directions, so an unconverted bridge between a PX4 autopilot and a ROS 2 stack produces a robot that turns the wrong way and reads altitude upside down. Convert at the boundary, label every message with its frame, and test the conversion with a known motion: drive north, and ENU y increases while NED x increases.

Common Mistakes

  • Quaternion order confusion. ROS geometry messages store (x, y, z, w); many math libraries default to (w, x, y, z). Swapping them produces rotations that look plausible at rest and are wrong everywhere else.
  • Camera optical frames. Camera frames conventionally look down their Z axis, while body frames look down X. Forgetting the optical-frame rotation makes projected points land 90° away from where the camera actually saw them.
  • Publishing a static world. Hard-coding map → base_link because "the robot starts at the origin" breaks the moment localization starts publishing real corrections — two publishers then fight over the same transform.
  • Ignoring timestamps. Transforming a scan with the latest pose instead of the pose at scan time smears every moving or turning measurement. tf2's time-travel lookups exist for exactly this reason.

Frequently Asked Questions

Why does ROS separate map and odom if both describe the robot's position?

odom is smooth but drifts; map is globally corrected but can jump when a correction arrives. Planning uses map, local control uses odom, and the map → odom transform absorbs the corrections so neither consumer sees the other's problem.

Should my world frame be ENU or NED?

Match your ecosystem: ROS 2 ground robotics is ENU by convention (REP-103/105), flight stacks are usually NED. What matters is that the choice is explicit, documented, and converted at every boundary.

How do I anchor a robot's map frame to real-world coordinates?

Pick a surveyed origin (a GNSS fix or control point), define the local ENU tangent frame there, and record the origin's latitude/longitude with the map. Every map-frame coordinate can then be converted back to geodetic coordinates deterministically.

Where to go next: The same frames in autonomous vehicles · Convert between spatial AI frames · Identify a logged coordinate format

Further reading: ROS REP-103 (Standard Units of Measure and Coordinate Conventions) and REP-105 (Coordinate Frames for Mobile Platforms) at ros.org; the tf2 documentation for time-aware transform handling.