MAVLink协议通信分析——(三)消息解析

第三章   消息解析

分析过消息包的结构后,继续向消息包的内部探索,开始分析负载信息PAYLOAD。

在消息库中,每条消息都作为一个类存在(Java版本),类中的注释文本详细地注明了每个成员变量代表的含义。这些成员变量不仅包括STX、SEQ这些包的描述信息,还包括封装入PAYLOAD的各个参数。在消息类中,还包含了pack() 打包方法和 unpack() 解包方法,为地面站和飞行控制软件的开发、应用提供了接口。

负载信息PAYLOAD内,大部分数据以Byte类型存储,同时也存在float型、short型等类型。需要注意的是,在Java中byte类型有符号位,能够覆盖-128—127范围,而C中byte为无符号位,覆盖范围为0—255。这一类差异在MavLink提供的方法中已经得到了妥善处理,使用MavLink协议提供的方法封装信息时无需担心,但如果是自己写封包解包方法,需要注意解析后读取参数值的类型转换问题。

负载信息的长度和格式并不统一,这是由于不同类型的消息包所需要传递的参数不一致而形成的。通过自己编写的“伪飞控”向地面站发送消息并接收,可以从Mission Planner地面站获取一系列消息包。查询各消息包内PAYLOAD含义,翻译后得到如下文本。

msg_request_data_stream:该消息的作用在上一章里已讲,现在读取其负载信息。

……

消息ID

两次该类型消息的

接收间隔(Short)

目标

系统

目标

组件

请求数据流

ID

开始/停止

标识

校验和

A  B

……

66

1000

1

1

11

1

255 104

req_message_rate:该类型消息请求间隔,用于控制飞控板向地面站发送指定类型消息的频率。

target_system,target_component:目标系统ID,笔者使用的Pixhawk飞控板这两项参数为1,1。

req_stream_id:请求数据流ID。非常重要的属性!该参数将直接影响飞控板返回数据流内信息包的类型,数据流ID为11时可以周期性收到VFR_HUD消息包和GLOBAL_POSITION_INT消息包,分别储存了平视显示器所需数据和GPS信息。

start_stop:数据流开始发送或停止发送标识。设为1则代表开始发送该数据流。

 

其他消息包内容由控制台打印,挑选部分展示。

 

MAVLINK_MSG_ID_ATTITUDE -time_boot_ms:16777195 roll:0.021675825 pitch:0.012977336 yaw:1.3565465rollspeed:-8.172542E-5 pitchspeed:-3.5201595E-4 yawspeed:3.577727E-4

Attitude状态报告,包括滚转角、偏航角、俯仰角(及其速度)等信息。

 

MAVLINK_MSG_ID_VFR_HUD -airspeed:0.0 groundspeed:0.0 alt:-0.07 climb:0.02 heading:77 throttle:0

共有 64 字节

平视显示器数据 Head Up Display

 

地面站接收到数据:

MAVLINK_MSG_ID_GLOBAL_POSITION_INT -time_boot_ms:16777215 lat:0 lon:0 alt:0 relative_alt:-70 vx:0 vy:0 vz:0hdg:7772

共有 36 字节

GPS定位信息

 

 

地面站接收到数据:

MAVLINK_MSG_ID_SYS_STATUS -onboard_control_sensors_present:16776207onboard_control_sensors_enabled:16751631onboard_control_sensors_health:16776207 load:130 voltage_battery:0current_battery:-1 drop_rate_comm:0 errors_comm:0 errors_count1:0errors_count2:0 errors_count3:0 errors_count4:0 battery_remaining:-1

常规系统状态信息

onboard_control_sensors_present:以位掩码表示控制器及传感器的存在状态,16776207(十进制)= 111111111111110000001111(二进制)

onboard_control_sensors_enabled:以位掩码表示控制器及传感器的启用状态,16751631(十进制)= 111111111001110000001111(二进制)

onboard_control_sensors_health:以位掩码表示控制器及传感器处于可用状态还是存在错误。转换为二进制同上。

以上掩码信息中,第一位表示gyro陀螺仪,第二位表示accelerometer加速度计,第六位表示GPS……详情见MAV_SYS_STATUS文件。

Load Maximum usage in percent of the mainloop time,主循环内时间的最大使用比例,1000表示100%,该值应保持小于1000

voltage_battery:电池电压,单位毫伏特。

current_battery:当前电池(电流),单位毫安。-1表示飞控未测量。

drop_rate_comm:通信丢失百分比,1000表示100%

errors_comm:通信错误 (UART, I2C, SPI, CAN),丢包。

Errors_countX:Autopilot-specific errors,飞控特定错误,未知含义。

battery_remaining:剩余电量,1表示1%-1autopilot estimate the remainingbattery,飞控估计电量。

 

 

MAVLINK_MSG_ID_POWER_STATUS -Vcc:4962 Vservo:21 flags:4

Vcc5V rail voltage in millivolts5V轨道电压,单位为毫伏。

Vservoservo rail voltage in millivolts,伺服(电机?)轨道电压,单位为毫伏。

Flagspower supply status flags,供电状态标识,4表示MAV_POWER_STATUS_USB_CONNECTEDUSB供电。详见MAV_POWER_STATUS

 

MAVLINK_MSG_ID_MEMINFO - brkval:0freemem:52240

位于Ardupilotmega包内,记录内存信息

Brkvalheap top,堆顶

Freemem:空闲内存大小,单位为字节。

 

MAVLINK_MSG_ID_MISSION_CURRENT -seq:0

声明当前活动任务项的序列号

 

MAVLINK_MSG_ID_GPS_RAW_INT -time_usec:0 lat:0 lon:0 alt:0 eph:0 epv:65535 vel:0 cog:0 fix_type:0satellites_visible:0

The global position, as returned by the Global PositioningSystem (GPS). This is NOT the global position estimate of the system, butrather a RAW sensor value. See message GLOBAL_POSITION for the global positionestimate. Coordinate frame is right-handed, Z-axis up (GPS frame)

全球定位,并非系统估计位置,而是RAW传感器值。(Raw Sensor 原始传感器?)——右手坐标系,Z轴向上。

time_usec:时间戳,单位为microseconds微秒。

LatLatitude (WGS84), in degrees * 1E7,纬度,单位为度数*107次方。

LonLongitude (WGS84), in degrees * 1E7,经度,单位为度数*107次方。

altAltitude (AMSL, NOT WGS84), in meters * 1000 (positive for up).Note that virtually all GPS modules provide the AMSL altitude     in addition to the WGS84 altitude.高度,单位为km,向上为正。注意所有GPS模块除了WGS84高度以外,均提供AMSL(平均海平面以上)高  度。

EphGPS HDOP horizontal dilution of position in cm (m*100). If unknown, set to: UINT16_MAXGPS水平精度因子,单位为厘米。

Epv GPS VDOP vertical dilution of position in cm (m*100). Ifunknown, set to: UINT16_MAXGPS垂直精度因子,单位为厘米。

Vel GPS ground speed (m/s * 100). If unknown, set to: UINT16_MAX,全球定位系统地速度,单位为百米每秒。

CogCourse over ground (NOT heading, but direction of movement) indegrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX

 实际航迹向,单位为百分之一度。

fix_type0-1: no fix, 2: 2D fix, 3: 3D fix, 4: DGPS, 5: RTK.GPS修正类型。

satellites_visible:卫星可见数,未知则填写255

 

MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT- nav_roll:0.0 nav_pitch:0.0 alt_error:0.14554046 aspd_error:0.0xtrack_error:0.0 nav_bearing:77 target_bearing:0 wp_dist:0

Outputs of the APM navigation controller. The primary use ofthis message is to check the response and signs of the controller before actualflight and to assist with tuning controller parameters.

APM导航控制器的输出,该信息主要功能为检查实飞前控制器的回复和信号,辅助调整控制参数。

nav_roll:当前所需的滚转角

……

alt_error:高度误差

aspd_error当前空速误差 m/s

xtrack_erroCurrent crosstrack error on x-y plane in meters.当前x-y平面横向轨迹误差  单位m

nav_bearingCurrent desired heading in degrees.前任务/目标方位单位

target_bearingBearing to current MISSION/target in degrees.当前任务/目标方位单位

wp_distDistance to active MISSION in meters就,至当前任务点的距离,单位为m

共有 147 字节

 

地面站接收到数据:

MAVLINK_MSG_ID_RAW_IMU -time_usec:4287561674 xacc:11 yacc:-9 zacc:-995 xgyro:0 ygyro:0 zgyro:0 xmag:25ymag:-133 zmag:325

The RAW IMU readings for the usual 9DOF sensor setup. Thismessage should always contain the true raw values without any scaling to allowdata capture and system debugging.

RAW IMU惯性测量单元此消息始终只包含原始信息

time_usec:时间戳

XaccX acceleration (raw) X轴向加速度

YaccY acceleration (raw) Y轴向加速度

ZaccZ acceleration (raw) Z轴向加速度

Xgyro Angular speed around X axis (raw) X轴旋转角速度

Ygyro Angular speed around Y axis (raw) Y轴旋转角速度

Zgyro Angular speed around Z axis (raw) Z轴旋转角速度

XmagX Magnetic field (raw) X磁场

YmagY Magnetic field (raw) Y磁场

ZmagZ Magnetic field (raw) Z磁场

 

MAVLINK_MSG_ID_SCALED_IMU2 -time_boot_ms:16777099 xacc:21 yacc:-6 zacc:-986 xgyro:-2 ygyro:3 zgyro:-6xmag:0 ymag:0 zmag:0

The RAW IMU readings for secondary 9DOF sensor setup. Thismessage should contain the scaled values to the described units

各项参数含义同上

 

MAVLINK_MSG_ID_SCALED_PRESSURE -time_boot_ms:16777099 press_abs:959.9057 press_diff:-0.0509375 temperature:3720

The pressure readings for the typical setup of one absolute anddifferential pressure sensor. The units are as specified in each field.绝对压强和压差传感器的读数。

time_boot_ms:时间戳

press_absAbsolute pressure (hectopascal),绝对压强,单位百帕斯卡

press_diffDifferential pressure 1 (hectopascal),压差,单位百帕斯卡

temperatureTemperature measurement (0.01 degrees celsius) 温度,单位为0.01摄氏温度

 

MAVLINK_MSG_ID_SERVO_OUTPUT_RAW -time_usec:4287561666 servo1_raw:1016 servo2_raw:1016 servo3_raw:1016servo4_raw:1016 servo5_raw:0 servo6_raw:0 servo7_raw:0 servo8_raw:0 port:0

The RAW values of the servo outputs (for RC input from theremote, use the RC_CHANNELS messages). The standard PPM modulation is asfollows: 1000 microseconds: 0%, 2000 microseconds: 100%. 伺服系统输出原始值,(远程RC输入使用RC_CHANNELS消息)标准PPM调制如下:1000微秒:0%2000微秒100%

time_usec:时间戳

servo1_rawServo output 1 value, in microseconds,伺服输出1的值,单位微秒。

……

PortServo output port (set of 8 outputs = 1 port). MostMAVs will just use one, but this allows to encode more than 8 servos.

      伺服输出端口,多数MAV只使用一个端口,最多可支持8伺服的编码。

 

MAVLINK_MSG_ID_RC_CHANNELS_RAW -time_boot_ms:16777099 chan1_raw:0 chan2_raw:0 chan3_raw:0 chan4_raw:0chan5_raw:0 chan6_raw:0 chan7_raw:0 chan8_raw:0 port:0 rssi:0

The RAW values of the RC channels received. The standard PPMmodulation is as follows: 1000 microseconds: 0%, 2000 microseconds: 100%.Individual receivers/transmitters might violate this specification. RC通道接收的原始值,标准PPM调制如下:1000微秒:0%2000微秒100%。不同接收器或转换器可能违反该规范。

time_usec:时间戳

chan1_raw:0 RC channel 1 value, in microseconds. A value ofUINT16_MAX implies the channel is unused.遥控通道1,单位为微秒。设为无符号位16位整数最大值表示该通道未使用。

……

port:0 Servo output port (set of 8 outputs = 1 port). Most MAVswill just use one, but this allows for more than 8 servos.

rssi:0 Receive signal strength indicator, 0: 0%, 100: 100%, 255:invalid/unknown.接收信号强度指示器,最小为0,最大为100

 

MAVLINK_MSG_ID_AHRS -omegaIx:-3.326245E-5 omegaIy:-1.11720045E-4 omegaIz:-3.0743552E-4accel_weight:0.0 renorm_val:0.0 error_rp:0.0013528633 error_yaw:0.0010219128

Status of DCM attitude estimator

omegaIx: X gyro drift estimate rad/s  X轴方向陀螺仪漂移量

omegaIy: Y gyro drift estimate rad/s

omegaIz: Z gyro drift estimate rad/s

accel_weight: average accel_weight.  平均加速权重(?)

renorm_val: average renormalisation value   平均重正化值(?)

error_rp: average error_roll_pitch value 

error_yaw: average error_yaw value  

 

MAVLINK_MSG_ID_HWSTATUS - Vcc:4962I2Cerr:0

Status of key hardware  关键硬件状态

Vccboard voltage (mV)  飞控电压  毫伏

I2CerrI2C error count I2C错误计数

 

MAVLINK_MSG_ID_SYSTEM_TIME -time_unix_usec:0 time_boot_ms:16777100

The system time is the time of the master clock, typically thecomputer clock of the main onboard computer.

系统时间

time_unix_usecTimestamp of the master clock in microseconds sinceUNIX epoch. 主时钟UNIX时间戳,1970-1-1

time_boot_msTimestamp of the component clock since boot time inmilliseconds. 自启动开始计时,时钟组件时间戳单位毫秒

 

共有 212 字节

  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值