Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EKF2 global position validity #23474

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

EKF2 global position validity #23474

wants to merge 10 commits into from

Conversation

bresch
Copy link
Member

@bresch bresch commented Jul 31, 2024

Solved Problem

  1. Once in inertial dead-reckoning, the position estimate drifts exponentially and even if a velocity-aiding sensor starts after some time, the global position shouldn't be valid anymore.
  2. FW manual position control mode requires a valid global position estimate but internally works using local coordinates. The mode thus cannot run without a GNSS fix or a manual reset despite having a "valid local position" (due to airspeed and sideslip fusion).
  3. Flying in FW using wind dead-reckoning requires to set the COM_FS_EPH to a really large value as commander would otherwise invalidate the local position validity
  4. FW auto takeoff and auto land modes don't require a valid global position to start but the backend can't execute correctly because it relies on a valid global position estimate.

Solution

  1. Invalidate global position when exceeding maximum the inertial dead-reckoning time (5s). The global position can then be valid again if the local position is valid and that a global position measurement is available (e.g.: GNSS, AGP or manual pos aiding).
  2. Make FW manual position work with local coordinates only
  3. Generalize the local position "relaxed" logic (currently used for optical flow) to work when the local position is obtained from velocity-aided dead reckoning (e.g.: optical flow, ev_vel, airspeed+sideslip)
  4. Deny switching to auto takeoff and auto land if global position is invalid. In the future we could also fix the logic to enable it correctly.

Note that we could publish NANs in the global position fields that are invalid but I wanted to follow the same scheme than in vehicle_local_position.

Test coverage

SITL tests:
In FW, start and stop several times GNSS and sideslip fusion. Modes switch correctly.
Screenshot from 2024-07-31 14-56-28

Even if local pos gets valid again, the local frame needs to be
re-aligned to a global origin to have a valid global position
@Jaeyoung-Lim
Copy link
Member

Yay! This is exactly why I removed global position from the guidance law 😁 Happy to see this finally getting used!

@mrpollo
Copy link
Contributor

mrpollo commented Jul 31, 2024

Really cool @bresch 👏


_position_reliant_on_optical_flow = !gps && optical_flow && !vision_position;
}
_position_reliant_on_velocity_aided_dead_reckoning = !estimator_status_flags.cs_inertial_dead_reckoning
Copy link
Member

Choose a reason for hiding this comment

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

Does this even matter? Couldn't "relaxed local position validity" simply be vehicle_local_position.xy_valid?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I'll check if there is any reason why it should be different

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it makes sense. Now "relaxed" is just without eph check.

Relaxed position is valid as long as a velocity aiding source is active
(e.g.: optical flow or airspeed+sideslip)
Fake pos/height fusion only starts when inertial dead reckoning time is
exceeded and is not considered as an aiding sensor anyway. The dead
reckoning flag is then enough to know if the position/velocity is valid.
@haumarco
Copy link
Contributor

haumarco commented Aug 2, 2024

Right now, _NED_origin_initialised represents if the global_ref was set and the local position is valid. If the NED origin was initialized should be checked with _pos_ref.isInitialized() right? Maybe renaming it to _NED_origin_valid would be better, or would it be possible to remove it?

This variable contains the location of the NED's origin in global
coordinates. It is then not the global origin but the global reference
of the local frame.

Also, to have a valid global position, this reference doesn't only needs
to be initialized but also valid. It is valid when the local frame is
locked in place by using velocity and/or position aiding sensors.
@bresch bresch marked this pull request as draft August 5, 2024 14:23
@bresch bresch self-assigned this Aug 5, 2024
@github-actions github-actions bot added the stale label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review/test
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants