Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
How to Use Inertial-Link IMUs with the imu_node
Description: This tutorial is an introduction to using the MicroStrain Inertial-Link IMU connected to a desktop. After reading the tutorial, you should be able to bring up the imu_node and display the IMU data.Keywords: IMU, driver
Tutorial Level: BEGINNER
Contents
Compiling
Start by getting the dependencies and compiling the driver.
$ rosdep install microstrain_3dmgx2_imu $ rosmake microstrain_3dmgx2_imu
Powered On and Plugged In
Make sure that your USB imu is plugged in and the power light is on.
Configuring the IMU
Make sure that the imu_node will be able to access the imu.
Start by listing the permissions of the IMU:
ls -l /dev/ttyUSB0
You will see something similar to:
crw-rw-XX- 1 root dialout 188, 0 2009-08-14 12:04 /dev/ttyUSB0
If XX is rw: the usb device is configured properly.
If XX is --: the usb device is no configured properly and you need to:
sudo chmod a+rw /dev/ttyUSB0
Starting a roscore
For the imu_node to work properly, a ros core must be running. In a new terminal:
$ roscore
Running the imu_node
In a new terminal, run the imu_node:
$ rosrun microstrain_3dmgx2_imu imu_node
You will see something similar to:
[ INFO] 1250276678.466059000: Started node [/imu], pid [17125], bound on [aqy], xmlrpc port [49515], tcpros port [44773], logging to [/u/mwise/ros/ros/log/imu_17125.log], using [real] time [ INFO] 1250276679.540144000: Connected to IMU [ Inertia-Link] model [ 4200] s/n [ 3046] options [ 5g 300d/s] [ INFO] 1250276679.540247000: Calibrating IMU gyros. [ INFO] 1250276689.650297000: IMU gyro calibration completed. [ INFO] 1250276689.650416000: Initializing IMU time with offset 0.000000. [ INFO] 1250276689.664184000: IMU sensor initialized.
Note: If your IMU is at a port other than /dev/ttyUSB0, you could explicitly specify the port parameter, for example:
$ rosrun microstrain_3dmgx2_imu imu_node _port:=/dev/ttyUSB1
Viewing the data
To see that everything is working and data is being published to ros, in a new terminal:
$ rostopic echo imu/data
You will see something similar to:
header: seq: 1791 stamp: 1263496141218770057 frame_id: imu orientation: x: -0.00113008373396 y: 0.00770460351395 z: 0.379699384935 w: 0.925077162566 orientation_covariance: [0.0012250000000000002, 0.0, 0.0, 0.0, 0.0012250000000000002, 0.0, 0.0, 0.0, 0.0012250000000000002] angular_velocity: x: 0.005341142416 y: -0.00330266845413 z: -7.2395623647e-06 angular_velocity_covariance: [2.8900000000000004e-08, 0.0, 0.0, 0.0, 2.8900000000000004e-08, 0.0, 0.0, 0.0, 2.8900000000000004e-08] linear_acceleration: x: 0.438507700588 y: 0.012467633853 z: -9.82538275752 linear_acceleration_covariance: [0.0096040000000000014, 0.0, 0.0, 0.0, 0.0096040000000000014, 0.0, 0.0, 0.0, 0.0096040000000000014] ---
Move the IMU around to see the data change.
Note that the covariances have been set to values consistent with the manufacturer datasheet. These covariances are very pessimistic and you will most likely be able to use smaller values in your application.