44 #include <mathlib/mathlib.h> 48 bool initialized =
false;
217 Vector3f vel_body = earth_to_body * vel_rel_earth;
219 float t0 = q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3;
226 float Hx = vel_body(1) * t0 / (pred_hagl * pred_hagl);
238 float pred_flow_x = vel_body(1) * earth_to_body(2, 2) / pred_hagl;
251 if (flow_test_ratio <= 1.0
f) {
254 _terrain_var = fmaxf(_terrain_var - KxHxP, 0.0
f);
259 float Hy = -vel_body(0) * t0 / (pred_hagl * pred_hagl);
268 float pred_flow_y = -vel_body(0) * earth_to_body(2, 2) / pred_hagl;
279 if (flow_test_ratio <= 1.0
f) {
282 _terrain_var = fmaxf(_terrain_var - KyHyP, 0.0
f);
Matrix3f quat_to_invrotmat(const Quatf &quat)
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
float _cos_tilt_rng
cosine of the range finder tilt rotation about the Y body axis
struct estimator::filter_control_status_u::@60 flags
Adapter / shim layer for system calls needed by ECL.
stateSample _state
state struct of the ekf running at the delayed time horizon
float _flow_innov[2]
flow measurement innovation (rad/sec)
float range_cos_max_tilt
cosine of the maximum tilt angle from the vertical that permits use of range finder and flow data ...
const data_type & get_newest()
float terrain_p_noise
process noise for terrain offset (m/sec)
void updateTerrainValidity()
bool _flow_for_terrain_data_ready
bool reject_hagl
9 - true if the height above ground observation has been rejected
Vector3f _flow_gyro_bias
bias errors in optical flow sensor rate gyro outputs (rad/sec)
float terrain_gradient
gradient of terrain used to estimate process noise due to changing position (m/m) ...
Vector3f cross_product(const Vector3f &vecIn1, const Vector3f &vecIn2)
float _terrain_var
variance of terrain position estimate (m**2)
float vehicle_variance_scaler
gain applied to vehicle height variance used in calculation of height above ground observation varian...
rangeSample _range_sample_delayed
Vector3f gyroXYZ
measured delta angle of the inertial frame about the body axes obtained from rate gyro measurements (...
float dt
amount of integration time (sec)
float P[_k_num_states][_k_num_states]
state covariance matrix
float rng
range (distance to ground) measurement (m)
float _terrain_vpos
estimated vertical position of the terrain underneath the vehicle in local NED frame (m) ...
uint64_t _time_last_of_fuse
time the last fusion of optical flow measurements were performed (uSec)
float _hagl_innov_var
innovation variance for the last height above terrain measurement (m**2)
void getHaglInnovVar(float *hagl_innov_var) override
Dcmf _R_to_earth
transformation matrix from body frame to earth frame from last EKF prediction
bool _terrain_initialised
true when the terrain estimator has been initialized
float flow_innov_gate
optical flow fusion innovation consistency gate size (STD)
Vector2f _flowRadXYcomp
measured delta angle of the image about the X and Y body axes after removal of body rotation (rad)...
Vector3f flow_pos_body
xyz position of range sensor focal point in body frame (m)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Vector2< float > Vector2f
void fuseFlowForTerrain()
float rng_gnd_clearance
minimum valid value for range when on ground (m)
filter_control_status_u _control_status
Vector3f vel
NED velocity in earth frame in m/s.
float range_noise
observation noise for range finder measurements (m)
static constexpr float sq(float var)
imuSample _imu_sample_delayed
bool _rng_hgt_valid
true if range finder sample retrieved from buffer is valid
Quatf quat_nominal
quaternion defining the rotation from body to earth frame
Vector3f pos
NED position in earth frame in m.
void runTerrainEstimator()
innovation_fault_status_u _innov_check_fail_status
void getTerrainVertPos(float *ret) override
float rng_sens_pitch
Pitch offset of the range sensor (rad). Sensor points out along Z axis when offset is zero...
Vector3< float > Vector3f
bool _hagl_valid
true when the height above ground estimate is valid
uint32_t opt_flow
3 - true if optical flow measurements are being fused
float _R_rng_to_earth_2_2
2,2 element of the rotation matrix from sensor frame to earth frame
float _hagl_innov
innovation of the last height above terrain measurement (m)
float _sin_tilt_rng
sine of the range finder tilt rotation about the Y body axis
float _flow_innov_var[2]
flow innovation variance ((rad/sec)**2)
uint32_t in_air
7 - true when the vehicle is airborne
RingBuffer< rangeSample > _range_buffer
flowSample _flow_sample_delayed
float range_noise_scaler
scaling from range measurement to noise (m/m)
float range_innov_gate
range finder fusion innovation consistency gate size (STD)
Vector3f imu_pos_body
xyz position of IMU in body frame (m)
void getHaglInnov(float *hagl_innov) override
struct estimator::innovation_fault_status_u::@58 flags
uint64_t _time_last_hagl_fuse
last system time that the hagl measurement failed it's checks (uSec)
Class for core functions for ekf attitude and position estimator.
bool isTerrainEstimateValid() const override
uint64_t time_us
timestamp of the measurement (uSec)
float delta_vel_dt
delta velocity integration period (sec)
float calcOptFlowMeasVar()
bool _range_data_ready
true when new range finder data has fallen behind the fusion time horizon and is available to be fuse...