Skip to main content
Version: 1.1.0

IMU

Hardware​

AutomatePro includes an onboard BNO085 9-axis MEMS IMU. The IMU combines a 3-axis accelerometer, 3-axis gyroscope, and 3-axis magnetometer. The driver publishes ROS 2 IMU data and, when enabled, magnetic-field, accuracy, tare, and calibration-status data, and reports its health on /diagnostics.

The arrows on the device indicate the IMU vector directions:

AutomatePro IMU axis directions

IMU Specifications​

ParameterValue
SensorBNO085
Sensing types3-axis gyroscope, 3-axis magnetometer, 3-axis accelerometer
Rotation vector error (dynamic)13.5 deg
Accelerometer accuracy10.3 m/s2
Gyroscope accuracy13.1 deg/s
Magnetometer accuracy11.4 uT
Default IMU sample rate100 Hz
Configurable IMU rateUp to 400 Hz, hardware dependent
Info

1 Based on IC manufacturer tests. Results on AutomatePro can vary by mounting, calibration, and magnetic environment. See the BNO080/BNO085 datasheet for manufacturer details.

ROS API​

Node: automatepro_imu_driver​

Publishers​

TopicTypeDescription
/sensor/imu/datasensor_msgs/msg/ImuOrientation, angular velocity, and linear acceleration.
/sensor/imu/magnetic_fieldsensor_msgs/msg/MagneticFieldMagnetic field data in tesla, when magnetometer publishing is enabled.
/sensor/imu/accuracyautomatepro_imu_driver/msg/ImuAccuracyOnce per second: the active orientation source, the orientation accuracy level, the heading accuracy in radians, the gyroscope and magnetic-field biases the sensor removes, and the vertical accelerometer bias measured at rest. The heading accuracy is NaN in game_rotation_vector mode.
/sensor/imu/calibration_statusautomatepro_imu_driver/msg/ImuCalibrationStatusAccuracy levels of the accelerometer, gyroscope, and magnetometer calibration, when calibration.publish_status is enabled.
/sensor/imu/taregeometry_msgs/msg/QuaternionStampedTare in effect, latched and published each time the tare changes. Published only when publish.tare.enabled is true.
/diagnosticsdiagnostic_msgs/msg/DiagnosticArrayIMU health once per second. Published only when publish.diagnostics.enabled is true.

Services​

ServiceTypeDescription
/sensor/imu/save_tarestd_srvs/srv/TriggerPersists the roll and pitch part of the current tare to sensor flash. Refused while a heading-only tare is active.
/sensor/imu/save_calibrationstd_srvs/srv/TriggerSaves Dynamic Calibration Data (DCD) to sensor flash. The unit must be at rest, and a calibration that fails its checks is refused.
/sensor/imu/clear_calibrationstd_srvs/srv/TriggerDeletes the stored calibration and restarts the sensor without one. The stored tare is kept.
/sensor/imu/reinitstd_srvs/srv/TriggerReinitializes the IMU driver and sensor.

Verify IMU Data​

Run these checks from AutomatePro over SSH:

. /opt/automatepro/scripts/ros-env.sh && automatepro_source_ros
ros2 node list | grep automatepro_imu_driver
ros2 topic echo /sensor/imu/data --once

If accuracy publishing is enabled, check the orientation accuracy:

ros2 topic echo /sensor/imu/accuracy --once

Enable calibration.publish_status to publish the accelerometer, gyroscope, and magnetometer accuracy levels on /sensor/imu/calibration_status. Accuracy levels use:

ValueMeaning
0Unreliable
1Low
2Medium
3High
255Unknown

Configuration​

Driver: automatepro_imu_driver
Container: automatepro-core-driver

info

Runtime ROS configuration is stored in /etc/opt/automatepro/ros. Packaged defaults are stored in /opt/automatepro/defconfig/ros.

Edit the IMU parameter file:

sudo nano /etc/opt/automatepro/ros/imu_params.yaml

Important parameters:

ParameterDefaultDescription
frame_idautomatepro_imu_linkFrame ID stamped on published IMU messages.
rotation_vector_modegame_rotation_vectorOrientation report type. Use rotation_vector for magnetic absolute heading, game_rotation_vector for relative heading without magnetometer, or geomagnetic_rotation_vector for geomagnetic heading.
rotation_vector_stabilizedtruePublishes the chip's AR/VR-stabilized rotation vector, which does not step when a knock or vibration disturbs the gravity estimate. Applies to game_rotation_vector and rotation_vector; geomagnetic_rotation_vector has no stabilized variant and stays plain, with a warning.
orientation.enabledfalseApplies the fixed mounting of AutomatePro in the published frame, on top of the chip's built-in mounting. When false, the driver publishes the AutomatePro frame.
orientation.roll_deg/pitch_deg/yaw_deg0.0/0.0/0.0Mounting orientation in degrees, as the roll, pitch, and yaw of a joint in the robot description. Set the mounting here or in the joint of frame_id in the robot description, never in both.
tare.on_startupfalseTakes one tare at every configure, once the unit is at rest. Leave disabled after commissioning.
tare.axesxyzTare mode: xyz makes the current pose the reference for roll, pitch, and yaw, and z zeroes the heading only. No other value is accepted.
tare.persistfalseSaves the roll and pitch part of the tare to flash when enabled. The heading part is never saved.
tare.use_persistedtrueApplies the roll and pitch tare saved in the sensor on top of the orientation. When false, the driver ignores the saved tare and uses the orientation alone. A tare saved by the earlier driver holds the whole reorientation: on such a unit, keep false and call /sensor/imu/save_tare once.
calibration.accelerometer.enabledtrueEnables BNO08x accelerometer dynamic calibration.
calibration.accelerometer.planarfalseEnables planar accelerometer calibration mode.
calibration.gyroscope.enabledfalseEnables BNO08x gyroscope dynamic calibration.
calibration.gyroscope.on_tablefalseEnables stationary on-table gyroscope calibration assist.
calibration.magnetic_field.enabledfalseEnables BNO08x magnetometer dynamic calibration. Enable only when magnetic heading is required and the environment is suitable.
calibration.save_dcdfalseSaves Dynamic Calibration Data to flash every 5 seconds while the unit is at rest and the calibration passes its checks, and once on deactivate under the same condition.
calibration.save_unverifiedfalseSaves the calibration even when it fails its checks, with a warning. Keep false unless the checks cannot pass on this installation.
calibration.publish_statusfalsePublishes /sensor/imu/calibration_status.
i2c.enabledtrueUses I2C communication.
i2c.bus/dev/i2c-7I2C bus path.
i2c.address0x4BBNO08x I2C address.
uart.enabledfalseUses UART communication instead of I2C when enabled and i2c.enabled is false.
uart.device/dev/ttyACM0UART device path when UART transport is enabled.
publish.accuracy.enabledtruePublishes /sensor/imu/accuracy.
publish.tare.enabledtruePublishes /sensor/imu/tare.
publish.diagnostics.enabledtruePublishes the IMU health on /diagnostics.
publish.imu.enabledtruePublishes /sensor/imu/data.
publish.imu.rate_hz100Requested IMU report rate in Hz.
publish.magnetic_field.enabledfalsePublishes /sensor/imu/magnetic_field.
publish.magnetic_field.rate_hz100Requested magnetometer report rate in Hz.
publish.magnetic_field.covariance.stddev_tesla1.4e-6Standard deviation of each magnetic field axis in tesla (1.4 uT), squared into the covariance of /sensor/imu/magnetic_field.
publish.imu.covariance.game_rotation_vector.orientation_roll_pitch_stddev_rad0.0436332Roll and pitch standard deviation in radians (2.5°) in game_rotation_vector mode.
publish.imu.covariance.game_rotation_vector.orientation_yaw_drift_radps1.45444e-4Yaw drift rate in rad/s (0.5° per minute) in game_rotation_vector mode. The yaw variance grows with the time since the last sensor initialization.
publish.imu.covariance.rotation_vector.orientation_stddev_rad0.0610865Orientation standard deviation in radians on every axis (3.5°) in rotation_vector mode.
publish.imu.covariance.geomagnetic_rotation_vector.orientation_stddev_rad0.0785398Orientation standard deviation in radians on every axis (4.5°) in geomagnetic_rotation_vector mode.
publish.imu.covariance.angular_velocity_stddev_radps0.0541052Angular velocity standard deviation per axis in rad/s (3.1° per second).
publish.imu.covariance.linear_acceleration_stddev_mps20.3Linear acceleration standard deviation per axis in m/s2.
Important

Restart automatepro-core-driver after changing the configuration. Configuration values are loaded when the driver container starts and are only applied after the service restarts.

sudo systemctl restart automatepro-core-driver

Default Configuration Shape​

/automatepro_imu_driver:
ros__parameters:
frame_id: "automatepro_imu_link"
rotation_vector_mode: "game_rotation_vector"
rotation_vector_stabilized: true
orientation:
enabled: false
roll_deg: 0.0
pitch_deg: 0.0
yaw_deg: 0.0
tare:
on_startup: false
axes: "xyz"
persist: false
use_persisted: true
calibration:
accelerometer:
enabled: true
planar: false
gyroscope:
enabled: false
on_table: false
magnetic_field:
enabled: false
save_dcd: false
save_unverified: false
publish_status: false
i2c:
enabled: true
bus: "/dev/i2c-7"
address: "0x4B"
uart:
enabled: false
device: "/dev/ttyACM0"
publish:
accuracy:
enabled: true
tare:
enabled: true
diagnostics:
enabled: true
magnetic_field:
enabled: false
rate_hz: 100
covariance:
stddev_tesla: 1.4e-6
imu:
enabled: true
rate_hz: 100
covariance:
game_rotation_vector:
orientation_roll_pitch_stddev_rad: 0.0436332
orientation_yaw_drift_radps: 1.45444e-4
rotation_vector:
orientation_stddev_rad: 0.0610865
geomagnetic_rotation_vector:
orientation_stddev_rad: 0.0785398
angular_velocity_stddev_radps: 0.0541052
linear_acceleration_stddev_mps2: 0.3

Example​

This example prints IMU and magnetic field messages, each at most once per second, by subscribing to /sensor/imu/data and /sensor/imu/magnetic_field; the driver publishes the magnetic field only when publish.magnetic_field.enabled is true. The tutorial package is available in the AutomatePro tutorials repository, and its README explains how to build and run the examples.

Source: imu.py

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.node import Node
from sensor_msgs.msg import Imu, MagneticField

LOG_PERIOD_S = 1.0


class ImuSubscriber(Node):

def __init__(self):
super().__init__('imu_subscriber')
self.imu_subscription = self.create_subscription(
Imu,
'/sensor/imu/data',
self.imu_callback,
10)
self.magnetic_field_subscription = self.create_subscription(
MagneticField,
'/sensor/imu/magnetic_field',
self.magnetic_field_callback,
10)

def imu_callback(self, msg):
self.get_logger().info(
'Received IMU message: orientation=%s, angular_velocity=%s, '
'linear_acceleration=%s' % (
msg.orientation, msg.angular_velocity, msg.linear_acceleration),
throttle_duration_sec=LOG_PERIOD_S)

def magnetic_field_callback(self, msg):
self.get_logger().info(
'Received MagneticField message: magnetic_field=%s' % msg.magnetic_field,
throttle_duration_sec=LOG_PERIOD_S)


def main(args=None):
rclpy.init(args=args)
node = ImuSubscriber()
try:
rclpy.spin(node)
except (KeyboardInterrupt, ExternalShutdownException):
pass
finally:
node.destroy_node()
rclpy.try_shutdown()


if __name__ == '__main__':
main()

Run the node using the following command:

ros2 run automatepro_python_tutorials imu_node

Orientation Commissioning​

Use this workflow when the IMU is remounted, when the reference orientation changes, or when a system needs a known rest pose.

Important

Perform tare and calibration only when the device is in its final mounting position and away from motors, steel structures, strong magnets, and current-carrying wires.

  1. Complete dynamic calibration.

    Gyroscope dynamic calibration is off in the packaged configuration, because slow yaw turns during operation mis-calibrate the gyroscope, and magnetometer calibration is off because the game rotation vector does not use the magnetometer. Accelerometer dynamic calibration stays on. For a calibration session, set calibration.gyroscope.enabled to true, and calibration.magnetic_field.enabled only if magnetic heading is required, then restart the core driver.

    Move the device through several stable orientations for accelerometer calibration, leave it stationary for gyroscope calibration, and perform magnetic rotations only if magnetic-field calibration is enabled. Set the device down still, then save the calibration. The service checks the calibration with the unit at rest and refuses to save one that fails the checks:

    ros2 service call /sensor/imu/save_calibration std_srvs/srv/Trigger

    Set calibration.gyroscope.enabled and calibration.magnetic_field.enabled back to false and restart the core driver. To start a calibration from scratch, call /sensor/imu/clear_calibration, which deletes the stored calibration and keeps the stored tare.

  2. Set mounting orientation.

    Set orientation.enabled to true and use orientation.roll_deg, pitch_deg, and yaw_deg to give the mounting of AutomatePro in the published frame. The driver applies it on top of the chip's built-in mounting, and re-applies it on startup and watchdog recovery. Set the mounting either here or in the joint of frame_id in the robot description, never in both. A tare is measured on top of orientation, so tare again after changing it.

  3. Tare the reference pose (optional).

    Place AutomatePro in the desired zero orientation, keep it still, and temporarily set:

    tare:
    on_startup: true
    axes: "xyz"
    persist: true
    use_persisted: true

    Restart the core driver and wait for Persisted level tare (roll and pitch) in the logs:

    sudo systemctl restart automatepro-core-driver
    sudo journalctl -u automatepro-core-driver -f

    After the tare completes, set tare.on_startup: false and tare.persist: false. Keep tare.use_persisted: true, except on a unit whose saved tare was written by the earlier driver: there, keep false and call /sensor/imu/save_tare once to overwrite it. The saved tare holds only roll and pitch; the heading is never saved, so after a restart the heading is the sensor's own, magnetic with rotation_vector and an arbitrary start value with game_rotation_vector. Use tare.axes: "z" to zero the heading alone; a heading-only tare is not saved.

  4. Verify the final output.

    Restart the core driver and verify that the rest pose and motion directions match your robot frame:

    sudo systemctl restart automatepro-core-driver
    ros2 topic echo /sensor/imu/data --field orientation --once
Developer Notes: rotation modes and persistence

rotation_vector_mode selects which BNO08x SH-2 report is enabled. game_rotation_vector does not use the magnetometer and reports relative heading. rotation_vector and geomagnetic_rotation_vector use magnetic information for heading.

A tare runs at every configure when tare.on_startup is enabled, once the unit is at rest. It is not repeated on watchdog recovery or /sensor/imu/reinit, which keep a tare in effect: whole with rotation_vector and geomagnetic_rotation_vector, and only its roll and pitch with game_rotation_vector, whose heading starts from an arbitrary value at every sensor start. The fixed mounting orientation is re-applied on every sensor initialization, including watchdog recovery.

Troubleshooting​

IMU Topic Is Missing​

Check that the driver is enabled:

grep ROS_DRIVER_IMU /etc/opt/automatepro/automatepro.conf

Check logs:

sudo journalctl -u automatepro-core-driver -n 100 --no-pager

Automatic Recovery​

The driver watches the sensor data stream and reinitializes the sensor when no data arrives for two seconds. This is the same action as the /sensor/imu/reinit service, and the period and timeout are fixed in the driver.

The mounting orientation configured under orientation is applied again on every reinitialization, and a tare in effect is kept, as described in Orientation Commissioning.

Orientation Is Correct After Startup but Wrong After Recovery​

Verify orientation.enabled: true. The fixed orientation mapping is the part reapplied on every sensor initialization.

Heading Drifts or Jumps​

Check the rotation-vector mode and magnetic environment. If the system does not require magnetic absolute heading, game_rotation_vector is less sensitive to magnetic disturbances. If magnetic heading is required, calibrate in the deployment environment and monitor /sensor/imu/accuracy.