mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 13:15:32 +08:00
Fixedwing: Fix circular landing when global origin is not set (#26223)
When not specified by navigator, the center of the landing orbit is set to the current position when landing is triggered.
This commit is contained in:
committed by
GitHub
parent
7c318a3296
commit
c71e2d41d6
@@ -388,11 +388,9 @@ FixedWingModeManager::set_control_mode_current(const hrt_abstime &now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if ((_control_mode.flag_control_auto_enabled && _control_mode.flag_control_position_enabled)
|
} else if ((_control_mode.flag_control_auto_enabled && _control_mode.flag_control_position_enabled)
|
||||||
&& (_position_setpoint_current_valid
|
&& _position_setpoint_current_valid) {
|
||||||
|| _pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_IDLE)) {
|
|
||||||
|
|
||||||
// Enter this mode only if the current waypoint has valid 3D position setpoints or is of type IDLE.
|
// Enter this mode only if the current waypoint has valid 3D position setpoints.
|
||||||
// A setpoint of type IDLE can be published by Navigator without a valid position, and is handled here in FW_POSCTRL_MODE_AUTO.
|
|
||||||
|
|
||||||
if (doing_backtransition) {
|
if (doing_backtransition) {
|
||||||
_control_mode_current = FW_POSCTRL_MODE_TRANSITION_TO_HOVER_LINE_FOLLOW;
|
_control_mode_current = FW_POSCTRL_MODE_TRANSITION_TO_HOVER_LINE_FOLLOW;
|
||||||
@@ -433,6 +431,28 @@ FixedWingModeManager::set_control_mode_current(const hrt_abstime &now)
|
|||||||
_control_mode_current = FW_POSCTRL_MODE_AUTO;
|
_control_mode_current = FW_POSCTRL_MODE_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (_control_mode.flag_control_auto_enabled && _control_mode.flag_control_position_enabled
|
||||||
|
&& (_pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_IDLE)) {
|
||||||
|
|
||||||
|
// A setpoint of type IDLE can be published by Navigator without a valid position, and is handled here in FW_POSCTRL_MODE_AUTO.
|
||||||
|
if (doing_backtransition) {
|
||||||
|
_control_mode_current = FW_POSCTRL_MODE_TRANSITION_TO_HOVER_HEADING_HOLD;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_control_mode_current = FW_POSCTRL_MODE_AUTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (_control_mode.flag_control_auto_enabled && _control_mode.flag_control_position_enabled
|
||||||
|
&& (_pos_sp_triplet.current.type == position_setpoint_s::SETPOINT_TYPE_LAND)) {
|
||||||
|
|
||||||
|
if (doing_backtransition) {
|
||||||
|
_control_mode_current = FW_POSCTRL_MODE_TRANSITION_TO_HOVER_HEADING_HOLD;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Only circular landing are supported when LAND is sent without valid position
|
||||||
|
_control_mode_current = FW_POSCTRL_MODE_AUTO_LANDING_CIRCULAR;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (_control_mode.flag_control_auto_enabled
|
} else if (_control_mode.flag_control_auto_enabled
|
||||||
&& _control_mode.flag_control_climb_rate_enabled
|
&& _control_mode.flag_control_climb_rate_enabled
|
||||||
&& _control_mode.flag_armed // only enter this modes if armed, as pure failsafe modes
|
&& _control_mode.flag_armed // only enter this modes if armed, as pure failsafe modes
|
||||||
@@ -1594,6 +1614,12 @@ void
|
|||||||
FixedWingModeManager::control_auto_landing_circular(const hrt_abstime &now, const float control_interval,
|
FixedWingModeManager::control_auto_landing_circular(const hrt_abstime &now, const float control_interval,
|
||||||
const Vector2f &ground_speed, const position_setpoint_s &pos_sp_curr)
|
const Vector2f &ground_speed, const position_setpoint_s &pos_sp_curr)
|
||||||
{
|
{
|
||||||
|
if (_time_started_landing == 0) {
|
||||||
|
// save time at which we started landing and reset landing abort status
|
||||||
|
reset_landing_state();
|
||||||
|
_time_started_landing = now;
|
||||||
|
}
|
||||||
|
|
||||||
const float airspeed_land = (_param_fw_lnd_airspd.get() > FLT_EPSILON) ? _param_fw_lnd_airspd.get() :
|
const float airspeed_land = (_param_fw_lnd_airspd.get() > FLT_EPSILON) ? _param_fw_lnd_airspd.get() :
|
||||||
_param_fw_airspd_min.get();
|
_param_fw_airspd_min.get();
|
||||||
|
|
||||||
@@ -1601,12 +1627,11 @@ FixedWingModeManager::control_auto_landing_circular(const hrt_abstime &now, cons
|
|||||||
|
|
||||||
|
|
||||||
const Vector2f local_position{_local_pos.x, _local_pos.y};
|
const Vector2f local_position{_local_pos.x, _local_pos.y};
|
||||||
Vector2f local_landing_orbit_center = _global_local_proj_ref.project(pos_sp_curr.lat, pos_sp_curr.lon);
|
|
||||||
|
|
||||||
if (_time_started_landing == 0) {
|
if (!_local_landing_orbit_center.isAllFinite()) {
|
||||||
// save time at which we started landing and reset landing abort status
|
_local_landing_orbit_center = _position_setpoint_current_valid
|
||||||
reset_landing_state();
|
? _global_local_proj_ref.project(pos_sp_curr.lat, pos_sp_curr.lon)
|
||||||
_time_started_landing = now;
|
: local_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool abort_on_terrain_timeout = checkLandingAbortBitMask(_param_fw_lnd_abort.get(),
|
const bool abort_on_terrain_timeout = checkLandingAbortBitMask(_param_fw_lnd_abort.get(),
|
||||||
@@ -1642,7 +1667,7 @@ FixedWingModeManager::control_auto_landing_circular(const hrt_abstime &now, cons
|
|||||||
1.0f);
|
1.0f);
|
||||||
|
|
||||||
/* lateral guidance first, because npfg will adjust the airspeed setpoint if necessary */
|
/* lateral guidance first, because npfg will adjust the airspeed setpoint if necessary */
|
||||||
const DirectionalGuidanceOutput sp = navigateLoiter(local_landing_orbit_center, local_position, loiter_radius,
|
const DirectionalGuidanceOutput sp = navigateLoiter(_local_landing_orbit_center, local_position, loiter_radius,
|
||||||
loiter_direction_ccw,
|
loiter_direction_ccw,
|
||||||
ground_speed, _wind_vel);
|
ground_speed, _wind_vel);
|
||||||
fixed_wing_lateral_setpoint_s fw_lateral_ctrl_sp{empty_lateral_control_setpoint};
|
fixed_wing_lateral_setpoint_s fw_lateral_ctrl_sp{empty_lateral_control_setpoint};
|
||||||
@@ -1700,7 +1725,7 @@ FixedWingModeManager::control_auto_landing_circular(const hrt_abstime &now, cons
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// follow the glide slope
|
// follow the glide slope
|
||||||
const DirectionalGuidanceOutput sp = navigateLoiter(local_landing_orbit_center, local_position, loiter_radius,
|
const DirectionalGuidanceOutput sp = navigateLoiter(_local_landing_orbit_center, local_position, loiter_radius,
|
||||||
loiter_direction_ccw,
|
loiter_direction_ccw,
|
||||||
ground_speed, _wind_vel);
|
ground_speed, _wind_vel);
|
||||||
fixed_wing_lateral_setpoint_s fw_lateral_ctrl_sp{empty_lateral_control_setpoint};
|
fixed_wing_lateral_setpoint_s fw_lateral_ctrl_sp{empty_lateral_control_setpoint};
|
||||||
@@ -2285,6 +2310,7 @@ FixedWingModeManager::reset_landing_state()
|
|||||||
|
|
||||||
_flare_states = FlareStates{};
|
_flare_states = FlareStates{};
|
||||||
|
|
||||||
|
_local_landing_orbit_center.setNaN();
|
||||||
_lateral_touchdown_position_offset = 0.0f;
|
_lateral_touchdown_position_offset = 0.0f;
|
||||||
|
|
||||||
_last_time_terrain_alt_was_valid = 0;
|
_last_time_terrain_alt_was_valid = 0;
|
||||||
@@ -2299,6 +2325,10 @@ FixedWingModeManager::reset_landing_state()
|
|||||||
|
|
||||||
float FixedWingModeManager::getMaxRollAngleNearGround(const float altitude, const float terrain_altitude) const
|
float FixedWingModeManager::getMaxRollAngleNearGround(const float altitude, const float terrain_altitude) const
|
||||||
{
|
{
|
||||||
|
if (!PX4_ISFINITE(altitude) || !PX4_ISFINITE(terrain_altitude)) {
|
||||||
|
return math::radians(_param_fw_r_lim.get());
|
||||||
|
}
|
||||||
|
|
||||||
// we want the wings level when at the wing height above ground
|
// we want the wings level when at the wing height above ground
|
||||||
const float height_above_ground = math::max(altitude - (terrain_altitude + _param_fw_wing_height.get()), 0.0f);
|
const float height_above_ground = math::max(altitude - (terrain_altitude + _param_fw_wing_height.get()), 0.0f);
|
||||||
|
|
||||||
@@ -2424,7 +2454,7 @@ FixedWingModeManager::getLandingTerrainAltitudeEstimate(const hrt_abstime &now,
|
|||||||
|
|
||||||
if (_local_pos.dist_bottom_valid) {
|
if (_local_pos.dist_bottom_valid) {
|
||||||
|
|
||||||
const float terrain_estimate = _local_pos.ref_alt + -_local_pos.z - _local_pos.dist_bottom;
|
const float terrain_estimate = _reference_altitude + -_local_pos.z - _local_pos.dist_bottom;
|
||||||
_last_valid_terrain_alt_estimate = terrain_estimate;
|
_last_valid_terrain_alt_estimate = terrain_estimate;
|
||||||
_last_time_terrain_alt_was_valid = now;
|
_last_time_terrain_alt_was_valid = now;
|
||||||
|
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ private:
|
|||||||
// orbit to altitude only when the aircraft has entered the final *straight approach.
|
// orbit to altitude only when the aircraft has entered the final *straight approach.
|
||||||
hrt_abstime _time_started_landing{0};
|
hrt_abstime _time_started_landing{0};
|
||||||
|
|
||||||
|
Vector2f _local_landing_orbit_center{NAN, NAN};
|
||||||
// [m] lateral touchdown position offset manually commanded during landing
|
// [m] lateral touchdown position offset manually commanded during landing
|
||||||
float _lateral_touchdown_position_offset{0.0f};
|
float _lateral_touchdown_position_offset{0.0f};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user