0

阿木币

2

精华

76 小时

在线时间

老司机

Rank: 2

发表于 2020-8-13 10:32:57 4494 浏览 5 回复

[导航算法] 关于EKF2中,MASK_ROTATE_EV 和 MASK_USE_EVYAW 同时启用

本帖最后由 wilsonleong 于 2020-8-13 11:06 编辑

如果 MASK_ROTATE_EV 和 MASK_USE_EVYAW 同时启用,EKF2只会算校准一次外部视觉的旋转矩阵,后面就不再校准了。具体是,程序是否进行外部视觉旋转矩阵校准是检查 _control_status.flags.ev_yaw 而不是 MASK_USE_EVYAW,所以刚开始 _control_status.flags.ev_yaw 为 false,程序进行了一次校准。到后面 MASK_USE_EVYAW 把 _control_status.flags.ev_yaw 设置为 true,就不再进行校准了。

但是这样不知道会不会对yaw角融合有什么影响?似乎是这个外部视觉的旋转矩阵只会拿去乘以外部视觉的位置,而外部视觉的姿态不做额外处理。wiki上说这两个选项不要同时启用的

Either bit 4 (EV_YAW) or bit 6 (EV_ROTATE) should be set to true, but not both together.

EKF\control.cpp (1.10)

void Ekf::controlExternalVisionFusion()
{
        // Check for new external vision data
        if (_ev_data_ready) {

                // if the ev data is not in a NED reference frame, then the transformation between EV and EKF navigation frames
                // needs to be calculated and the observations rotated into the EKF frame of reference
                if ((_params.fusion_mode & MASK_ROTATE_EV) && ((_params.fusion_mode & MASK_USE_EVPOS) || (_params.fusion_mode & MASK_USE_EVVEL)) && !_control_status.flags.ev_yaw) {
                        // rotate EV measurements into the EKF Navigation frame
                        calcExtVisRotMat();
                }

                // external vision aiding selection logic
                if (_control_status.flags.tilt_align && _control_status.flags.yaw_align) {

                                /* ...... */

                                if ((_params.fusion_mode & MASK_ROTATE_EV) && !(_params.fusion_mode & MASK_USE_EVYAW)
                                        && !_ev_rot_mat_initialised)  {
                                        // Reset transformation between EV and EKF navigation frames when starting fusion
                                        resetExtVisRotMat();
                                        _ev_rot_mat_initialised = true;
                                        ECL_INFO_TIMESTAMPED("EKF external vision aligned");
                                }
                        }
                }

                // external vision yaw aiding selection logic
                if (!_control_status.flags.gps && (_params.fusion_mode & MASK_USE_EVYAW) && !_control_status.flags.ev_yaw && _control_status.flags.tilt_align) {
                        // don't start using EV data unless daa is arriving frequently
                        if (_time_last_imu - _time_last_ext_vision < 2 * EV_MAX_INTERVAL) {

                                /* ...... */

                                // turn on fusion of external vision yaw measurements and disable all magnetometer fusion
                                _control_status.flags.ev_yaw = true;
                                _control_status.flags.mag_hdg = false;
                                _control_status.flags.mag_dec = false;

                                /* ...... */
                        }
                }

                /* ...... */

                // determine if we should use the yaw observation
                if (_control_status.flags.ev_yaw) {
                        fuseHeading();

                }

        } else if ((_control_status.flags.ev_pos || _control_status.flags.ev_vel)
                   && (_time_last_imu >= _time_last_ext_vision)
                   && ((_time_last_imu - _time_last_ext_vision) > (uint64_t)_params.reset_timeout_max)) {

                // Turn off EV fusion mode if no data has been received
                _control_status.flags.ev_pos = false;
                _control_status.flags.ev_vel = false;
                _control_status.flags.ev_yaw = false;
                ECL_INFO_TIMESTAMPED("EKF External Vision Data Stopped");

        }
}

EKF\control.cpp (1.11)

void Ekf::controlExternalVisionFusion()
{
        // Check for new external vision data
        if (_ev_data_ready) {

                // if the ev data is not in a NED reference frame, then the transformation between EV and EKF navigation frames
                // needs to be calculated and the observations rotated into the EKF frame of reference
                if ((_params.fusion_mode & MASK_ROTATE_EV) && ((_params.fusion_mode & MASK_USE_EVPOS) || (_params.fusion_mode & MASK_USE_EVVEL)) && !_control_status.flags.ev_yaw) {
                        // rotate EV measurements into the EKF Navigation frame
                        calcExtVisRotMat();
                }

                /* ...... */

                // external vision yaw aiding selection logic
                if (!_control_status.flags.gps && (_params.fusion_mode & MASK_USE_EVYAW) && !_control_status.flags.ev_yaw && _control_status.flags.tilt_align) {
                        // don't start using EV data unless data is arriving frequently
                        if (isRecent(_time_last_ext_vision, 2 * EV_MAX_INTERVAL)) {
                                // reset the yaw angle to the value from the vision quaternion
                                const Eulerf euler_obs(_ev_sample_delayed.quat);
                                const float yaw = euler_obs(2);
                                const float yaw_variance = fmaxf(_ev_sample_delayed.angVar, sq(1.0e-2f));

                                resetQuatStateYaw(yaw, yaw_variance, true);

                                // flag the yaw as aligned
                                _control_status.flags.yaw_align = true;

                                // turn on fusion of external vision yaw measurements and disable all magnetometer fusion
                                _control_status.flags.ev_yaw = true;
                                _control_status.flags.mag_dec = false;

                                stopMagHdgFusion();
                                stopMag3DFusion();

                                ECL_INFO_TIMESTAMPED("starting vision yaw fusion");
                        }
                }

                /* ...... */

                // determine if we should use the yaw observation
                if (_control_status.flags.ev_yaw) {
                        fuseHeading();
                }

        } else if ((_control_status.flags.ev_pos || _control_status.flags.ev_vel)
                   && isTimedOut(_time_last_ext_vision, (uint64_t)_params.reset_timeout_max)) {

                // Turn off EV fusion mode if no data has been received
                stopEvFusion();
                ECL_INFO_TIMESTAMPED("vision data stopped");

        }
}

扫一扫浏览分享
回复

使用道具 举报

0

阿木币

2

精华

76 小时

在线时间

老司机

Rank: 2

 楼主| 发表于 2020-8-13 10:44:15

本帖最后由 wilsonleong 于 2020-8-13 11:05 编辑

但是这样不知道会不会对yaw角融合有什么影响?似乎是这个外部视觉的旋转矩阵只会拿去乘以外部视觉的位置,而外部视觉的姿态不做额外处理。wiki上说这两个选项不要同时启用的

Either bit 4 (EV_YAW) or bit 6 (EV_ROTATE) should be set to true, but not both together.

回复 点赞

使用道具 举报

144

阿木币

0

精华

31 小时

在线时间

老司机

Rank: 2

发表于 2020-8-13 11:46:34
大佬 你这些问题都看不懂。。。 只能不懂帮顶了。。
回复 点赞

使用道具 举报

0

阿木币

2

精华

76 小时

在线时间

老司机

Rank: 2

 楼主| 发表于 2020-8-13 13:18:15 来自手机
shanghuo 发表于 2020-8-13 11:46
大佬 你这些问题都看不懂。。。 只能不懂帮顶了。。

我也是初学菜鸟
回复 点赞

使用道具 举报

0

阿木币

2

精华

76 小时

在线时间

老司机

Rank: 2

 楼主| 发表于 2021-6-4 19:56:39
本帖最后由 wilsonleong 于 2021-6-4 20:03 编辑

过了很久,再来思考这个问题。
wiki明确表明这两个mask flag是互斥的,而且必须开启其中一个:Either bit 4 (EV_YAW) or bit 6 (EV_ROTATE) should be set to true, but not both together.先看MASK_ROTATE_EV的描述:set to true if the EV observations are in a non NED reference frame and need to be rotated before being used

基于此:
1.如果只开MASK_ROTATE_EV,关闭MASK_USE_EVYAW,那么EKF2中YAW的来源只能是Magnetometer或者GPS,他们都是NED坐标系的,而外部SLAM或者MoCap的数据是FRD的,所以FRD系的数据是要旋转到NED的。
2.如果只开MASK_USE_EVYAW,关闭MASK_ROTATE_EV,意思就是使用外部SLAM或者MoCap的FRD坐标系来确定YAW,不用Magnetometer或者GPS的NED了,所以也不需要旋转FRD的数据了。

总结一下,想用外部视觉,又想保持NED坐标系,那只能放弃外部视觉的YAW,转而使用Magnetometer或者GPS来估计YAW,这时候开启MASK_ROTATE_EV。反之,不需要保持着NED的YAW指向的话,那直接用外部视觉的YAW就好,这时候开MASK_USE_EVYAW。
简单说:
1. Heading w.r.t. North  -->  MASK_ROTATE_EV
2. Heading w.r.t. external vision frame  -->  MASK_USE_EVYAW

欢迎指正!

回复 点赞

使用道具 举报

0

阿木币

2

精华

76 小时

在线时间

老司机

Rank: 2

 楼主| 发表于 2021-6-4 20:01:42
wilsonleong 发表于 2021-6-4 19:56
过了很久,再来思考这个问题。
wiki明确表明这两个mask flag是互斥的,而且必须开启其中一个:Either bit 4 ...

屏幕截图 2021-06-04 200014.png
回复 点赞

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表