mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-05 03:08:53 +08:00
FlightTask - When switching task, pass the last setpoints of the previous task to the new task
This is done to allow proper initialization of the new FlightTask and give it a chance to continue the setpoints without discontinuity. The function checkSetpoints replaces the setpoints containing NANs with an estimate of the state. The estimate is usually the current estimate of the EKF or zero. The transition FlightTask also provides an estimate of the current acceleration to properly initialize the next FlightTask after back-transition. This avoid having to initialize the accelerations to zero knowing that the actual acceleration is usually far from zero.
This commit is contained in:
committed by
Mathieu Bresciani
parent
d24c415fd7
commit
1414f50cea
@@ -41,12 +41,17 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
bool FlightTaskAutoLineSmoothVel::activate()
|
||||
bool FlightTaskAutoLineSmoothVel::activate(vehicle_local_position_setpoint_s state_prev)
|
||||
{
|
||||
bool ret = FlightTaskAutoMapper2::activate();
|
||||
bool ret = FlightTaskAutoMapper2::activate(state_prev);
|
||||
|
||||
checkSetpoints(state_prev);
|
||||
const Vector3f accel_prev{state_prev.acc_x, state_prev.acc_y, state_prev.acc_z};
|
||||
const Vector3f vel_prev = Vector3f(state_prev.vx, state_prev.vy, state_prev.vz);
|
||||
const Vector3f pos_prev = Vector3f(state_prev.x, state_prev.y, state_prev.z);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
_trajectory[i].reset(0.f, _velocity(i), _position(i));
|
||||
_trajectory[i].reset(accel_prev(i), vel_prev(i), pos_prev(i));
|
||||
}
|
||||
|
||||
_yaw_sp_prev = _yaw;
|
||||
|
||||
Reference in New Issue
Block a user