Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Support full vision variance #680

Merged
merged 4 commits into from
Jan 8, 2020
Merged

Support full vision variance #680

merged 4 commits into from
Jan 8, 2020

Conversation

kamilritz
Copy link
Contributor

@kamilritz kamilritz commented Dec 9, 2019

This PR add support to use all variance information in the visual_odometry message. It uses a 3d variance for position and velocity. Since we only fuse visual heading and not attitude, we do only support a one-dimensional uncertainty for the heading.
Since external vision fusion in ECL is still fusing single measurement sequentially, we can not profit from the covariance values at the moment, so they are not added to the interface.

Secondly, the interface is expanded such that a 3D auxiliary velocity vector is passed instead of 2d vector. The vertical velocity is not fused at the moment. Since the control logic is not in place at the moment. This will be added, when we add finer fusion control granularity for all sensors.

See here for the corresponding Firmware PR.

Unit tested cases:

  • fusion start logic for external vision position, velocity and heading
  • state's horizontal velocity uncertainty is decreasing faster in direction of smaller uncertainty in vision velocity measurement. Also in case where we have to align vision reference frame
  • correct estimation of the alignment of the vision reference

jkflying
jkflying previously approved these changes Dec 9, 2019
Copy link
Contributor

@jkflying jkflying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tiny formatting fix. Also I guess all these things add flash usage...

EKF/control.cpp Outdated
_ev_vel_innov(0) = _state.vel(0) - vel_aligned(0);
_ev_vel_innov(1) = _state.vel(1) - vel_aligned(1);
_ev_vel_innov(2) = _state.vel(2) - vel_aligned(2);
_ev_vel_innov= _state.vel - vel_aligned;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_ev_vel_innov= _state.vel - vel_aligned;
_ev_vel_innov = _state.vel - vel_aligned;

@mhkabir
Copy link
Member

mhkabir commented Dec 9, 2019

This is awesome!

This came up sometime back for me, when I was working on fast flights down long tunnels with vision. Assuming isotropic measurement uncertainty is not a good assumption especially for visual-inertial odometry systems where the error strongly depends on direction of motion and feature distribution.

Another issue I ran into after implementing this was that the covariances too need to be rotated into the navigation frame (when using NED for GPS and an arbitrary vision frame) before being used. I think this is missing in this PR, but could've missed it on mobile.

@mhkabir
Copy link
Member

mhkabir commented Dec 9, 2019

Also need to review that switching the auxvel interface to 3D doesn't have unexpected effects on the height when the external system doesn't provide a Z vel estimate (like the current landing target estimator implementation)

@kamilritz
Copy link
Contributor Author

Another issue I ran into after implementing this was that the covariances too need to be rotated into the navigation frame (when using NED for GPS and an arbitrary vision frame) before being used. I think this is missing in this PR, but could've missed it on mobile.

@mhkabir I missed that, thanks for catching that. It is now added. Please have a look again. I do not have vision system with proper variance information, so I can not really test this at the moment.

@kamilritz
Copy link
Contributor Author

Also need to review that switching the auxvel interface to 3D doesn't have unexpected effects on the height when the external system doesn't provide a Z vel estimate (like the current landing target estimator implementation)

@mhkabir IMO this should be handled by the EKF2_AID_MASK parameter at some point. Such that you configure which components you want to fuse. At the moment the vertical component fusion is commented out.

@@ -305,7 +305,10 @@ void Ekf::controlExternalVisionFusion()
_ev_pos_innov(1) = _state.pos(1) - _hpos_pred_prev(1) - ev_delta_pos(1);

// observation 1-STD error, incremental pos observation is expected to have more uncertainty
ev_pos_obs_var(0) = ev_pos_obs_var(1) = sq(fmaxf(_ev_sample_delayed.posErr, 0.5f));
Matrix3f ev_pos_var = matrix::diag(_ev_sample_delayed.posVar);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply

Vector3f ev_pos_var = _ev_rot_mat * _ev_sample_delayed.posVar?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I guess it's nicer to have it as a matrix if we ever end up actually propagating the covariances.

@kamilritz kamilritz force-pushed the ev_variance branch 2 times, most recently from 41fc265 to 75099a3 Compare January 8, 2020 08:17
Copy link
Contributor

@jkflying jkflying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone over this in detail and it seems good. Unit tests also help. And the scope should be limited to people running VIO systems if there is an issue.

@bresch bresch merged commit 94484f0 into master Jan 8, 2020
@bresch bresch deleted the ev_variance branch January 8, 2020 13:36
@mhkabir
Copy link
Member

mhkabir commented Jan 8, 2020

@bresch Squash please next time 😢

Bisection is already near-impossible

@bresch
Copy link
Member

bresch commented Jan 8, 2020

@mhkabir oops, sorry for that.; I'll check how the commits look next time.

@kamilritz
Copy link
Contributor Author

@mhkabir @bresch I would argue that it was the right thing to do here since the commits were separated in independent parts. The mistake that I made was combining full vision variance, auxiliiary velocity interface change and flash space saving in one PR. Sorry for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants