Skip to content

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, imu_joint and imu_link on Remo, from aboveRemo with the Raspberry Pi deck, from above, with its front at the top. chassis_link is at the center of the base plate, with its x axis forward and its y axis to the left. imu_link is at the IMU board on the breadboard, 4.01 cm behind and 2.34 cm left of chassis_link. Its x axis points to the right and its y axis forward. The z axes of both point up, out of the drawing. A dashed line, the fixed joint imu_joint, connects the two origins. Remo with the Raspberry Pi deck, from above front x y z x y z chassis_link imu_link imu_joint a fixed joint breadboard imu_joint puts imu_link 4.01 cm back, 2.34 cm left and 1.3 cm up, and turns it by −90° about z
chassis_link, imu_joint and imu_link on Remo, from the right sideRemo with the Raspberry Pi deck, from its right side, with its front on the right. chassis_link is on top of the base plate, with its x axis forward and its z axis up. imu_link is 1.3 cm higher, on the breadboard. Its y axis points forward and its z axis up. chassis_link’s y axis points into the drawing, and imu_link’s x axis out of it. Remo with the Raspberry Pi deck, from the right side front floor breadboard x z y y z x chassis_link imu_link imu_joint imu_link lies 1.3 cm above chassis_link, on the breadboard
Remo’s frames, to scale. 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.
chassis_link, imu_joint and imu_link on DiffBot, from the right sideDiffBot from its right side, with its front on the right. chassis_link is at the center of the base plate. imu_link lies 1 cm straight above it, and its axes point the same way as chassis_link’s: x forward, z up, and y into the drawing. A dashed line, the fixed joint imu_joint, connects the two origins. A box shows the two frames 4 times larger. This mounting is a placeholder of DiffBot’s URDF model. It is not measured on the robot. DiffBot’s placeholder mounting, from the right side front floor x z y 4× larger imu_link imu_joint 1 cm up, not turned chassis_link Placeholder: imu_link 1 cm above chassis_link, not turned
DiffBot’s frames in its URDF model, to scale. 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_link lies 4.01 cm behind chassis_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 seen from the rear left, with the lidar platform hidden. A ring marks the blue BNO055 board on the breadboard, beside the Teensy and behind the Raspberry Pi

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. The IMU's center lies 7.6 cm behind the wheel axle and 2.34 cm left of the center line. Its x axis points to the robot's right, its y axis forward

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: a BNO055 on the breadboard next to the Teensy, which reads it -->
<xacro:imu_sensor parent_link="chassis_link"
                  sensor_prop="${sensor_props}"
                  plugin_filename="$(arg imu_plugin)">
  <origin xyz="$(arg imu_xyz)" rpy="$(arg imu_rpy)" />
</xacro:imu_sensor>

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:arg name="imu_xyz" default="-0.0401 0.0234 0.013" />
<xacro:arg name="imu_rpy" default="0 0 -1.5707963" />

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
<joint name="imu_joint" type="fixed">
  <parent link="chassis_link"/>
  <child link="imu_link"/>
  <origin rpy="0 0 -1.5707963" xyz="-0.0401 0.0234 0.013"/>
</joint>

How the joint's numbers give the mounting:

  • Position: −4.01 cm, +2.34 cm and +1.3 cm from chassis_link. chassis_link lies 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 in remo.urdf.xacro says 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
<!-- Base link at the drive axle's midpoint, and the chassis around it. axle_x is how far the
     axle is in front of the plate's center. The wheel config gives the axle's position from the
     plate's front edge instead (x_offset), so axle_x = half the plate's length - x_offset
     (0.070 - 0.034 = 0.036 m). The wheel macro places the wheels with the same formula. -->
<xacro:property name="axle_x" value="${base_props['base']['x_size']/2 - front_wheel_props['x_offset']}"/>
  • Position: imu_link lies 1 cm straight above chassis_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
<!-- Where the IMU (imu_link) sits on chassis_link. DiffBot uses the same BNO055 board as Remo,
     moved between the robots, but its mounting on DiffBot isn't measured yet. So these defaults
     are placeholders: on the plate, with the board's axes along the robot's (x forward, z up).
     The measured mounting goes here. To try another one, override them, for example
     imu_xyz:='0 0 0.02' imu_rpy:='0 0 0'. -->
<xacro:arg name="imu_xyz" default="0 0 0.01" />
<xacro:arg name="imu_rpy" default="0 0 0" />

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
<xacro:imu_sensor parent_link="chassis_link" sensor_prop="${sensor_prop}">
  <origin xyz="$(arg imu_xyz)" rpy="$(arg imu_rpy)" />
</xacro:imu_sensor>

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_link is the IMU's frame: a point on the robot with three axes. Every value in the IMU's message is along these axes.
  • chassis_link is 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 declares chassis_link in its base macro: DiffBot's in common_macros.urdf.xacro, lines 197–207, and Remo's in remo_base_macro.urdf.xacro, lines 20–30.
  • imu_joint is not a frame. It is the fixed joint that puts imu_link on chassis_link. In tf, the joint appears as the transform from chassis_link to imu_link. The joint's origin says where the IMU sensor sits and how the IMU sensor is turned:
    • xyz is the position in m, along chassis_link's x, y and z axes.
    • rpy is 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
<!-- base_link is the robot's reference frame: the midpoint between the drive wheels, where
     diff_drive_controller's odometry puts the robot. The chassis' geometry, mass and all
     attached parts are defined around chassis_link, the center of the base plate, which lies
     axle_x behind it. -->
<link name="base_link" />
<joint name="chassis_joint" type="fixed">
  <parent link="base_link"/>
  <child link="chassis_link"/>
  <origin xyz="${-axle_x} 0 0" rpy="0 0 0"/>
</joint>
<link name="chassis_link">

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
<!-- base_link is the robot's reference frame: the midpoint between the drive wheels, where
     diff_drive_controller's odometry puts the robot. chassis_link is the center of the base
     plate, axle_x behind base_link. The plate's geometry and mass, and all parts attached to
     it, are defined around chassis_link. -->
<link name="base_link" />
<joint name="chassis_joint" type="fixed">
  <parent link="base_link"/>
  <child link="chassis_link"/>
  <origin xyz="${-axle_x} 0 0" rpy="0 0 0"/>
</joint>
<link name="chassis_link">

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 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
<xacro:macro name="imu_sensor" params="parent_link sensor_prop *origin">

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
<joint name="imu_joint" type="fixed">
  <parent link="${parent_link}"/>
  <child link="imu_link"/>
  <xacro:insert_block name="origin"/>
</joint>

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
<xacro:imu_sensor parent_link="chassis_link" sensor_prop="${sensor_prop}">
  <origin xyz="$(arg imu_xyz)" rpy="$(arg imu_rpy)" />
</xacro:imu_sensor>

How xacro puts the macro and the call together:

  1. <xacro:imu_sensor …> is the call. The name after xacro: is the macro's name.
  2. parent_link="chassis_link" fills the parameter parent_link. In the macro, ${parent_link} stands for the parameter's value. So the joint's parent becomes chassis_link.
  3. sensor_prop="${sensor_prop}" fills the parameter sensor_prop with the robot's sensor settings. The joint doesn't use them. The link does.
  4. *origin is 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.
  5. <xacro:insert_block name="origin"/> marks the place in the macro where xacro puts that element.
  6. $(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
<joint name="imu_joint" type="fixed">
  <parent link="chassis_link"/>
  <child link="imu_link"/>
  <origin rpy="0 0 0" xyz="0 0 0.01"/>
</joint>

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 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
<xacro:property name="imu" value="${sensor_prop['imu']}"/>

<link name="imu_link">
  <xacro:if value="${imu['mesh'] != ''}">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://${package_name}/meshes/sensors/${imu['mesh']}" scale="${imu['scale']}"/>
      </geometry>
      <material name="dark_grey"/>
    </visual>
  </xacro:if>
  <xacro:if value="${imu['mesh'] == ''}">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <box size="${imu['size']['x']} ${imu['size']['y']} ${imu['size']['z']}"/>
      </geometry>
      <material name="red"/>
    </visual>
  </xacro:if>
  <collision>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
      <box size="${imu['size']['x']} ${imu['size']['y']} ${imu['size']['z']}"/>
    </geometry>
  </collision>
  <xacro:box_inertia m="${imu['mass']}" x="${imu['size']['x']}" y="${imu['size']['y']}" z="${imu['size']['z']}"/>
</link>

imu in these lines holds the IMU's settings. They reach the link in three steps:

  1. DiffBot's xacro file reads the file sensors.yaml into the property sensor_prop. The xacro file builds the YAML path and loads it into that property, in diffbot.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)}"/>
    
  2. The call passes sensor_prop to the macro, as step 3 of the list above says.

  3. The highlighted line takes the entry imu out of sensor_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
imu:
  # IMU mass in kg: 3 g, the BNO055 board that DiffBot and Remo share, weighed with its header
  # pins. DiffBot's base mass in base.yaml was weighed without the board, so this link adds the
  # board's mass.
  mass: 0.003
  size:             # A BNO055 breakout board, in m
    x: 0.027
    y: 0.020
    z: 0.004
  mesh: ''          # No mesh: a red box of this size
  scale: '0.001 0.001 0.001'

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.