For Teaching and Learning ROS2
This guide provides a clear and concise setup for integrating an Xsens MTi IMU sensor with ROS 2 Humble using the xsens_mti_ros2_driver package. It includes installation steps, configuration, usage instructions, and troubleshooting tips based on real-world debugging.
To use the Xsens MTi IMU with ROS 2 Humble, ensure you have the following:
- ROS 2 Humble installed on your system (Ubuntu 22.04 recommended).
- A Colcon workspace (e.g.,
~/botdev). - An Xsens MTi sensor (e.g., MTi-1, MTi-3, MTi-7, or MTi-600 series).
- A USB cable or USB-to-Serial adapter (e.g., PL2303, FTDI) for connecting the sensor.
- External power supply for UART-only sensors (if applicable).
- Basic dependencies:
ros-humble-ros-base,python3-colcon-common-extensions.
Follow these steps to set up the xsens_mti_ros2_driver package in your ROS 2 workspace:
-
Navigate to your Colcon workspace:
cd ~/ros2_ws/src
-
Clone the Xsens MTi ROS 2 driver repository:
git clone https://github.com/fs-feup/xsens-imu.git
-
Install dependencies: Ensure all required ROS 2 dependencies are installed:
sudo apt update sudo apt install ros-humble-ros-base python3-colcon-common-extensions
-
Build the workspace:
cd ~/ros2_ws colcon build --symlink-install
-
Source the workspace:
source ~/ros2_ws/install/setup.bash
-
Connect the Xsens MTi sensor:
- Plug the sensor into your computer via USB or a USB-to-Serial adapter.
- For UART-only sensors, ensure an external power supply is connected.
-
Verify device detection: Check if the sensor is detected (e.g., as
/dev/ttyUSB0):ls /dev/tty* -
Set permissions (if needed): Grant access to the serial port:
sudo chmod 666 /dev/ttyUSB0
-
Configure the sensor (optional):
- Use the Xsens MT Manager software to set baud rates, output formats, or other sensor settings if required.
- Ensure the sensor’s baud rate matches the driver’s configuration (default: 115200).
-
Update ROS parameters: Edit the driver’s configuration file (e.g.,
xsens_mti_ros2_driver/config/xsens_mti_node.yaml) to match your sensor’s port and settings:xsens_mti_node: ros__parameters: port: "/dev/ttyUSB0" baudrate: 115200 frame_id: "imu_link"
-
Source the workspace (if not already done):
source ~/ros2_ws/install/setup.bash
-
Launch the driver: Start the ROS 2 node for the Xsens MTi sensor:
ros2 launch xsens_mti_ros2_driver xsens_mti_node.launch.py
-
Verify output: Check published topics (e.g.,
/imu/data,/imu/mag):ros2 topic list ros2 topic echo /imu/data
-
No data on topics:
- Verify the sensor is connected and powered.
- Check the serial port and baud rate in the configuration file.
- Ensure the correct permissions are set for the serial port.
-
Serial port errors:
- Run
dmesg | grep ttyto debug USB-to-Serial adapter issues. - Try a different USB port or adapter (e.g., FTDI instead of PL2303).
- Edit the config file, set auto_detect to false and add your port ID through
ls -l /dev/ttyUSB*and the baud rate
- Run
-
Driver not building:
- Ensure all dependencies are installed (
rosdep install --from-paths src --ignore-src -r -y).
- Ensure all dependencies are installed (
-
Incorrect IMU data:
- Calibrate the sensor using Xsens MT Manager.
- Verify the
frame_idand coordinate system in the configuration file.
For additional support, check the Xsens Support Portal or the driver’s GitHub Issues.
sudo apt update
sudo apt-get install ros-humble-sick-scan-xd
colcon build- Connect your PC to the LiDAR via Ethernet.
- Set a static IP on your PC in the same subnet as the LiDAR.
Example:
sudo ip addr add 192.168.0.10/24 dev eth0ros2 launch sick_scan_xd sick_tim_5xx.launch.pyDefault Configuration: The driver expects binary protocol.
Fix Options:
Use telnet:
telnet 192.168.0.1 2111If you prefer not to change the scanner:
ros2 launch sick_scan_xd sick_tim_5xx.launch.py use_binary_protocol:=false- Ensure IP settings are correctly configured.
- Temporarily disable firewall for initial setup if needed.
- SOPAS Engineering Tool (Windows only) can help verify configuration.