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_covarianceandangular_velocity_covariancefrom 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 fromCLOCK_MONOTONIC)header.frame_id: frame name; defaultimu_linklinear_acceleration: accelerometer axes in m/s²angular_velocity: gyroscope axes in rad/sorientation: 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)
TipChange the topic name with the
imu_topicparameter or ROS 2 remapping.
Services
Two std_srvs/srv/Trigger services control acquisition at runtime:
| Service (default) | Function |
|---|---|
~/enable | Enable IMU data acquisition (start interrupt thread) |
~/disable | Pause IMU data acquisition (stop interrupt thread) |
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
frame_id | string | imu_link | Frame ID in IMU messages |
fuse_by | string | accel | Fusion reference sensor: accel or gyro |
max_age_ns | int | 50000000 | Max interpolation time gap in nanoseconds; recommend ≥ 3× ODR period |
publish_rate | double | 0.0 | Fixed publish rate in Hz; 0.0 = publish as data arrives |
auto_start | bool | true | Start acquisition automatically on node launch |
imu_topic | string | rdkimu/data | IMU data topic name |
enable_service_name | string | ~/enable | Enable service name |
disable_service_name | string | ~/disable | Disable service name |
accel_bwp | string | NORMAL | Accelerometer filter mode: OSR4, OSR2, or NORMAL |
accel_odr | string | 400 | Accelerometer ODR: 12_5, 25, …, 1600 |
accel_range | string | 24G | Accelerometer range: 3G, 6G, 12G, 24G |
gyro_range | string | 2000DPS | Gyroscope range: 125DPS ~ 2000DPS |
gyro_bandwidth | string | ODR400_BW47 | Gyroscope bandwidth, e.g. ODR2000_BW532 (see enum) |
accel_drdy_int | string | INT1 | Accelerometer interrupt pin: INT1 or INT2 |
accel_int_gpio_mode | string | PP_H | Accelerometer interrupt GPIO mode: PP_H, PP_L, OD_H, OD_L |
gyro_drdy_int | string | INT3 | Gyroscope interrupt pin: INT3 or INT4 |
gyro_int_gpio_mode | string | PP_H | Gyroscope interrupt GPIO mode; same values as above |
accel_drdy_gpio_chip | int | 4 | SoC accelerometer interrupt GPIO chip |
accel_drdy_gpio_line | int | 2 | SoC accelerometer interrupt GPIO line |
gyro_drdy_gpio_chip | int | 3 | SoC gyroscope interrupt GPIO chip |
gyro_drdy_gpio_line | int | 12 | SoC gyroscope interrupt GPIO line |
fifo_length | int | 256 | Software FIFO length (frames) |
fifo_mode | string | OVERWRITE | FIFO full policy: DROP or OVERWRITE |
irq_priority | int | -1 | Interrupt thread real-time priority (-1 = auto) |
irq_thread_timeout_ns | int | 1000000000 | Interrupt 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