mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 19:41:36 +08:00
c++11 initialization cleanup (#237)
This commit is contained in:
@@ -146,10 +146,6 @@ Ekf::Ekf():
|
||||
_dt_ekf_avg = 0.001f * (float)(FILTER_UPDATE_PERIOD_MS);
|
||||
}
|
||||
|
||||
Ekf::~Ekf()
|
||||
{
|
||||
}
|
||||
|
||||
bool Ekf::init(uint64_t timestamp)
|
||||
{
|
||||
bool ret = initialise_interface(timestamp);
|
||||
|
||||
@@ -48,7 +48,7 @@ class Ekf : public EstimatorInterface
|
||||
public:
|
||||
|
||||
Ekf();
|
||||
~Ekf();
|
||||
~Ekf() = default;
|
||||
|
||||
// initialise variables to sane values (also interface class)
|
||||
bool init(uint64_t timestamp);
|
||||
@@ -245,13 +245,13 @@ private:
|
||||
|
||||
matrix::Dcm<float> _R_to_earth; // transformation matrix from body frame to earth frame from last EKF predition
|
||||
|
||||
float P[_k_num_states][_k_num_states]; // state covariance matrix
|
||||
float P[_k_num_states][_k_num_states]{}; // state covariance matrix
|
||||
|
||||
float _vel_pos_innov[6]; // innovations: 0-2 vel, 3-5 pos
|
||||
float _vel_pos_innov_var[6]; // innovation variances: 0-2 vel, 3-5 pos
|
||||
float _vel_pos_innov[6]{}; // innovations: 0-2 vel, 3-5 pos
|
||||
float _vel_pos_innov_var[6]{}; // innovation variances: 0-2 vel, 3-5 pos
|
||||
|
||||
float _mag_innov[3]; // earth magnetic field innovations
|
||||
float _mag_innov_var[3]; // earth magnetic field innovation variance
|
||||
float _mag_innov[3]{}; // earth magnetic field innovations
|
||||
float _mag_innov_var[3]{}; // earth magnetic field innovation variance
|
||||
|
||||
float _airspeed_innov; // airspeed measurement innovation
|
||||
float _airspeed_innov_var; // airspeed measurement innovation variance
|
||||
@@ -263,8 +263,8 @@ private:
|
||||
float _heading_innov_var; // heading measurement innovation variance
|
||||
|
||||
// optical flow processing
|
||||
float _flow_innov[2]; // flow measurement innovation
|
||||
float _flow_innov_var[2]; // flow innovation variance
|
||||
float _flow_innov[2]{}; // flow measurement innovation
|
||||
float _flow_innov_var[2]{}; // flow innovation variance
|
||||
Vector3f _flow_gyro_bias; // bias errors in optical flow sensor rate gyro outputs
|
||||
Vector3f _imu_del_ang_of; // bias corrected delta angle measurements accumulated across the same time frame as the optical flow rates
|
||||
float _delta_time_of; // time in sec that _imu_del_ang_of was accumulated over
|
||||
@@ -277,7 +277,7 @@ private:
|
||||
Quaternion _q_down_sampled; // down sampled quaternion (tracking delta angles between ekf update steps)
|
||||
Vector3f _vel_err_integ; // integral of velocity tracking error
|
||||
Vector3f _pos_err_integ; // integral of position tracking error
|
||||
float _output_tracking_error[3];// contains the magnitude of the angle, velocity and position track errors (rad, m/s, m)
|
||||
float _output_tracking_error[3]{};// contains the magnitude of the angle, velocity and position track errors (rad, m/s, m)
|
||||
|
||||
// variables used for the GPS quality checks
|
||||
float _gpsDriftVelN; // GPS north position derivative (m/s)
|
||||
@@ -306,7 +306,7 @@ private:
|
||||
// Variables used to control activation of post takeoff functionality
|
||||
float _last_on_ground_posD; // last vertical position when the in_air status was false (m)
|
||||
|
||||
gps_check_fail_status_u _gps_check_fail_status;
|
||||
gps_check_fail_status_u _gps_check_fail_status{};
|
||||
|
||||
// Terrain height state estimation
|
||||
float _terrain_vpos; // estimated vertical position of the terrain underneath the vehicle in local NED frame (m)
|
||||
|
||||
+1
-1
@@ -774,7 +774,7 @@ void Ekf::get_innovation_test_status(uint16_t *status, float *mag, float *vel, f
|
||||
// return a bitmask integer that describes which state estimates are valid
|
||||
void Ekf::get_ekf_soln_status(uint16_t *status)
|
||||
{
|
||||
ekf_solution_status soln_status;
|
||||
ekf_solution_status soln_status{};
|
||||
soln_status.flags.attitude = _control_status.flags.tilt_align && _control_status.flags.yaw_align && (_fault_status.value == 0);
|
||||
soln_status.flags.velocity_horiz = (_control_status.flags.gps || _control_status.flags.ev_pos || _control_status.flags.opt_flow) && (_fault_status.value == 0);
|
||||
soln_status.flags.velocity_vert = (_control_status.flags.baro_hgt || _control_status.flags.ev_hgt || _control_status.flags.gps_hgt || _control_status.flags.rng_hgt) && (_fault_status.value == 0);
|
||||
|
||||
@@ -89,11 +89,6 @@ EstimatorInterface::EstimatorInterface():
|
||||
_delta_vel_prev.setZero();
|
||||
}
|
||||
|
||||
EstimatorInterface::~EstimatorInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Accumulate imu data and store to buffer at desired rate
|
||||
void EstimatorInterface::setIMUData(uint64_t time_usec, uint64_t delta_ang_dt, uint64_t delta_vel_dt, float (&delta_ang)[3],
|
||||
float (&delta_vel)[3])
|
||||
@@ -227,7 +222,7 @@ void EstimatorInterface::setBaroData(uint64_t time_usec, float data)
|
||||
// limit data rate to prevent data being lost
|
||||
if (time_usec - _time_last_baro > _min_obs_interval_us) {
|
||||
|
||||
baroSample baro_sample_new;
|
||||
baroSample baro_sample_new{};
|
||||
baro_sample_new.hgt = data;
|
||||
baro_sample_new.time_us = time_usec - _params.baro_delay_ms * 1000;
|
||||
|
||||
@@ -248,7 +243,7 @@ void EstimatorInterface::setAirspeedData(uint64_t time_usec, float true_airspeed
|
||||
|
||||
// limit data rate to prevent data being lost
|
||||
if (time_usec - _time_last_airspeed > _min_obs_interval_us) {
|
||||
airspeedSample airspeed_sample_new;
|
||||
airspeedSample airspeed_sample_new{};
|
||||
airspeed_sample_new.true_airspeed = true_airspeed;
|
||||
airspeed_sample_new.eas2tas = eas2tas;
|
||||
airspeed_sample_new.time_us = time_usec - _params.airspeed_delay_ms * 1000;
|
||||
|
||||
@@ -52,7 +52,7 @@ class EstimatorInterface
|
||||
|
||||
public:
|
||||
EstimatorInterface();
|
||||
~EstimatorInterface();
|
||||
~EstimatorInterface() = default;
|
||||
|
||||
virtual bool init(uint64_t timestamp) = 0;
|
||||
virtual bool update() = 0;
|
||||
@@ -328,7 +328,7 @@ protected:
|
||||
float _tas_test_ratio; // tas innovation consistency check ratio
|
||||
float _terr_test_ratio; // height above terrain measurement innovation consistency check ratio
|
||||
float _beta_test_ratio; // sideslip innovation consistency check ratio
|
||||
innovation_fault_status_u _innov_check_fail_status;
|
||||
innovation_fault_status_u _innov_check_fail_status{};
|
||||
|
||||
// IMU vibration monitoring
|
||||
Vector3f _delta_ang_prev; // delta angle from the previous IMU measurement
|
||||
@@ -358,7 +358,7 @@ protected:
|
||||
uint64_t _time_last_ext_vision; // timestamp of last external vision measurement in microseconds
|
||||
uint64_t _time_last_optflow;
|
||||
|
||||
fault_status_u _fault_status;
|
||||
fault_status_u _fault_status{};
|
||||
|
||||
// allocate data buffers and intialise interface variables
|
||||
bool initialise_interface(uint64_t timestamp);
|
||||
@@ -370,10 +370,10 @@ protected:
|
||||
float _mag_declination_to_save_deg; // magnetic declination to save to EKF2_MAG_DECL (deg)
|
||||
|
||||
// this is the current status of the filter control modes
|
||||
filter_control_status_u _control_status;
|
||||
filter_control_status_u _control_status{};
|
||||
|
||||
// this is the previous status of the filter control modes - used to detect mode transitions
|
||||
filter_control_status_u _control_status_prev;
|
||||
filter_control_status_u _control_status_prev{};
|
||||
|
||||
// perform a vector cross product
|
||||
Vector3f cross_product(const Vector3f &vecIn1, const Vector3f &vecIn2);
|
||||
|
||||
@@ -99,8 +99,6 @@ bool Ekf::collect_gps(uint64_t time_usec, struct gps_message *gps)
|
||||
|
||||
// start collecting GPS if there is a 3D fix and the NED origin has been set
|
||||
return _NED_origin_initialised && (gps->fix_type >= 3);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user