yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
IMU Sensor Module📖
1. Introduction to the IMU Module
  • Introduction to IMU Module
2. Multi-master communication case
1. PC Communication
  • For PC
2. Serial communication
  • For STM32F103C8T6
  • For MSPM0G3507
  • For MSPM0G3519new
  • For ESP32
  • For Arduino
  • For Raspberry Pi Pico
  • For Raspberry Pi 5
  • For Jetson
  • For RDK
3. IIC Communication
  • For STM32F103C8T6
  • For MSPM0G3507
  • For MSPM0G3519new
  • For ESP32
  • For Arduino
  • For Raspberry Pi Pico
  • For Raspberry Pi 5
  • For Jetson
  • For RDK
3. Application Cases of Microcontroller-Based Cars
  • 1. Autonomous Driving Car
4. ROS Application Cases
ROS1 Applications
  • 1. IMU data printing
  • 2. Rviz Visualization
  • 3. IMU-integrated radar mapping and navigation
ROS2 Applications
  • 1. IMU data printing
  • 2. Rviz Visualization
  • 3. IMU-integrated radar mapping and navigation
Download
  • Code
  • VM_File
  • Docker_Image
  • 3D_Model_File
  • Hardware_DataSheet
  • Communication_Protocol
  • PC_Software
Download ZIP

Welcome to IMU Sensor Module repository

1. IMU data printing

IMU Data Printing

IMU Data Printing1. Connecting the Device2. Binding Device ID2.1 Device Viewing Commands2.2 Establishing Port MappingIntroduction to Rule File Syntax2.3 Verification and Viewing3. Installing the Driver Library3.1 Downloading the File3.2 Installing the Driver LibraryUnzipInstall LibraryInstall other necessary libraries4. IMU ROS environment configuration4.1 Creating and compiling a workspace4.2 Printing IMU Data5. Raspberry Pi 5, RDK X5 series, Jetson series5.1 Installing Docker5.2 Importing Docker Images5.3 Start the Docker Image5.4 Print IMU Data

This tutorial uses Ubuntu 22.04 and ROS2 version Humble as an example.

1. Connecting the Device

Connect the IMU attitude sensor to the host controller's USB port using a Type-C cable.

If using a virtual machine, refer to the following steps:

Virtual machine displays a pop-up window

image-20251022184733332

Virtual machine does not display a pop-up window

image-20251022184934184

2. Binding Device ID

2.1 Device Viewing Commands

View Device ID

xxxxxxxxxx
lsusb

image-20251022185043976

View Device Number

xxxxxxxxxx
ll /dev/ttyU*

image-20251022190125351

2.2 Establishing Port Mapping

Enter the rules.d directory

xxxxxxxxxx
cd /etc/udev/rules.d/

Create a new file named myimu.rules and write the following content:

xxxxxxxxxx
sudo gedit myimu.rules

If it prompts that the gedit command cannot be found, run:

xxxxxxxxxx
sudo apt install gedit -y

Write the following content:

xxxxxxxxxx
KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0777", SYMLINK+="myimu"

image-20251022190246546

Save and exit to apply the rule

xxxxxxxxxx
sudo udevadm trigger
sudo service udev reload
sudo service udev restart

Replug and replug the USB device. Done!

Introduction to Rule File Syntax

xxxxxxxxxx
KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0777", SYMLINK+="myimu"

Analysis

xxxxxxxxxx
KERNEL # The device name matching the event
ATTR{filename} # The sysfs attribute of the device matching the event. ... idVendor # Manufacturer ID
idProduct # Product ID
SYMLINK # Creates a symbolic link for the device file under /dev/. This gives the device an alias.
MODE # Sets permissions for the device.

2.3 Verification and Viewing

xxxxxxxxxx
ll /dev/my*

image-20251022190323459

3. Installing the Driver Library

3.1 Downloading the File

The latest version of the driver library, named YbImuLib.zip, is provided in the data folder.

image-20251020201127769

3.2 Installing the Driver Library

Copy the YbImuLib.zip file to the virtual machine.

image-20251022192643980

Unzip

xxxxxxxxxx
unzip YbImuLib.zip 

image-20251022192725342

Install Library

xxxxxxxxxx
cd YbImuLib

Run the installation command. If you see the version number displayed at the end, the installation was successful. This command will overwrite any previously installed Rosmaster_Lib driver library.

xxxxxxxxxx
sudo python3 setup.py install

image-20251022192850077

Install other necessary libraries

xxxxxxxxxx
sudo pip3 install pyserial
sudo pip3 install smbus2

4. IMU ROS environment configuration

4.1 Creating and compiling a workspace

Open the command terminal and run the following command:

Return to the home directory and create a new workspace

xxxxxxxxxx
  mkdir ros_imu_ws
  cd ros_imu_ws
  mkdir src
  colcon build --symlink-install

Copy the imu_ros2_device folder to the ~/ros_imu_ws/src directory.

image-20251022190651142

Compile

xxxxxxxxxx
cd ~/ros_imu_ws
colcon build

After successful compilation, add the workspace path to .bashrc

xxxxxxxxxx
sudo gedit ~/.bashrc

Copy the following content to the end of the file:

xxxxxxxxxx
source ~/ros_imu_ws/install/setup.bash

image-20251022191904662 Save and exit, update environment variables

xxxxxxxxxx
source  ~/.bashrc

4.2 Printing IMU Data

Open a terminal and start the IMU node

xxxxxxxxxx
ros2 run imu_ros2_device ybimu_driver

Open a second terminal and check the IMU topic

xxxxxxxxxx
ros2 topic list

image-20251022194305798

Print the data for the /imu/data_raw topic

xxxxxxxxxx
ros2 topic echo /imu/data_raw

image-20251022193623421

Open a third terminal and print /imu/mag Topic Data

xxxxxxxxxx
ros2 topic echo /imu/mag 

image-20251022193700981

5. Raspberry Pi 5, RDK X5 series, Jetson series

Note: Steps 2. Binding Device ID and 3. Installing Driver Libraries need to be completed beforehand.

5.1 Installing Docker

  1. Docker official website installation reference manual: https://docs.docker.com/engine/install/ubuntu/
  2. Use the following command for one-click installation:

Note: Docker installation failure is normal. You can try multiple times, or install it after using a proxy. You need to search online for how to use a proxy.

xxxxxxxxxx
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
  1. Check Docker Version
xxxxxxxxxx
sudo docker version

5.2 Importing Docker Images

Upload all files in the ROS1_noetic folder within the Docker image folder in the attached folder to the main controller. Then run the following command to import it.

image-20251027170839624

xxxxxxxxxx
docker load -i ros2_imu.tar

Note: Importing images takes a long time, please be patient. It is recommended to use a TF card of 64GB or more with at least 30GB of free space to avoid insufficient space causing import failure.

5.3 Start the Docker Image

xxxxxxxxxx
sh ros2_humble.sh

5.4 Print IMU Data

Start the IMU Node

xxxxxxxxxx
ros2 run imu_ros2_device ybimu_driver

image-20251027173205937

Open a second terminal and view the container ID

xxxxxxxxxx
docker ps

Based on the container ID displayed above, change the container ID in the following command to the actual displayed ID, allowing multiple terminals to access the same Docker container

xxxxxxxxxx
docker exec -it container_id /bin/bash

image-20251027172744387

Check IMU topics

xxxxxxxxxx
ros2 topic list

image-20251027172813704

Print /imu/data_raw topic data

xxxxxxxxxx
ros2 topic echo /imu/data_raw

image-20251027172917731

Print /imu/mag topic data

xxxxxxxxxx
ros2 topic echo /imu/mag

image-20251027173011169

IMU-integrated radar mapping and navigation
Rviz Visualization

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文