ROS application routine1. ROS environment installation2. Bind the port3. IMU Ros package usage3.1 Compilation Workspace3.2 Modify parameter configuration3.3 Running the visual interface
This routine assumes that the system has already installed the ROS development environment by default. If the ROS environment is not installed, please install the ROS environment by yourself before running this routine.
Please run the corresponding command in the terminal
If you are using ubuntu 16.04, ROS kinetic, python2:
sudo apt-get install ros-kinetic-imu-tools ros-kinetic-rviz-imu-plugin
sudo apt-get install python-visual
If you are using ubuntu 18.04, ROS Melodic, python2:
xxxxxxxxxx
sudo apt-get install ros-melodic-imu-tools ros-melodic-rviz-imu-plugin
If you are using ubuntu 20.04, ROS Noetic, python3:
xxxxxxxxxx
sudo apt-get install ros-noetic-imu-tools ros-noetic-rviz-imu-plugin
pip3 install pyserial
Install ROS serial driver
xxxxxxxxxx
sudo apt-get install ros-$ROS_DISTRO-serial
The following content takes ubuntu 18.04, ROS Melodic version as an example.
First connect the IMU module to the USB port of the computer, and then copy the sample program ros_imu_ws.zip in the data to the user directory. Run the following command to unzip:
xxxxxxxxxx
unzip ros_imu_ws.zip
cd ~/ros_imu_ws
sudo bash bind_usb.sh
Restart the computer to make the bound port take effect
xxxxxxxxxx
sudo reboot
After restarting, check whether the port has been bound.
xxxxxxxxxx
ll /dev/imu_usb
Note: This method is only suitable for the case that the external USB device has only one CP2102 serial port chip. If there are multiple USB devices driven by CP2102, please do not use this binding method.
Open a command terminal and run the following command:
xxxxxxxxxx
cd ~/ros_imu_ws/
catkin_make -j
cd src/scripts/
sudo chmod 777 *.py
echo "source ~/ros_imu_ws/devel/setup.sh" >> ~/.bashrc
source ~/.bashrc
The baud rate is set according to the actual use. The default baud rate is 9600. If the user modifies the baud rate through the host computer, it needs to be modified accordingly to the modified baud rate.
Enter the workspace directory src/launch,
Open the configuration parameters in the rviz_and_imu.launch file.
xxxxxxxxxx
cd ~/ros_imu_ws/src/launch
vim rviz_and_imu.launch
If you have already operated 2. Bind the port, skip to 3.3 to run the visual interface. If the 2. Binding port operation is not performed, you need to manually modify the USB device number corresponding to the module. The specific operations are as follows:
xxxxxxxxxx
ls /dev/ttyUSB*
If the computer is connected to multiple USB devices, you can check the port once without inserting the inertial navigation module.
After inserting the inertial navigation module, check the port again, and compare the port numbers printed out twice before and after.
The second time, the extra port number is the USB device number of the inertial navigation module.
Modify parameter configuration. Parameters that need to be modified include the USB port number and baud rate.
Enter the workspace directory src/launch,
Open the configuration parameters in the rviz_and_imu.launch file.
xxxxxxxxxx
cd ~/ros_imu_ws/src/launch
vim rviz_and_imu.launch
The device number is /dev/ttyUSB0 (the code uses /dev/ttyUSB0 by default).
If the number recognized by your computer is not USB0, change it to the number recognized by your computer.
Note: If multiple USB serial devices are connected, it may be necessary to manually check and modify the corresponding serial number every time the device is turned on.
Save and exit after modification is complete.
If you are prompted that you do not have the USB permission, enter the following command in the terminal to increase the permission, or add the current user to the USB device permission list.
xxxxxxxxxx
sudo chmod 777 /dev/ttyUSB0
xxxxxxxxxx
roslaunch wit_ros_imu rviz_and_imu.launch
Open two new terminals and enter the following two lines of commands respectively to view the data.
xxxxxxxxxx
rostopic echo /wit/imu
rostopic echo /wit/mag
As shown below. Information output byrostopic echo