mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 08:13:56 -04:00
AC_PosControl: add alt hold without feed forward
This commit is contained in:
parent
3c3392aae5
commit
f55c31a157
@ -148,11 +148,35 @@ void AC_PosControl::set_alt_target_with_slew(float alt_cm, float dt)
|
|||||||
_pos_target.z = constrain_float(_pos_target.z,curr_alt-_leash_down_z,curr_alt+_leash_up_z);
|
_pos_target.z = constrain_float(_pos_target.z,curr_alt-_leash_down_z,curr_alt+_leash_up_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// set_alt_target_from_climb_rate - adjusts target up or down using a climb rate in cm/s
|
/// set_alt_target_from_climb_rate - adjusts target up or down using a climb rate in cm/s
|
||||||
/// should be called continuously (with dt set to be the expected time between calls)
|
/// should be called continuously (with dt set to be the expected time between calls)
|
||||||
/// actual position target will be moved no faster than the speed_down and speed_up
|
/// actual position target will be moved no faster than the speed_down and speed_up
|
||||||
/// target will also be stopped if the motors hit their limits or leash length is exceeded
|
/// target will also be stopped if the motors hit their limits or leash length is exceeded
|
||||||
void AC_PosControl::set_alt_target_from_climb_rate(float climb_rate_cms, float dt, bool force_descend)
|
void AC_PosControl::set_alt_target_from_climb_rate(float climb_rate_cms, float dt, bool force_descend)
|
||||||
|
{
|
||||||
|
// adjust desired alt if motors have not hit their limits
|
||||||
|
// To-Do: add check of _limit.pos_down?
|
||||||
|
if ((climb_rate_cms<0 && (!_motors.limit.throttle_lower || force_descend)) || (climb_rate_cms>0 && !_motors.limit.throttle_upper && !_limit.pos_up)) {
|
||||||
|
_pos_target.z += climb_rate_cms * dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do not let target alt get above limit
|
||||||
|
if (_alt_max > 0 && _pos_target.z > _alt_max) {
|
||||||
|
_pos_target.z = _alt_max;
|
||||||
|
_limit.pos_up = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear feed forward
|
||||||
|
_vel_desired.z = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set_alt_target_from_climb_rate_ff - adjusts target up or down using a climb rate in cm/s using feed-forward
|
||||||
|
/// should be called continuously (with dt set to be the expected time between calls)
|
||||||
|
/// actual position target will be moved no faster than the speed_down and speed_up
|
||||||
|
/// target will also be stopped if the motors hit their limits or leash length is exceeded
|
||||||
|
/// set force_descend to true during landing to allow target to move low enough to slow the motors
|
||||||
|
void AC_PosControl::set_alt_target_from_climb_rate_ff(float climb_rate_cms, float dt, bool force_descend)
|
||||||
{
|
{
|
||||||
// jerk_z is calculated to reach full acceleration in 1000ms.
|
// jerk_z is calculated to reach full acceleration in 1000ms.
|
||||||
float jerk_z = _accel_z_cms * POSCONTROL_JERK_RATIO;
|
float jerk_z = _accel_z_cms * POSCONTROL_JERK_RATIO;
|
||||||
|
@ -126,6 +126,13 @@ public:
|
|||||||
/// set force_descend to true during landing to allow target to move low enough to slow the motors
|
/// set force_descend to true during landing to allow target to move low enough to slow the motors
|
||||||
void set_alt_target_from_climb_rate(float climb_rate_cms, float dt, bool force_descend);
|
void set_alt_target_from_climb_rate(float climb_rate_cms, float dt, bool force_descend);
|
||||||
|
|
||||||
|
/// set_alt_target_from_climb_rate_ff - adjusts target up or down using a climb rate in cm/s using feed-forward
|
||||||
|
/// should be called continuously (with dt set to be the expected time between calls)
|
||||||
|
/// actual position target will be moved no faster than the speed_down and speed_up
|
||||||
|
/// target will also be stopped if the motors hit their limits or leash length is exceeded
|
||||||
|
/// set force_descend to true during landing to allow target to move low enough to slow the motors
|
||||||
|
void set_alt_target_from_climb_rate_ff(float climb_rate_cms, float dt, bool force_descend);
|
||||||
|
|
||||||
/// add_takeoff_climb_rate - adjusts alt target up or down using a climb rate in cm/s
|
/// add_takeoff_climb_rate - adjusts alt target up or down using a climb rate in cm/s
|
||||||
/// should be called continuously (with dt set to be the expected time between calls)
|
/// should be called continuously (with dt set to be the expected time between calls)
|
||||||
/// almost no checks are performed on the input
|
/// almost no checks are performed on the input
|
||||||
@ -199,6 +206,9 @@ public:
|
|||||||
/// get_desired_velocity - returns xy desired velocity (i.e. feed forward) in cm/s in lat and lon direction
|
/// get_desired_velocity - returns xy desired velocity (i.e. feed forward) in cm/s in lat and lon direction
|
||||||
const Vector3f& get_desired_velocity() { return _vel_desired; }
|
const Vector3f& get_desired_velocity() { return _vel_desired; }
|
||||||
|
|
||||||
|
/// set_desired_velocity_z - sets desired velocity in cm/s in z axis
|
||||||
|
void set_desired_velocity_z(float vel_z_cms) {_vel_desired.z = vel_z_cms;}
|
||||||
|
|
||||||
/// set_desired_velocity_xy - sets desired velocity in cm/s in lat and lon directions
|
/// set_desired_velocity_xy - sets desired velocity in cm/s in lat and lon directions
|
||||||
/// when update_xy_controller is next called the position target is moved based on the desired velocity and
|
/// when update_xy_controller is next called the position target is moved based on the desired velocity and
|
||||||
/// the desired velocities are fed forward into the rate_to_accel step
|
/// the desired velocities are fed forward into the rate_to_accel step
|
||||||
|
Loading…
Reference in New Issue
Block a user