aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-09-21 13:32:47 +0200
committerThomas Gubler <thomasgubler@gmail.com>2014-09-22 10:59:54 +0200
commitd113fcfc54c246f3d5ac22ad5485f7103aecab41 (patch)
tree73cf5641999caf02301d9337e80b22f3e0707518
parent5a0e0d041229700d2ae9c14e4ab2798d34fff14c (diff)
downloadpx4-firmware-d113fcfc54c246f3d5ac22ad5485f7103aecab41.tar.gz
px4-firmware-d113fcfc54c246f3d5ac22ad5485f7103aecab41.tar.bz2
px4-firmware-d113fcfc54c246f3d5ac22ad5485f7103aecab41.zip
commander: move position of gps failure check
-rw-r--r--src/modules/commander/commander.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp
index b43f08f67..bf15bbeb6 100644
--- a/src/modules/commander/commander.cpp
+++ b/src/modules/commander/commander.cpp
@@ -1205,24 +1205,6 @@ int commander_thread_main(int argc, char *argv[])
check_valid(global_position.timestamp, POSITION_TIMEOUT, eph_good, &(status.condition_global_position_valid), &status_changed);
- /* check if GPS fix is ok */
- if (gps_position.fix_type >= 3 && //XXX check eph and epv ?
- hrt_elapsed_time(&gps_position.timestamp_position) < FAILSAFE_DEFAULT_TIMEOUT) {
- /* handle the case where gps was regained */
- if (status.gps_failure) {
- status.gps_failure = false;
- status_changed = true;
- mavlink_log_critical(mavlink_fd, "gps regained");
- }
- } else {
- if (!status.gps_failure) {
- status.gps_failure = true;
- status_changed = true;
- mavlink_log_critical(mavlink_fd, "gps fix lost");
- }
- }
-
-
/* update home position */
if (!status.condition_home_position_valid && status.condition_global_position_valid && !armed.armed &&
(global_position.eph < eph_threshold) && (global_position.epv < epv_threshold)) {
@@ -1434,6 +1416,23 @@ int commander_thread_main(int argc, char *argv[])
globallocalconverter_init((double)gps_position.lat * 1.0e-7, (double)gps_position.lon * 1.0e-7, (float)gps_position.alt * 1.0e-3f, hrt_absolute_time());
}
+ /* check if GPS fix is ok */
+ if (gps_position.fix_type >= 3 && //XXX check eph and epv ?
+ hrt_elapsed_time(&gps_position.timestamp_position) < FAILSAFE_DEFAULT_TIMEOUT) {
+ /* handle the case where gps was regained */
+ if (status.gps_failure) {
+ status.gps_failure = false;
+ status_changed = true;
+ mavlink_log_critical(mavlink_fd, "gps regained");
+ }
+ } else {
+ if (!status.gps_failure) {
+ status.gps_failure = true;
+ status_changed = true;
+ mavlink_log_critical(mavlink_fd, "gps fix lost");
+ }
+ }
+
/* start mission result check */
orb_check(mission_result_sub, &updated);