36 #include <mathlib/mathlib.h> 46 checkSetpoints(last_setpoint);
48 const Vector2f vel_prev(last_setpoint.
vx, last_setpoint.
vy);
49 const Vector2f pos_prev(last_setpoint.
x, last_setpoint.
y);
51 _smoothing_xy.reset(accel_prev, vel_prev, pos_prev);
52 _smoothing_z.reset(last_setpoint.
acceleration[2], last_setpoint.
vz, last_setpoint.
z);
62 _smoothing_z.reset(0.
f, 0.
f, _position(2));
68 if (!PX4_ISFINITE(setpoints.
x)) { setpoints.
x = _position(0); }
70 if (!PX4_ISFINITE(setpoints.
y)) { setpoints.
y = _position(1); }
72 if (!PX4_ISFINITE(setpoints.
z)) { setpoints.
z = _position(2); }
75 if (!PX4_ISFINITE(setpoints.
vx)) { setpoints.
vx = _velocity(0); }
77 if (!PX4_ISFINITE(setpoints.
vy)) { setpoints.
vy = _velocity(1); }
79 if (!PX4_ISFINITE(setpoints.
vz)) { setpoints.
vz = _velocity(2); }
82 for (
int i = 0; i < 3; i++) {
89 _smoothing_xy.setCurrentPosition(_position.xy());
94 _smoothing_xy.setCurrentVelocity(_velocity.xy());
99 _smoothing_z.setCurrentPosition(_position(2));
104 _smoothing_z.setCurrentVelocity(_velocity(2));
111 _updateTrajConstraints();
112 _updateTrajVelFeedback();
113 _updateTrajCurrentPositionEstimate();
118 _updateTrajectories(_velocity_setpoint);
126 _updateTrajConstraintsXY();
127 _updateTrajConstraintsZ();
132 _smoothing_xy.setMaxJerk(_param_mpc_jerk_max.get());
133 _smoothing_xy.setMaxAccel(_param_mpc_acc_hor_max.get());
134 _smoothing_xy.setMaxVel(_constraints.speed_xy);
139 _smoothing_z.setMaxJerk(_param_mpc_jerk_max.get());
141 _smoothing_z.setMaxAccelUp(_param_mpc_acc_up_max.get());
142 _smoothing_z.setMaxVelUp(_constraints.speed_up);
144 _smoothing_z.setMaxAccelDown(_param_mpc_acc_down_max.get());
145 _smoothing_z.setMaxVelDown(_constraints.speed_down);
150 _smoothing_xy.setVelSpFeedback(
Vector2f(_velocity_setpoint_feedback));
151 _smoothing_z.setVelSpFeedback(_velocity_setpoint_feedback(2));
156 _smoothing_xy.setCurrentPositionEstimate(
Vector2f(_position));
157 _smoothing_z.setCurrentPositionEstimate(_position(2));
162 _smoothing_xy.update(_deltatime,
Vector2f(vel_target));
163 _smoothing_z.update(_deltatime, vel_target(2));
174 _jerk_setpoint.xy() = _smoothing_xy.getCurrentJerk();
175 _acceleration_setpoint.xy() = _smoothing_xy.getCurrentAcceleration();
176 _velocity_setpoint.xy() = _smoothing_xy.getCurrentVelocity();
177 _position_setpoint.xy() = _smoothing_xy.getCurrentPosition();
182 _jerk_setpoint(2) = _smoothing_z.getCurrentJerk();
183 _acceleration_setpoint(2) = _smoothing_z.getCurrentAcceleration();
184 _velocity_setpoint(2) = _smoothing_z.getCurrentVelocity();
185 _position_setpoint(2) = _smoothing_z.getCurrentPosition();
void _updateTrajConstraintsZ()
void _updateTrajVelFeedback()
void _updateSetpoints() override
updates all setpoints
void _ekfResetHandlerVelocityXY() override
void reActivate() override
Call this to reset an active Flight Task.
Flight task for smooth manual controlled position.
bool activate(vehicle_local_position_setpoint_s last_setpoint) override
Call once on the event where you switch to the task.
virtual void _updateSetpoints() override
updates all setpoints
void _ekfResetHandlerPositionZ() override
void _ekfResetHandlerVelocityZ() override
void _updateTrajCurrentPositionEstimate()
bool activate(vehicle_local_position_setpoint_s last_setpoint) override
Call once on the event where you switch to the task.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Vector2< float > Vector2f
void _updateTrajConstraintsXY()
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTaskManualPosition,(ParamFloat< px4::params::MPC_JERK_MAX >) _param_mpc_jerk_max,(ParamFloat< px4::params::MPC_ACC_UP_MAX >) _param_mpc_acc_up_max,(ParamFloat< px4::params::MPC_ACC_DOWN_MAX >) _param_mpc_acc_down_max) private void _updateTrajConstraints()
void _ekfResetHandlerPositionXY() override
Reset position or velocity setpoints in case of EKF reset event.
void _updateTrajectories(Vector3f vel_target)