可视化和回放MAVLink飞行日志
这个例子展示了如何加载一个遥测日志(TLOG)包含MAVLink数据包到MATLAB®。信息提取为策划的细节。然后再次模拟飞行,消息转载MAVLink通信接口。这出版模仿一个无人机(UAV)执行tlog的飞行记录。
负载MAVLink TLOG
创建一个mavlinkdialect
对象使用“common.xml”
方言。使用mavlinktlog
这个方言加载TLOG数据。
方言= mavlinkdialect (“common.xml”);logimport = mavlinktlog (“mavlink_flightlog.tlog”、方言);
从TLOG提取GPS信息并使用可视化geoplot
。
公司= readmsg (logimport,“MessageName”,“GPS_RAW_INT”,…“时间”100年[0]);latlon = msgs.Messages {1};%过滤新鲜感的消息latlon = latlon (latlon。lat ~ = 0 & latlon。朗~ = 0:);图()geoplot(双(latlon.lat) / 1 e7,双(latlon.lon) / 1 e7);
从TLOG提取消息的态度。指定的态度的消息名称信息。画出卷、俯仰、偏航数据使用stackedplot
。
公司= readmsg (logimport,“MessageName”,“态度”,“时间”100年[0]);图()stackedplot (msgs.Messages {1}, {“滚”,“节”,“偏航”});
回放MAVLink日志条目
创建一个MAVLink通信接口和发布的消息从TLOG用户定义的UDP端口。创建一个发送方和接收方通过MAVLink消息。这种通信系统的工作原理一样,真正的硬件使用MAVLink通信协议将会发布消息。
发送方= mavlinkio(方言,“SystemID”,1“ComponentID”,1…“AutopilotType”,“MAV_AUTOPILOT_GENERIC”,…的组件类型,“MAV_TYPE_QUADROTOR”);连接(发送者,UDP的);destinationPort = 14550;destinationHost =“127.0.0.1”;接收机= mavlinkio(方言);连接(接收机,UDP的,“LocalPort”,destinationPort);用户= mavlinksub(接收器,“态度”,“NewMessageFcn”@ (~ msg) disp (msg.Payload));
发送第一个100消息的速度50赫兹。
有效载荷= table2struct (msgs.Messages {1});attitudeDefinition = msginfo(方言,“态度”);为msgIdx = 1:10 0 sendudpmsg(发送者、结构(“是否”attitudeDefinition.MessageID,“有效载荷”有效载荷(msgIdx))、destinationHost destinationPort);暂停(1/50);结束
断开从MAVLink通讯接口。
断开(接收器)断开(发送方)