mavlink代码V2.0

帧组成

V1 帧组成

在这里插入图片描述
STX:数据包起始标志,0xFE;

V2 帧组成

在这里插入图片描述
STX:数据包起始标志,0xFD;
LEN:PAYLOAD的长度;
SEQ:数据包序号,0~255,每次发送一个数据包,序号就会累加,循环往复,用于检测丢包;
SYS ID:设备系统级的ID,表明自己的ID身份!
COMP ID:设备组件级的ID,一个相同系统可能有多个不同组件都使用MAVLink进行通信;
PAYLOAD:存放通信数据,可能是信息、命令等;

帧结构体

V1 head

在这里插入图片描述

MAVPACKED(
typedef struct __mavlink_message {
	uint16_t checksum; ///< sent at end of packet
	uint8_t magic;   ///< protocol magic marker
	uint8_t len;     ///< Length of payload
	uint8_t seq;     ///< Sequence of packet
	uint8_t sysid;   ///< ID of message sender system/aircraft
	uint8_t compid;  ///< ID of the message sender component
	uint8_t msgid;   ///< ID of message in payload
	uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8];
}) mavlink_message_t;

V2 head

在这里插入图片描述

MAVPACKED(
typedef struct __mavlink_message {
	uint16_t checksum;      ///< sent at end of packet
	uint8_t magic;          ///< protocol magic marker
	uint8_t len;            ///< Length of payload
	uint8_t incompat_flags; ///< flags that must be understood
	uint8_t compat_flags;   ///< flags that can be ignored if not understood
	uint8_t seq;            ///< Sequence of packet
	uint8_t sysid;          ///< ID of message sender system/aircraft
	uint8_t compid;         ///< ID of the message sender component
	uint32_t msgid:24;      ///< ID of message in payload
	uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8];
	uint8_t ck[2];          ///< incoming checksum bytes
	uint8_t signature[MAVLINK_SIGNATURE_BLOCK_LEN];
}) mavlink_message_t;

mavlink

0.mavlink github
git clone https://github.com/mavlink/mavlink.git

1.ModuleNotFoundError: No module named ‘pymavlink.generator’ 
# https://blog.youkuaiyun.com/qq_41256129/article/details/117202591
pip install pymavlink

pip如果需要升级
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
python mavgenerate.py

参考 MAVLink系列——生成MAVLink库

推荐参考代码

相关资料

参考博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

静思心远

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值