RTL_mission_fast: continue mission if RTL is triggered while in Mission

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer
2024-05-24 13:34:12 +02:00
parent f9e2ab8d44
commit b9d3b9f211
3 changed files with 27 additions and 9 deletions
+7 -7
View File
@@ -314,6 +314,13 @@ protected:
*/
bool position_setpoint_equal(const position_setpoint_s *p1, const position_setpoint_s *p2) const;
/**
* @brief Set the Mission Index
*
* @param[in] index Index of the mission item
*/
void setMissionIndex(int32_t index);
bool _is_current_planned_mission_item_valid{false}; /**< Flag indicating if the currently loaded mission item is valid*/
bool _mission_has_been_activated{false}; /**< Flag indicating if the mission has been activated*/
bool _mission_checked{false}; /**< Flag indicating if the mission has been checked by the mission validator*/
@@ -421,13 +428,6 @@ private:
*/
bool cameraWasTriggering();
/**
* @brief Set the Mission Index
*
* @param[in] index Index of the mission item
*/
void setMissionIndex(int32_t index);
/**
* @brief Parameters update
*
+17 -2
View File
@@ -52,12 +52,27 @@ RtlMissionFast::RtlMissionFast(Navigator *navigator) :
}
void RtlMissionFast::on_inactive()
{
MissionBase::on_inactive();
_vehicle_status_sub.update();
_mission_index_prior_rtl = _vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION ?
_mission.current_seq : -1;
}
void RtlMissionFast::on_activation()
{
_home_pos_sub.update();
_is_current_planned_mission_item_valid = setMissionToClosestItem(_global_pos_sub.get().lat, _global_pos_sub.get().lon,
_global_pos_sub.get().alt, _home_pos_sub.get().alt, _vehicle_status_sub.get()) == PX4_OK;
// set mission item to closest item if not already in mission
if (_mission_index_prior_rtl < 0) {
_is_current_planned_mission_item_valid = setMissionToClosestItem(_global_pos_sub.get().lat, _global_pos_sub.get().lon,
_global_pos_sub.get().alt, _home_pos_sub.get().alt, _vehicle_status_sub.get()) == PX4_OK;
} else {
setMissionIndex(_mission_index_prior_rtl);
_is_current_planned_mission_item_valid = isMissionValid();
}
if (_land_detected_sub.get().landed) {
// already landed, no need to do anything, invalidad the position mission item.
+3
View File
@@ -56,6 +56,7 @@ public:
~RtlMissionFast() = default;
void on_activation() override;
void on_inactive() override;
rtl_time_estimate_s calc_rtl_time_estimate() override;
@@ -63,5 +64,7 @@ private:
bool setNextMissionItem() override;
void setActiveMissionItems() override;
int _mission_index_prior_rtl{-1};
uORB::SubscriptionData<home_position_s> _home_pos_sub{ORB_ID(home_position)}; /**< home position subscription */
};