Skip to content

Commit

Permalink
redundancy: Add communication timeout information
Browse files Browse the repository at this point in the history
Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Aug 9, 2024
1 parent b7c8be4 commit bc397e6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/modules/redundancy/redundancy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ void Redundancy::manage_spare_disarming()
landed--;
}

/* We have been landed the needed time, allowed to disarm as soon as primary is disarmed */
/* We have been landed the needed time, allowed to disarm as soon as primary is disarmed.
* Primary FC timeout is handled as if it was disarmed. This enables auto-disarm
* in case primary FC is completely died
*/

if (landed == 0 && armed &&
_status[PRIMARY_FC_IDX].arming_state != vehicle_status_s::ARMING_STATE_ARMED) {
(_status[PRIMARY_FC_IDX].arming_state != vehicle_status_s::ARMING_STATE_ARMED ||
_autopilot_timeout[PRIMARY_FC_IDX])) {
PX4_INFO("Disarming as landed and primary disarmed");
force_disarm();
landed = -1;
Expand All @@ -200,6 +204,8 @@ void Redundancy::manage_spare()

void Redundancy::Run()
{
hrt_abstime now = hrt_absolute_time();

_landed_sub.copy(&_landed);

for (int i = 0; i < _n_autopilots; i++) {
Expand All @@ -211,6 +217,14 @@ void Redundancy::Run()
// This controller
_vehicle_status_sub.copy(&_status[i]);
}

if (_status[i].timestamp < now + 1_s) {
if (!_autopilot_timeout[i]) {
PX4_ERR("Controller %d timed out!\n", i);
}

_autopilot_timeout[i] = true;
}
}

if (_controller_idx == PRIMARY_FC_IDX) {
Expand Down

0 comments on commit bc397e6

Please sign in to comment.