First, make sure you have compatible IMU module. We recommend
Grove - IMU 9DOF v2.0 but any module with
MPU-9250 sensor should work.
IMU functionality was introduced in leo_firmware version 0.5, so make sure to stay updated.
By default, the IMU will work on hSens2 port. You can change it to hSens1 by modifying params.h in
Connect the sensor pins according to CORE2 manual
You can use female jumper cables, or create your own IDC cable, like this one:
If you use Grove IMU, you can 3D print one of our
custom elecronic box lids (TODO: link) to attach the module inside the box:
Log in to the Rover's console via SSH
To set IMU functionality on or off, you need to send message to
rostopic pub /core2/set_imu std_msgs/Bool -- "data: true"
Now, you need to reset the board to apply changes. You can do this by turning on and off the whole Rover, or by sending a message to
rostopic pub /core2/reset_board std_msgs/Empty
After the board reset, new topics should spawn:
/imu/mag in which IMU gyroscope, accelerometer and magnetometer readings are published. (you can check available topics with
Check if the readings are correct with
rostopic echo, for example:
rostopic echo /imu/gyro
The sensor's accelerometer and gyroscope X, Y and Z axes should be printed on the board. If they are not, you can check MPU9250 IC orientation and identify the axes with this drawing:
The magnetometer axes were also transformed to these axes to comply with North-West-Up world frame.
The gyroscope data (
imu/gyro topic) represents angular velocity around sensor's axes in rad/s (radians per second).
The accelerometer data (
imu/accel topic) represents linear acceleration along sensor's axes in m/s2 (meters per second squared)
The magnetometer data (
imu/mag topic) represents magnetic field along sensor's axes in G (Gauss)
The firmware also provides services that perform sensor calibration and store the results in a persistent storage.
To calibrate gyroscope and accelerometer biases, just place the Rover on a flat surface, parallel to the ground and call the calibration service:
rosservice call /imu/calibrate_gyro_accel
Calibrating the magnetometer is a bit more difficult task, as it requires collection of a whole range of measurements on each axis. The method that works best is to move the sensor in a 3-dimensional figure eight, however, such motion can be hard to accomplish with the whole Rover.
To start the calibration, just call the service:
rosservice call /imu/calibrate_mag
After 4 seconds, the firmware should start data collection. After another 15 seconds, the service should return success message. Try to move the sensor in a varied motion for the whole duration of the service call.