mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-01 23:40:34 +08:00
Remove q_valid flag from attitude topic
This commit is contained in:
@@ -473,7 +473,6 @@ void AttitudeEstimatorQ::task_main()
|
||||
att.yawspeed = _rates(2);
|
||||
|
||||
memcpy(&att.q[0], _q.data, sizeof(att.q));
|
||||
att.q_valid = true;
|
||||
|
||||
/* the instance count is not used here */
|
||||
int att_inst;
|
||||
|
||||
@@ -726,7 +726,6 @@ void Ekf2::task_main()
|
||||
att.q[1] = q(1);
|
||||
att.q[2] = q(2);
|
||||
att.q[3] = q(3);
|
||||
att.q_valid = true;
|
||||
|
||||
att.rollspeed = gyro_rad[0];
|
||||
att.pitchspeed = gyro_rad[1];
|
||||
|
||||
@@ -535,15 +535,15 @@ void Ekf2Replay::logIfUpdated()
|
||||
log_message.body.att.q_x = att.q[1];
|
||||
log_message.body.att.q_y = att.q[2];
|
||||
log_message.body.att.q_z = att.q[3];
|
||||
log_message.body.att.roll = att.roll;
|
||||
log_message.body.att.pitch = att.pitch;
|
||||
log_message.body.att.yaw = att.yaw;
|
||||
log_message.body.att.roll = 0;
|
||||
log_message.body.att.pitch = 0;
|
||||
log_message.body.att.yaw = 0;
|
||||
log_message.body.att.roll_rate = att.rollspeed;
|
||||
log_message.body.att.pitch_rate = att.pitchspeed;
|
||||
log_message.body.att.yaw_rate = att.yawspeed;
|
||||
log_message.body.att.gx = att.g_comp[0];
|
||||
log_message.body.att.gy = att.g_comp[1];
|
||||
log_message.body.att.gz = att.g_comp[2];
|
||||
log_message.body.att.gx = 0;
|
||||
log_message.body.att.gy = 0;
|
||||
log_message.body.att.gz = 0;
|
||||
|
||||
writeMessage(_write_fd, (void *)&log_message.head1, _formats[LOG_ATT_MSG].length);
|
||||
|
||||
|
||||
@@ -929,7 +929,7 @@ void BlockLocalPositionEstimator::predict()
|
||||
// state or covariance
|
||||
if (!_validXY && !_validZ) { return; }
|
||||
|
||||
if (integrate && _sub_att.get().q_valid) {
|
||||
if (integrate) {
|
||||
matrix::Quaternion<float> q(&_sub_att.get().q[0]);
|
||||
_eul = matrix::Euler<float>(q);
|
||||
_R_att = matrix::Dcm<float>(q);
|
||||
|
||||
@@ -1925,7 +1925,6 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
hil_attitude.q[1] = q(1);
|
||||
hil_attitude.q[2] = q(2);
|
||||
hil_attitude.q[3] = q(3);
|
||||
hil_attitude.q_valid = true;
|
||||
|
||||
hil_attitude.rollspeed = hil_state.rollspeed;
|
||||
hil_attitude.pitchspeed = hil_state.pitchspeed;
|
||||
|
||||
@@ -507,27 +507,22 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
orb_copy(ORB_ID(sensor_combined), sensor_combined_sub, &sensor);
|
||||
|
||||
if (sensor.timestamp + sensor.accelerometer_timestamp_relative != accel_timestamp) {
|
||||
if (att.q_valid) {
|
||||
/* correct accel bias */
|
||||
sensor.accelerometer_m_s2[0] -= acc_bias[0];
|
||||
sensor.accelerometer_m_s2[1] -= acc_bias[1];
|
||||
sensor.accelerometer_m_s2[2] -= acc_bias[2];
|
||||
/* correct accel bias */
|
||||
sensor.accelerometer_m_s2[0] -= acc_bias[0];
|
||||
sensor.accelerometer_m_s2[1] -= acc_bias[1];
|
||||
sensor.accelerometer_m_s2[2] -= acc_bias[2];
|
||||
|
||||
/* transform acceleration vector from body frame to NED frame */
|
||||
for (int i = 0; i < 3; i++) {
|
||||
acc[i] = 0.0f;
|
||||
/* transform acceleration vector from body frame to NED frame */
|
||||
for (int i = 0; i < 3; i++) {
|
||||
acc[i] = 0.0f;
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
acc[i] += R(i, j) * sensor.accelerometer_m_s2[j];
|
||||
}
|
||||
for (int j = 0; j < 3; j++) {
|
||||
acc[i] += R(i, j) * sensor.accelerometer_m_s2[j];
|
||||
}
|
||||
|
||||
acc[2] += CONSTANTS_ONE_G;
|
||||
|
||||
} else {
|
||||
memset(acc, 0, sizeof(acc));
|
||||
}
|
||||
|
||||
acc[2] += CONSTANTS_ONE_G;
|
||||
|
||||
accel_timestamp = sensor.timestamp + sensor.accelerometer_timestamp_relative;
|
||||
accel_updates++;
|
||||
}
|
||||
@@ -551,8 +546,9 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
|
||||
if (updated) { //check if altitude estimation for lidar is enabled and new sensor data
|
||||
|
||||
if (params.enable_lidar_alt_est && lidar.current_distance > lidar.min_distance && lidar.current_distance < lidar.max_distance
|
||||
&& (R(2, 2) > 0.7f)) {
|
||||
if (params.enable_lidar_alt_est && lidar.current_distance > lidar.min_distance
|
||||
&& lidar.current_distance < lidar.max_distance
|
||||
&& (R(2, 2) > 0.7f)) {
|
||||
|
||||
if (!use_lidar_prev && use_lidar) {
|
||||
lidar_first = true;
|
||||
@@ -614,7 +610,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
float body_v_est[2] = { 0.0f, 0.0f };
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
body_v_est[i] = R( 0, i) * x_est[1] + R(1, i) * y_est[1] + R(2, i) * z_est[1];
|
||||
body_v_est[i] = R(0, i) * x_est[1] + R(1, i) * y_est[1] + R(2, i) * z_est[1];
|
||||
}
|
||||
|
||||
/* set this flag if flow should be accurate according to current velocity and attitude rate estimate */
|
||||
|
||||
@@ -321,7 +321,6 @@ void Simulator::handle_message(mavlink_message_t *msg, bool publish)
|
||||
hil_attitude.q[1] = q(1);
|
||||
hil_attitude.q[2] = q(2);
|
||||
hil_attitude.q[3] = q(3);
|
||||
hil_attitude.q_valid = true;
|
||||
|
||||
hil_attitude.rollspeed = hil_state.rollspeed;
|
||||
hil_attitude.pitchspeed = hil_state.pitchspeed;
|
||||
|
||||
Reference in New Issue
Block a user