APM:Libraries
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes | List of all members
AP_Motors Class Referenceabstract

#include <AP_Motors_Class.h>

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

Classes

struct  AP_Motors_flags
 
struct  AP_Motors_limit
 

Public Types

enum  motor_frame_class {
  MOTOR_FRAME_UNDEFINED = 0, MOTOR_FRAME_QUAD = 1, MOTOR_FRAME_HEXA = 2, MOTOR_FRAME_OCTA = 3,
  MOTOR_FRAME_OCTAQUAD = 4, MOTOR_FRAME_Y6 = 5, MOTOR_FRAME_HELI = 6, MOTOR_FRAME_TRI = 7,
  MOTOR_FRAME_SINGLE = 8, MOTOR_FRAME_COAX = 9, MOTOR_FRAME_TAILSITTER = 10, MOTOR_FRAME_HELI_DUAL = 11,
  MOTOR_FRAME_DODECAHEXA = 12, MOTOR_FRAME_HELI_QUAD = 13
}
 
enum  motor_frame_type {
  MOTOR_FRAME_TYPE_PLUS = 0, MOTOR_FRAME_TYPE_X = 1, MOTOR_FRAME_TYPE_V = 2, MOTOR_FRAME_TYPE_H = 3,
  MOTOR_FRAME_TYPE_VTAIL = 4, MOTOR_FRAME_TYPE_ATAIL = 5, MOTOR_FRAME_TYPE_Y6B = 10, MOTOR_FRAME_TYPE_Y6F = 11
}
 
enum  spool_up_down_desired { DESIRED_SHUT_DOWN = 0, DESIRED_SPIN_WHEN_ARMED = 1, DESIRED_THROTTLE_UNLIMITED = 2 }
 
enum  pwm_type {
  PWM_TYPE_NORMAL = 0, PWM_TYPE_ONESHOT = 1, PWM_TYPE_ONESHOT125 = 2, PWM_TYPE_BRUSHED = 3,
  PWM_TYPE_DSHOT150 = 4, PWM_TYPE_DSHOT300 = 5, PWM_TYPE_DSHOT600 = 6, PWM_TYPE_DSHOT1200 = 7
}
 

Public Member Functions

 AP_Motors (uint16_t loop_rate, uint16_t speed_hz=AP_MOTORS_SPEED_DEFAULT)
 
bool initialised_ok () const
 
bool armed () const
 
void armed (bool arm)
 
void set_interlock (bool set)
 
bool get_interlock () const
 
void set_roll (float roll_in)
 
void set_pitch (float pitch_in)
 
void set_yaw (float yaw_in)
 
void set_throttle (float throttle_in)
 
void set_throttle_avg_max (float throttle_avg_max)
 
void set_throttle_filter_cutoff (float filt_hz)
 
void set_forward (float forward_in)
 
void set_lateral (float lateral_in)
 
float get_roll () const
 
float get_pitch () const
 
float get_yaw () const
 
float get_throttle () const
 
float get_throttle_bidirectional () const
 
float get_forward () const
 
float get_lateral () const
 
virtual float get_throttle_hover () const =0
 
virtual void set_desired_spool_state (enum spool_up_down_desired spool)
 
enum spool_up_down_desired get_desired_spool_state (void) const
 
void set_air_density_ratio (float ratio)
 
virtual void set_update_rate (uint16_t speed_hz)
 
virtual void init (motor_frame_class frame_class, motor_frame_type frame_type)=0
 
virtual void set_frame_class_and_type (motor_frame_class frame_class, motor_frame_type frame_type)=0
 
virtual void output ()=0
 
virtual void output_min ()=0
 
virtual void output_test (uint8_t motor_seq, int16_t pwm)=0
 
virtual uint16_t get_motor_mask ()=0
 
void set_radio_passthrough (float roll_input, float pitch_input, float throttle_input, float yaw_input)
 
void set_loop_rate (uint16_t loop_rate)
 
pwm_type get_pwm_type (void) const
 

Static Public Member Functions

static AP_Motorsget_instance (void)
 

Public Attributes

struct AP_Motors::AP_Motors_limit limit
 

Protected Member Functions

virtual void output_armed_stabilizing ()=0
 
virtual void rc_write (uint8_t chan, uint16_t pwm)
 
virtual void rc_write_angle (uint8_t chan, int16_t angle_cd)
 
virtual void rc_set_freq (uint32_t mask, uint16_t freq_hz)
 
virtual uint32_t rc_map_mask (uint32_t mask) const
 
void add_motor_num (int8_t motor_num)
 
virtual void update_throttle_filter ()=0
 
virtual void save_params_on_disarm ()
 
int16_t calc_pwm_output_1to1 (float input, const SRV_Channel *servo)
 
int16_t calc_pwm_output_0to1 (float input, const SRV_Channel *servo)
 

Protected Attributes

struct AP_Motors::AP_Motors_flags _flags
 
uint16_t _loop_rate
 
uint16_t _speed_hz
 
float _roll_in
 
float _pitch_in
 
float _yaw_in
 
float _throttle_in
 
float _forward_in
 
float _lateral_in
 
float _throttle_avg_max
 
LowPassFilterFloat _throttle_filter
 
spool_up_down_desired _spool_desired
 
float _air_density_ratio
 
uint16_t _motor_fast_mask
 
float _roll_radio_passthrough
 
float _pitch_radio_passthrough
 
float _throttle_radio_passthrough
 
float _yaw_radio_passthrough
 
AP_Int8 _pwm_type
 

Static Private Attributes

static AP_Motors_instance
 

Detailed Description

Definition at line 29 of file AP_Motors_Class.h.

Member Enumeration Documentation

◆ motor_frame_class

Enumerator
MOTOR_FRAME_UNDEFINED 
MOTOR_FRAME_QUAD 
MOTOR_FRAME_HEXA 
MOTOR_FRAME_OCTA 
MOTOR_FRAME_OCTAQUAD 
MOTOR_FRAME_Y6 
MOTOR_FRAME_HELI 
MOTOR_FRAME_TRI 
MOTOR_FRAME_SINGLE 
MOTOR_FRAME_COAX 
MOTOR_FRAME_TAILSITTER 
MOTOR_FRAME_HELI_DUAL 
MOTOR_FRAME_DODECAHEXA 
MOTOR_FRAME_HELI_QUAD 

Definition at line 32 of file AP_Motors_Class.h.

◆ motor_frame_type

Enumerator
MOTOR_FRAME_TYPE_PLUS 
MOTOR_FRAME_TYPE_X 
MOTOR_FRAME_TYPE_V 
MOTOR_FRAME_TYPE_H 
MOTOR_FRAME_TYPE_VTAIL 
MOTOR_FRAME_TYPE_ATAIL 
MOTOR_FRAME_TYPE_Y6B 
MOTOR_FRAME_TYPE_Y6F 

Definition at line 48 of file AP_Motors_Class.h.

◆ pwm_type

Enumerator
PWM_TYPE_NORMAL 
PWM_TYPE_ONESHOT 
PWM_TYPE_ONESHOT125 
PWM_TYPE_BRUSHED 
PWM_TYPE_DSHOT150 
PWM_TYPE_DSHOT300 
PWM_TYPE_DSHOT600 
PWM_TYPE_DSHOT1200 

Definition at line 154 of file AP_Motors_Class.h.

◆ spool_up_down_desired

Enumerator
DESIRED_SHUT_DOWN 
DESIRED_SPIN_WHEN_ARMED 
DESIRED_THROTTLE_UNLIMITED 

Definition at line 99 of file AP_Motors_Class.h.

Constructor & Destructor Documentation

◆ AP_Motors()

AP_Motors::AP_Motors ( uint16_t  loop_rate,
uint16_t  speed_hz = AP_MOTORS_SPEED_DEFAULT 
)

Definition at line 33 of file AP_Motors_Class.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ add_motor_num()

void AP_Motors::add_motor_num ( int8_t  motor_num)
protected

Definition at line 203 of file AP_Motors_Class.cpp.

Referenced by AP_MotorsMatrix::add_motor_raw(), get_pwm_type(), AP_MotorsTri::init(), AP_MotorsCoax::init(), and AP_MotorsSingle::init().

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

◆ armed() [1/2]

bool AP_Motors::armed ( ) const
inline

◆ armed() [2/2]

void AP_Motors::armed ( bool  arm)

Definition at line 64 of file AP_Motors_Class.cpp.

Here is the call graph for this function:

◆ calc_pwm_output_0to1()

int16_t AP_Motors::calc_pwm_output_0to1 ( float  input,
const SRV_Channel servo 
)
protected

Definition at line 185 of file AP_Motors_Class.cpp.

Referenced by save_params_on_disarm(), and AP_MotorsHeli_Single::write_aux().

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

◆ calc_pwm_output_1to1()

int16_t AP_Motors::calc_pwm_output_1to1 ( float  input,
const SRV_Channel servo 
)
protected

Definition at line 165 of file AP_Motors_Class.cpp.

Referenced by AP_MotorsHeli_Quad::move_actuators(), AP_MotorsHeli_Single::move_yaw(), and save_params_on_disarm().

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

◆ get_desired_spool_state()

enum spool_up_down_desired AP_Motors::get_desired_spool_state ( void  ) const
inline

Definition at line 107 of file AP_Motors_Class.h.

◆ get_forward()

float AP_Motors::get_forward ( ) const
inline

Definition at line 94 of file AP_Motors_Class.h.

◆ get_instance()

static AP_Motors* AP_Motors::get_instance ( void  )
inlinestatic

Definition at line 63 of file AP_Motors_Class.h.

◆ get_interlock()

bool AP_Motors::get_interlock ( ) const
inline

Definition at line 76 of file AP_Motors_Class.h.

◆ get_lateral()

float AP_Motors::get_lateral ( ) const
inline

Definition at line 95 of file AP_Motors_Class.h.

Here is the call graph for this function:

◆ get_motor_mask()

virtual uint16_t AP_Motors::get_motor_mask ( )
pure virtual

Implemented in AP_MotorsHeli, AP_MotorsHeli_Single, AP_MotorsHeli_Dual, AP_MotorsHeli_Quad, AP_MotorsCoax, AP_MotorsSingle, AP_MotorsTri, AP_MotorsMatrix, and AP_MotorsTailsitter.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ get_pitch()

float AP_Motors::get_pitch ( ) const
inline

Definition at line 90 of file AP_Motors_Class.h.

Referenced by DataFlash_Class::Log_Write_Rate().

Here is the caller graph for this function:

◆ get_pwm_type()

pwm_type AP_Motors::get_pwm_type ( void  ) const
inline

Definition at line 162 of file AP_Motors_Class.h.

Here is the call graph for this function:

◆ get_roll()

float AP_Motors::get_roll ( ) const
inline

Definition at line 89 of file AP_Motors_Class.h.

Referenced by DataFlash_Class::Log_Write_Rate().

Here is the caller graph for this function:

◆ get_throttle()

float AP_Motors::get_throttle ( ) const
inline

Definition at line 92 of file AP_Motors_Class.h.

Referenced by AC_PosControl::init_takeoff(), DataFlash_Class::Log_Write_Rate(), AP_MotorsTailsitter::output_armed_stabilizing(), AP_MotorsMatrix::output_armed_stabilizing(), AP_MotorsCoax::output_armed_stabilizing(), AP_MotorsSingle::output_armed_stabilizing(), AP_MotorsTri::output_armed_stabilizing(), AP_MotorsHeli::output_armed_stabilizing(), AP_MotorsHeli::output_armed_zero_throttle(), AP_MotorsMulticopter::output_boost_throttle(), AP_MotorsHeli::output_disarmed(), AP_MotorsMulticopter::output_logic(), and AP_MotorsMulticopter::update_throttle_hover().

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

◆ get_throttle_bidirectional()

float AP_Motors::get_throttle_bidirectional ( ) const
inline

Definition at line 93 of file AP_Motors_Class.h.

Referenced by AP_Motors6DOF::output_armed_stabilizing(), AP_Motors6DOF::output_armed_stabilizing_vectored(), and AP_Motors6DOF::output_armed_stabilizing_vectored_6dof().

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

◆ get_throttle_hover()

virtual float AP_Motors::get_throttle_hover ( ) const
pure virtual

◆ get_yaw()

float AP_Motors::get_yaw ( ) const
inline

Definition at line 91 of file AP_Motors_Class.h.

Referenced by DataFlash_Class::Log_Write_Rate().

Here is the caller graph for this function:

◆ init()

virtual void AP_Motors::init ( motor_frame_class  frame_class,
motor_frame_type  frame_type 
)
pure virtual

Implemented in AP_MotorsHeli, AP_MotorsCoax, AP_MotorsSingle, AP_MotorsTri, and AP_MotorsTailsitter.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ initialised_ok()

bool AP_Motors::initialised_ok ( ) const
inline

Definition at line 66 of file AP_Motors_Class.h.

◆ output()

virtual void AP_Motors::output ( )
pure virtual

Implemented in AP_MotorsHeli, and AP_MotorsMulticopter.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ output_armed_stabilizing()

virtual void AP_Motors::output_armed_stabilizing ( )
protectedpure virtual

Implemented in AP_MotorsHeli, AP_Motors6DOF, AP_MotorsCoax, AP_MotorsSingle, AP_MotorsTri, AP_MotorsMatrix, and AP_MotorsTailsitter.

Referenced by get_pwm_type(), and AP_MotorsMulticopter::output().

Here is the caller graph for this function:

◆ output_min()

virtual void AP_Motors::output_min ( )
pure virtual

Implemented in AP_MotorsHeli, AP_MotorsMulticopter, and AP_Motors6DOF.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ output_test()

virtual void AP_Motors::output_test ( uint8_t  motor_seq,
int16_t  pwm 
)
pure virtual

Implemented in AP_MotorsHeli, AP_MotorsHeli_Single, AP_MotorsHeli_Dual, AP_MotorsCoax, AP_MotorsSingle, AP_MotorsTri, AP_MotorsHeli_Quad, AP_MotorsMatrix, and AP_MotorsTailsitter.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ rc_map_mask()

uint32_t AP_Motors::rc_map_mask ( uint32_t  mask) const
protectedvirtual

Definition at line 151 of file AP_Motors_Class.cpp.

Referenced by AP_MotorsMatrix::get_motor_mask(), AP_MotorsTri::get_motor_mask(), AP_MotorsCoax::get_motor_mask(), AP_MotorsSingle::get_motor_mask(), AP_MotorsHeli_Single::get_motor_mask(), get_pwm_type(), and rc_set_freq().

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

◆ rc_set_freq()

void AP_Motors::rc_set_freq ( uint32_t  mask,
uint16_t  freq_hz 
)
protectedvirtual

Definition at line 105 of file AP_Motors_Class.cpp.

Referenced by get_pwm_type(), AP_MotorsMatrix::set_update_rate(), AP_MotorsTri::set_update_rate(), AP_MotorsHeli_Quad::set_update_rate(), AP_MotorsSingle::set_update_rate(), AP_MotorsCoax::set_update_rate(), AP_MotorsHeli_Dual::set_update_rate(), and AP_MotorsHeli_Single::set_update_rate().

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

◆ rc_write()

void AP_Motors::rc_write ( uint8_t  chan,
uint16_t  pwm 
)
protectedvirtual

◆ rc_write_angle()

void AP_Motors::rc_write_angle ( uint8_t  chan,
int16_t  angle_cd 
)
protectedvirtual

Definition at line 96 of file AP_Motors_Class.cpp.

Referenced by get_pwm_type(), AP_MotorsSingle::output_to_motors(), and AP_MotorsCoax::output_to_motors().

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

◆ save_params_on_disarm()

virtual void AP_Motors::save_params_on_disarm ( )
inlineprotectedvirtual

Reimplemented in AP_MotorsMulticopter.

Definition at line 179 of file AP_Motors_Class.h.

Referenced by armed().

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

◆ set_air_density_ratio()

void AP_Motors::set_air_density_ratio ( float  ratio)
inline

Definition at line 110 of file AP_Motors_Class.h.

◆ set_desired_spool_state()

virtual void AP_Motors::set_desired_spool_state ( enum spool_up_down_desired  spool)
inlinevirtual

Definition at line 105 of file AP_Motors_Class.h.

Referenced by AP_MotorsMulticopter::output_min(), and stability_test().

Here is the caller graph for this function:

◆ set_forward()

void AP_Motors::set_forward ( float  forward_in)
inline

Definition at line 85 of file AP_Motors_Class.h.

◆ set_frame_class_and_type()

virtual void AP_Motors::set_frame_class_and_type ( motor_frame_class  frame_class,
motor_frame_type  frame_type 
)
pure virtual

Implemented in AP_MotorsHeli, AP_MotorsCoax, AP_MotorsSingle, AP_MotorsTri, and AP_MotorsTailsitter.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ set_interlock()

void AP_Motors::set_interlock ( bool  set)
inline

Definition at line 73 of file AP_Motors_Class.h.

Referenced by stability_test().

Here is the caller graph for this function:

◆ set_lateral()

void AP_Motors::set_lateral ( float  lateral_in)
inline

Definition at line 86 of file AP_Motors_Class.h.

◆ set_loop_rate()

void AP_Motors::set_loop_rate ( uint16_t  loop_rate)
inline

Definition at line 152 of file AP_Motors_Class.h.

◆ set_pitch()

void AP_Motors::set_pitch ( float  pitch_in)
inline

Definition at line 80 of file AP_Motors_Class.h.

Referenced by AC_AttitudeControl_Heli::rate_bf_to_motor_roll_pitch(), AC_AttitudeControl_Sub::rate_controller_run(), AC_AttitudeControl_Heli::rate_controller_run(), AC_AttitudeControl_Multi::rate_controller_run(), and stability_test().

Here is the caller graph for this function:

◆ set_radio_passthrough()

void AP_Motors::set_radio_passthrough ( float  roll_input,
float  pitch_input,
float  throttle_input,
float  yaw_input 
)

Definition at line 76 of file AP_Motors_Class.cpp.

Referenced by set_update_rate().

Here is the caller graph for this function:

◆ set_roll()

void AP_Motors::set_roll ( float  roll_in)
inline

Definition at line 79 of file AP_Motors_Class.h.

Referenced by AC_AttitudeControl_Heli::rate_bf_to_motor_roll_pitch(), AC_AttitudeControl_Sub::rate_controller_run(), AC_AttitudeControl_Heli::rate_controller_run(), AC_AttitudeControl_Multi::rate_controller_run(), and stability_test().

Here is the caller graph for this function:

◆ set_throttle()

void AP_Motors::set_throttle ( float  throttle_in)
inline

Definition at line 82 of file AP_Motors_Class.h.

Referenced by AC_AttitudeControl_Sub::set_throttle_out(), AC_AttitudeControl_Multi::set_throttle_out(), AC_AttitudeControl_Heli::set_throttle_out(), AC_AttitudeControl::set_throttle_out_unstabilized(), and stability_test().

Here is the caller graph for this function:

◆ set_throttle_avg_max()

void AP_Motors::set_throttle_avg_max ( float  throttle_avg_max)
inline

Definition at line 83 of file AP_Motors_Class.h.

Referenced by AC_AttitudeControl_Sub::set_throttle_out(), AC_AttitudeControl_Multi::set_throttle_out(), and setup().

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

◆ set_throttle_filter_cutoff()

void AP_Motors::set_throttle_filter_cutoff ( float  filt_hz)
inline

Definition at line 84 of file AP_Motors_Class.h.

Referenced by AC_AttitudeControl_Sub::set_throttle_out(), AC_AttitudeControl_Multi::set_throttle_out(), AC_AttitudeControl_Heli::set_throttle_out(), and AC_AttitudeControl::set_throttle_out_unstabilized().

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

◆ set_update_rate()

virtual void AP_Motors::set_update_rate ( uint16_t  speed_hz)
inlinevirtual

Reimplemented in AP_MotorsHeli, AP_MotorsHeli_Single, AP_MotorsHeli_Dual, AP_MotorsCoax, AP_MotorsSingle, AP_MotorsHeli_Quad, AP_MotorsTri, AP_MotorsMatrix, and AP_MotorsTailsitter.

Definition at line 125 of file AP_Motors_Class.h.

Here is the call graph for this function:

◆ set_yaw()

void AP_Motors::set_yaw ( float  yaw_in)
inline

Definition at line 81 of file AP_Motors_Class.h.

Referenced by AC_AttitudeControl_Sub::rate_controller_run(), AC_AttitudeControl_Heli::rate_controller_run(), AC_AttitudeControl_Multi::rate_controller_run(), and stability_test().

Here is the caller graph for this function:

◆ update_throttle_filter()

virtual void AP_Motors::update_throttle_filter ( )
protectedpure virtual

Implemented in AP_MotorsHeli, and AP_MotorsMulticopter.

Referenced by get_pwm_type().

Here is the caller graph for this function:

Member Data Documentation

◆ _air_density_ratio

float AP_Motors::_air_density_ratio
protected

◆ _flags

struct AP_Motors::AP_Motors_flags AP_Motors::_flags
protected

◆ _forward_in

float AP_Motors::_forward_in
protected

◆ _instance

AP_Motors * AP_Motors::_instance
staticprivate

Definition at line 222 of file AP_Motors_Class.h.

Referenced by AP_Motors(), and get_instance().

◆ _lateral_in

float AP_Motors::_lateral_in
protected

◆ _loop_rate

uint16_t AP_Motors::_loop_rate
protected

◆ _motor_fast_mask

uint16_t AP_Motors::_motor_fast_mask
protected

Definition at line 211 of file AP_Motors_Class.h.

Referenced by rc_set_freq().

◆ _pitch_in

float AP_Motors::_pitch_in
protected

◆ _pitch_radio_passthrough

float AP_Motors::_pitch_radio_passthrough
protected

◆ _pwm_type

AP_Int8 AP_Motors::_pwm_type
protected

Definition at line 219 of file AP_Motors_Class.h.

Referenced by get_pwm_type(), and rc_set_freq().

◆ _roll_in

float AP_Motors::_roll_in
protected

◆ _roll_radio_passthrough

float AP_Motors::_roll_radio_passthrough
protected

◆ _speed_hz

uint16_t AP_Motors::_speed_hz
protected

◆ _spool_desired

spool_up_down_desired AP_Motors::_spool_desired
protected

◆ _throttle_avg_max

float AP_Motors::_throttle_avg_max
protected

◆ _throttle_filter

LowPassFilterFloat AP_Motors::_throttle_filter
protected

◆ _throttle_in

float AP_Motors::_throttle_in
protected

◆ _throttle_radio_passthrough

float AP_Motors::_throttle_radio_passthrough
protected

◆ _yaw_in

float AP_Motors::_yaw_in
protected

◆ _yaw_radio_passthrough

float AP_Motors::_yaw_radio_passthrough
protected

Definition at line 217 of file AP_Motors_Class.h.

Referenced by AP_MotorsHeli::output_disarmed(), and set_radio_passthrough().

◆ limit

struct AP_Motors::AP_Motors_limit AP_Motors::limit

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