mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
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:
@@ -314,6 +314,13 @@ protected:
|
|||||||
*/
|
*/
|
||||||
bool position_setpoint_equal(const position_setpoint_s *p1, const position_setpoint_s *p2) const;
|
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 _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_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*/
|
bool _mission_checked{false}; /**< Flag indicating if the mission has been checked by the mission validator*/
|
||||||
@@ -421,13 +428,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool cameraWasTriggering();
|
bool cameraWasTriggering();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the Mission Index
|
|
||||||
*
|
|
||||||
* @param[in] index Index of the mission item
|
|
||||||
*/
|
|
||||||
void setMissionIndex(int32_t index);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parameters update
|
* @brief Parameters update
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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()
|
void RtlMissionFast::on_activation()
|
||||||
{
|
{
|
||||||
_home_pos_sub.update();
|
_home_pos_sub.update();
|
||||||
|
|
||||||
_is_current_planned_mission_item_valid = setMissionToClosestItem(_global_pos_sub.get().lat, _global_pos_sub.get().lon,
|
// set mission item to closest item if not already in mission
|
||||||
_global_pos_sub.get().alt, _home_pos_sub.get().alt, _vehicle_status_sub.get()) == PX4_OK;
|
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) {
|
if (_land_detected_sub.get().landed) {
|
||||||
// already landed, no need to do anything, invalidad the position mission item.
|
// already landed, no need to do anything, invalidad the position mission item.
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
~RtlMissionFast() = default;
|
~RtlMissionFast() = default;
|
||||||
|
|
||||||
void on_activation() override;
|
void on_activation() override;
|
||||||
|
void on_inactive() override;
|
||||||
|
|
||||||
rtl_time_estimate_s calc_rtl_time_estimate() override;
|
rtl_time_estimate_s calc_rtl_time_estimate() override;
|
||||||
|
|
||||||
@@ -63,5 +64,7 @@ private:
|
|||||||
bool setNextMissionItem() override;
|
bool setNextMissionItem() override;
|
||||||
void setActiveMissionItems() 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 */
|
uORB::SubscriptionData<home_position_s> _home_pos_sub{ORB_ID(home_position)}; /**< home position subscription */
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user