mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 07:33:34 +08:00
Removed stupid sensor counter, replaced it with much more useful timestamps
This commit is contained in:
@@ -200,8 +200,8 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
bool landed = true;
|
||||
hrt_abstime landed_time = 0;
|
||||
|
||||
uint32_t accel_counter = 0;
|
||||
uint32_t baro_counter = 0;
|
||||
hrt_abstime accel_timestamp = 0;
|
||||
hrt_abstime baro_timestamp = 0;
|
||||
|
||||
bool ref_inited = false;
|
||||
hrt_abstime ref_init_start = 0;
|
||||
@@ -310,8 +310,8 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
if (fds_init[0].revents & POLLIN) {
|
||||
orb_copy(ORB_ID(sensor_combined), sensor_combined_sub, &sensor);
|
||||
|
||||
if (wait_baro && sensor.baro_counter != baro_counter) {
|
||||
baro_counter = sensor.baro_counter;
|
||||
if (wait_baro && sensor.baro_timestamp != baro_timestamp) {
|
||||
baro_timestamp = sensor.baro_timestamp;
|
||||
|
||||
/* mean calculation over several measurements */
|
||||
if (baro_init_cnt < baro_init_num) {
|
||||
@@ -384,7 +384,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
if (updated) {
|
||||
orb_copy(ORB_ID(sensor_combined), sensor_combined_sub, &sensor);
|
||||
|
||||
if (sensor.accelerometer_counter != accel_counter) {
|
||||
if (sensor.accelerometer_timestamp != accel_timestamp) {
|
||||
if (att.R_valid) {
|
||||
/* correct accel bias */
|
||||
sensor.accelerometer_m_s2[0] -= acc_bias[0];
|
||||
@@ -408,13 +408,13 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
memset(corr_acc, 0, sizeof(corr_acc));
|
||||
}
|
||||
|
||||
accel_counter = sensor.accelerometer_counter;
|
||||
accel_timestamp = sensor.accelerometer_timestamp;
|
||||
accel_updates++;
|
||||
}
|
||||
|
||||
if (sensor.baro_counter != baro_counter) {
|
||||
if (sensor.baro_timestamp != baro_timestamp) {
|
||||
corr_baro = baro_offset - sensor.baro_alt_meter - z_est[0];
|
||||
baro_counter = sensor.baro_counter;
|
||||
baro_timestamp = sensor.baro_timestamp;
|
||||
baro_updates++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user