What is IMU
IMU stands for inertial measurement unit, which is composed of three single-axis accelerometers and three single-axis gyroscopes. The accelerometer detects the acceleration signal of the object in the carrier coordinate system in three independent axes, while the gyroscope detects the angular velocity signal of the carrier relative to the navigation coordinate system. After processing these signals, the attitude of the object can be calculated.
It is worth noting that IMU provides relative positioning information. Its function is to measure the route of the object relative to the starting point, so it cannot provide information about your specific location. Therefore, it is often used together with GPS. When the GPS signal is weak in some places, IMU can play its role, allowing the car to continue to obtain absolute position information so as not to get lost.
In fact, the mobile phones we use every day, the cars and airplanes we take, and even missiles and spacecraft all use IMU. However, the cost and accuracy vary.
According to different scenarios, IMU has different requirements for accuracy. High accuracy also means high cost.
Low-precision IMU: used in ordinary consumer electronic products. This low-precision IMU is very cheap and is commonly used in mobile phones and sports watches. It is often used to record the number of steps.
Medium-precision IMU: used in unmanned driving. The price ranges from a few hundred to tens of thousands of yuan, depending on the positioning accuracy requirements of the unmanned vehicle.
High-precision IMU: used in missiles or space shuttles. Take missiles as an example. From the launch of the missile to the hitting of the target, the aerospace-grade IMU can achieve extremely high-precision calculations, and the error can even be less than one meter.
In addition to the accuracy and cost, IMU has two very critical characteristics. The first is the high update frequency, and the operating frequency can reach more than 100Hz; the second is the high calculation accuracy in a short period of time, without too much error.
IMU message under ROS
The IMU message under ROS looks like:
std_msgs/Header header
uint32 seq
timestamp // timestamp
string frame_id
geometry_msgs/Quaternion orientation // orientation
float64 x
float64 y
float64 z
float64 w
float64[9] orientation_covariance // orientation covariance
geometry_msgs/Vector3 angular_velocity // angular velocity
float64 x
float64 y
float64 z
float64[9] angular_velocity_covariance // angular velocity covariance
geometry_msgs/Vector3 linear_acceleration // linear acceleration
float64 x
float64 y
float64 z
float64[9] linear_acceleration_covariance // linear acceleration covariance
This message type provides IMU data, including orientation, angular velocity, and linear acceleration. Here’s a detailed explanation of each part:
- Header
seq
: Sequence number of the message.timestamp
: Timestamp indicating when the message was generated.frame_id
: Identifier of the reference coordinate frame.
- Orientation
x, y, z, w
: Components of the quaternion representing the IMU’s current orientation.orientation_covariance
: A 9-element array representing the covariance matrix of the orientation, indicating the uncertainty of the orientation measurement.
- Angular Velocity
x, y, z
: Components of the angular velocity, corresponding to the three axes.angular_velocity_covariance
: A 9-element array representing the covariance matrix of the angular velocity, indicating the uncertainty of the angular velocity measurement.
- Linear Acceleration
x, y, z
: Components of the linear acceleration, corresponding to the three axes.linear_acceleration_covariance
: A 9-element array representing the covariance matrix of the linear acceleration, indicating the uncertainty of the linear acceleration measurement.
How to record IMU data in Limo
- Open a new terminal. Run the following command:
roslaunch limo_bringup limo_start.launch
- Record IMU data
rosbag record -O bag_name.bag/topic1_name/topic2_name/xxx
Press Ctrl+C to end the recording. The file is automatically saved in the root directory with the name imu.bag.
Rosbag records a specific topic name:
rosbag record -O bag_name.bag /topic1_name /topic2_name /xxx
- Play back the data at 0.5 times the speed:
rosbag play -r 0.5 imu.bag
The terminal will display:
Visualize the data by rqt_plot
Replay the recored IMU data. And open the terminal and input:
rqt_plot
Close the LIMO driver.
In the interface, choose IMU topic data. Click ‘+’. Then you can see 3 angular velocity of IMU. And click the right side of the interface. Finally, you will see the IMU data changing.
Quiz
● Use ROS and rviz to visualize IMU sensor data.
Requirements:
- Subscribe to the IMU data topic and parse the data.
- Publish the parsed data to rviz.
- Use the IMU plugin in rviz to visualize the data in the form of a 3D model.
● Tips:
- You need to use an IMU data parsing library, such as the imu_filter_madgwick library that comes with ROS.
- You can refer to the IMU display tutorial on the ROS Wiki.
● Use IMU sensors to implement robot posture control.
Requirements:
- Subscribe to the IMU data topic and parse the data.
- Calculate the robot’s posture based on the IMU data.
- Implement robot posture control, such as keeping the robot stable, adjusting the robot’s posture, etc.
● Tips:
- You can use the robot control library in ROS, such as ROS Control.
About Limo
Limo is a smart educational robot published by AgileX Robotics. More details please visit: https://global.agilex.ai/
If you are interested in Limo or have some technical questions about it, feel free to join AgileX Robotics or AgileX Robotics. Let’s talk about it!