MC auto: fix land nudging

Revert removal of isTargetModified as this is required when the target
is changed by "RC help" (nudging) during landing.
This commit is contained in:
bresch 2025-02-24 09:04:42 +01:00 committed by Mathieu Bresciani
parent 393d4c13db
commit c09c63171c
2 changed files with 15 additions and 0 deletions

View File

@ -159,6 +159,11 @@ bool FlightTaskAuto::update()
_checkEmergencyBraking();
Vector3f waypoints[] = {_prev_wp, _position_setpoint, _next_wp};
if (isTargetModified()) {
// In case the target has been modified, we take this as the next waypoints
waypoints[2] = _position_setpoint;
}
const bool should_wait_for_yaw_align = _param_mpc_yaw_mode.get() == int32_t(yaw_mode::towards_waypoint_yaw_first)
&& !_yaw_sp_aligned;
const bool force_zero_velocity_setpoint = should_wait_for_yaw_align || _is_emergency_braking_active;
@ -759,6 +764,15 @@ bool FlightTaskAuto::_generateHeadingAlongTraj()
return res;
}
bool FlightTaskAuto::isTargetModified() const
{
const bool xy_modified = (_target - _position_setpoint).xy().longerThan(FLT_EPSILON);
const bool z_valid = PX4_ISFINITE(_position_setpoint(2));
const bool z_modified = z_valid && std::fabs((_target - _position_setpoint)(2)) > FLT_EPSILON;
return xy_modified || z_modified;
}
void FlightTaskAuto::_updateTrajConstraints()
{
// update params of the position smoothing

View File

@ -108,6 +108,7 @@ protected:
void _checkEmergencyBraking();
bool _generateHeadingAlongTraj(); /**< Generates heading along trajectory. */
bool isTargetModified() const;
void _updateTrajConstraints();
void rcHelpModifyYaw(float &yaw_sp);