APM(PX4)中增加新的mavlink消息,传递信息到misson planner显示

来源:互联网 发布:个人做淘宝客怎么备案 编辑:程序博客网 时间:2024/04/29 19:25

1.增加消息,修改libraries/GCS_MAVLink/message_definitions/下的ardupilotmega.xml文件,增加如下代码

    <message name="CUSTOMER" id="227">
      <description>customer val</description>
      <field name="val1" type="float">value 1 </field>
      <field name="val2" type="float">value 2</field>
    </message>  

2.运行 ./libraries/GCS_MAVLink/generate.sh命令,升级mavlink文件。

3.增加此消息的发送,需要修改ArduCopter下的GCS_Mavlink.cpp文件

  • 在data_stream_send的最后,增加send_message(MSG_CUSTOMER);
  • 在try_send_message中,增加

    case MSG_CUSTOMER:
        CHECK_PAYLOAD_SIZE(CUSTOMER);
        copter.send_customer(chan);
        break; 

  • 定义send_customer函数,

void NOINLINE Copter::send_customer(mavlink_channel_t chan)
{
        mavlink_msg_customer_send(chan,1.03,5.01);
}

4.在ArduCopter下的copter.h中声明刚才定义的函数。即增加 void send_customer(mavlink_channel_t chan);

5.修改./libraries/GCS_MAVLink/gcs.h文件,在ap_message中增加MSG_CUSTOMER。

6.重新编译。

  


2 0
原创粉丝点击