ROS2 Jazzy driver for the ST LSM6DS3 6-axis IMU (3-axis accelerometer + 3-axis gyroscope) over I2C.
Publishes sensor_msgs/Imu with linear acceleration and angular velocity data.
- Publishes
sensor_msgs/Imuonimu/data_raw fake_modefor testing without hardware (random Gaussian data)- Configurable accelerometer range: ±2g / ±4g / ±8g / ±16g
- Configurable gyroscope range: ±245 / ±500 / ±1000 / ±2000 dps
- Block Data Update (BDU) enabled for consistent readings
- Runtime
publish_ratechange viaros2 param set - Calibration and reset services
- ROS 2 Jazzy
- Python 3
smbus2(only for real hardware:pip install smbus2)
cd ~/ros2_ws
colcon build --packages-select lsm6ds3_imu --symlink-install
source install/setup.bashros2 launch lsm6ds3_imu lsm6ds3_launch.pyros2 run lsm6ds3_imu lsm6ds3_node.pyros2 launch lsm6ds3_imu lsm6ds3_launch.py \
params_file:=path/to/your_params.yamlSet fake_mode: false in your YAML file.
ros2 launch lsm6ds3_imu lsm6ds3_launch.py \
params_file:=/path/to/custom_params.yamlros2 topic echo /imu/data_raw| Parameter | Type | Default | Description |
|---|---|---|---|
fake_mode |
bool | true |
Generate random data without hardware |
i2c_bus |
int | 1 |
I2C bus number (/dev/i2c-N) |
device_address |
int | 0x6A |
I2C address (ALT: 0x6B) |
publish_rate |
float | 50.0 |
Publishing rate in Hz (runtime changeable) |
frame_id |
string | imu_link |
TF frame ID |
accel_range |
int | 0 |
0=±2g, 1=±4g, 2=±8g, 3=±16g |
gyro_range |
int | 0 |
0=±245dps, 1=±500dps, 2=±1000dps, 3=±2000dps |
accel_covariance |
float | 0.04 |
Diagonal covariance (m²/s⁴) |
gyro_covariance |
float | 0.02 |
Diagonal covariance (rad²/s²) |
| Service | Type | Description |
|---|---|---|
imu/calibrate |
std_srvs/srv/Trigger |
Collect gyro samples for 2 s, compute bias offset |
imu/reset |
std_srvs/srv/Trigger |
Clear bias, reinitialize sensor |
lsm6ds3_imu/
├── CMakeLists.txt
├── package.xml
├── config/
│ └── lsm6ds3_params.yaml
├── launch/
│ └── lsm6ds3_launch.py
├── lsm6ds3_imu/
│ ├── __init__.py
│ └── lsm6ds3_driver.py
├── nodes/
│ └── lsm6ds3_node.py
├── test/
│ └── test_lsm6ds3_node.py
├── .gitignore
├── LICENSE
├── CONTRIBUTING.md
└── README.md
Tested on Ubuntu 24.04 (WSL2) with fake_mode: true.
| Test Category | Test | Result |
|---|---|---|
| Topics | imu/data_raw publishes sensor_msgs/Imu |
PASS |
| Services | imu/calibrate returns success=True |
PASS |
| Services | imu/reset returns success=True |
PASS |
| Parameters | publish_rate runtime change |
PASS |
| Shutdown | Clean exit | PASS |
| Linting | pep257, flake8, copyright, xmllint | PASS |
MIT