发送调试值
在软件开发过程中,输出单个重要数字通常是必要的。 这就是 MAVLink 的通用 NAMED_VALUE_FLOAT
、DEBUG
和 DEBUG_VECT
数据包的来源。
在 MAVLink 调试消息和 uORB 主题之间进行映射
MAVLink调试消息转换为/自 uORB 主题。 为了发送或接收 MAVLink 调试消息,您必须分别发布或订阅相应的主题。 下面是一个表,其中总结了 MAVLink 调试消息和 uORB 主题之间的映射:
教程:发送字符串/浮点配对
本教程演示如何使用关联的 uORB 主题 debug_key_value
NAMED_VALUE_FLOAT
发送 MAVLink 消息。
本教程的代码可在此处找到:
开启教程 app,方法是在你配置的主板上的 mavlink 调试应用程序来取消/开启
设置调试发布所需的只是此代码段。 首先添加头文件:
然后广播调试值主题(一个针对不同发布名称的广播就足够了)。 把这个放在你的主循环前面:
而发送主循环更简单:
:::caution Multiple debug messages must have enough time between their respective publishings for Mavlink to process them. This means that either the code must wait between publishing multiple debug messages, or alternate the messages on each function call iteration. :::
The result in QGroundControl then looks like this on the real-time plot:
教程:发送字符串/浮点配对
首先,订阅主题 debug_key_value
:
然后对主题进行监听:
当 debug_key_value
主题上有新消息可用时,不要忘记根据其键属性对其进行筛选,以便放弃键与 velx
不同的消息:
When a new message is available on the debug_key_value
topic, do not forget to filter it based on its key attribute in order to discard the messages with key different than velx
:
Last updated