Understanding the MAVLink connection between ArduSub and Mavros

Hi
I plan to write a 6-DOF controller for the BlueROV2 as my master thesis. For this I have the following setup: A BlueROV2, heavy configuration, with the pixhawk flight controller (3DR Pixhawk 1 · PX4 v1.9.0 User Guide) and a topside computer running ROS2 humble and communicating with ArduSub via Mavros.

Now, I wish to evaluate the IMU in the pixhawk, to get a grip of the quality of the estimated orientation. Since the pixhawk contains multiple accelerometers and gyroscopes, I would like to know which one I’m using and whether I can choose between them.

Mavros publishes several IMU related topics, the ones related to inertial sensors are /imu/data, /imu/data_raw and /imu/mag. I traced those back to their corresponding MAVlink messages (Messages (common) · MAVLink Developer Guide) and found the following connections:

/imu/data: ATTITUDE, ATTITUDE_QUATERNION
/imu/data_raw: HIGHRES_IMU, RAW_IMU, SCALED_IMU
/imu/mag: HIGHRES_IMU, RAW_IMU, SCALED_IMU

However, I have not yet been able to determine to which sensors these MAVlink messages are linked. Do you have any Information on this, or can point me to literature on this topic? I would be grateful for every hint.

Another question, that arose, regards the frequency at which Mavros publishes the IMU messages. This is currently at about 10 Hz, which is quite slow. To me, it seems that a message is published as soon as a MAVlink message is received, so I was wondering how I could increase the frequency of the MAVlink messages.

I hope my problems are formulated clearly, if you have any questions please don’t hesitate to reach out to me.

Hi @franka

This site is auto-generated and will tell you where in the ArduSub code a MAV message is sent from: MAVLink Support | ArduSub

Looking at ATTITUDE, it points to libraries/GCS_MAVLink/GCS_Common.cpp. Tracing the code, the message is sent here: https://github.com/ArduPilot/ardupilot/blob/e9f46b91cda16cf7a48eb9861fea13e452c5c08c/libraries/GCS_MAVLink/GCS_Common.cpp#L4633

This function gets the data from AP::ahrs(), which is a singleton that manages the AHRS system and the underlying EKF cores (also called “lanes”). So, we can infer that this data comes from the output of the currently running EKF core, not the IMU inputs.

You’ll need to look at how the EKF cores are set up via the various EK2_* and EK3_* parameters to see how they are configured. Typically there is a core for each IMU on the system, and a Pixhawk flight controller has 2 IMUs, so there will be 2 cores. Only 1 core will be active at a time. This document is a bit old, but a good backgrounder: Extended Kalman Filter (EKF) — Copter documentation

As for message frequency, messages are bundled into stream groups, and the GCS (e.g., QGroundControl) can control the frequency of the various stream groups. MAVLink Support | ArduSub

There is another way to specify a per-message frequency using mavros, see this code for an example: https://github.com/clydemcqueen/orca4/blob/77152829e1d65781717ca55379c229145d6006e9/orca_base/src/manager.cpp#L129

If you want the raw IMU data you can get that (after the flight is over) by looking at the dataflash logs recorded on the Pixhawk SD card. Take a look at this description: Onboard Log Messages | ArduSub I have not looked at this data closely, but IIRC it is logged at 20Hz.

I hope this helps!

1 Like

Hi @clyde

Thanks for your detailed answer, it was indeed helpful :slight_smile:

I followed your example for the /mavros/imu/data_raw topic, looking through the libraries /GCS_MAVLink/GCS_common.cpp and /AP_InertialSensor/AP_IntertialSensors.cpp and it seems to me, that SCALED_IMU and RAW_IMU both publish data from the IMU1 (https://github.com/ArduPilot/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L5853).

I then had a look into the INS_* Parameters in QGround Control, where IDs for several accelerometers and Gyroscopes can be found, the first of which are
INS_ACC_ID: 1246218
INS_GYR_ID: 2163722

Now I’m wondering how to find the actual sensors behind these IDs. Do you know where I could find this Information?

Take a look at Tools/scripts/decode_devid.py:

1 Like