The `_deadreckon_time_exceeded` flag is used in
`local_position_is_valid()`. This means that
`_params.valid_timeout_max` after startup, in my observed case 5
seconds, the local position switche from valid to invalid and then after
a while back to valid again.
With this fix, the local position is flagged invalid from boot and gets validated after the first aiding event.
Co-authored-by: Julian Oes <julian@oes.ch>
* ekf: disable xy accel bias learning before takeoff
As those biases are usually poorly observable before takeoff because
they are almost perpendicular to the gravity vector, learning is often
driven by noise and numerical issues. This results in incorrect bias
learning before takeoff when the drone is static on ground for a long
period of time.
* ekf: update unit test and change indicator
This is a non-functional change required to select accel bias estimation
per axis selection. The intent is then to disable the learning before
takeoff of the components that are poorly observable.
* Support vision velocity expressed in body frame
* Use switch statement for vision velocity frame
* Robustify vision velocity frame test
* Increase lower bound on vision velocity noise to 0.05 m/s
* EKF: Improve covariance prediction stability
Eliminates collapse of vertical velocity state variance due to rounding errors that can occur under some operating conditions.
* EKF: Fix typo
* test: Fix initialisation test cases
Provide sufficient time for variances to stabilise and fix calculation of reference quaternion for alignment.
* test: Allow for accumulated rounding error in IMU sampling test
* test: Allow sufficient time for quaternion variances to reduce after initial alignment
* test: Increase allowance for tilt alignment delay and inertial nav errors
* test: Increase allowance for tilt alignment delay and inertial nav errors
* adpat reset velocity test
* test: update change indication file
* test: Adjust tests to handle alignment time and prediction errors
* README.md: Add documentation for change indicator test
* EKF: centralize range finder tilt check
* Ekf-control: do not double check for terrain estimate validity
isRangeAidSuitable can only return true if the terrain estimate is valid
so there is no need for an additional check
* range_finder_checks: restructure the checks to avoid early returns
There is now only one clear path that can lead to the validity being
true.
Furthermore, if the _rng_hgt_valid is true, we can trust it and we don't
need for additional checks such as tilt.
The case where we need to provide fake measurements because the drone is
on the ground and the range finder data is bad is already handled
in "controlHeightFusion" so there is no need to hack the range finder
checks with that.
* Add Sensor and SensorRangeFinder classes
The purpose is to encapsulate the checks for each sensor in a dedicated
class with the same interface
* SensorRangeFinder: encapsulate in estimator::sensor namespace
* EKF: rename _sensor_rng to _range_sensor
* Range checks: include limits in valid range
* RangeChecks: update comment in the continuity checks
* RangeChecks: move more low-level checks in functions
Also move setTilt out of the terrain estimator, this is anyway protected internally
to not compute cos/sin if the parameter did not change.
* Sensor: remove unused virtual functions
Those are not required yet but can still be added later
* SensorRangeFinder: re-organise member variables
Also rename getRangeToEarth to getCosTilt
* SensorRangeFinder: split setSensorTilt and setCosMaxTilt functions
* SensorRangeFinder: Add a few unit tests
- good data
- tilt exceeded
- max range exceeded
* SensorRangeFinder: set hysteresis in us instead of ms
* SensorRangeFinder: Add more tests
* SensorRangeFinder: update continuity, hysteresis and stuck tests
* SensorRangeFinder: rename variables
* SensorRangeFinder: get rid of "delayed" specification
From the SensorRangeFinder class point of view, it's not relevant to
know if the data is delayed or not
* SensorRangeFinder: move time_last_valid out of stuck check
* SensorRangeFinder: rename file names to sensor_range_finder
* SensorRangeFinder: address Kamil's comments
* SensorRangeFinder: Add more tilt tests
* SensorRangeFinder: store current tilt offset
This is to avoid recomputing cos/sin functions at each loop
* EKF: Enable GPS flight without magnetometer
Enables takeoff in a non-GPS flight mode with mag fusion type set to MAG_FUSE_TYPE_NONE. After sufficient movement the EKF will reset the yaw tot he EKF-GSF estimate. After that GPS fusion will commence.
* EKF: Fix unconstrained yaw and yaw variance growth when on ground
* EKF: Ensure first yaw alignment can't be blocked
* EKF: Increase yaw variance limit allowed for alignment
Flight test data indicates that an uncertainty value of 15 deg still provides a reliable yaw estimate and enables an earlier alignment/reset if required.
* EKF: Remove unexecutable code
* EKF: Restructure heading fusion
* EKF: parameterise quarter variance check and retune default value
* EKF: Pass by reference instead of pointer
* EKF: Clarify reset logic
* EKF: Remove incorrect setting of mag field alignment flag
* EKF: Non-functional tidy up
* EKF: Fix non-use of function argument
The updateQuaternion function was using the _heading_innovation class variable instead of setting it using the innovation argument.
* EKF: Fix undefined variable
* EKF: Use single precision atan2
* EKF: remove unnecessary timer reset and unwanted execution of reset function
* EKF: Don't declare a mag fault when non-use is user selected
Doing so produces unnecessary user alerts.
Replace the multiple if-else statements by a generic equation.
- For a multicopter, the attenuation factor is 2 and symmetrical
- For a fixedwing, the attenuation factor is 1 if the acceleration is
positive and that centripetal correction is available and 2 otherwise.
Note that the function "sq" needs to be const in order to be used in a
const function.
* ekf2: centralize mag covariance reset. A complete and clean reset of the
mag states covariances is now performed through the "resetMagCov"
function only. This avoid having slight differences of implementations
across the code.
* Ekf: reset quat cov with initial uncertainty instead of zero