具体操作如下,我们可以用flightplot打开基于SLAM定点飞行的PX4日志,选择日志中的vehicle_attitude_0.q[0]和vehicle_visual_odometry_0.q[0]这两项参数,进行对比,vehicle_attitude_0对应飞控基于自身imu及视觉偏航估计出的姿态四元数,vehicle_visual_odometry_0对应SLAM位姿中的四元数,q[0]是对应四元数中的第一位数字w(The quaternion uses the Hamilton convention, and the order is q(w, x, y, z))。
比如这是VehicleOdometry这个uORB消息类型的内容,它最后的注释有写VehicleOdometry这个类型对应的uORB消息名称,有vehicle_odometry vehicle_mocap_odometry vehicle_visual_odometry estimator_odometry。 我们这次用的就是日志中记录的vehicle_visual_odometry这个uORB消息,对应SLAM位姿。
https://docs.px4.io/main/zh/msg_docs/VehicleOdometry.html
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# Vehicle odometry data. Fits ROS REP 147 for aerial vehicles
uint32 MESSAGE_VERSION = 0
uint64 timestamp # time since system start (microseconds)uint64 timestamp_sample
uint8 POSE_FRAME_UNKNOWN = 0uint8 POSE_FRAME_NED = 1 # NED earth-fixed frameuint8 POSE_FRAME_FRD = 2 # FRD world-fixed frame, arbitrary heading referenceuint8 pose_frame # Position and orientation frame of reference
float32[3] position # Position in meters. Frame of reference defined by local_frame. NaN if invalid/unknownfloat32[4] q # Quaternion rotation from FRD body frame to reference frame. First value NaN if invalid/unknown
uint8 VELOCITY_FRAME_UNKNOWN = 0uint8 VELOCITY_FRAME_NED = 1 # NED earth-fixed frameuint8 VELOCITY_FRAME_FRD = 2 # FRD world-fixed frame, arbitrary heading referenceuint8 VELOCITY_FRAME_BODY_FRD = 3 # FRD body-fixed frameuint8 velocity_frame # Reference frame of the velocity data
float32[3] velocity # Velocity in meters/sec. Frame of reference defined by velocity_frame variable. NaN if invalid/unknown
float32[3] angular_velocity # Angular velocity in body-fixed frame (rad/s). NaN if invalid/unknown
float32[3] position_variancefloat32[3] orientation_variancefloat32[3] velocity_variance
uint8 reset_counterint8 quality
# TOPICS vehicle_odometry vehicle_mocap_odometry vehicle_visual_odometry# TOPICS estimator_odometry
这是VehicleAttitude这个uORB消息类型的内容,对应的uORB消息有vehicle_attitude vehicle_attitude_groundtruth external_ins_attitude estimator_attitude
我们这次对比用到了日志中记录的vehicle_attitude这个uORB消息,对应飞控基于自身imu及视觉偏航估计出的姿态四元数。
https://docs.px4.io/main/zh/msg_docs/VehicleAttitude.html
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# This is similar to the mavlink message ATTITUDE_QUATERNION, but for onboard use# The quaternion uses the Hamilton convention, and the order is q(w, x, y, z)
uint32 MESSAGE_VERSION = 0
uint64 timestamp # time since system start (microseconds)
uint64 timestamp_sample # the timestamp of the raw data (microseconds)
float32[4] q # Quaternion rotation from the FRD body frame to the NED earth framefloat32[4] delta_q_reset # Amount by which quaternion has changed during last resetuint8 quat_reset_counter # Quaternion reset counter
# TOPICS vehicle_attitude vehicle_attitude_groundtruth external_ins_attitude# TOPICS estimator_attitude
用flightplot显示日志中这个两个参数后,可以看到两个参数的曲线基本是重合的,和我们前面分析的一致,没有说出现两个参数出现比较大的累计漂移的情况,也应该不会出现。
而且两个参数的四元数对应的坐标系,参考上面对应消息文件里的说明,vehicle_attitude里的四元数是对应FRD坐标系在NED坐标系下的姿态,vehicle_visual_odometry里的呢 虽然它写的是FRD坐标系在参考坐标系下的姿态,这里的参考坐标系呢我们传视觉位姿时一般没有指定,vehicle_visual_odometry这个uORB消息里的pose_frame这一项的值实际也是0,实际默认一般也是NED(飞控端) ,也就是飞控端的视觉位姿也是FRD在NED坐标系下的位姿(可以参考这篇文章 https://mp.weixin.qq.com/s/12fLFqkDi1FVMVQ45mU4Ug ),所以vehicle_visual_odometry里的四元数是可以直接和vehicle_attitude里的四元数进行对比的,不用做额外的坐标系转换。
为了看清具体时延,可以进一步放大,对比时间戳差值,如下图所示,可以看到横轴的时间相差大概在200ms左右,可以粗略认为是SLAM位姿的时延是200ms左右,如果我们飞PX4的SLAM定位时,想修改PX4飞控中的EKF2_EV_DELAY参数,使得它更为准确,也可以基于此进行填写,EKF2_EV_DELAY参数含义是Vision Position Estimator delay relative to IMU measurements,它的可修改范围是0-300ms。