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:
bresch
2019-07-16 13:09:09 +02:00
committed by Mathieu Bresciani
parent d24c415fd7
commit 1414f50cea
28 changed files with 151 additions and 99 deletions
@@ -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;