@@ -23,6 +23,7 @@ extern "C" {
23
23
#include " log_util.h"
24
24
}
25
25
26
+ #define DATANEW_TIMEOUT 75
26
27
#define TIMEOUT_CYCLES 250000 // 25k = 1 sec fro testing 10/14/2023 => 250k = 10 sec
27
28
#define TIMOUT_MS 10000 // 10 sec
28
29
@@ -147,21 +148,17 @@ void SystemManager::systemManagerTask() {
147
148
148
149
this ->rcInputs_ = rcController_->GetRCControl ();
149
150
150
- // TO-DO: need to implement it using is_Data_New;
151
- // boolean is true if data has not changed since the last cycle
152
- bool is_unchanged{rcInputs_.throttle == prevthrottle && rcInputs_.yaw == prevyaw &&
153
- rcInputs_.roll == prevroll && rcInputs_.pitch == prevpitch};
154
-
155
- if (is_unchanged) {
156
- DisconnectionCount += 1 ; // if its not changed we increment the timeout counter
157
- if (DisconnectionCount > TIMEOUT_CYCLES) { // if timeout has occured
158
- DisconnectionCount =
159
- TIMEOUT_CYCLES + 1 ; // avoid overflow but keep value above threshold
160
- this ->rcInputs_ .arm = 0 ; // failsafe
161
- }
162
- } else {
163
- DisconnectionCount = 0 ; // if the data has changed we want to reset out counter
164
- }
151
+ // Is_Data_new implementation for failsafe
152
+ if (!this ->rcInputs_ .isDataNew ){ // if the data is not new
153
+
154
+ DisconnectionCount += 1 ; // increment the counter
155
+ if (DisconnectionCount > DATANEW_TIMEOUT){ // if the counter is greater than 75, then we can disarm
156
+ this ->rcInputs_ .arm = 0 ; // disarm the drone for failsafe
157
+ }
158
+ }
159
+ else {
160
+ DisconnectionCount = 0 ; // if the data is new, then we reset to 0.
161
+ }
165
162
166
163
watchdog_.refreshWatchdog (); // always hit the dog
167
164
0 commit comments