Skip to content

Commit

Permalink
AutoSmoothVel - Override checkTakeoff with task-specific logic and re…
Browse files Browse the repository at this point in the history
…activate z axis with downward velocity to takeoff smoothly
  • Loading branch information
bresch committed May 14, 2019
1 parent 813f5e7 commit 844d980
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ bool FlightTaskAutoLineSmoothVel::activate()

void FlightTaskAutoLineSmoothVel::reActivate()
{
// Don't reset during takeoff TODO: Find a proper solution
// The issue here is that with a small increment of velocity setpoint (generated by this flight task), the
// land detector doesn't detect takeoff and without takeoff detection, the
// flight task is always reset.
// On ground, reset acceleration and velocity to zero
for (int i = 0; i < 2; ++i) {
_trajectory[i].reset(0.f, 0.f, _position(i));
}

_trajectory[2].reset(0.f, 0.7f, _position(2));
}

void FlightTaskAutoLineSmoothVel::_generateSetpoints()
Expand Down Expand Up @@ -143,6 +145,7 @@ void FlightTaskAutoLineSmoothVel::_prepareSetpoints()
// If the position setpoints are set to NAN, the values in the velocity setpoints are used as velocity targets: nothing to do here.

_checkEkfResetCounters();
_want_takeoff = false;

if (PX4_ISFINITE(_position_setpoint(0)) &&
PX4_ISFINITE(_position_setpoint(1))) {
Expand Down Expand Up @@ -191,6 +194,7 @@ void FlightTaskAutoLineSmoothVel::_prepareSetpoints()
_velocity_setpoint(2) = vel_sp_z;
}

_want_takeoff = _velocity_setpoint(2) < -0.3f;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class FlightTaskAutoLineSmoothVel : public FlightTaskAutoMapper2

void _generateSetpoints() override; /**< Generate setpoints along line. */

/** determines when to trigger a takeoff (ignored in flight) */
bool _checkTakeoff() override { return _want_takeoff; };

inline float _constrainOneSide(float val, float constrain);
void _checkEkfResetCounters(); /**< Reset the trajectories when the ekf resets velocity or position */
void _generateHeading();
Expand All @@ -75,7 +78,9 @@ class FlightTaskAutoLineSmoothVel : public FlightTaskAutoMapper2
void _prepareSetpoints(); /**< Generate velocity target points for the trajectory generator. */
void _generateTrajectory();
VelocitySmoothing _trajectory[3]; ///< Trajectories in x, y and z directions
float _yaw_sp_prev;

float _yaw_sp_prev{NAN};
bool _want_takeoff{false};

/* counters for estimator local position resets */
struct {
Expand Down

0 comments on commit 844d980

Please sign in to comment.