Skip to main content

SDK ROS2 Package Reference

File Layout

The ROS2 portion is in rdk-imu-module-sdk/ros2 and depends on the C API. The ros2 directory is a colcon workspace:

Before build:

ros2/
└── src
└── rdk_imu_module
├── CMakeLists.txt # Build configuration
├── launch
│ └── rdk_imu.launch.py # Launch file
├── package.xml
├── scripts
│ └── imu_stress_test.py # Stress test script
└── src
└── rdk_imu_node.cpp # Node source

After build:

ros2/
├── install/
├── build/
├── log/
└── src/

Build Instructions

Before building the ROS2 package, compile the C API shared library so core/lib contains .so, .so.x, and .so.x.x.x. The ROS2 package depends on that library; CMake detects and installs it into install automatically.

With your ROS2 environment sourced, run colcon build from the ros2 directory.

API Reference

Node Behavior

  • Fused output: Calls C API rdk_imu_read_fused() for 1D linear interpolation and time-aligned 6-axis data.
  • Automatic covariance: Computes diagonal entries of linear_acceleration_covariance and angular_velocity_covariance from configured accelerometer filter bandwidth and gyroscope bandwidth, using BMI088 noise density from the datasheet.
  • Runtime control: ROS2 services to pause/resume IMU data acquisition at any time.
  • Flexible parameters: Sensor settings, topic names, and service names are configurable via ROS parameters at launch.

Launch

Ensure the ROS 2 package is built and the workspace is sourced, then launch:

source install/setup.bash
ros2 launch rdk_imu_module rdk_imu.launch.py

The node runs as rdk_imu_node and logs to the console by default.

Published Topics

  • Default topic: /rdkimu/data

  • Message type: sensor_msgs/msg/Imu

  • Contents:

    • header.stamp: fused timestamp (nanosecond hardware time from CLOCK_MONOTONIC)
    • header.frame_id: frame name; default imu_link
    • linear_acceleration: accelerometer axes in m/s²
    • angular_velocity: gyroscope axes in rad/s
    • orientation: not provided; quaternion is always (0,0,0,1)
    • Covariance: accelerometer and gyroscope diagonal variances computed from bandwidth and noise density; orientation covariance set to -1 (unknown)
    Tip

    Change the topic name with the imu_topic parameter or ROS 2 remapping.

Services

Two std_srvs/srv/Trigger services control acquisition at runtime:

Service (default)Function
~/enableEnable IMU data acquisition (start interrupt thread)
~/disablePause IMU data acquisition (stop interrupt thread)
Tip

Configure service names with enable_service_name and disable_service_name.

Configurable Parameters

All parameters below can be set in the launch file or on the command line. They are read at startup and cannot be changed at runtime:

ParameterTypeDefaultDescription
frame_idstringimu_linkFrame ID in IMU messages
fuse_bystringaccelFusion reference sensor: accel or gyro
max_age_nsint50000000Max interpolation time gap in nanoseconds; recommend ≥ 3× ODR period
publish_ratedouble0.0Fixed publish rate in Hz; 0.0 = publish as data arrives
auto_startbooltrueStart acquisition automatically on node launch
imu_topicstringrdkimu/dataIMU data topic name
enable_service_namestring~/enableEnable service name
disable_service_namestring~/disableDisable service name
accel_bwpstringNORMALAccelerometer filter mode: OSR4, OSR2, or NORMAL
accel_odrstring400Accelerometer ODR: 12_5, 25, …, 1600
accel_rangestring24GAccelerometer range: 3G, 6G, 12G, 24G
gyro_rangestring2000DPSGyroscope range: 125DPS ~ 2000DPS
gyro_bandwidthstringODR400_BW47Gyroscope bandwidth, e.g. ODR2000_BW532 (see enum)
accel_drdy_intstringINT1Accelerometer interrupt pin: INT1 or INT2
accel_int_gpio_modestringPP_HAccelerometer interrupt GPIO mode: PP_H, PP_L, OD_H, OD_L
gyro_drdy_intstringINT3Gyroscope interrupt pin: INT3 or INT4
gyro_int_gpio_modestringPP_HGyroscope interrupt GPIO mode; same values as above
accel_drdy_gpio_chipint4SoC accelerometer interrupt GPIO chip
accel_drdy_gpio_lineint2SoC accelerometer interrupt GPIO line
gyro_drdy_gpio_chipint3SoC gyroscope interrupt GPIO chip
gyro_drdy_gpio_lineint12SoC gyroscope interrupt GPIO line
fifo_lengthint256Software FIFO length (frames)
fifo_modestringOVERWRITEFIFO full policy: DROP or OVERWRITE
irq_priorityint-1Interrupt thread real-time priority (-1 = auto)
irq_thread_timeout_nsint1000000000Interrupt thread wait timeout in nanoseconds

Sensor parameters map 1:1 to C API rdk_imu_config_t; see C API Reference.

Usage Examples

View live data:

ros2 topic echo /rdkimu/data
ros2 topic hz /rdkimu/data

Pause/resume acquisition:

ros2 service call /rdk_imu_node/enable std_srvs/srv/Trigger
ros2 service call /rdk_imu_node/disable std_srvs/srv/Trigger

Launch with custom parameters (e.g. topic name and rate):

ros2 launch rdk_imu_module rdk_imu.launch.py imu_topic:=/my_imu publish_rate:=200.0