APM::Rover下GCS_MAVLink的逻辑梳理

前言

这里结合之前添加的mavlink消息,梳理下从飞控的物理端口到应用层的消息传递过程;
顺带再把整个框架在梳理了一遍;这里结合Rover来叙述,可能和copter有些区别,先开始吧~

libraries

这里需要说明下,关于mavlink的协议及生成部分,这里就不详细叙述了,后面专门单独写一篇文章来叙述。
还是说回GCS_MAVLink,先来分析下文件结构:

/ardupilot/libraries/GCS_MAVLink
|——example
|——GCS_Common.cpp
|——GCS_DeviceOp.cpp
|——GCS_Logs.cpp
|——GCS_MAVLink.cpp
|——GCS_MAVLink.h
|——GCS_serial_control.cpp
|——GCS_Signing.cpp
|——GCS.h
|——MAVLink_routing.cpp
|——MAVLink_routing.h

这里我们挨个举例进行梳理

GCS_Common.cpp

这里可以看出说包含的头文件,以及mavlink本身的一些工具函数:
头文件

这里就很明显能看出来是处理GCS上行的数据对应的处理函数(gimbal、gps、mission、param、radio、rc、set_mode…):
接收处理函数

下面就是飞控端下行的数据处理函数(accelcal、ahrs、version、battery、gps、message、heartbeat、home、radio_in、power_status、raw_imu、sensor_offsets…),基本上通过接收和发送这些工具函数就能大概和GCS界面上的操作对应起来了(如果熟悉一款GCS的话);
发送处理函数
接下来就是GCS_DeviceOp:

GCS_DeviceOp

先列出数据包的结构吧
handle device operations over MAVLink
从这句话翻译来看,差不多可以知道,GCS_DeviceOp就是通过mavlink,对飞控上设备进行读写操作

typedef struct __mavlink_device_op_read_t {
	 uint32_t request_id;      /*< request ID - copied to reply*/
	 uint8_t target_system;    /*< System ID*/
	 uint8_t target_component; /*< Component ID*/
	 uint8_t bustype;          /*< The bus type*/
	 uint8_t bus;              /*< Bus number*/
	 uint8_t address;          /*< Bus address*/
	 char busname[40];         /*< Name of device on bus (for SPI)*/
	 uint8_t regstart;         /*< First register to read*/
	 uint8_t count;           /*< count of registers to read*/
} mavlink_device_op_read_t;

typedef struct __mavlink_device_op_write_t {
	 uint32_t request_id;      /*< request ID - copied to reply*/
	 uint8_t target_system;    /*< System ID*/
	 uint8_t target_component; /*< Component ID*/
	 uint8_t bustype;          /*< The bus type*/
	 uint8_t bus;              /*< Bus number*/
	 uint8_t address;          /*< Bus address*/
	 char busname[40];         /*< Name of device on bus (for SPI)*/
	 uint8_t regsta
  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
APM 2.5 启动过程中 mavlink 1.0 协议监听 > text: Demo Servos! severity=1; text=68; >>> GCS Msg: MAVLINK_MSG_ID_HEARTBEAT ( 0/0x00) >>> FE 09 75 FF BE 00 00 00 00 00 06 03 00 00 03 90 B8 , W:1 >>> custom_mode=0; type=6; autopilot=3; base_mode=0; system_status=0; mavlink_version=3; > Apm Msg : MAVLINK_MSG_ID_HEARTBEAT ( 0/0x00) > FE 09 38 01 01 00 10 00 00 00 01 03 11 02 03 37 5F , W:1 > custom_mode=16; type=1; autopilot=3; base_mode=17; system_status=2; mavlink_version=3; > Apm Msg : MAVLINK_MSG_ID_SYS_STATUS ( 1/0x01) > FE 1F 39 01 01 01 0F FC FF FF 0F 00 00 00 0F FC FF FF 00 00 60 27 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 FF 4B 3D , W:1 > onboard_control_sensors_present=-1009; onboard_control_sensors_enabled=15; onboard_control_sensors_health=-1009; load=0; voltage_battery=10080; current_battery=-1; drop_rate_comm=0; errors_comm=0; errors_count1=0; errors_count2=0; errors_count3=0; errors_count4=0; battery_remaining=-1; > Apm Msg : MAVLINK_MSG_ID_STATUSTEXT (253/0xFD) > FE 33 3A 01 01 FD 01 44 65 6D 6F 20 53 65 72 76 6F 73 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9B 2C , W:1 > text: Demo Servos! severity=1; text=68; >>> GCS Msg: MAVLINK_MSG_ID_HEARTBEAT ( 0/0x00) >>> FE 09 76 FF BE 00 00 00 00 00 06 03 00 00 03 AE 3B , W:1 >>> custom_mode=0; type=6; autopilot=3; base_mode=0; system_status=0; mavlink_version=3; > Apm Msg : MAVLINK_MSG_ID_HEARTBEAT ( 0/0x00) > FE 09 3B 01 01 00 10 00 00 00 01 03 11 02 03 09 DC , W:1 > custom_mode=16; type=1; autopilot=3; base_mode=17; system_status=2; mavlink_version=3; > Apm Msg : MAVLINK_MSG_ID_SYS_STATUS ( 1/0x01) > FE 1F 3C 01 01 01 0F FC FF FF 0F 00 00 00 0F FC FF FF 00 00 60 27 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 FF 1A 30 , W:1 > onboard_control_sensors_present=-1009; onboard_control_sensors_enabled=15; onboard_control_sensors_health=-1009; load=0; voltage_battery=10080; current_battery=-1; dro
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值