在APM中添加新的mavlink消息

在最新的APM代码中添加MAVLINK消息和教程中介绍的有些出入。

请对照“]Pixhawk源码笔记十一:增加新的MAVLink消息”进行添加


首先在common.xmlardupilotmega.xml文件中添加你的信息的定义声明。

这2个文件的实际位置和笔记十一是不同的。实际是在“Modules/mavlink/message_definitions/v1.0”之中

然后可以在common.xml中仿造添加一条消息,例如我测试的是在文件最后结尾处加入

<message id="255" name="TEMP">
               <description>send temperature to gcs</description>
               <field type="int16_t" name="temperature1">Raw Temperature measurement (raw)</field>
               <field type="int16_t" name="temperature2">Raw Temperature measurement (raw)</field>
               <field type="int16_t" name="temperature3">Raw Temperature measurement (raw)</field>
               <field type="int16_t" name="temperature4">Raw Temperature measurement (raw)</field>
</message>


添加后保存文件,编译。

会发现在Build.ArduCopter/libraries/GCS_MAVLink/include/mavlink/v1.0/common文件下 会多出来新的文件mavlink_msg_temp.h

然后在

GCS.h中的class GCS_MAVLINK

中增加新成员void send_temp(void);


然后在GCS_Common.cpp中加入函数实体

// 发送温度数据//
void GCS_MAVLINK::send_temp(void)
{
    mavlink_msg_temp_send(chan, 0x0a,0x0b,0x0c,0x0d);//四个变量,测试使用。方便在串口助手里面找到。
}

最后将这个命令加入到发送循环当中。

例如在GCS_Mavlink.cpp当中的红色的部分。

bool GCS_MAVLINK::try_send_message(enum ap_message id)

{

.....................................

case MSG_RAW_IMU2:
        CHECK_PAYLOAD_SIZE(SCALED_PRESSURE);
        copter.gcs[chan-MAVLINK_COMM_0].send_scaled_pressure(copter.barometer);
       
copter.gcs[chan-MAVLINK_COMM_0].send_temp();//

.......................................................................

}

然后在电脑端利用串口助手链接PIXHAWK,你会发现可以接收到数据,但是接收不到加的这组数据。

因为你要打开MissionPlanner激活一下。然后关闭MP,打开串口助手就可以查找到

FE 08 42 01 01 FF 0A 00 0B 00 0C 00 0D 00 38 96

这组命令

以上是我自己添加mavlink的步骤和方法,内容比较少,都是干货。中间涉及的步骤和C++语言结构等等内容

希望大家帮一起补充全。


  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
您可以使用Elastic APM .NET Agent来在.NET Core应用程序进行配置,以下是一些基本步骤: 1. 在您的.NET Core应用程序添加Elastic APM .NET Agent依赖项。 2. 在您的应用程序配置Elastic APM .NET Agent。这可以通过在您的程序的Startup类添加一个服务并提供配置信息来实现。您可以使用环境变量或JSON文件来提供这些配置信息。 3. 在您的应用程序使用Elastic APM API来记录事务和拦截器。 以下是一个简单的示例: 1. 添加Elastic APM .NET Agent依赖项 (可以在项目文件添加): <PackageReference Include="Elastic.Apm.AspNetCore" Version="1.10.0" /> 2. 在Startup.cs文件添加服务 public void ConfigureServices(IServiceCollection services) { services .AddElasticApm(options => { options.ServiceName = "my-service-name"; }) .AddMvc(); } 3. 在您的代码使用Elastic APM API: [HttpGet("search")] public async Task<IActionResult> Search([FromQuery] string q) { using var transaction = _tracer.StartTransaction("search", "query"); transaction.Context.Labels["custom-label"] = "custom-value"; try { var result = await _searchService.SearchAsync(q); transaction.Context.Http = new HttpInfo() { Method = "GET", Url = new Uri($"http://example.com/search?q={q}"), StatusCode = 200 }; return Ok(result); } catch (Exception ex) { transaction.CaptureException(ex); return StatusCode(500); } } 请注意,以上示例仅用于说明,您需要根据您的应用程序类型和需要进行更多的自定义配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值