From 84e11a0cac53f753f65b0bea4659e1f2d9c0b35e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 5 Sep 2012 11:37:17 +0200 Subject: Fixed correct RC loss detection, AR.Drone is now shutting down motors after 1 s of RC loss. Added debug topic. --- apps/commander/commander.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apps/commander/commander.c') diff --git a/apps/commander/commander.c b/apps/commander/commander.c index 80d2c58f8..4135abf60 100644 --- a/apps/commander/commander.c +++ b/apps/commander/commander.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include @@ -1174,6 +1175,7 @@ int commander_thread_main(int argc, char *argv[]) /* End battery voltage check */ /* Start RC state check */ + bool prev_lost = current_status.rc_signal_lost; if (rc.chan_count > 4 && (hrt_absolute_time() - rc.timestamp) < 100000) { @@ -1238,10 +1240,18 @@ int commander_thread_main(int argc, char *argv[]) /* flag as lost and update interval since when the signal was lost (to initiate RTL after some time) */ current_status.rc_signal_cutting_off = true; current_status.rc_signal_lost_interval = hrt_absolute_time() - rc.timestamp; + /* if the RC signal is gone for a full second, consider it lost */ if (current_status.rc_signal_lost_interval > 1000000) current_status.rc_signal_lost = true; } + /* Check if this is the first loss or first gain*/ + if ((!prev_lost && current_status.rc_signal_lost) || + prev_lost && !current_status.rc_signal_lost) { + /* publish rc lost */ + publish_armed_status(¤t_status); + } + /* End mode switch */ /* END RC state check */ -- cgit v1.2.3