Skip to content

feat(commander): add failsafe for traffic avoidance system#27887

Open
anilkir wants to merge 2 commits into
mainfrom
ak/feat-traff-avoid-failsafe
Open

feat(commander): add failsafe for traffic avoidance system#27887
anilkir wants to merge 2 commits into
mainfrom
ak/feat-traff-avoid-failsafe

Conversation

@anilkir

@anilkir anilkir commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Solved Problem

COM_ARM_TRAFF only ever gated arming. It didn't have a way to trigger an in-flight failsafe (Warn/RTL/Land) if a previously-detected ADS-B/FLARM traffic avoidance system stopped reporting mid-flight.

Solution

Replaced COM_ARM_TRAFF with COM_TRAFF_AVOID, a single parameter that drives both the arming check and a new in-flight failsafe. Adds traffic_avoidance_unhealthy to FailsafeFlags.msg, wires Failsafe::fromTrafficAvoidanceActParam() in failsafe.cpp/.h, updates trafficAvoidanceCheck.cpp to report both the health/arming result and the failsafe flag, and migrates existing COM_ARM_TRAFF values via param_translation.cpp. Unit tests cover both the health-check boundary (arming block at value 2) and the failsafe action mapping (all 5 values).

  • Value: 0, Arming: Allowed, In-flight-action: None
  • Value: 1, Arming: Allowed, In-flight-action: Warn
  • Value: 2, Arming: Blocked, In-flight-action: Warn
  • Value: 3, Arming: Blocked, In-flight-action: RTL
  • Value: 4, Arming: Blocked, In-flight-action: Land

Changelog Entry

For release notes:

Feature: Traffic avoidance (ADS-B/FLARM) system loss now triggers a configurable in-flight failsafe (Warn/RTL/Land), not just an arming check.
New parameter: COM_TRAFF_AVOID (replaces COM_ARM_TRAFF, migrated automatically on upgrade)
Documentation: docs/en/peripherals/adsb_flarm.md updated with the new parameter table.

Alternatives

Test coverage

Context

Related links, screenshot before/after, video

@anilkir anilkir self-assigned this Jul 13, 2026
@github-actions github-actions Bot added kind:test Adds or improves tests. scope:commander Arming, modes, failsafe, health checks, or vehicle state. scope:uorb uORB messages, generated interfaces, or message translation. scope:parameters Parameter definitions, metadata, migration, or defaults. scope:testing Unit, integration, fuzzing, or test data. scope:docs labels Jul 13, 2026
@anilkir anilkir changed the title Ak/feat traff avoid failsafe feat(commander): add failsafe for traffic avoidance system Jul 13, 2026
@github-actions github-actions Bot added the kind:feature Request or change that adds new functionality. label Jul 13, 2026
@anilkir anilkir requested a review from MaEtUgR July 13, 2026 23:22
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 304 byte (0.02 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +304  +0.0%    +304    .text
    +4.9%     +68  +4.9%     +68    param_modify_on_import()
    [NEW]     +54  [NEW]     +54    Failsafe::fromTrafficAvoidanceActParam()
     +45%     +52   +45%     +52    TrafficAvoidanceChecks::checkAndReport()
    +0.0%     +52  +0.0%     +52    g_cromfs_image
    +2.1%     +32  +2.1%     +32    Failsafe::checkStateAndMode()
    +4.3%     +20  +4.3%     +20    Failsafe::Failsafe()
    +0.0%     +16  +0.0%     +16    [section .text]
    +1.9%     +16  +1.9%     +16    ucdr_serialize_failsafe_flags()
    +5.1%     +12  +5.1%     +12    Failsafe::updateParamsImpl()
    +0.6%      +8  +0.6%      +8    Commander::dataLinkCheck()
    [NEW]      +4  [NEW]      +4    CSWTCH.801
    +4.8%      +4  +4.8%      +4    FlightTask
     +50%      +4   +50%      +4    Zero
    +4.2%      +4  +4.2%      +4    perf_reset
    +0.0%      +4  +0.0%      +4    uORB::compressed_fields
    [DEL]      -4  [DEL]      -4    CSWTCH.802
    -2.0%      -4  -2.0%      -4    Commander::updateParameters()
    -1.0%      -4  -1.0%      -4    EKFGSF_yaw::fuseVelocity()
   -105.4%      -4 -105.4%      -4    [2 Others]
    -7.1%     -14  -7.1%     -14    Commander::updateParamsImpl()
    -1.1%     -16  -1.1%     -16    Commander::Commander()
  +0.0%     +37  [ = ]       0    .debug_abbrev
  +0.0%      +8  [ = ]       0    .debug_aranges
  +0.0%     +40  [ = ]       0    .debug_frame
  +0.0%    +276  [ = ]       0    .debug_info
  +0.0%    +455  [ = ]       0    .debug_line
    [DEL]      -2  [ = ]       0    [Unmapped]
    +0.0%    +457  [ = ]       0    [section .debug_line]
  +0.0%    +247  [ = ]       0    .debug_loclists
  +0.0%     +45  [ = ]       0    .debug_rnglists
    [NEW]      +2  [ = ]       0    [Unmapped]
    +0.0%     +43  [ = ]       0    [section .debug_rnglists]
  +0.0%    +148  [ = ]       0    .debug_str
  -0.4%      -1  [ = ]       0    .shstrtab
  +0.0%     +45  [ = ]       0    .strtab
    [NEW]     +11  [ = ]       0    CSWTCH.801
    [DEL]     -11  [ = ]       0    CSWTCH.802
    [NEW]     +45  [ = ]       0    Failsafe::fromTrafficAvoidanceActParam()
  +0.0%     +32  [ = ]       0    .symtab
    [NEW]     +32  [ = ]       0    CSWTCH.801
    [DEL]     -32  [ = ]       0    CSWTCH.802
   -25.0%     -16  [ = ]       0    Commander::handleCommandActuatorTest()
    +100%     +16  [ = ]       0    Commander::updateParameters()
   -25.0%     -16  [ = ]       0    Commander::updateParamsImpl()
    +100%     +32  [ = ]       0    EKFGSF_yaw::fuseVelocity()
    [NEW]     +32  [ = ]       0    Failsafe::fromTrafficAvoidanceActParam()
   -20.0%     -16  [ = ]       0    Failsafe::isFailsafeIgnored()
    +100%     +16  [ = ]       0    Failsafe::updateArmingState()
    +100%     +16  [ = ]       0    HealthAndArmingCheckBase::updateParams()
    -0.3%     -32  [ = ]       0    [section .symtab]
  -3.4%    -304  [ = ]       0    [Unmapped]
  +0.0% +1.30Ki  +0.0%    +304    TOTAL

px4_fmu-v6x [Total VM Diff: 288 byte (0.01 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +288  +0.0%    +288    .text
    +4.9%     +68  +4.9%     +68    param_modify_on_import()
    +0.0%     +56  +0.0%     +56    g_cromfs_image
    [NEW]     +54  [NEW]     +54    Failsafe::fromTrafficAvoidanceActParam()
     +45%     +52   +45%     +52    TrafficAvoidanceChecks::checkAndReport()
    +2.1%     +32  +2.1%     +32    Failsafe::checkStateAndMode()
    +4.3%     +20  +4.3%     +20    Failsafe::Failsafe()
    +0.0%     +16  +0.0%     +16    [section .text]
    +1.9%     +16  +1.9%     +16    ucdr_serialize_failsafe_flags()
    +5.1%     +12  +5.1%     +12    Failsafe::updateParamsImpl()
    +0.6%      +8  +0.6%      +8    Commander::dataLinkCheck()
    [NEW]      +4  [NEW]      +4    CSWTCH.801
    +0.0%      +4  +0.0%      +4    uORB::compressed_fields
    -3.1%      -2  -3.1%      -2    Failsafe::updateArmingState()
   -120.0%      -2 -120.0%      -2    [1 Others]
    [DEL]      -4  [DEL]      -4    CSWTCH.802
    -2.0%      -4  -2.0%      -4    Commander::updateParameters()
    -1.0%      -4  -1.0%      -4    EKFGSF_yaw::fuseVelocity()
   -33.3%      -4 -33.3%      -4    Zero
   -16.7%      -4 -16.7%      -4    perf_cancel
    -7.1%     -14  -7.1%     -14    Commander::updateParamsImpl()
    -1.1%     -16  -1.1%     -16    Commander::Commander()
  +0.0%     +37  [ = ]       0    .debug_abbrev
  +0.0%      +8  [ = ]       0    .debug_aranges
  +0.0%     +40  [ = ]       0    .debug_frame
  +0.0%    +276  [ = ]       0    .debug_info
  +0.0%    +455  [ = ]       0    .debug_line
   -28.6%      -2  [ = ]       0    [Unmapped]
    +0.0%    +457  [ = ]       0    [section .debug_line]
  +0.0%    +247  [ = ]       0    .debug_loclists
  +0.0%     +45  [ = ]       0    .debug_rnglists
    [NEW]      +2  [ = ]       0    [Unmapped]
    +0.0%     +43  [ = ]       0    [section .debug_rnglists]
  +0.0%    +148  [ = ]       0    .debug_str
  -0.4%      -1  [ = ]       0    .shstrtab
  +0.0%     +45  [ = ]       0    .strtab
    [NEW]     +11  [ = ]       0    CSWTCH.801
    [DEL]     -11  [ = ]       0    CSWTCH.802
    [NEW]     +45  [ = ]       0    Failsafe::fromTrafficAvoidanceActParam()
  +0.0%     +32  [ = ]       0    .symtab
    [NEW]     +32  [ = ]       0    CSWTCH.801
    [DEL]     -32  [ = ]       0    CSWTCH.802
   -25.0%     -16  [ = ]       0    Commander::handleCommandActuatorTest()
    +100%     +16  [ = ]       0    Commander::updateParameters()
   -25.0%     -16  [ = ]       0    Commander::updateParamsImpl()
    +100%     +32  [ = ]       0    EKFGSF_yaw::fuseVelocity()
    [NEW]     +32  [ = ]       0    Failsafe::fromTrafficAvoidanceActParam()
   -20.0%     -16  [ = ]       0    Failsafe::isFailsafeIgnored()
    +100%     +16  [ = ]       0    Failsafe::updateArmingState()
    +100%     +16  [ = ]       0    HealthAndArmingCheckBase::updateParams()
    -0.3%     -32  [ = ]       0    [section .symtab]
  -4.9%    -288  [ = ]       0    [Unmapped]
  +0.0% +1.30Ki  +0.0%    +288    TOTAL

Updated: 2026-07-14T21:23:15

@github-actions

Copy link
Copy Markdown
Contributor

No broken links found in changed files.

@dakejahl dakejahl requested a review from JonasPerolini July 13, 2026 23:43
@anilkir anilkir force-pushed the ak/feat-traff-avoid-failsafe branch from 42a54c0 to 25a96de Compare July 14, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature Request or change that adds new functionality. kind:test Adds or improves tests. scope:commander Arming, modes, failsafe, health checks, or vehicle state. scope:docs scope:parameters Parameter definitions, metadata, migration, or defaults. scope:testing Unit, integration, fuzzing, or test data. scope:uorb uORB messages, generated interfaces, or message translation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant