Send Debug String / Float Pairs

官网英文原文地址:http://dev.px4.io/advanced-debug-values.html

It is often necessary during software development to output individual important numbers.

This is where the generic 'NAMED_VALUE' packets of MAVLink come in.

Files

The code for this tutorial is available here:

  • Debug Tutorial Code
  • Enable the tutorial app by uncommenting / enabling the mavlink debug app in the config of your board

All required to set up a debug publication is this code snippet. First add the header file:

``` #include

#include <uORB/topics/debug_key_value.h>```

Then advertise the debug value topic (one advertisement for different published names is sufficient). Put this in front of your main loop:

```/* advertise debug value */
struct debug_key_value_s dbg = { .key = "velx", .value = 0.0f };
orb_advert_t pub_dbg = orb_advertise(ORB_ID(debug_key_value), &dbg);```

And sending in the main loop is even simpler:

dbg.value = position[0]; orb_publish(ORB_ID(debug_key_value), pub_dbg, &dbg);

The result in QGroundControl then looks like this on the real-time plot: debug

© PX4WIKI team all right reserved,powered by Gitbook该文件修订时间: 2017-01-04 03:03:43