10 Oct 2012

Analyzing mavlink packages

I am currently on the search for a simple way to graph and analyze ArduPilot Mega telemetry logs. APM uses mavlink as protocol.

Andrew Tridgel has written a nice python library for the mavlink protocol which is called (who would have guessed?) pymalink.

pymavlink comes with a couple of examples which are quiet usefull (check the pymavlink/examples folder).

mavlogdump.py will generate an ASCII representation of the binary data structs. This outpu can be easily converted with sed, grep, awk, etc. for analysis in other programs.

mavplot.py can be used to graph data from the file.

I am currently analyzing a crash of a fixed wing drone. It's far away and all I have is a telemetry log file. mavplot.py could nicely display, that the drone stalled shortly after the takeoff, still unsure why.

mavplot.py example usage:

$ pymavlink/examples/mavgraph.py --planner --mav10 sander.tlog \
  VFR_HUD.airspeed 'VFR_HUD.groundspeed' '(SERVO_OUTPUT_RAW.servo1_raw-1000)/100' \
  '(SERVO_OUTPUT_RAW.servo2_raw-1000)/100' '(SERVO_OUTPUT_RAW.servo3_raw-1000)/100' \ 
  '(SERVO_OUTPUT_RAW.servo4_raw-1000)/100' ATTITUDE.roll ATTITUDE.pitch ATTITUDE.yaw \
  'VFR_HUD.alt/10'
 

The nice thing about these tools is, that parameters can contain python expressions which means, all the values can be adjusted to a specific need.