主要内容

mavlinkdialect

解析和存储MAVLink方言XML

描述

mavlinkdialect对象解析并存储从MAVLink消息定义文件中提取的消息和enum定义(. xml).消息定义文件定义此特定方言支持的消息。金宝app消息定义的结构由MAVLink消息协议定义。

创建

描述

例子

方言= mavlinkdialect(“common.xml”)使用该方法创建Mavlink方言common.xml标准MAVLINK消息的文件。

方言= mavlinkdialect (dialectXML)指定用于解析消息定义的XML文件。输入设置了DialectXML财产。

方言= mavlinkdialect (dialectXML版)附加说明MAVLink协议版本。输入设置DialectXML版本属性,分别。

属性

全部展开

mavlink语句名称,指定为字符串。此名称基于XML文件名。

例子:“ardupilotmega”

数据类型:字符|字符串

MAVLink协议版本,指定为1或2。

数据类型:

对象的功能

createcmd 创建MAVLink命令消息
createmsg 创建mavlink消息
deserializemsg 从二进制缓冲区反序列化MAVLink消息
Msginfo. 消息ID的消息定义
enumenfo. 枚举ID的枚举定义
enum2num 给定条目的枚举值
num2enum 枚举项的给定值

例子

全部折叠

此示例显示如何解析Mavlink XML文件并从定义中创建邮件和命令。

注意:本例要求您安装无人机机器人系统工具箱®库。调用roboticsAddons打开加载项资源管理器并安装库。

解析和存储MAVLink方言XML。指定XML路径。默认的“common.xml”方言。这个XML文件包含所有消息和枚举定义。

方言= mavlinkdialect (“common.xml”);

创建一个MAVLink命令mav_cmd.枚举,它是发送到UAV的Mavlink命令的枚举。指定设置为“int”要么“长”,以及作为整数或字符串的类型。

cmdmsg = createcmd(方言,“长”, 22)
cmdMsg =结构体字段:msgstr: 76有效负载:[1x1 struct]

验证命令名称使用num2enum.指令22是无人机的起飞指令。您可以使用转换回IDenum2num.您的方言可以包含许多具有不同名称和id的不同枚举。

cmdName = num2enum(方言,“MAV_CMD”, 22)
cmdName = " MAV_CMD_NAV_TAKEOFF "
cmdID = enum2num(方言,“MAV_CMD”cmdName)
cmdID = 22

使用enumenfo.的表mav_cmd.enum条目。

信息= enuminfo(方言,“MAV_CMD”);信息。条目{:}
ans =133×3表名称值说明_____________________________________ _____ _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________“MAV_CMD_NAV_WAYPOINT” 16“导航到航点。”“mav_cmd_nav_loiter_unlim”17“在此航路点围绕此航路点无限的时间”“mav_cmd_nav_loiter_turns”18“loits围绕此航点x转动”mav_cmd_nav_loiter_time“19”在此航路点围绕此航路点“mav_cmd_nav_return_to_launch”20“返回启动位置“Mav_Cmd_nav_land”21“地点”“”mav_cmd_nav_takeoff“22”从地面/手中起飞“”mav_cmd_nav_land_local“23”在本地位置(仅限本地帧)“”mav_cmd_nav_takeoff_local“24”从本地位置开始起飞(仅限本地帧)" "MAV_CMD_NAV_FOLLOW" 25 "Vehicle following, i.e. this waypoint represents the position of a moving vehicle" "MAV_CMD_NAV_CONTINUE_AND_CHANGE_ALT" 30 "Continue on the current course and climb/descend to specified altitude. When the altitude is reached continue to the next command (i.e., don't proceed to the next command until the desired altitude is reached." "MAV_CMD_NAV_LOITER_TO_ALT" 31 "Begin loiter at the specified Latitude and Longitude. If Lat=Lon=0, then loiter at the current position. Don't consider the navigation command complete (don't leave loiter) until the altitude has been reached. Additionally, if the Heading Required parameter is non-zero the aircraft will not leave the loiter until heading toward the next waypoint. " "MAV_CMD_DO_FOLLOW" 32 "Being following a target" "MAV_CMD_DO_FOLLOW_REPOSITION" 33 "Reposition the MAV after a follow target command has been sent" "MAV_CMD_DO_ORBIT" 34 "Start orbiting on the circumference of a circle defined by the parameters. Setting any value NaN results in using defaults." "MAV_CMD_NAV_ROI" 80 "Sets the region of interest (ROI) for a sensor set or the vehicle itself. This can then be used by the vehicles control system to control the vehicle attitude and the attitude of various sensors such as cameras." ⋮

查询特定消息ID的方言。使用消息ID创建空白MAVLINK消息。

信息= msginfo(方言,“心跳”
信息=1×4表消息id MessageName描述字段  _________ ___________ ___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ___________ 0“心跳”heartbeat消息表明系统存在并正在响应。MAV和自动驾驶仪硬件的类型允许接收系统适当地处理来自该系统的进一步信息(例如,通过基于自动驾驶仪布局用户界面)。”{6 x6表}
味精= createmsg(方言,info.MessageID);
介绍了R2019a