mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
rtl: redability suggestions from review, remove unused subscription
This commit is contained in:
parent
a416437561
commit
7a6506f2dd
@ -357,12 +357,13 @@ void RTL::setRtlTypeAndDestination()
|
||||
// check the closest allowed destination.
|
||||
findRtlDestination(destination_type, destination, safe_point_index);
|
||||
|
||||
switch (destination_type) {
|
||||
case DestinationType::DESTINATION_TYPE_MISSION_LAND:
|
||||
if (destination_type == DestinationType::DESTINATION_TYPE_MISSION_LAND) {
|
||||
new_rtl_type = RtlType::RTL_DIRECT_MISSION_LAND;
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
|
||||
new_rtl_type = RtlType::RTL_DIRECT;
|
||||
|
||||
land_approaches_s rtl_land_approaches{readVtolLandApproaches(destination)};
|
||||
|
||||
// set loiter position to destination initially, overwrite for VTOL if land approaches exist
|
||||
@ -375,10 +376,6 @@ void RTL::setRtlTypeAndDestination()
|
||||
&& rtl_land_approaches.isAnyApproachValid()) {
|
||||
landing_loiter = chooseBestLandingApproach(rtl_land_approaches);
|
||||
}
|
||||
|
||||
new_rtl_type = RtlType::RTL_DIRECT;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +403,7 @@ PositionYawSetpoint RTL::findClosestSafePoint(float min_dist, uint8_t &safe_poin
|
||||
const bool vtol_in_fw_mode = _vehicle_status_sub.get().is_vtol
|
||||
&& (_vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING);
|
||||
|
||||
PositionYawSetpoint safe_point{NAN, NAN, NAN, NAN};
|
||||
PositionYawSetpoint safe_point{(double)NAN, (double)NAN, NAN, NAN};
|
||||
|
||||
if (_safe_points_updated) {
|
||||
_one_rally_point_has_land_approach = false;
|
||||
|
||||
@ -158,7 +158,7 @@ private:
|
||||
* @brief calculate return altitude from return altitude parameter, current altitude and cone angle
|
||||
*
|
||||
* @param[in] rtl_position landing position of the rtl
|
||||
* param[in] destination_type type of the rtl destination
|
||||
* @param[in] destination_type type of the rtl destination
|
||||
* @param[in] cone_half_angle_deg half angle of the cone [deg]
|
||||
* @return return altitude
|
||||
*/
|
||||
@ -229,7 +229,7 @@ private:
|
||||
mutable DatamanCache _dataman_cache_landItem{"rtl_dm_cache_miss_land", 2};
|
||||
uint32_t _mission_id = 0u;
|
||||
uint32_t _safe_points_id = 0u;
|
||||
PositionYawSetpoint _last_position_before_link_loss{NAN, NAN, NAN, NAN};
|
||||
PositionYawSetpoint _last_position_before_link_loss{(double)NAN, (double)NAN, NAN, NAN};
|
||||
|
||||
mission_stats_entry_s _stats;
|
||||
|
||||
|
||||
@ -489,7 +489,7 @@ rtl_time_estimate_s RtlDirect::calc_rtl_time_estimate()
|
||||
case RTLState::MOVE_TO_LAND:
|
||||
case RTLState::TRANSITION_TO_MC:
|
||||
case RTLState::MOVE_TO_LAND_HOVER: {
|
||||
// Add cruise segment to home
|
||||
// Add cruise segment to destination
|
||||
float move_to_land_dist{0.f};
|
||||
matrix::Vector2f direction{};
|
||||
|
||||
|
||||
@ -46,7 +46,6 @@
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/SubscriptionInterval.hpp>
|
||||
#include <uORB/topics/home_position.h>
|
||||
#include <uORB/topics/navigator_mission_item.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/rtl_time_estimate.h>
|
||||
@ -167,10 +166,10 @@ private:
|
||||
bool _force_heading{false};
|
||||
RtlTimeEstimator _rtl_time_estimator;
|
||||
|
||||
PositionYawSetpoint _destination{NAN, NAN, NAN, NAN}; ///< the RTL position to fly to
|
||||
PositionYawSetpoint _destination{(double)NAN, (double)NAN, NAN, NAN}; ///< the RTL position to fly to
|
||||
loiter_point_s _land_approach;
|
||||
|
||||
float _rtl_alt{0.0f}; ///< AMSL altitude at which the vehicle should return to the home position
|
||||
float _rtl_alt{0.0f}; ///< AMSL altitude at which the vehicle should transit to the destination
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamFloat<px4::params::RTL_DESCEND_ALT>) _param_rtl_descend_alt,
|
||||
@ -185,7 +184,6 @@ private:
|
||||
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
uORB::SubscriptionData<vehicle_global_position_s> _global_pos_sub{ORB_ID(vehicle_global_position)}; /**< global position subscription */
|
||||
uORB::SubscriptionData<home_position_s> _home_pos_sub{ORB_ID(home_position)}; /**< home position subscription */
|
||||
uORB::SubscriptionData<vehicle_land_detected_s> _land_detected_sub{ORB_ID(vehicle_land_detected)}; /**< vehicle land detected subscription */
|
||||
uORB::SubscriptionData<vehicle_status_s> _vehicle_status_sub{ORB_ID(vehicle_status)}; /**< vehicle status subscription */
|
||||
uORB::SubscriptionData<wind_s> _wind_sub{ORB_ID(wind)};
|
||||
|
||||
@ -258,11 +258,10 @@ void RtlMissionFastReverse::handleLanding(WorkItemType &new_work_item_type)
|
||||
_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND ||
|
||||
_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND_AFTER_TRANSITION)) {
|
||||
|
||||
const bool loiter_indefinitely = _param_rtl_land_delay.get() < -FLT_EPSILON;
|
||||
|
||||
_mission_item.lat = _home_pos_sub.get().lat;
|
||||
_mission_item.lon = _home_pos_sub.get().lon;
|
||||
_mission_item.yaw = NAN;
|
||||
_mission_item.altitude = _global_pos_sub.get().alt;
|
||||
_mission_item.altitude_is_relative = false;
|
||||
|
||||
// make previous and next setpoints invalid, such that there will be no line following.
|
||||
@ -274,14 +273,17 @@ void RtlMissionFastReverse::handleLanding(WorkItemType &new_work_item_type)
|
||||
do_need_move_to_item()) {
|
||||
new_work_item_type = WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND;
|
||||
|
||||
_mission_item.altitude = _global_pos_sub.get().alt;
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
_mission_item.autocontinue = true;
|
||||
_mission_item.time_inside = 0.0f;
|
||||
|
||||
} else {
|
||||
_mission_item.altitude = loiter_indefinitely ? _home_pos_sub.get().alt + _param_rtl_descend_alt.get() : _global_pos_sub.get().alt;
|
||||
_mission_item.nav_cmd = loiter_indefinitely ? NAV_CMD_WAYPOINT : NAV_CMD_LAND;
|
||||
_mission_item.nav_cmd = NAV_CMD_LAND;
|
||||
|
||||
if (_param_rtl_land_delay.get() < -FLT_EPSILON) { // parameter negative -> loiter indefinitely instead of landing
|
||||
_mission_item.altitude = _home_pos_sub.get().alt + _param_rtl_descend_alt.get();
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
}
|
||||
|
||||
_mission_item.land_precision = _param_rtl_pld_md.get();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user