增加MAVLink协议 自定义消息.md

来源:互联网 发布:如何提升淘宝店铺销量 编辑:程序博客网 时间:2024/05/16 09:20

在common.xml 或者要使用的飞控xml文件里面增加类似代码

因为飞控、地面站使用ardupilotmega.xml
这里在ardupilotmega.xml里面
增加发动机转速参数消息包
219 to 224 预留的协议ID
如下定义了3个协议包

id221 发动机转速

MOTORS_COUNT发动机数量
MOTORS发动机转速

id222 喷洒农药相关

PESTICIDE_CONSUME 农药剩余
FLOW_RATE喷药速率

id223 用于计算作业区域面积(比如打点器)

DIRECTION,数据发送方向
LATITUDE,当前打点器纬度
LONGITUDE,当前打点器经度

      <!-- 219 to 224 RESERVED for more GOPRO-->        <!--无人机自定义协议区域-->          <message id="221" name="MOTORS">            <description>motors speed</description>                        <field name="MOTORS_COUNT" type="uint8_t">Motors Count</field>            <field name="MOTORS" type="float[8]">Motors speed Array</field>        </message>            <message id="222" name="PESTICIDE">            <description>Farming Pesticide</description>                        <field name="PESTICIDE_CONSUME" type="float">Pesticide Consume</field>            <field name="FLOW_RATE" type="float">Pesticide flow rate</field>        </message>        <message id="223" name="SAMPLE_MISSION_AREA">            <description>Sampling  Mission Area int the real geographic position</description>                        <field name="DIRECTION" type="uint8_t">Data transport direction(1 GCS to autopilot, 0 autopilot to GCS)</field>            <field name="LATITUDE" type="float">current Sampling position latitude</field>            <field name="LONGITUDE" type="float">current Sampling position longitude</field>        </message>        <!--无人机自定义协议区域-->

既可以在ardupilotmega 文件夹下面生成对应的消息包打包和解包的头文件(这里是 mavlink_msg_motors.h

最后可以在MAVLinkProtocol.cc里面处理对应的消息包了

原创粉丝点击