Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LSM6DS3 IMU — ROS2 Jazzy Driver (I2C)

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.

Features

  • Publishes sensor_msgs/Imu on imu/data_raw
  • fake_mode for 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_rate change via ros2 param set
  • Calibration and reset services

Prerequisites

  • ROS 2 Jazzy
  • Python 3
  • smbus2 (only for real hardware: pip install smbus2)

Installation

cd ~/ros2_ws
colcon build --packages-select lsm6ds3_imu --symlink-install
source install/setup.bash

Usage

Launch (fake mode — default)

ros2 launch lsm6ds3_imu lsm6ds3_launch.py

Run node directly

ros2 run lsm6ds3_imu lsm6ds3_node.py

Real hardware (Raspberry Pi)

ros2 launch lsm6ds3_imu lsm6ds3_launch.py \
  params_file:=path/to/your_params.yaml

Set fake_mode: false in your YAML file.

YAML parameter override

ros2 launch lsm6ds3_imu lsm6ds3_launch.py \
  params_file:=/path/to/custom_params.yaml

Verify output

ros2 topic echo /imu/data_raw

Parameters

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²)

Services

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

Package Structure

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

Test Results

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

License

MIT

About

ROS2 Jazzy driver for ST LSM6DS3 6-axis IMU (accelerometer + gyroscope) over I2C

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages