Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill out MISSION_CURRENT.mission_state for MAVlink #24278

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Jan 30, 2025

Solved Problem

@cmic0 brought up to me that we should populate the field MISSION_CURRENT.mission_state which is sent out via MAVLink.

Solution

I started populating it based on the uORB message mission_result with the main goal to at least see if there is a mission at all and when it is finished. But there are many uncovered cases still:

  1. What happens when there's no update of mission_result on uORB, the message is then zero initialized and wrong data gets populated.
  2. When exactly to fill the states NOT_STARTED, ACTIVE, PAUSED because the mission_result is also updated in land, takeoff, VTOL takeoff situations and not just mission mode, also mission mode would need to be checked separately which together with the scheduling on mission_result updates wouldn't work out well. So I think the structure needs to be changed and the mission state kept and updated as part of the mission interface for these to be correct.

Changelog Entry

Fill out MISSION_CURRENT.mission_state for MAVlink

Test coverage

This is work in progress and needs further case handling and testing. We could just will the states we know like e.g. finished only and leave the rest for now 🤔

I'm not sure about all cases, this needs further clarification and testing.
@MaEtUgR MaEtUgR requested a review from cmic0 January 30, 2025 15:19
Copy link

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 104 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +104  +0.0%    +104    .text
  +0.1%    +104  +0.1%    +104    src/modules/mavlink/modules__mavlink_unity.cpp
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
  -0.0%      -3  -0.0%      -3    [section .text]
+0.0%     +56  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
-0.0%      -8  [ = ]       0    .debug_aranges
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +28  [ = ]       0    .debug_frame
-0.0%     -88  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -13  [ = ]       0    ../../src/modules/commander/Commander.cpp
  +0.0%      +3  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp
  -0.1%     -29  [ = ]       0    ../../src/modules/navigator/land.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/mission.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/mission_base.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/mission_feasibility_checker.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/navigator_main.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/rtl.cpp
  -0.1%     -29  [ = ]       0    ../../src/modules/navigator/takeoff.cpp
  -0.1%     -29  [ = ]       0    ../../src/modules/navigator/vtol_takeoff.cpp
  -0.1%     -13  [ = ]       0    msg/topics_sources/mission_result.cpp
  -0.1%     -15  [ = ]       0    msg/topics_sources/uORBMessageFieldsGenerated.cpp
  +0.0%    +106  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+0.0%     +32  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +57  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+0.0%     +66  [ = ]       0    .debug_loc
  +0.1%     +15  [ = ]       0    ../../src/modules/navigator/mission_base.cpp
  +0.1%     +15  [ = ]       0    ../../src/modules/navigator/navigator_main.cpp
  -0.2%     -15  [ = ]       0    ../../src/modules/navigator/rtl_direct.cpp
  +0.0%     +51  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
-0.0%     -11  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  -4.5%      -3  [ = ]       0    task/task_cancelpt.c
+0.0%    +173  [ = ]       0    .debug_str
  -0.0%     -15  [ = ]       0    ../../src/modules/commander/Commander.cpp
  +0.1%    +188  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+1.0%      +2  [ = ]       0    .shstrtab
+0.0%     +18  [ = ]       0    .strtab
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +32  [ = ]       0    [section .strtab]
  +0.0%     +18  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
-0.9%    -104  [ = ]       0    [Unmapped]
+0.0%    +268  +0.0%    +104    TOTAL

px4_fmu-v6x [Total VM Diff: 88 byte (0 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +88  +0.0%     +88    .text
  +0.1%    +104  +0.1%    +104    src/modules/mavlink/modules__mavlink_unity.cpp
  -0.0%     -16  -0.0%     -16    [section .text]
+0.0%     +56  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
-0.0%      -8  [ = ]       0    .debug_aranges
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +28  [ = ]       0    .debug_frame
-0.0%     -88  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -13  [ = ]       0    ../../src/modules/commander/Commander.cpp
  +0.0%      +3  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp
  -0.1%     -29  [ = ]       0    ../../src/modules/navigator/land.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/mission.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/mission_base.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/mission_feasibility_checker.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/navigator_main.cpp
  -0.0%     -13  [ = ]       0    ../../src/modules/navigator/rtl.cpp
  -0.1%     -29  [ = ]       0    ../../src/modules/navigator/takeoff.cpp
  -0.1%     -29  [ = ]       0    ../../src/modules/navigator/vtol_takeoff.cpp
  -0.1%     -13  [ = ]       0    msg/topics_sources/mission_result.cpp
  -0.1%     -15  [ = ]       0    msg/topics_sources/uORBMessageFieldsGenerated.cpp
  +0.0%    +106  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+0.0%     +32  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +57  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+0.0%     +51  [ = ]       0    .debug_loc
  +0.3%     +15  [ = ]       0    ../../src/modules/commander/ModeManagement.cpp
  -0.2%     -15  [ = ]       0    ../../src/modules/navigator/rtl_direct.cpp
  +0.0%     +51  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
-0.0%      -8  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%    +173  [ = ]       0    .debug_str
  -0.0%     -15  [ = ]       0    ../../src/modules/commander/Commander.cpp
  +0.1%    +188  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
+0.9%      +2  [ = ]       0    .shstrtab
+0.0%     +18  [ = ]       0    .strtab
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +32  [ = ]       0    [section .strtab]
  +0.0%     +18  [ = ]       0    src/modules/mavlink/modules__mavlink_unity.cpp
-0.1%     -88  [ = ]       0    [Unmapped]
+0.0%    +256  +0.0%     +88    TOTAL

Updated: 2025-01-30T15:25:15

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