APM:Libraries
Public Member Functions | Private Attributes | List of all members
AC_PosControl_Sub Class Reference

#include <AC_PosControl_Sub.h>

Inheritance diagram for AC_PosControl_Sub:
[legend]
Collaboration diagram for AC_PosControl_Sub:
[legend]

Public Member Functions

 AC_PosControl_Sub (const AP_AHRS_View &ahrs, const AP_InertialNav &inav, const AP_Motors &motors, AC_AttitudeControl &attitude_control)
 
void set_alt_max (float alt)
 
void set_alt_min (float alt)
 
void set_alt_target_from_climb_rate (float climb_rate_cms, float dt, bool force_descend) override
 
void set_alt_target_from_climb_rate_ff (float climb_rate_cms, float dt, bool force_descend) override
 
- Public Member Functions inherited from AC_PosControl
 AC_PosControl (const AP_AHRS_View &ahrs, const AP_InertialNav &inav, const AP_Motors &motors, AC_AttitudeControl &attitude_control)
 Constructor. More...
 
void set_dt (float delta_sec)
 set_dt - sets time delta in seconds for all controllers (i.e. 100hz = 0.01, 400hz = 0.0025) More...
 
float get_dt () const
 
void set_speed_z (float speed_down, float speed_up)
 
float get_speed_up () const
 get_speed_up - accessor for current up speed in cm/s More...
 
float get_speed_down () const
 get_speed_down - accessors for current down speed in cm/s. Will be a negative number More...
 
float get_vel_target_z () const
 get_vel_target_z - returns current vertical speed in cm/s More...
 
void set_accel_z (float accel_cmss)
 set_accel_z - set vertical acceleration in cm/s/s More...
 
float get_accel_z () const
 get_accel_z - returns current vertical acceleration in cm/s/s More...
 
void calc_leash_length_z ()
 
void set_alt_target (float alt_cm)
 set_alt_target - set altitude target in cm above home More...
 
void set_alt_target_with_slew (float alt_cm, float dt)
 
void add_takeoff_climb_rate (float climb_rate_cms, float dt)
 
void set_alt_target_to_current_alt ()
 set_alt_target_to_current_alt - set altitude target to current altitude More...
 
void shift_alt_target (float z_cm)
 shift altitude target (positive means move altitude up) More...
 
void relax_alt_hold_controllers (float throttle_setting)
 relax_alt_hold_controllers - set all desired and targets to measured More...
 
float get_alt_target () const
 
float get_alt_error () const
 get_alt_error - returns altitude error in cm More...
 
float get_horizontal_error () const
 
void set_target_to_stopping_point_z ()
 set_target_to_stopping_point_z - sets altitude target to reasonable stopping altitude in cm above home More...
 
void get_stopping_point_z (Vector3f &stopping_point) const
 get_stopping_point_z - calculates stopping point based on current position, velocity, vehicle acceleration More...
 
void init_takeoff ()
 init_takeoff - initialises target altitude if we are taking off More...
 
bool is_active_z () const
 
void update_z_controller ()
 update_z_controller - fly to altitude in cm above home More...
 
float get_leash_down_z () const
 
float get_leash_up_z () const
 
float get_lean_angle_max_cd () const
 get_lean_angle_max_cd - returns the maximum lean angle the autopilot may request More...
 
void init_xy_controller (bool reset_I=true)
 
void set_accel_xy (float accel_cmss)
 set_accel_xy - set horizontal acceleration in cm/s/s More...
 
float get_accel_xy () const
 
void set_speed_xy (float speed_cms)
 set_speed_xy - set horizontal speed maximum in cm/s More...
 
float get_speed_xy () const
 
void set_limit_accel_xy (void)
 
void calc_leash_length_xy ()
 
void set_leash_length_xy (float leash)
 set the horizontal leash length More...
 
const Vector3fget_pos_target () const
 get_pos_target - get target as position vector (from home in cm) More...
 
void set_pos_target (const Vector3f &position)
 set_pos_target in cm from home More...
 
void set_xy_target (float x, float y)
 set_xy_target in cm from home More...
 
void shift_pos_xy_target (float x_cm, float y_cm)
 shift position target target in x, y axis More...
 
const Vector3fget_desired_velocity ()
 get_desired_velocity - returns xy desired velocity (i.e. feed forward) in cm/s in lat and lon direction More...
 
void set_desired_velocity_z (float vel_z_cms)
 set_desired_velocity_z - sets desired velocity in cm/s in z axis More...
 
void clear_desired_velocity_ff_z ()
 
void set_desired_accel_xy (float accel_lat_cms, float accel_lon_cms)
 
void set_desired_velocity_xy (float vel_lat_cms, float vel_lon_cms)
 
void set_desired_velocity (const Vector3f &des_vel)
 
void override_vehicle_velocity_xy (const Vector2f &vel_xy)
 
void freeze_ff_z ()
 freeze_ff_z - used to stop the feed forward being calculated during a known discontinuity More...
 
bool is_active_xy () const
 
void update_xy_controller (float ekfNavVelGainScaler)
 update_xy_controller - run the horizontal position controller - should be called at 100hz or higher More...
 
void set_target_to_stopping_point_xy ()
 set_target_to_stopping_point_xy - sets horizontal target to reasonable stopping position in cm from home More...
 
void get_stopping_point_xy (Vector3f &stopping_point) const
 
float get_distance_to_target () const
 get_distance_to_target - get horizontal distance to position target in cm (used for reporting) More...
 
int32_t get_bearing_to_target () const
 get_bearing_to_target - get bearing to target position in centi-degrees More...
 
void init_vel_controller_xyz ()
 xyz velocity controller More...
 
void update_vel_controller_xy (float ekfNavVelGainScaler)
 
void update_vel_controller_xyz (float ekfNavVelGainScaler)
 
float get_roll () const
 get desired roll, pitch which should be fed into stabilize controllers More...
 
float get_pitch () const
 
float get_leash_xy () const
 
AC_Pget_pos_z_p ()
 get pid controllers More...
 
AC_Pget_vel_z_p ()
 
AC_PIDget_accel_z_pid ()
 
AC_Pget_pos_xy_p ()
 
AC_PID_2Dget_vel_xy_pid ()
 
const Vector3fget_vel_target () const
 accessors for reporting More...
 
const Vector3fget_accel_target () const
 
void accel_to_lean_angles (float accel_x_cmss, float accel_y_cmss, float &roll_target, float &pitch_target) const
 
void lean_angles_to_accel (float &accel_x_cmss, float &accel_y_cmss) const
 
float time_since_last_xy_update () const
 
void write_log ()
 

Private Attributes

float _alt_max
 
float _alt_min
 

Additional Inherited Members

- Static Public Attributes inherited from AC_PosControl
static const struct AP_Param::GroupInfo var_info []
 
- Protected Member Functions inherited from AC_PosControl
void run_z_controller ()
 
void desired_accel_to_vel (float nav_dt)
 move velocity target using desired acceleration More...
 
void desired_vel_to_pos (float nav_dt)
 desired_vel_to_pos - move position target using desired velocities More...
 
void run_xy_controller (float dt, float ekfNavVelGainScaler)
 
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 position kP gain More...
 
void init_ekf_xy_reset ()
 initialise and check for ekf position resets More...
 
void check_for_ekf_xy_reset ()
 check for ekf position reset and adjust loiter or brake target position More...
 
void init_ekf_z_reset ()
 initialise ekf z axis reset check More...
 
void check_for_ekf_z_reset ()
 check for ekf position reset and adjust loiter or brake target position More...
 
- Static Protected Member Functions inherited from AC_PosControl
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 More...
 
static Vector3f sqrt_controller (const Vector3f &error, float p, float second_ord_lim)
 Proportional controller with piecewise sqrt sections to constrain second derivative. More...
 
- Protected Attributes inherited from AC_PosControl
struct AC_PosControl::poscontrol_flags _flags
 
struct AC_PosControl::poscontrol_limit_flags _limit
 
const AP_AHRS_View_ahrs
 
const AP_InertialNav_inav
 
const AP_Motors_motors
 
AC_AttitudeControl_attitude_control
 
AP_Float _accel_xy_filt_hz
 
AP_Float _lean_angle_max
 
AC_P _p_pos_z
 
AC_P _p_vel_z
 
AC_PID _pid_accel_z
 
AC_P _p_pos_xy
 
AC_PID_2D _pid_vel_xy
 
float _dt
 
uint32_t _last_update_xy_ms
 
uint32_t _last_update_z_ms
 
float _speed_down_cms
 
float _speed_up_cms
 
float _speed_cms
 
float _accel_z_cms
 
float _accel_last_z_cms
 
float _accel_cms
 
float _leash
 
float _leash_down_z
 
float _leash_up_z
 
float _roll_target
 
float _pitch_target
 
Vector3f _pos_target
 
Vector3f _pos_error
 
Vector3f _vel_desired
 
Vector3f _vel_target
 
Vector3f _vel_error
 
Vector3f _vel_last
 
Vector3f _accel_desired
 
Vector3f _accel_target
 
Vector3f _accel_error
 
Vector2f _vehicle_horiz_vel
 
float _distance_to_target
 
LowPassFilterFloat _vel_error_filter
 
LowPassFilterVector2f _accel_target_filter
 
uint32_t _ekf_xy_reset_ms
 
uint32_t _ekf_z_reset_ms
 

Detailed Description

Definition at line 5 of file AC_PosControl_Sub.h.

Constructor & Destructor Documentation

◆ AC_PosControl_Sub()

AC_PosControl_Sub::AC_PosControl_Sub ( const AP_AHRS_View ahrs,
const AP_InertialNav inav,
const AP_Motors motors,
AC_AttitudeControl attitude_control 
)

Definition at line 3 of file AC_PosControl_Sub.cpp.

Member Function Documentation

◆ set_alt_max()

void AC_PosControl_Sub::set_alt_max ( float  alt)
inline

set_alt_max - sets maximum altitude above the ekf origin in cm only enforced when set_alt_target_from_climb_rate is used set to zero to disable limit

Definition at line 13 of file AC_PosControl_Sub.h.

◆ set_alt_min()

void AC_PosControl_Sub::set_alt_min ( float  alt)
inline

set_alt_min - sets the minimum altitude (maximum depth) in cm only enforced when set_alt_target_from_climb_rate is used set to zero to disable limit

Definition at line 18 of file AC_PosControl_Sub.h.

Here is the call graph for this function:

◆ set_alt_target_from_climb_rate()

void AC_PosControl_Sub::set_alt_target_from_climb_rate ( float  climb_rate_cms,
float  dt,
bool  force_descend 
)
overridevirtual

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) 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

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) 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

Reimplemented from AC_PosControl.

Definition at line 14 of file AC_PosControl_Sub.cpp.

Referenced by set_alt_min().

Here is the caller graph for this function:

◆ set_alt_target_from_climb_rate_ff()

void AC_PosControl_Sub::set_alt_target_from_climb_rate_ff ( float  climb_rate_cms,
float  dt,
bool  force_descend 
)
overridevirtual

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

Reimplemented from AC_PosControl.

Definition at line 45 of file AC_PosControl_Sub.cpp.

Referenced by set_alt_min().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _alt_max

float AC_PosControl_Sub::_alt_max
private

◆ _alt_min

float AC_PosControl_Sub::_alt_min
private

The documentation for this class was generated from the following files: