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

AP_NavEKF3: add source selection to allow switching between GPS and T265 #14803

Merged
merged 38 commits into from
Nov 20, 2020

Conversation

rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented Jul 13, 2020

This PR adds support for manually switching the EKF3 between sensors sources used for position, velocity and yaw. It also includes a lua script to automatically switch between GPS and NonGPS sources.

  • New AP_NavEKF_Source class is relatively simple with 10 new parameters that allow the user to set to sources (primary and secondary) for position (_POSXY, POSXY2, POSZ, POSZ2), velocity (_VELXY, _VELXY2, _VELZ, _VELZ2) and yaw (_YAW, _YAW2). This class allows the currently active source for each axis to be get or set using methods like getPosXYSource().
  • RC_Channel option "89" allows the user to change all active sources between the primary and secondary
  • EKF3 is enhanced to check the active source when deciding what sensor data to fuse. It also checks for a change in source and performs a reset.

This PR also includes a couple of additional, mostly unrelated fixes:

  • EKF3's ExtNav support enhanced to allow using non-ExtNav altitude (i.e. baro, rangefinder, etc)
  • VisualOdometry T265 driver ignores sensor input for 1 second after a reset (in testing we've found dozens of resets happen one after the other)
  • AHRS's PreArm check method is made consistent with other subsystems

This has been tested in SITL and on a real vehicle. I've put the logs for two tests below:

To test using GPS + Vicon in SITL the following parameters should be set:

  • AHRS_EKF_TYPE = 3
  • EK2_ENABLE = 0
  • EK3_ENABLE = 1
  • EK3_SRC1_POSXY = 3 (GPS)
  • EK3_SRC2_POSXY = 6 (External Nav)
  • EK3_SRC1_POSZ = 1 (Baro)
  • EK3_SRC2_POSZ = 6 (External Nav)
  • EK3_SRC1_VELXY = 3 (GPS)
  • EK3_SRC2_VELXY = 6 (External Nav)
  • EK3_SRC1_VELZ = 3 (GPS)
  • EK3_SRC2_VELZ = 6 (External Nav)
  • EKF3_SRC1_YAW = 1 (Compass)
  • EK3_SRC2_YAW = 2 (External)
  • VISO_TYPE = 1
  • SERIAL5_PROTOCOL = 2 (MAVLink)
  • RC9_OPTION = 90 (EKF Pos Source)

Then start SITL from the ArduCopter directory with this command

  • ../Tools/autotest/sim_vehicle.py --map --console -A "--uartF=sim:vicon:"

To switch between sources:

  • rc 9 1000 (switches to GPS)
  • rc 9 1500 (switches to vicon)

To add offsets in position and orientation to the SITL vehicle:

  • param set SIM_VICON_YAW 45 (to rotate the Vicon system by 45 degrees)
  • param set SIM_VICON_GLIT_Y 50 (to add 50m of offset in the Y axis to the Vicon system)

These are the known issues and questions:

  • PreArm check is perhaps too strict because it checks the EK3_SRC_xxx2 parameters which many users may not use
  • The fall back from GPS->Optical Flow doesn't work anymore but in practice I don't think it worked before either.
  • Source changes of Z-axis velocity alone will not trigger a velocity reset. This is mostly because of existing limitations in the EKF.
  • When the Yaw source changes to the compass, the vehicle's yaw takes 1 to 2 seconds to rotate around to the correct heading. I'm unsure why it is so slow because resets to ExtNav yaw occur immediately

This is the additional testing we should do before merging:

  • Yaw resets from all possible sources (Compass, GSF, ExtNav)

All feedback is greatly appreciated!

@rmackay9
Copy link
Contributor Author

This is failing semaphore because the Matek405-wing has run out of space to fit the firmware.

tridge
tridge previously requested changes Jul 14, 2020
libraries/AP_NavEKF3/AP_NavEKF3_Control.cpp Outdated Show resolved Hide resolved
libraries/AP_NavEKF/AP_NavEKF_Source.h Outdated Show resolved Hide resolved
libraries/AP_NavEKF/AP_NavEKF_Source.cpp Outdated Show resolved Hide resolved
libraries/AP_NavEKF3/AP_NavEKF3.cpp Show resolved Hide resolved
libraries/AP_NavEKF3/AP_NavEKF3.cpp Outdated Show resolved Hide resolved
@rmackay9
Copy link
Contributor Author

rmackay9 commented Jul 14, 2020

Actions for me:

  • test yaw including resets for all combinations
  • test the heck out of this to ensure there are no dangerous issues
  • create a list of combinations of param values that aren't actually supported
  • setup a meeting with Tridge & Paul to go over this

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

This is conflicting horribly already.

libraries/AP_NavEKF/AP_NavEKF_Source.cpp Outdated Show resolved Hide resolved
@mcelhennyi
Copy link

Is there a way for an offboard computer to make this switch?

Or maybe a way to make it compare GPS to VIO confidence and have it automatically swap?

rmackay9 and others added 19 commits November 20, 2020 15:19
switches automatically between gps, external nav and optical flow
if we get to this point we must be using the compass fallback logic,
and should do the reset
MAG_CAL param description include deprecated values
Pre-arm check of MAG_CAL using deprecated values
effective_magCal interprets 5 (was EXTERNAL_YAW) as Never, 6 (was EXTERNAL_YAW_FALLBACK) as WhenFlying
Update comments in param conversion from MAG_CAL to EK3_SRC1_YAW
@rmackay9 rmackay9 force-pushed the ekf-pos-source2 branch 2 times, most recently from 4dd5b57 to 79d0043 Compare November 20, 2020 06:21
shorten param conversion config error
if gps and optical flow are enabled we default SRC2_VELXY to optflow
convert_params run from InitialiseFilter
ensure param conversion only run once
@rmackay9 rmackay9 merged commit d1983b0 into ArduPilot:master Nov 20, 2020
@rmackay9
Copy link
Contributor Author

Thanks for all the feedback and reviews, merged!

@tridge
Copy link
Contributor

tridge commented Nov 20, 2020

yay!

@rmackay9 rmackay9 deleted the ekf-pos-source2 branch April 12, 2021 23:34
@Hwurzburg Hwurzburg removed the WikiNeeded needs wiki update label Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants