@@ -233,19 +233,13 @@ class MulticopterPositionControl : public ModuleBase<MulticopterPositionControl>
233
233
void publish_trajectory_sp (const vehicle_local_position_setpoint_s &traj);
234
234
235
235
/* *
236
- * Checks if smooth takeoff is initiated.
237
- * @param position_setpoint_z the position setpoint in the z-Direction
238
- * @param velocity setpoint_z the velocity setpoint in the z-Direction
236
+ * Update smooth takeoff setpoint ramp to bring the vehicle off the ground without step.
237
+ * @param z_sp position setpoint in the z-Direction
238
+ * @param vz_sp velocity setpoint in the z-Direction
239
+ * @param jz_sp jerk setpoint in the z-Direction
240
+ * @param min_ground_clearance minimal distance to the ground in which e.g. optical flow works correctly
239
241
*/
240
- void check_for_smooth_takeoff (const float &position_setpoint_z, const float &velocity_setpoint_z,
241
- const float &jerk_sp, const vehicle_constraints_s &constraints);
242
-
243
- /* *
244
- * Check if smooth takeoff has ended and updates accordingly.
245
- * @param position_setpoint_z the position setpoint in the z-Direction
246
- * @param velocity setpoint_z the velocity setpoint in the z-Direction
247
- */
248
- void update_smooth_takeoff (const float &position_setpoint_z, const float &velocity_setpoint_z);
242
+ void update_smooth_takeoff (const float z_sp, const float vz_sp, const float jz_sp, const float min_ground_clearance);
249
243
250
244
/* *
251
245
* Adjust the setpoint during landing.
@@ -655,8 +649,7 @@ MulticopterPositionControl::run()
655
649
656
650
// do smooth takeoff after delay if there's a valid vertical velocity or position
657
651
if (_spoolup_time_hysteresis.get_state () && PX4_ISFINITE (_states.position (2 )) && PX4_ISFINITE (_states.velocity (2 ))) {
658
- check_for_smooth_takeoff (setpoint.z , setpoint.vz , setpoint.jerk_z , constraints);
659
- update_smooth_takeoff (setpoint.z , setpoint.vz );
652
+ update_smooth_takeoff (setpoint.z , setpoint.vz , setpoint.jerk_z , constraints.min_distance_to_ground );
660
653
}
661
654
662
655
// disable horizontal / yaw control during smooth takeoff and limit maximum speed upwards
@@ -987,21 +980,20 @@ MulticopterPositionControl::start_flight_task()
987
980
}
988
981
989
982
void
990
- MulticopterPositionControl::check_for_smooth_takeoff (const float &z_sp, const float &vz_sp,
991
- const float &jerk_sp, const vehicle_constraints_s &constraints)
983
+ MulticopterPositionControl::update_smooth_takeoff (const float z_sp, const float vz_sp, const float jz_sp, const float min_ground_clearance)
992
984
{
993
985
// Check for smooth takeoff
994
986
if (_vehicle_land_detected.landed && !_in_smooth_takeoff) {
995
987
// Vehicle is still landed and no takeoff was initiated yet.
996
988
// Adjust for different takeoff cases.
997
989
// The minimum takeoff altitude needs to be at least 20cm above minimum distance or, if valid, above minimum distance
998
990
// above ground.
999
- float min_altitude = PX4_ISFINITE (constraints. min_distance_to_ground ) ? (constraints. min_distance_to_ground + 0 .05f ) :
991
+ float min_altitude = PX4_ISFINITE (min_ground_clearance ) ? (min_ground_clearance + 0 .05f ) :
1000
992
0 .2f ;
1001
993
1002
994
// takeoff was initiated through velocity setpoint
1003
995
_smooth_velocity_takeoff = PX4_ISFINITE (vz_sp) && vz_sp < -0 .1f ;
1004
- bool jerk_triggered_takeoff = PX4_ISFINITE (jerk_sp ) && jerk_sp < -FLT_EPSILON;
996
+ bool jerk_triggered_takeoff = PX4_ISFINITE (jz_sp ) && jz_sp < -FLT_EPSILON;
1005
997
_smooth_velocity_takeoff |= jerk_triggered_takeoff;
1006
998
1007
999
if ((PX4_ISFINITE (z_sp) && z_sp < _states.position (2 ) - min_altitude) || _smooth_velocity_takeoff) {
@@ -1013,11 +1005,7 @@ MulticopterPositionControl::check_for_smooth_takeoff(const float &z_sp, const fl
1013
1005
1014
1006
}
1015
1007
}
1016
- }
1017
1008
1018
- void
1019
- MulticopterPositionControl::update_smooth_takeoff (const float &z_sp, const float &vz_sp)
1020
- {
1021
1009
// If in smooth takeoff, adjust setpoints based on what is valid:
1022
1010
// 1. position setpoint is valid -> go with takeoffspeed to specific altitude
1023
1011
// 2. position setpoint not valid but velocity setpoint valid: ramp up velocity
0 commit comments