Reading Mavlink special messages, using pymavlink

Hi there all,
I am following ardusub’s official docs, so I can read mavlink messages that suits my needs.
At the time of writing this, data that I need are:

  • time (as time of reading data)
  • depth
  • pressure
  • temperature
  • heading

Searching the forum and in Mavlink’s documentation, I could find those messages :

  • time - SYSTEM_TIME (from Mavlink’s common messages)
  • depth - GLOBAL_POSITION_INT or VFR_HUD (found here and mentioned also in here)
  • pressure - SCALED_PRESSURE2 (found here, also here and in this thead)
  • temperature - RAW_PRESSURE or SCALED_PRESSURE (also SCALED_PRESSURE2, SCALED_PRESSURE3 found in mavlink docs, but cannot decide which is the correct message)
  • heading - VFR_HUD, RAW_IMU and ATTITUDE (found here and here)

specially for the heading, my search results confused me, since I cannot tell the difference between VFR_HUD , RAW_IMU, ATTITUDE and AHRS

I think… testing those and at the same time crosschecking with QGC’s data, can give me an answer. But I would like anyone’s suggestion in this forum, based on your experience.

Thanks is advance !!

Hi,

  • depth - you should use VFR_HUD, GLOBAL_POSITION_INT is for GPS systems.
  • temperature - it depends, you can get the temperature of the pressure sensor (Bar100, Bar30, Bar02) with SCALED_PRESSURE2 or Celsius Fast-Response Temperature Sensor with SCALED_PRESSURE3.
  • heading - RAW_IMU is the raw values from the sensor. For heading estimation, you should use VFR_HUD (0° … 360º [degree]) or ATTITUDE (-pi … +pi [rad]), the only difference is the unit.

Since ArduPilot messages are limited and are used in multiple devices/concepts, some messages like SCALED_PRESSURE2 and SCALED_PRESSURE3 can be a bit confuse, but everything else is straightforward after reading the documentation.

Hey @patrickelectric thanks for the answer !!
you didn’t mention anything about time or pressure, so I suppose I was right on those.
To sum up … mavlink messages I need are:

  • time - SYSTEM_TIME.time_unix_usec
  • depth - VFR_HUD.alt
  • pressure - SCALED_PRESSURE2.press_diff
  • temperature - SCALED_PRESSURE2.temperature (I use the Bar30 sensor)
  • heading - VFR_HUD.heading

please correct me if anything of the above is wrong.

I also encountered some difference between mavlink time and local time (on the system python is reading the messages) - a very small one, but in a case of video timing might be critical.
I also saw this mentioned in Writing telemetry data (specifically, depth) to gopro video? - #5 by mspencer

Is there a workaround on this ??
and what is the status of Add option to set system time via GCS ??

many thanks

Hi,

Yes, I just did the corrections, your other assumptions are correct.

Everything looks right.

For the time issue, this should be fixed if you are using the last version of ArduSub and QGC. After doing the connection with the vehicle, QGC will set the time based on the surface computer date/time information, you can also set the desired time with system_time_send.

1 Like

Patrick thank you very much for your answer !!

1 Like

Hi,
How did you read all this parameter’s mavlink message ? Can you help me ? Thanks.

There’s a difference between “mavlink messages” (which are regularly communicated between the vehicle and ground control software) and “vehicle parameters” (which the vehicle uses for internal control, and to interpret the messages/commands it gets sent). We have examples for getting both:

The discussion in this thread has all been about mavlink messages, so I expect you want the first one.