mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 07:13:34 +08:00
Random improvements
This commit is contained in:
committed by
Mathieu Bresciani
parent
7d3814b1d8
commit
ef9f1053d0
+12
-6
@@ -57,22 +57,28 @@ void Ekf::controlFusionModes()
|
|||||||
// and declare the tilt alignment complete
|
// and declare the tilt alignment complete
|
||||||
if ((angle_err_var_vec(0) + angle_err_var_vec(1)) < sq(math::radians(3.0f))) {
|
if ((angle_err_var_vec(0) + angle_err_var_vec(1)) < sq(math::radians(3.0f))) {
|
||||||
_control_status.flags.tilt_align = true;
|
_control_status.flags.tilt_align = true;
|
||||||
_control_status.flags.yaw_align = resetMagHeading(_mag_lpf.getState());
|
_control_status.flags.yaw_align = resetMagHeading(_mag_lpf.getState()); // TODO: is this needed?
|
||||||
|
|
||||||
|
|
||||||
// send alignment status message to the console
|
// send alignment status message to the console
|
||||||
if (_control_status.flags.baro_hgt) {
|
if (_control_status.flags.baro_hgt) {
|
||||||
ECL_INFO("%llu: EKF aligned, (pressure height, IMU buf: %i, OBS buf: %i)", (unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
ECL_INFO("%llu: EKF aligned, (pressure height, IMU buf: %i, OBS buf: %i)",
|
||||||
|
(unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
||||||
|
|
||||||
} else if (_control_status.flags.ev_hgt) {
|
} else if (_control_status.flags.ev_hgt) {
|
||||||
ECL_INFO("%llu: EKF aligned, (EV height, IMU buf: %i, OBS buf: %i)", (unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
ECL_INFO("%llu: EKF aligned, (EV height, IMU buf: %i, OBS buf: %i)",
|
||||||
|
(unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
||||||
|
|
||||||
} else if (_control_status.flags.gps_hgt) {
|
} else if (_control_status.flags.gps_hgt) {
|
||||||
ECL_INFO("%llu: EKF aligned, (GPS height, IMU buf: %i, OBS buf: %i)", (unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
ECL_INFO("%llu: EKF aligned, (GPS height, IMU buf: %i, OBS buf: %i)",
|
||||||
|
(unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
||||||
|
|
||||||
} else if (_control_status.flags.rng_hgt) {
|
} else if (_control_status.flags.rng_hgt) {
|
||||||
ECL_INFO("%llu: EKF aligned, (range height, IMU buf: %i, OBS buf: %i)", (unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
ECL_INFO("%llu: EKF aligned, (range height, IMU buf: %i, OBS buf: %i)",
|
||||||
|
(unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
||||||
} else {
|
} else {
|
||||||
ECL_ERR("%llu: EKF aligned, (unknown height, IMU buf: %i, OBS buf: %i)", (unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
ECL_ERR("%llu: EKF aligned, (unknown height, IMU buf: %i, OBS buf: %i)",
|
||||||
|
(unsigned long long)_imu_sample_delayed.time_us, (int)_imu_buffer_length, (int)_obs_buffer_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -592,18 +592,18 @@ bool Ekf::resetMagHeading(const Vector3f &mag_init, bool increase_yaw_var, bool
|
|||||||
Dcmf R_to_earth(euler321);
|
Dcmf R_to_earth(euler321);
|
||||||
|
|
||||||
// calculate the observed yaw angle
|
// calculate the observed yaw angle
|
||||||
if (_control_status.flags.ev_yaw) {
|
if (_params.mag_fusion_type <= MAG_FUSE_TYPE_3D) {
|
||||||
// convert the observed quaternion to a rotation matrix
|
|
||||||
Dcmf R_to_earth_ev(_ev_sample_delayed.quat); // transformation matrix from body to world frame
|
|
||||||
// calculate the yaw angle for a 312 sequence
|
|
||||||
euler321(2) = atan2f(R_to_earth_ev(1, 0), R_to_earth_ev(0, 0));
|
|
||||||
|
|
||||||
} else if (_params.mag_fusion_type <= MAG_FUSE_TYPE_3D) {
|
|
||||||
// rotate the magnetometer measurements into earth frame using a zero yaw angle
|
// rotate the magnetometer measurements into earth frame using a zero yaw angle
|
||||||
Vector3f mag_earth_pred = R_to_earth * mag_init;
|
Vector3f mag_earth_pred = R_to_earth * mag_init;
|
||||||
// the angle of the projection onto the horizontal gives the yaw angle
|
// the angle of the projection onto the horizontal gives the yaw angle
|
||||||
euler321(2) = -atan2f(mag_earth_pred(1), mag_earth_pred(0)) + getMagDeclination();
|
euler321(2) = -atan2f(mag_earth_pred(1), mag_earth_pred(0)) + getMagDeclination();
|
||||||
|
|
||||||
|
} else if (_control_status.flags.ev_yaw) {
|
||||||
|
// convert the observed quaternion to a rotation matrix
|
||||||
|
Dcmf R_to_earth_ev(_ev_sample_delayed.quat); // transformation matrix from body to world frame
|
||||||
|
// calculate the yaw angle for a 312 sequence
|
||||||
|
euler321(2) = atan2f(R_to_earth_ev(1, 0), R_to_earth_ev(0, 0));
|
||||||
|
|
||||||
} else if (_params.mag_fusion_type == MAG_FUSE_TYPE_INDOOR && _mag_use_inhibit) {
|
} else if (_params.mag_fusion_type == MAG_FUSE_TYPE_INDOOR && _mag_use_inhibit) {
|
||||||
// we are operating without knowing the earth frame yaw angle
|
// we are operating without knowing the earth frame yaw angle
|
||||||
return true;
|
return true;
|
||||||
@@ -650,18 +650,18 @@ bool Ekf::resetMagHeading(const Vector3f &mag_init, bool increase_yaw_var, bool
|
|||||||
R_to_earth(2, 1) = s1;
|
R_to_earth(2, 1) = s1;
|
||||||
|
|
||||||
// calculate the observed yaw angle
|
// calculate the observed yaw angle
|
||||||
if (_control_status.flags.ev_yaw) {
|
if (_params.mag_fusion_type <= MAG_FUSE_TYPE_3D) {
|
||||||
// convert the observed quaternion to a rotation matrix
|
|
||||||
Dcmf R_to_earth_ev(_ev_sample_delayed.quat); // transformation matrix from body to world frame
|
|
||||||
// calculate the yaw angle for a 312 sequence
|
|
||||||
euler312(0) = atan2f(-R_to_earth_ev(0, 1), R_to_earth_ev(1, 1));
|
|
||||||
|
|
||||||
} else if (_params.mag_fusion_type <= MAG_FUSE_TYPE_3D) {
|
|
||||||
// rotate the magnetometer measurements into earth frame using a zero yaw angle
|
// rotate the magnetometer measurements into earth frame using a zero yaw angle
|
||||||
Vector3f mag_earth_pred = R_to_earth * mag_init;
|
Vector3f mag_earth_pred = R_to_earth * mag_init;
|
||||||
// the angle of the projection onto the horizontal gives the yaw angle
|
// the angle of the projection onto the horizontal gives the yaw angle
|
||||||
euler312(0) = -atan2f(mag_earth_pred(1), mag_earth_pred(0)) + getMagDeclination();
|
euler312(0) = -atan2f(mag_earth_pred(1), mag_earth_pred(0)) + getMagDeclination();
|
||||||
|
|
||||||
|
} else if (_control_status.flags.ev_yaw) {
|
||||||
|
// convert the observed quaternion to a rotation matrix
|
||||||
|
Dcmf R_to_earth_ev(_ev_sample_delayed.quat); // transformation matrix from body to world frame
|
||||||
|
// calculate the yaw angle for a 312 sequence
|
||||||
|
euler312(0) = atan2f(-R_to_earth_ev(0, 1), R_to_earth_ev(1, 1));
|
||||||
|
|
||||||
} else if (_params.mag_fusion_type == MAG_FUSE_TYPE_INDOOR && _mag_use_inhibit) {
|
} else if (_params.mag_fusion_type == MAG_FUSE_TYPE_INDOOR && _mag_use_inhibit) {
|
||||||
// we are operating without knowing the earth frame yaw angle
|
// we are operating without knowing the earth frame yaw angle
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user