Skip to content

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Oct 15, 2025

Solved Problem

When analysing logs I found that the (dis)arm reason is reported wrong according to the message definition because the logged uORB message vehicle_status specifically the ARM_DISARM_REASON_... enum values are not in sync with the events enum defined in the json and autogenerated into the arm_disarm_reason_t type.

Solution

  1. Add static_asserts for each enum value with the same name of both the uORB and event value. This does not force a new reason to be added to both places but at least checks the existing ones and gives a hint that the two have to match when people do a full text search.
  2. Remove unused (dis)arm reasons. The reasons are passed to the calls of either arm() or disarm() and some of them are deprecated but were never removed:
    • transition_to_standby arming state machine leftover
    • failure_detector was used for failure detection actions before Commander failsafe state machine rewrite #20172 and are now handled as failsafe actions
    • shutdown arming state machine leftover
    • unit_test arming state machine unit testing leftover
    • lockdown I made an extra commit because it's more complicated since it's still used but not really a usefully reachable code path since Commander failsafe state machine rewrite #20172 Please read the commit description for more details.
  3. Make the wording of some of the reasons a bit simpler and more consistent.
  4. Remove the remaining useless call with lockdown see last point of 2. and the in depth commit message.

Changelog Entry

Fix (dis)arm reason enumeration

Test coverage

The static asserts are now passing (which they weren't after the first commit). The naming was consistently replaced. I didn't plan any additional testing. Please review.

Context

Related links, screenshot before/after, video

…ents and uORB

that's the failing test because of which the (dis)arm reason can be wrong based on the message definition.
- removing deprecated ones
- syncing used ones to the enum value events defined already
- make naming more consistent
1. It was added because the action for ESCs not arming in time was lockdown and in this case it should "also" disarm (why not disarm directly in the first place?)
see a7f2f29
2. but lockdown was also used such that motors don't spin in HITL which then caused auto disarm hence a workaround
see 1ac3110
3. and in the big commander failsafe rewrite (#20172) the ESCs not arming case was treated as a failsafe that disarms and not using lockdown anymore
4. and then also the  multicopter throw launch (#21170) started using lockdown to stop motors before throw which had to be excluded similar to the workaround in 2.

So as a result the cases where lockdown is used now are HITL and throw launch, both don't want to cause an automatic disarm hence they are both exluded and the lockdown disarm should not be reachable and can be removed.

Note: The case where you kill during a throw launch and get an automatic disarm is now correctly handled in my eyes. Before the disarm was skipped.
@MaEtUgR MaEtUgR requested a review from bkueng October 15, 2025 14:11
@MaEtUgR MaEtUgR self-assigned this Oct 15, 2025
Copy link

github-actions bot commented Oct 15, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: -168 byte (-0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +55  [ = ]       0    .debug_abbrev
-0.0% -6.41Ki  [ = ]       0    .debug_info
-0.0%     -52  [ = ]       0    .debug_line
  [NEW]      +7  [ = ]       0    [Unmapped]
  -0.0%     -59  [ = ]       0    [section .debug_line]
-0.0%     -88  [ = ]       0    .debug_loclists
-0.0%      -2  [ = ]       0    .debug_rnglists
-0.0%    -426  [ = ]       0    .debug_str
+2.0%    +168  [ = ]       0    [Unmapped]
-0.0%    -168  -0.0%    -168    .text
  -4.5%      -4  -4.5%      -4    FlightTask
  -9.8%     -40  -9.8%     -40    Commander::handleAutoDisarm()
  -0.0%     -48  -0.0%     -48    [section .text]
  -0.0%     -76  -0.0%     -76    g_cromfs_image
-0.0% -6.91Ki  -0.0%    -168    TOTAL

px4_fmu-v6x [Total VM Diff: -168 byte (-0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +55  [ = ]       0    .debug_abbrev
-0.0% -6.34Ki  [ = ]       0    .debug_info
-0.0%     -60  [ = ]       0    .debug_line
 -28.6%      -2  [ = ]       0    [Unmapped]
  -0.0%     -58  [ = ]       0    [section .debug_line]
-0.0%     -86  [ = ]       0    .debug_loclists
-0.0%    -426  [ = ]       0    .debug_str
+4.1%    +168  [ = ]       0    [Unmapped]
-0.0%    -168  -0.0%    -168    .text
  -9.8%     -40  -9.8%     -40    Commander::handleAutoDisarm()
  -0.0%     -56  -0.0%     -56    [section .text]
  -0.0%     -72  -0.0%     -72    g_cromfs_image
-0.0% -6.84Ki  -0.0%    -168    TOTAL

Updated: 2025-10-15T16:29:52

to solve: 'static_assert' with no message is a C++17 extension
in Mac CI
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 15, 2025

Mac CI wanted a message for each static_cast 'static_assert' with no message is a C++17 extension so I added that in 89825b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant