ROS2 Application
System configuration: Ubuntu 22.04
ROS2 version: humble
ROS2 environment setup
- Update the download sources
PowerShell
sudo apt update- Enter the ros2 installation command
PowerShell
wget http://fishros.com/install -O fishros && . fishrosConnect the device to the VM
- Check the device
PowerShell
ll /dev/ttyUSB*- Create the port mapping
PowerShell
sudo gedit /etc/udev/rules.d/99-serial-imu.rules- Fill in the mapping file contents
PowerShell
KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0777", SYMLINK+="imu-serial"- Save and exit, then run the commands to apply the rules
PowerShell
sudo udevadm trigger
sudo service udev reload
sudo service udev restart- Verify
PowerShell
ll /dev/imu-serialImport the prepared archive
Available in the same Feishu directory: IMU_ROS2.zip
Transfer it to the VM with a file transfer tool
Install the IMU_Library library
PowerShell
# After downloading and extracting the IMU_ROS2 archive, enter the IMU_Library directory and run setup.py
cd IMU_ROS2/IMU_Library
# Install the library and its dependencies
pip install -e .
# Or install with setup.py
python setup.py installInstall Python libraries
PowerShell
sudo pip3 install pyserial
sudo pip3 install smbus2Build the ROS2 project
- Return to the ~/IMU_ROS2 directory
PowerShell
cd IMU_ROS2
colcon build --symlink-install- Add the workspace ~/IMU_ROS2 to the environment variables
PowerShell
# Edit ~/.bashrc
sudo gedit ~/.bashrc
# Write the following command at the end
source ~/IMU_ROS2/install/setup.bashAfter a successful build, run the following command to check whether the imu_ros2 package contains executables
ros2 pkg executables imu_ros2
Start the ROS2 nodes
PowerShell
source install/setup.bash
ros2 run imu_ros2 imu_publisherIMU data output
- Open a new terminal and list the imu topics
PowerShell
ros2 topic list- Print the /imu/data topic data
PowerShell
ros2 topic echo /imu/data- Open a new terminal and check the msg topic
PowerShell
ros2 topic echo /imu/magRViz2 visualization
- Run the command to open the rviz interface
PowerShell
ros2 launch imu_ros2 imu_visualization.launch.pyFAQ
- If the node fails to start, try the following commands
PowerShell
# Run in the ~/IMU_ROS2 directory
source install/setup.bash
# Port number issue
sudo chmod 666 /dev/imu-serial
