39 #include <mathlib/mathlib.h> 53 _setDefaultConstraints();
55 _updateAltitudeAboveGround();
62 _thrust_setpoint =
Vector3f(NAN, NAN, NAN);
67 if (_highEnoughForLandingGear()) {
68 _gear.landing_gear = landing_gear_s::GEAR_UP;
73 _prepareIdleSetpoints();
77 _prepareLandSetpoints();
84 _preparePositionSetpoints();
88 _prepareTakeoffSetpoints();
92 _prepareVelocitySetpoints();
96 _preparePositionSetpoints();
100 if (_param_com_obs_avoid.get()) {
101 _obstacle_avoidance.updateAvoidanceDesiredSetpoints(_position_setpoint, _velocity_setpoint, (
int)_type);
102 _obstacle_avoidance.injectAvoidanceSetpoints(_position_setpoint, _velocity_setpoint, _yaw_setpoint,
107 _generateSetpoints();
110 _type_previous = _type;
118 _velocity_setpoint = _velocity;
119 _position_setpoint = _position;
125 _position_setpoint =
Vector3f(NAN, NAN, NAN);
126 _velocity_setpoint =
Vector3f(NAN, NAN, NAN);
127 _thrust_setpoint.zero();
132 float land_speed = _getLandSpeed();
135 _position_setpoint =
Vector3f(_target(0), _target(1), NAN);
139 _constraints.tilt =
math::radians(_param_mpc_tiltmax_lnd.get());
140 _gear.landing_gear = landing_gear_s::GEAR_DOWN;
146 _position_setpoint = _target;
147 const float speed_tko = (_alt_above_ground > _param_mpc_land_alt1.get()) ? _constraints.speed_up :
148 _param_mpc_tko_speed.get();
149 _velocity_setpoint =
Vector3f(NAN, NAN, -speed_tko);
151 _gear.landing_gear = landing_gear_s::GEAR_DOWN;
158 _position_setpoint =
Vector3f(NAN, NAN, _position(2));
160 _velocity_setpoint =
Vector3f(vel_sp_xy(0), vel_sp_xy(1), NAN);
166 _position_setpoint = _target;
167 _velocity_setpoint =
Vector3f(NAN, NAN, NAN);
173 _alt_above_ground = -_position(2);
175 if (PX4_ISFINITE(_dist_to_bottom)) {
177 _alt_above_ground = _dist_to_bottom;
179 }
else if (_sub_home_position.get().valid_alt) {
181 _alt_above_ground = -_position(2) + _sub_home_position.get().z;
187 FlightTaskAuto::updateParams();
190 _param_mpc_land_alt1.set(
math::max(_param_mpc_land_alt1.get(), _param_mpc_land_alt2.get()));
196 return _alt_above_ground > 2.0f;
201 bool rc_assist_enabled = _param_mpc_land_rc_help.get();
202 bool rc_is_valid = !_sub_vehicle_status.get().rc_signal_lost;
204 float throttle = 0.5f;
206 if (rc_is_valid && rc_assist_enabled) {
207 throttle = _sub_manual_control_setpoint.get().z;
212 if (_alt_above_ground > _param_mpc_land_alt1.get()) {
213 speed = _constraints.speed_down;
216 float land_speed = _param_mpc_land_speed.get();
217 float head_room = _constraints.speed_down - land_speed;
219 speed = land_speed + 2 * (0.5f - throttle) * head_room;
222 if (speed < land_speed * 0.5
f) {
223 speed = land_speed * 0.5f;
bool activate(vehicle_local_position_setpoint_s last_setpoint) override
Call once on the event where you switch to the task.
Abstract Flight task which generates local setpoints based on the triplet type.
float _getLandSpeed()
Returns landing descent speed.
void _preparePositionSetpoints()
void _prepareLandSetpoints()
void _reset()
Resets member variables to current vehicle state.
constexpr T radians(T degrees)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Vector2< float > Vector2f
void _prepareVelocitySetpoints()
bool update() override
To be called regularly in the control loop cycle to execute the task.
void _prepareTakeoffSetpoints()
Vector3< float > Vector3f
void updateParams() override
See ModuleParam class.
bool activate(vehicle_local_position_setpoint_s last_setpoint) override
Call once on the event where you switch to the task.
bool _highEnoughForLandingGear()
Checks if gears can be lowered.
constexpr _Tp max(_Tp a, _Tp b)
void _updateAltitudeAboveGround()
Computes altitude above ground based on sensors available.
void _prepareIdleSetpoints()