* EKF: Add comparison test for mag field fusion generated code
* EKF: convert mag field fusion to use SymPy generated code
* EKF: Add test comparison program for yaw fusion equations
* Stop setting 0 to 0
* Reduce if/else statement to only if
* EKF: more accurate implementation for sequential fusion of magnetometer data
* test: update change indicator
* Use matrix::SparseVector<float, 24, ...> for observation jacobian
* Adapt the auto code generation to allow for different bracket styles
* Add auto generated code for mag fusion
* Add generic computation of KHP
* Apply generic computation of KHP to mag fusion
* tests: update change indicator
* tests: update change indicator
Co-authored-by: kamilritz <kritz@ethz.ch>
* added python script with ekf derivation (WIP)
Signed-off-by: RomanBapst <bapstroman@gmail.com>
* worked on c code auto-generation
Signed-off-by: RomanBapst <bapstroman@gmail.com>
* save before variable name change
Signed-off-by: RomanBapst <bapstroman@gmail.com>
* changed symbol names
Signed-off-by: RomanBapst <bapstroman@gmail.com>
* added codegeneration class
Signed-off-by: RomanBapst <bapstroman@gmail.com>
* improve 3D mag fusion derivation
Signed-off-by: RomanBapst <bapstroman@gmail.com>
* EKF: Extend ekf sympy derivation to include all observation types
* EKF: Add custom ecl::powf function for integer powers
* EKF: Convert ekf covariance prediction to use sympy output
* EKF: Add test program to compare sympy and matlab covariance prediction
Also tests ecl::powf(x,exp) function
* EKF: simplify ecl::powf function
* Generate code to subfolder generated/
* Add printouts for showing code generation progress
* Move generated covariance code to generated folder
* Upgrade code generation to python3
* main.py: Remove unused create_symbols function
& making code more compact
* main.py: move main part into function
* Code generation: fix passing wrong rotation matrix to yaw_observation ()
* EKF: Amend generated code filename for consistency
* Move ecl::powf function test to unit tests
* EKF: Use updated ecl:powf functionality in test program
* Move ecl::powf to utils.hpp
* Update ecl::powf test
* Update output change indication
* test: update expected output for change indicator
* test: update expected output for change indicator again
Co-authored-by: RomanBapst <bapstroman@gmail.com>
Co-authored-by: kamilritz <kritz@ethz.ch>
Minor consistency fixes for the copyright header and update the tables to current. PX4Buildbot will periodically update the tables automatically from this point.
- updated table to 2 bytes (int16) per element and scaled the inclination/declination/strength tables to use most of the range without being too awkward
- tables have been extended to include the full latitude range
- expanded the API slightly to offer declination/inclination in both degrees/radians and the magnetic strength in Gauss and Tesla
- generated some simple testing that verifies interpolation between points
When the antennas are not parallel to the x body axis, the GPS message
contains the angular offset but the data is already corrected in the
driver. EKF2 should then not add this offset during the initialisation.
This fixes the cases where the yaw message from the GNSS receiver would
take more time than the vel/pos. The estimator should wait and not
immediately fall back to an other aiding source after 5sec.
If it never comes, it will never fall back, but this is ok since the
user wants to fly with GPS aiding an not with something else.
If the user selects GPS yaw fusion but that there is no GPS yaw data in
the GPS message or if the fusion is rejected for some time, the GPS yaw
data is declared faulty and the fusion is stopped to allow an other
source of yaw aiding to start.
This is how it is also done in ekf2_main. Otherwise, this leads to
multiple integration of the same IMU data due to asynchronous sensor
updates triggering a prediction step between IMU updates.
Fix unit tests that broke because of this fix
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: do not fuse multiple times the same height
The _fuse_height flag was never set to zero, hence the fusion was called
at each iteration, even if no new data is available.
The effects were: high CPU usage and virtually less measurement noise
due to multiple fusion of the same sample
Also remve unused variables
* Add primitive logging for Ekf
* Add python script to extract sensor data from ULog
* Add primitive sensor replay
* Add iris_gps data for sensor replay
* Add CI for functional change indication
* Update sensor replay flow data type
* update iris_gps_change indication
* test: Update EKF replay test documentation
Co-authored-by: Paul Riseborough <priseborough@users.noreply.github.com>