Skip to content

Commit

Permalink
Check mission climb always on current mission item (PX4#22230)
Browse files Browse the repository at this point in the history
* mission_base: reset inactivation index when user set a new mission index, or mission is reset.

* mission_base: check Climb required always on current mission item
  • Loading branch information
KonradRudin authored Oct 18, 2023
1 parent e8a0a07 commit 9887058
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/modules/navigator/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ Mission::set_current_mission_index(uint16_t index)
set_mission_items();
}

// User has actively set new index, reset.
_inactivation_index = -1;

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion src/modules/navigator/mission_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ MissionBase::on_activation()
}
}

checkClimbRequired(resume_index);
checkClimbRequired(_mission.current_seq);
set_mission_items();

_inactivation_index = -1; // reset
Expand Down Expand Up @@ -557,6 +557,7 @@ MissionBase::checkMissionRestart()
if (_system_disarmed_while_inactive && _mission_has_been_activated && (_mission.count > 0U)
&& ((_mission.current_seq + 1) == _mission.count)) {
setMissionIndex(0);
_inactivation_index = -1; // reset
_is_current_planned_mission_item_valid = isMissionValid(_mission);
resetMissionJumpCounter();
_navigator->reset_cruising_speed();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigator/mission_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class MissionBase : public MissionBlock, public ModuleParams
bool _system_disarmed_while_inactive{false}; /**< Flag indicating if the system has been disarmed while mission is inactive*/
mission_s _mission; /**< Currently active mission*/
float _mission_init_climb_altitude_amsl{NAN}; /**< altitude AMSL the vehicle will climb to when mission starts */
int _inactivation_index{-1}; // index of mission item at which the mission was paused. Used to resume survey missions at previous waypoint to not lose images.

DatamanCache _dataman_cache{"mission_dm_cache_miss", 10}; /**< Dataman cache of mission items*/
DatamanClient &_dataman_client = _dataman_cache.client(); /**< Dataman client*/
Expand Down Expand Up @@ -428,7 +429,6 @@ class MissionBase : public MissionBlock, public ModuleParams
int32_t _load_mission_index{-1}; /**< Mission inted of loaded mission items in dataman cache*/
int32_t _dataman_cache_size_signed; /**< Size of the dataman cache. A negativ value indicates that previous mission items should be loaded, a positiv value the next mission items*/

int _inactivation_index{-1}; // index of mission item at which the mission was paused. Used to resume survey missions at previous waypoint to not lose images.
bool _align_heading_necessary{false}; // if true, heading of vehicle needs to be aligned with heading of next waypoint. Used to create new mission items for heading alignment.

mission_item_s _last_gimbal_configure_item {};
Expand Down

0 comments on commit 9887058

Please sign in to comment.