17 #define POSCONTROL_ACCELERATION_MIN 50.0f // minimum horizontal acceleration in cm/s/s - used for sanity checking acceleration in leash length calculation 18 #define POSCONTROL_ACCEL_XY 100.0f // default horizontal acceleration in cm/s/s. This is overwritten by waypoint and loiter controllers 19 #define POSCONTROL_ACCEL_XY_MAX 980.0f // max horizontal acceleration in cm/s/s that the position velocity controller will ask from the lower accel controller 20 #define POSCONTROL_STOPPING_DIST_UP_MAX 300.0f // max stopping distance (in cm) vertically while climbing 21 #define POSCONTROL_STOPPING_DIST_DOWN_MAX 200.0f // max stopping distance (in cm) vertically while descending 23 #define POSCONTROL_SPEED 500.0f // default horizontal speed in cm/s 24 #define POSCONTROL_SPEED_DOWN -150.0f // default descent rate in cm/s 25 #define POSCONTROL_SPEED_UP 250.0f // default climb rate in cm/s 27 #define POSCONTROL_ACCEL_Z 250.0f // default vertical acceleration in cm/s/s. 29 #define POSCONTROL_LEASH_LENGTH_MIN 100.0f // minimum leash lengths in cm 31 #define POSCONTROL_DT_50HZ 0.02f // time difference in seconds for 50hz update rate 32 #define POSCONTROL_DT_400HZ 0.0025f // time difference in seconds for 400hz update rate 34 #define POSCONTROL_ACTIVE_TIMEOUT_MS 200 // position controller is considered active if it has been called within the past 0.2 seconds 36 #define POSCONTROL_VEL_ERROR_CUTOFF_FREQ 4.0f // low-pass filter on velocity error (unit: hz) 37 #define POSCONTROL_THROTTLE_CUTOFF_FREQ 2.0f // low-pass filter on accel error (unit: hz) 38 #define POSCONTROL_ACCEL_FILTER_HZ 2.0f // low-pass filter on acceleration (unit: hz) 39 #define POSCONTROL_JERK_RATIO 1.0f // Defines the time it takes to reach the requested acceleration 41 #define POSCONTROL_OVERSPEED_GAIN_Z 2.0f // gain controlling rate at which z-axis speed is brought back within SPEED_UP and SPEED_DOWN range 57 void set_dt(
float delta_sec);
287 void accel_to_lean_angles(
float accel_x_cmss,
float accel_y_cmss,
float& roll_target,
float& pitch_target)
const;
Generic PID algorithm, with EEPROM-backed storage of constants.
float get_speed_xy() const
void get_stopping_point_xy(Vector3f &stopping_point) const
uint32_t _last_update_z_ms
void init_takeoff()
init_takeoff - initialises target altitude if we are taking off
float get_alt_target() const
const AP_Motors & _motors
void set_desired_velocity_xy(float vel_lat_cms, float vel_lon_cms)
float get_lean_angle_max_cd() const
get_lean_angle_max_cd - returns the maximum lean angle the autopilot may request
void init_ekf_xy_reset()
initialise and check for ekf position resets
void shift_pos_xy_target(float x_cm, float y_cm)
shift position target target in x, y axis
Generic PID algorithm, with EEPROM-backed storage of constants.
void set_alt_target_with_slew(float alt_cm, float dt)
const Vector3f & get_accel_target() const
float _distance_to_target
const Vector3f & get_vel_target() const
accessors for reporting
static const struct AP_Param::GroupInfo var_info[]
float get_distance_to_target() const
get_distance_to_target - get horizontal distance to position target in cm (used for reporting) ...
virtual void set_alt_target_from_climb_rate(float climb_rate_cms, float dt, bool force_descend)
float get_alt_error() const
get_alt_error - returns altitude error in cm
void get_stopping_point_z(Vector3f &stopping_point) const
get_stopping_point_z - calculates stopping point based on current position, velocity, vehicle acceleration
const AP_AHRS_View & _ahrs
void clear_desired_velocity_ff_z()
void update_z_controller()
update_z_controller - fly to altitude in cm above home
void set_desired_accel_xy(float accel_lat_cms, float accel_lon_cms)
void init_vel_controller_xyz()
xyz velocity controller
void run_xy_controller(float dt, float ekfNavVelGainScaler)
AC_PosControl(const AP_AHRS_View &ahrs, const AP_InertialNav &inav, const AP_Motors &motors, AC_AttitudeControl &attitude_control)
Constructor.
float get_leash_up_z() const
void update_xy_controller(float ekfNavVelGainScaler)
update_xy_controller - run the horizontal position controller - should be called at 100hz or higher ...
void set_limit_accel_xy(void)
float get_horizontal_error() const
static Vector3f sqrt_controller(const Vector3f &error, float p, float second_ord_lim)
Proportional controller with piecewise sqrt sections to constrain second derivative.
LowPassFilterVector2f _accel_target_filter
void override_vehicle_velocity_xy(const Vector2f &vel_xy)
void set_leash_length_xy(float leash)
set the horizontal leash length
void update_vel_controller_xy(float ekfNavVelGainScaler)
uint16_t reset_accel_to_throttle
Generic PID algorithm, with EEPROM-backed storage of constants.
uint16_t reset_rate_to_accel_z
void set_xy_target(float x, float y)
set_xy_target in cm from home
AP_MotorsMatrix motors(400)
float get_roll() const
get desired roll, pitch which should be fed into stabilize controllers
void add_takeoff_climb_rate(float climb_rate_cms, float dt)
void update_vel_controller_xyz(float ekfNavVelGainScaler)
Object managing one P controller.
bool is_active_xy() const
A system for managing and storing variables that are of general interest to the system.
void desired_vel_to_pos(float nav_dt)
desired_vel_to_pos - move position target using desired velocities
uint16_t reset_accel_to_lean_xy
float get_accel_xy() const
float get_speed_up() const
get_speed_up - accessor for current up speed in cm/s
void check_for_ekf_xy_reset()
check for ekf position reset and adjust loiter or brake target position
void relax_alt_hold_controllers(float throttle_setting)
relax_alt_hold_controllers - set all desired and targets to measured
ArduCopter attitude control library.
void lean_angles_to_accel(float &accel_x_cmss, float &accel_y_cmss) const
const Vector3f & get_pos_target() const
get_pos_target - get target as position vector (from home in cm)
struct AC_PosControl::poscontrol_limit_flags _limit
void accel_to_lean_angles(float accel_x_cmss, float accel_y_cmss, float &roll_target, float &pitch_target) const
AC_AttitudeControl & _attitude_control
AP_Float _accel_xy_filt_hz
void init_xy_controller(bool reset_I=true)
void set_desired_velocity_z(float vel_z_cms)
set_desired_velocity_z - sets desired velocity in cm/s in z axis
float get_leash_down_z() const
void set_speed_z(float speed_down, float speed_up)
struct AC_PosControl::poscontrol_flags _flags
void calc_leash_length_z()
void set_desired_velocity(const Vector3f &des_vel)
void set_dt(float delta_sec)
set_dt - sets time delta in seconds for all controllers (i.e. 100hz = 0.01, 400hz = 0...
AC_PID_2D & get_vel_xy_pid()
void calc_leash_length_xy()
float get_accel_z() const
get_accel_z - returns current vertical acceleration in cm/s/s
void set_accel_z(float accel_cmss)
set_accel_z - set vertical acceleration in cm/s/s
void init_ekf_z_reset()
initialise ekf z axis reset check
AC_P & get_pos_z_p()
get pid controllers
float get_speed_down() const
get_speed_down - accessors for current down speed in cm/s. Will be a negative number ...
virtual void set_alt_target_from_climb_rate_ff(float climb_rate_cms, float dt, bool force_descend)
void set_pos_target(const Vector3f &position)
set_pos_target in cm from home
const AP_InertialNav & _inav
Vector2f _vehicle_horiz_vel
Common definitions and utility routines for the ArduPilot libraries.
int32_t get_bearing_to_target() const
get_bearing_to_target - get bearing to target position in centi-degrees
void freeze_ff_z()
freeze_ff_z - used to stop the feed forward being calculated during a known discontinuity ...
const Vector3f & get_desired_velocity()
get_desired_velocity - returns xy desired velocity (i.e. feed forward) in cm/s in lat and lon directi...
static bool limit_vector_length(float &vector_x, float &vector_y, float max_length)
limit vector to a given length, returns true if vector was limited
void shift_alt_target(float z_cm)
shift altitude target (positive means move altitude up)
Copter PID control class.
void set_target_to_stopping_point_xy()
set_target_to_stopping_point_xy - sets horizontal target to reasonable stopping position in cm from h...
void set_alt_target(float alt_cm)
set_alt_target - set altitude target in cm above home
void check_for_ekf_z_reset()
check for ekf position reset and adjust loiter or brake target position
void set_accel_xy(float accel_cmss)
set_accel_xy - set horizontal acceleration in cm/s/s
uint32_t _last_update_xy_ms
#define error(fmt, args ...)
uint16_t reset_desired_vel_to_pos
uint16_t vehicle_horiz_vel_override
void set_target_to_stopping_point_z()
set_target_to_stopping_point_z - sets altitude target to reasonable stopping altitude in cm above hom...
float time_since_last_xy_update() const
void desired_accel_to_vel(float nav_dt)
move velocity target using desired acceleration
Copter PID control class.
AC_PID & get_accel_z_pid()
float get_leash_xy() const
float get_vel_target_z() const
get_vel_target_z - returns current vertical speed in cm/s
virtual float get_altitude() const =0
void set_speed_xy(float speed_cms)
set_speed_xy - set horizontal speed maximum in cm/s
LowPassFilterFloat _vel_error_filter
uint32_t _ekf_xy_reset_ms
float calc_leash_length(float speed_cms, float accel_cms, float kP) const
calc_leash_length - calculates the horizontal leash length given a maximum speed, acceleration and po...
void set_alt_target_to_current_alt()
set_alt_target_to_current_alt - set altitude target to current altitude