IMU Simulation: Position and Axes
This page shows where the simulated IMU sits on each robot and which way the IMU's axes point. Read the page to find which axis of the IMU's message is forward on your robot, or to change the mounting. This page belongs to IMU: Simulation, which shows the IMU's message.
Three names of the robot's URDF model describe the mounting. imu_link is the IMU's frame, chassis_link is the frame at the center of the robot's base plate, and imu_joint is the fixed joint that puts imu_link on chassis_link. This page first shows the mounting on each robot, then explains the two frames and their fixed joint and the lines of the robot's URDF model that make them.
The mounting on each robot
Choose your robot. The figure's tabs and the tabs of the text below switch together:
chassis_link is at the center of the base plate’s top. imu_joint, the dashed line, is a fixed joint. It puts imu_link on chassis_link, at the IMU’s board (blue) on the breadboard. Red is x, green is y and blue is z. A ring with a dot is an axis that points at you, a ring with a cross one that points away.imu_joint, the dashed line, puts imu_link 1 cm straight above chassis_link, the dot, without a rotation. So imu_link’s axes point the same way as chassis_link’s: x forward (red), z up (blue), and y to the left, away from you (the ring with a cross). The mounting is a placeholder. It isn’t measured on the robot.- Position:
imu_linklies 4.01 cm behindchassis_link, 2.34 cm to its left and 1.3 cm above it. That is 7.6 cm behind the wheel axle and 8 cm above the floor. - Rotation: −90° about z. The board lies flat on the breadboard.
- Axes:
imu_link's x axis points to the robot's right, its y axis forward and its z axis up. - For example: when Remo speeds up forward with 0.5 m/s², the +0.5 m/s² appear in \(f_y\), the message's
linear_acceleration.y. A left turn reads as a positive yaw rate \(\omega_z\). - Measured on the robot: yes. A tilt test on Remo showed the axes, as the bench checks describe, and the position on the breadboard was checked on the robot.
The two pictures show the mounting on a rendering of Remo:
Remo from the rear left, rendered with its mesh files installed and with the lidar platform hidden, which would cover the breadboard. The ring marks the IMU board on the breadboard, at the rear.
Remo from above, front up, rendered with its mesh files installed. The IMU's y axis points forward and its x axis to the right. Its z axis points up, toward you. Select the picture to see the dimensions at full size.
The public remo_description repository has empty placeholders for the mesh files, as STL files on the Remo Description page explains. With the placeholders, RViz and Gazebo show Remo without its meshes. The simulated IMU works the same: Gazebo's IMU sensor needs imu_link, not the board's mesh.
Remo's URDF model describes the BNO055 board on the breadboard on the Raspberry Pi deck. The diffbot repository uses Remo's URDF model at remo_description 2.5.0, the version that diffbot_dev.repos names. The call of the macro puts the IMU on chassis_link. The link and the joint in the robot's URDF model explains what a macro and its call are. The excerpt shows the call, from remo.urdf.xacro, lines 211–216:
| remo.urdf.xacro: the call of imu_sensor | |
|---|---|
211 212 213 214 215 216 | |
imu_xyz and imu_rpy are xacro arguments, declared at the top of the file with their defaults. The excerpt shows the two arguments, from remo.urdf.xacro, lines 26–27:
| remo.urdf.xacro: the IMU's mounting | |
|---|---|
26 27 | |
Xacro turns the call into this joint in Remo's URDF model. The lines are xacro's output for remo.urdf.xacro at 2.5.0, with the arguments' defaults. They aren't a file in a repository:
| Remo's URDF, expanded by xacro: imu_joint | |
|---|---|
1 2 3 4 5 | |
How the joint's numbers give the mounting:
- Position: −4.01 cm, +2.34 cm and +1.3 cm from
chassis_link.chassis_linklies 3.6 cm behind the wheel axle, as the comment in the collapsed box below explains. So the chip's center lies 7.6 cm behind the wheel axle, 2.34 cm left of the robot's center line, and 8 cm above the floor. The board's header pins sit in the breadboard. - Rotation: \(-\pi/2\) rad, −90°, about z. Both z axes point up, so a left turn is positive for the IMU as for the robot. The yaw of −90° turns
imu_link's y axis forward, so a forward acceleration appears in \(f_y\) and not in \(f_x\). The comment above the arguments inremo.urdf.xacrosays how each value was found.
Where chassis_link lies behind the wheel axle
The excerpt shows the lines of Remo's xacro file that compute axle_x, how far the wheel axle is in front of chassis_link, from remo.urdf.xacro, lines 71–75. The comment gives the value, 0.036 m:
| remo.urdf.xacro: axle_x | |
|---|---|
71 72 73 74 75 | |
- Position:
imu_linklies 1 cm straight abovechassis_link. - Rotation: none.
- Axes:
imu_link's axes point the same way as the robot's: x forward, y to the left and z up. - For example: when DiffBot speeds up forward with 0.5 m/s², the +0.5 m/s² appear in \(f_x\), the message's
linear_acceleration.x. A left turn reads as a positive yaw rate \(\omega_z\). - Measured on the robot: no. These values are placeholders. DiffBot uses the same BNO055 board as Remo, moved from one robot to the other, and its mounting on DiffBot isn't measured yet.
The excerpt shows the two arguments of DiffBot's xacro file with their comment, from diffbot.urdf.xacro, lines 4–10:
| diffbot.urdf.xacro: the IMU's mounting | |
|---|---|
4 5 6 7 8 9 10 | |
The call of the macro passes the two arguments to the joint. The excerpt shows the call, from diffbot.urdf.xacro, lines 80–82:
| diffbot.urdf.xacro: the call of imu_sensor | |
|---|---|
80 81 82 | |
In DiffBot's URDF model, the joint's origin is <origin rpy="0 0 0" xyz="0 0 0.01"/>, on chassis_link, as the expanded joint in the link and the joint in the robot's URDF model shows. To try another mounting, override the arguments when you run xacro, for example xacro diffbot.urdf.xacro imu_xyz:='0 0 0.02'.
Seen from above, the two frames lie on top of each other. So the figure shows DiffBot from the side.
The two frames and their fixed joint
The figure of the mounting shows three parts: two frames and the joint between them. Both robots have them, with other values. Their names come from the robot's URDF model:
imu_linkis the IMU's frame: a point on the robot with three axes. Every value in the IMU's message is along these axes.chassis_linkis the frame at the center of the robot's base plate. Its x axis points forward, its y axis to the left and its z axis up, as REP 103, ROS's convention for coordinate frames, asks for a robot's body. Each robot's URDF model declareschassis_linkin its base macro: DiffBot's incommon_macros.urdf.xacro, lines 197–207, and Remo's inremo_base_macro.urdf.xacro, lines 20–30.imu_jointis not a frame. It is the fixed joint that putsimu_linkonchassis_link. In tf, the joint appears as the transform fromchassis_linktoimu_link. The joint's origin says where the IMU sensor sits and how the IMU sensor is turned:xyzis the position in m, alongchassis_link's x, y and z axes.rpyis the rotation in rad: roll about x, pitch about y and yaw about z.
Where the two base macros declare chassis_link
The excerpt shows the lines of DiffBot's base macro that declare base_link, chassis_link and the joint between them, from common_macros.urdf.xacro, lines 197–207:
| common_macros.urdf.xacro (DiffBot): chassis_link | |
|---|---|
197 198 199 200 201 202 203 204 205 206 207 | |
The next excerpt shows the same lines of Remo's base macro, from remo_base_macro.urdf.xacro, lines 20–30:
| remo_base_macro.urdf.xacro (Remo): chassis_link | |
|---|---|
20 21 22 23 24 25 26 27 28 29 30 | |
The EKF needs the yaw rate \(\omega_z\) along the robot's axes, not along the IMU's. The EKF converts the IMU's values with this joint's transform. robot_state_publisher publishes the transform: this ROS node reads the robot's URDF model and publishes the position of every link to tf, ROS's system for transforms between frames. In the simulation, diffbot_control.launch starts robot_state_publisher.
The link and the joint in the robot's URDF model
The robots' URDF models are written in xacro, XML with variables and macros. The program xacro reads a robot's xacro files and writes one URDF file: the robot's URDF model, which ROS and Gazebo use.
A macro is a piece of a URDF model with a name and with blanks. A call names the macro and fills the blanks. Where xacro finds a call, it writes the macro's content, with the blanks filled in. So one macro can put the same part on two robots, at a different place on each.
Both robots' URDF models declare imu_link and imu_joint in a macro named imu_sensor. The excerpts below are DiffBot's. Remo's macro in remo_description declares the same link and joint.
The macro's first line: the excerpt shows the line that gives the macro's name and its blanks, which xacro calls parameters, from common_sensors.xacro, line 204:
| common_sensors.xacro: the macro imu_sensor and its parameters | |
|---|---|
204 | |
The joint: the excerpt shows the joint in the macro, from common_sensors.xacro, lines 236–240. The highlighted lines use two of the parameters:
| common_sensors.xacro: imu_joint in the macro | |
|---|---|
236 237 238 239 240 | |
The call: the excerpt shows the call in DiffBot's xacro file, from diffbot.urdf.xacro, lines 80–82:
| diffbot.urdf.xacro: the call of imu_sensor | |
|---|---|
80 81 82 | |
How xacro puts the macro and the call together:
<xacro:imu_sensor …>is the call. The name afterxacro:is the macro's name.parent_link="chassis_link"fills the parameterparent_link. In the macro,${parent_link}stands for the parameter's value. So the joint's parent becomeschassis_link.sensor_prop="${sensor_prop}"fills the parametersensor_propwith the robot's sensor settings. The joint doesn't use them. The link does.*originis a parameter of another kind. The star says that this blank doesn't take a value in quotes. It takes a whole XML element: the element that stands between the call's opening and closing tags. Here that is the<origin … />line. The xacro documentation calls such a parameter a block parameter.<xacro:insert_block name="origin"/>marks the place in the macro where xacro puts that element.$(arg imu_xyz)and$(arg imu_rpy)are arguments of the robot's xacro file. Each has a default value, and you can set another one when you run xacro. The mounting on each robot shows their values.
The result is this joint in DiffBot's URDF model. The lines are xacro's output for diffbot.urdf.xacro at the pinned commit, with the arguments' defaults. They aren't a file in a repository:
| DiffBot's URDF, expanded by xacro: imu_joint | |
|---|---|
1 2 3 4 5 | |
So the macro says that the IMU has a link and a joint. The call says where the joint puts the link. That is why the position and the rotation stand in each robot's xacro file, and not in the macro. type="fixed" means that the joint can't move: imu_link keeps its place on chassis_link, as the board keeps its place on the robot.
The link
The macro's link gives the IMU a shape, a collision box and a mass. The excerpt shows the link, from common_sensors.xacro, lines 206–234:
| common_sensors.xacro: the IMU's settings and imu_link | |
|---|---|
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
imu in these lines holds the IMU's settings. They reach the link in three steps:
-
DiffBot's xacro file reads the file
sensors.yamlinto the propertysensor_prop. The xacro file builds the YAML path and loads it into that property, indiffbot.urdf.xacro, lines 32–33:diffbot.urdf.xacro: the property sensor_prop 32 33
<xacro:property name="sensor_yaml" value="$(find ${package_name})/config/${robot_name}/sensors.yaml" /> <xacro:property name="sensor_prop" value="${xacro.load_yaml(sensor_yaml)}"/> -
The call passes
sensor_propto the macro, as step 3 of the list above says. - The highlighted line takes the entry
imuout ofsensor_prop.
The excerpt shows the entry, from sensors.yaml, lines 16–26:
| sensors.yaml: the IMU's entry | |
|---|---|
16 17 18 19 20 21 22 23 24 25 26 | |
DiffBot's entry has no mesh, so the link draws a red box of the board's size, 27 × 20 × 4 mm. The collision box has the same size, and box_inertia gives the link the board's mass, 3 g. Remo's sensors.yaml entry names the mesh for the BNO055 board.
Comments
Comments are GitHub Discussions, shown with giscus. Loading them connects to giscus.app (hosted by Vercel, USA) and GitHub (USA); you need a GitHub account to comment.

