Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb055fd

Browse files
breschLorenzMeier
authored andcommitted
AutoSmoothVel - Override checkTakeoff with task-specific logic and reactivate z axis with downward velocity to takeoff smoothly
1 parent 7c7d980 commit bb055fd

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/lib/FlightTasks/tasks/AutoLineSmoothVel/FlightTaskAutoLineSmoothVel.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ bool FlightTaskAutoLineSmoothVel::activate()
5757

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

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

145147
_checkEkfResetCounters();
148+
_want_takeoff = false;
146149

147150
if (PX4_ISFINITE(_position_setpoint(0)) &&
148151
PX4_ISFINITE(_position_setpoint(1))) {
@@ -191,6 +194,7 @@ void FlightTaskAutoLineSmoothVel::_prepareSetpoints()
191194
_velocity_setpoint(2) = vel_sp_z;
192195
}
193196

197+
_want_takeoff = _velocity_setpoint(2) < -0.3f;
194198
}
195199
}
196200

src/lib/FlightTasks/tasks/AutoLineSmoothVel/FlightTaskAutoLineSmoothVel.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class FlightTaskAutoLineSmoothVel : public FlightTaskAutoMapper2
6767

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

70+
/** determines when to trigger a takeoff (ignored in flight) */
71+
bool _checkTakeoff() override { return _want_takeoff; };
72+
7073
inline float _constrainOneSide(float val, float constrain);
7174
void _checkEkfResetCounters(); /**< Reset the trajectories when the ekf resets velocity or position */
7275
void _generateHeading();
@@ -75,7 +78,9 @@ class FlightTaskAutoLineSmoothVel : public FlightTaskAutoMapper2
7578
void _prepareSetpoints(); /**< Generate velocity target points for the trajectory generator. */
7679
void _generateTrajectory();
7780
VelocitySmoothing _trajectory[3]; ///< Trajectories in x, y and z directions
78-
float _yaw_sp_prev;
81+
82+
float _yaw_sp_prev{NAN};
83+
bool _want_takeoff{false};
7984

8085
/* counters for estimator local position resets */
8186
struct {

0 commit comments

Comments
 (0)