aboutsummaryrefslogtreecommitdiff
path: root/src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-03-18 18:28:54 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-03-18 18:28:54 +0100
commitbce67c6b036cddbe1542f910c6e605256283768f (patch)
tree0fc9487ce26dc97aa8d9aee56e43cb1d6ee3fa4a /src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp
parent7cdb7291af52f2b60aa53607e7ec229fecf7497f (diff)
downloadpx4-firmware-bce67c6b036cddbe1542f910c6e605256283768f.tar.gz
px4-firmware-bce67c6b036cddbe1542f910c6e605256283768f.tar.bz2
px4-firmware-bce67c6b036cddbe1542f910c6e605256283768f.zip
Init / reinit improvements
Diffstat (limited to 'src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp')
-rw-r--r--src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp b/src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp
index df2608f83..8b41e7479 100644
--- a/src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp
+++ b/src/modules/fw_att_pos_estimator/fw_att_pos_estimator_main.cpp
@@ -604,6 +604,9 @@ FixedwingEstimator::task_main()
orb_check(_gps_sub, &gps_updated);
if (gps_updated) {
+
+ uint64_t last_gps = _gps.timestamp_position;
+
orb_copy(ORB_ID(vehicle_gps_position), _gps_sub, &_gps);
perf_count(_perf_gps);
@@ -612,6 +615,14 @@ FixedwingEstimator::task_main()
newDataGps = false;
} else {
+
+ /* check if we had a GPS outage for a long time */
+ if (hrt_elapsed_time(&last_gps) > 5 * 1000 * 1000) {
+ ResetPosition();
+ ResetVelocity();
+ ResetStoredStates();
+ }
+
/* fuse GPS updates */
//_gps.timestamp / 1e3;
@@ -688,6 +699,12 @@ FixedwingEstimator::task_main()
/**
+ * CHECK IF THE INPUT DATA IS SANE
+ */
+ CheckAndBound();
+
+
+ /**
* PART TWO: EXECUTE THE FILTER
**/
@@ -715,7 +732,9 @@ FixedwingEstimator::task_main()
_local_pos.ref_timestamp = _gps.timestamp_position;
// Store
- _baro_ref = baroHgt;
+ orb_copy(ORB_ID(sensor_baro), _baro_sub, &_baro);
+ _baro_ref = _baro.altitude;
+ baroHgt = _baro.altitude - _baro_ref;
_baro_gps_offset = baroHgt - alt;
// XXX this is not multithreading safe