Prerequisites
Ubuntu 20.04 with ROS1 Noetic installed, along with Python3.
1. Installing ROS IMU Dependencies
sudo apt-get install ros-noetic-imu-tools ros-noetic-rviz-imu-plugin
2. Downloading the Official Example Program
Download the ROS package from the official WIT Motion GitHub repository:
GitHub - WITMOTION/WitStandardProtocol_JY901
Extract the ROS package contents into your home directory. On Ubuntu, you need an additional package to extract RAR files:
sudo apt-get install unrar
3. Building the Workspace
cd ~/wit/wit_ros_ws/
catkin_make
If catkin_make fails due to Python version issues, use:
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
Fix missing dependencies if compilation fails:
pip3 install modbus_tk
Set up script permissions and source the workspace:
cd ~/wit/wit_ros_ws/src/scripts/
sudo chmod 755 *.py
source ~/wit/wit_ros_ws/devel/setup.bash
echo "source ~/wit/wit_ros_ws/devel/setup.bash" >> ~/.bashrc
4. Running the ROS Driver and Visualizing IMU Data
4.1 Identifying the USB Port
ls /dev/ttyUSB*
4.2 Configuring the Launch File
Open wit_imu.launch in the ROS package and make the following changes:
- Set
typefromnormaltomodbus - Update
valueto match your USB port (e.g.,/dev/ttyUSB0) - Set baud rate to
115200(if errors occur, try9600)
4.3 Launching the ROS Driver
Grant USB permissions:
sudo chmod 666 /dev/ttyUSB0
Start the IMU driver:
roslaunch wit_ros_imu wit_imu.launch
4.4 Reading IMU Data
Open a new terminal and run the data acquisition script:
cd ~/wit/wit_ros_ws/src/scripts/
python3 read_imu_orientation.py
This displays real-time orientation and sensor data from the IMU.
4.5 Visualizing IMU Orientation
Launch RViz with IMU plugin visualization:
roslaunch wit_ros_imu rviz_and_imu.launch
This opens RViz dsiplaying the IMU's real-time orientation in a 3D view.