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 the Docker Image5.3 Start the Docker Image5.4 Print IMU Data

This tutorial uses Ubuntu 20.04 and ROS1 version Noetic 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-20251017172535342

Virtual machine does not display a pop-up window

image-20251017172815386

2. Binding Device ID

2.1 Device Viewing Commands

View Device ID

lsusb

image-20251017173003617

View Device Number

xxxxxxxxxx
ll /dev/ttyU*

image-20251017173034606

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-20251017173246357

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

​x
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-20251017173324078

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-20251023103137262

Unzip

xxxxxxxxxx
unzip YbImuLib.zip 

image-20251023103204834

Install Library

xxxxxxxxxx
cd YbImuLib

Run the installation command. If you see the installation version number 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-20251023103238359

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, return to the home directory, and run the following command:

Create a new workspace

xxxxxxxxxx
mkdir ros_imu_ws
cd ros_imu_ws
mkdir src
cd src
catkin_init_workspace

Copy the imu_ros1_device folder to the ~/ros_imu_ws/src directory

image-20251023103518621

Compile

xxxxxxxxxx
cd ~/ros_imu_ws
catkin_make

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/devel/setup.bash

image-20251017173936856

Save and exit, update environment variables

xxxxxxxxxx
source  ~/.bashrc

4.2 Printing IMU Data

Open a terminal and start roscore

xxxxxxxxxx
roscore

Open another terminal and start the IMU node

xxxxxxxxxx
rosrun imu_ros1_device ybimu_driver.py

Open a second terminal and check the IMU topic

xxxxxxxxxx
rostopic list

image-20251017174722631

Print the data for the /imu/data_raw topic

xxxxxxxxxx
rostopic echo /imu/data_raw

image-20251017175112095

Open a new third terminal and print the topic data /imu/mag

xxxxxxxxxx
rostopic echo /imu/mag 

image-20251017175202635

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 using a proxy. You need to search online for instructions on using a proxy.

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

5.2 Importing the Docker Image

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-20251027153601469

xxxxxxxxxx
docker load -i ros1_imu.tar

Note: Importing the image 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 ros1_noetic.sh

5.4 Print IMU Data

Start roscore

xxxxxxxxxx
roscore

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-20251027161425277

Start the IMU node

xxxxxxxxxx
rosrun imu_ros1_device ybimu_driver.py

image-20251027161452397

Open a third terminal, refer to the second terminal for multi-terminal access to the same Docker container.

xxxxxxxxxx
docker ps
xxxxxxxxxx
docker exec -it container_id /bin/bash
​

Check IMU topics

xxxxxxxxxx
rostopic list

image-20251027161624356

Print /imu/data_raw topic data

xxxxxxxxxx
rostopic echo /imu/data_raw

image-20251027161747316

Print /imu/mag topic data

xxxxxxxxxx
rostopic echo /imu/mag

image-20251027161825453

Autonomous Driving Car
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/中文