Browse Source

AC_AttitudeControl: AC_PosControl: Separate landing and terrain following.

gps-1.3.1
Leonard Hall 4 years ago committed by Randy Mackay
parent
commit
0fff010046
  1. 29
      libraries/AC_AttitudeControl/AC_PosControl.cpp
  2. 13
      libraries/AC_AttitudeControl/AC_PosControl.h

29
libraries/AC_AttitudeControl/AC_PosControl.cpp

@ -790,6 +790,7 @@ void AC_PosControl::init_z() @@ -790,6 +790,7 @@ void AC_PosControl::init_z()
_pid_accel_z.reset_filter();
// initialise vertical offsets
_pos_offset_target_z = 0.0;
_pos_offset_z = 0.0;
_vel_offset_z = 0.0;
_accel_offset_z = 0.0;
@ -855,11 +856,33 @@ void AC_PosControl::input_vel_accel_z(float &vel, const float accel, bool ignore @@ -855,11 +856,33 @@ void AC_PosControl::input_vel_accel_z(float &vel, const float accel, bool ignore
/// set_pos_target_z_from_climb_rate_cm - adjusts target up or down using a commanded climb rate in cm/s
/// using the default position control kinematic path.
/// The zero target altitude is varied to follow pos_offset_z
void AC_PosControl::set_pos_target_z_from_climb_rate_cm(const float vel)
{
// remove terrain offsets for flat earth assumption
_pos_target.z -= _pos_offset_z;
_vel_desired.z -= _vel_offset_z;
_accel_desired.z -= _accel_offset_z;
float vel_temp = vel;
input_vel_accel_z(vel_temp, 0, false);
// update the vertical position, velocity and acceleration offsets
update_pos_offset_z(_pos_offset_target_z);
// add terrain offsets
_pos_target.z += _pos_offset_z;
_vel_desired.z += _vel_offset_z;
_accel_desired.z += _accel_offset_z;
}
/// land_at_climb_rate_cm - adjusts target up or down using a commanded climb rate in cm/s
/// using the default position control kinematic path.
/// ignore_descent_limit turns off output saturation handling to aid in landing detection. ignore_descent_limit should be true unless landing.
void AC_PosControl::set_pos_target_z_from_climb_rate_cm(const float vel, bool ignore_descent_limit)
void AC_PosControl::land_at_climb_rate_cm(const float vel, bool ignore_descent_limit)
{
float vel2 = vel;
input_vel_accel_z(vel2, 0, ignore_descent_limit);
float vel_temp = vel;
input_vel_accel_z(vel_temp, 0, ignore_descent_limit);
}
/// input_pos_vel_accel_z - calculate a jerk limited path from the current position, velocity and acceleration to an input position velocity and acceleration.

13
libraries/AC_AttitudeControl/AC_PosControl.h

@ -196,10 +196,15 @@ public: @@ -196,10 +196,15 @@ public:
/// The parameter limit_output specifies if the velocity and acceleration limits are applied to the sum of commanded and correction values or just correction.
virtual void input_vel_accel_z(float &vel, const float accel, bool ignore_descent_limit, bool limit_output = true);
/// set_pos_target_z_from_climb_rate_cm - adjusts target up or down using a climb rate in cm/s
/// set_pos_target_z_from_climb_rate_cm - adjusts target up or down using a commanded climb rate in cm/s
/// using the default position control kinematic path.
/// The zero target altitude is varied to follow pos_offset_z
void set_pos_target_z_from_climb_rate_cm(const float vel);
/// land_at_climb_rate_cm - adjusts target up or down using a commanded climb rate in cm/s
/// using the default position control kinematic path.
/// ignore_descent_limit turns off output saturation handling to aid in landing detection. ignore_descent_limit should be true unless landing.
void set_pos_target_z_from_climb_rate_cm(const float vel, bool ignore_descent_limit);
void land_at_climb_rate_cm(const float vel, bool ignore_descent_limit);
/// input_pos_vel_accel_z - calculate a jerk limited path from the current position, velocity and acceleration to an input position velocity and acceleration.
/// The function takes the current position, velocity, and acceleration and calculates the required jerk limited adjustment to the acceleration for the next time dt.
@ -296,6 +301,9 @@ public: @@ -296,6 +301,9 @@ public:
/// Offset
/// set_pos_offset_target_z_cm - set altitude offset target in cm above home
void set_pos_offset_target_z_cm(float pos_offset_target_z) { _pos_offset_target_z = pos_offset_target_z; }
/// set_pos_offset_z_cm - set altitude offset in cm above home
void set_pos_offset_z_cm(float pos_offset_z) { _pos_offset_z = pos_offset_z; }
@ -461,6 +469,7 @@ protected: @@ -461,6 +469,7 @@ protected:
Vector3f _accel_target; // acceleration target in NEU cm/s/s
Vector3f _limit_vector; // the direction that the position controller is limited, zero when not limited
Vector2f _vehicle_horiz_vel; // velocity to use if _flags.vehicle_horiz_vel_override is set
float _pos_offset_target_z; // vertical position offset target in NEU cm from home
float _pos_offset_z; // vertical position offset in NEU cm from home
float _vel_offset_z; // vertical velocity offset in NEU cm/s calculated by pos_to_rate step
float _accel_offset_z; // vertical acceleration offset in NEU cm/s/s

Loading…
Cancel
Save