High-precision IMU Attitude Sensor Usage Tutorial
Download the Compressed PacketIMU_ROS1.zip, unzip it, and then enter ~/IMU_Library
- **Install the required Python libraries for the code **
PowerShell
pip install pyserial
pip install smbus2- **Install the IMU_Library **
PowerShell
# Install the library and its dependencies
pip install -e .
# Or install with setup.py
python setup.py install- Set Port Mapping
PowerShell
# To prevent the port from changing after unplugging, set up port mapping
sudo gedit /etc/udev/rules.d/99-serial-imu.rules
# If the message that the gedit command is not found appears, install it first
sudo apt install gedit
# Fill in the mapping content
KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0777", SYMLINK+="imu-serial"
# Parameter description:
`--mode`: Communication mode: `serial` (serial port) or `i2c`
`--port`: Serial port name (e.g., `/dev/ttyUSB0`) or I2C port number (e.g., `7`)
`--rate`: Data printing frequency (Hz), default 10Hz
`--debug`: Enable debug mode, show detailed information
# Save and exit, then run the command to apply the rules
sudo udevadm trigger
sudo service udev reload
sudo service udev restart
# Verify
ll /dev/imu-serial
# Output example:
lrwxrwxrwx 1 root root 7 1月 22 10:00 /dev/imu-serial -> ttyUSB0Serial Communication
- Enter the ~/IMU_Library/IMU_Library directory and run the IMU_Serial_Library.py file
PowerShell
cd ~/imu_ros1/src/IMU_ROS1/IMU_Library/IMU_Library
# or
cd ~/imu_ros2/src/IMU_ROS2/IMU_Library/IMU_Library
# Run the IMU data printing file
python3 IMU_Serial_Library.pyI2C Communication
- Enter the ~/IMU_Library/IMU_Library directory and run the IMU_I2C_Library.py file
PowerShell
cd ~/IMU_Library/IMU_Library
# Run the IMU data printing file
python3 IMU_I2C_Library.pyIMU Calibration
- Enter the ~/IMU_Library/IMU_Library directory and run the imu_calibration_tool.py file
PowerShell
cd ~/IMU_Library/IMU_Library
# Run the IMU calibration code file -- serial communication calibration
# Run all calibrations (full, magnetometer, temperature)
python3 imu_calibration_tool.py --mode serial --port /dev/imu-serial
# Full calibration only
python3 imu_calibration_tool.py --mode serial --port /dev/imu-serial --calibrate imu
# Magnetometer only
python3 imu_calibration_tool.py --mode serial --port /dev/imu-serial --calibrate mag
# Temperature only
python3 imu_calibration_tool.py --mode serial --port /dev/imu-serial --calibrate temp
# Run the IMU calibration code file -- I2C communication calibration
# Run all calibrations (full, magnetometer, temperature)
python3 imu_calibration_tool.py --mode i2c --port 1
# Full calibration only
python3 imu_calibration_tool.py --mode i2c --port 1 --calibrate imu
# Magnetometer only
python3 imu_calibration_tool.py --mode i2c --port 1 --calibrate mag
# Temperature only
python3 imu_calibration_tool.py --mode i2c --port 1 --calibrate tempOfficial Repository Example
Juxi Technology provides complete open-source code for the IMU module: GitHub
ROS1 / ROS2 Examples
The repository natively supports ROS1 and ROS2, including calibration tools and visualization nodes:
bash
git clone https://github.com/Juxi-Technology/ICM42670P-High-Precision-IMU-Module.git
cd ICM42670P-High-Precision-IMU-Module
# ROS2
colcon build
source install/setup.bash
ros2 launch icm42670p imu_launch.pyPython Calibration Tool
bash
# Run six-face calibration to obtain accurate accelerometer and gyroscope bias
python calibration/calibrate.py --port /dev/ttyUSB0- IMU Inertial Module
- Multi-Board Examples
- I2C Communication
- Serial Communication
- ROS Examples

