Browse Source

AP_Motors: add get_frame_mav_type

zr-v5.1
Peter Hall 4 years ago committed by Randy Mackay
parent
commit
d0e1e85b9e
  1. 2
      libraries/AP_Motors/AP_MotorsCoax.cpp
  2. 1
      libraries/AP_Motors/AP_MotorsHeli.cpp
  3. 8
      libraries/AP_Motors/AP_MotorsMatrix.cpp
  4. 2
      libraries/AP_Motors/AP_MotorsSingle.cpp
  5. 2
      libraries/AP_Motors/AP_MotorsTailsitter.cpp
  6. 2
      libraries/AP_Motors/AP_MotorsTri.cpp
  7. 4
      libraries/AP_Motors/AP_Motors_Class.h

2
libraries/AP_Motors/AP_MotorsCoax.cpp

@ -37,6 +37,8 @@ void AP_MotorsCoax::init(motor_frame_class frame_class, motor_frame_type frame_t @@ -37,6 +37,8 @@ void AP_MotorsCoax::init(motor_frame_class frame_class, motor_frame_type frame_t
SRV_Channels::set_angle(SRV_Channels::get_motor_function(i), AP_MOTORS_COAX_SERVO_INPUT_RANGE);
}
_mav_type = MAV_TYPE_COAXIAL;
// record successful initialisation if what we setup was the desired frame_class
set_initialised_ok(frame_class == MOTOR_FRAME_COAX);
}

1
libraries/AP_Motors/AP_MotorsHeli.cpp

@ -159,6 +159,7 @@ void AP_MotorsHeli::init(motor_frame_class frame_class, motor_frame_type frame_t @@ -159,6 +159,7 @@ void AP_MotorsHeli::init(motor_frame_class frame_class, motor_frame_type frame_t
// set flag to true so targets are initialized once aircraft is armed for first time
_heliflags.init_targets_on_arming = true;
_mav_type = MAV_TYPE_HELICOPTER;
}
// set frame class (i.e. quad, hexa, heli) and type (i.e. x, plus)

8
libraries/AP_Motors/AP_MotorsMatrix.cpp

@ -492,6 +492,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -492,6 +492,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
switch (frame_class) {
case MOTOR_FRAME_QUAD:
_mav_type = MAV_TYPE_QUADROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_PLUS:
add_motor(AP_MOTORS_MOT_1, 90, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 2);
@ -618,6 +619,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -618,6 +619,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
break; // quad
case MOTOR_FRAME_HEXA:
_mav_type = MAV_TYPE_HEXAROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_PLUS:
add_motor(AP_MOTORS_MOT_1, 0, AP_MOTORS_MATRIX_YAW_FACTOR_CW, 1);
@ -668,6 +670,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -668,6 +670,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
break;
case MOTOR_FRAME_OCTA:
_mav_type = MAV_TYPE_OCTOROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_PLUS:
add_motor(AP_MOTORS_MOT_1, 0, AP_MOTORS_MATRIX_YAW_FACTOR_CW, 1);
@ -747,6 +750,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -747,6 +750,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
break;
case MOTOR_FRAME_OCTAQUAD:
_mav_type = MAV_TYPE_OCTOROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_PLUS:
add_motor(AP_MOTORS_MOT_1, 0, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 1);
@ -807,6 +811,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -807,6 +811,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
break;
case MOTOR_FRAME_DODECAHEXA: {
_mav_type = MAV_TYPE_DODECAROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_PLUS:
add_motor(AP_MOTORS_MOT_1, 0, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 1); // forward-top
@ -844,6 +849,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -844,6 +849,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
break;
case MOTOR_FRAME_Y6:
_mav_type = MAV_TYPE_HEXAROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_Y6B:
// Y6 motor definition with all top motors spinning clockwise, all bottom motors counter clockwise
@ -875,6 +881,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -875,6 +881,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
break;
case MOTOR_FRAME_DECA:
_mav_type = MAV_TYPE_DECAROTOR;
switch (frame_type) {
case MOTOR_FRAME_TYPE_PLUS:
add_motor(AP_MOTORS_MOT_1, 0, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 1);
@ -910,6 +917,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty @@ -910,6 +917,7 @@ void AP_MotorsMatrix::setup_motors(motor_frame_class frame_class, motor_frame_ty
default:
// matrix doesn't support the configured class
success = false;
_mav_type = MAV_TYPE_GENERIC;
break;
} // switch frame_class

2
libraries/AP_Motors/AP_MotorsSingle.cpp

@ -37,6 +37,8 @@ void AP_MotorsSingle::init(motor_frame_class frame_class, motor_frame_type frame @@ -37,6 +37,8 @@ void AP_MotorsSingle::init(motor_frame_class frame_class, motor_frame_type frame
SRV_Channels::set_angle(SRV_Channels::get_motor_function(i), AP_MOTORS_SINGLE_SERVO_INPUT_RANGE);
}
_mav_type = MAV_TYPE_COAXIAL;
// record successful initialisation if what we setup was the desired frame_class
set_initialised_ok(frame_class == MOTOR_FRAME_SINGLE);
}

2
libraries/AP_Motors/AP_MotorsTailsitter.cpp

@ -53,6 +53,8 @@ void AP_MotorsTailsitter::init(motor_frame_class frame_class, motor_frame_type f @@ -53,6 +53,8 @@ void AP_MotorsTailsitter::init(motor_frame_class frame_class, motor_frame_type f
SRV_Channels::set_aux_channel_default(SRV_Channel::k_tiltMotorLeft, CH_4);
SRV_Channels::set_angle(SRV_Channel::k_tiltMotorLeft, SERVO_OUTPUT_RANGE);
_mav_type = MAV_TYPE_COAXIAL;
// record successful initialisation if what we setup was the desired frame_class
set_initialised_ok(frame_class == MOTOR_FRAME_TAILSITTER);
}

2
libraries/AP_Motors/AP_MotorsTri.cpp

@ -54,6 +54,8 @@ void AP_MotorsTri::init(motor_frame_class frame_class, motor_frame_type frame_ty @@ -54,6 +54,8 @@ void AP_MotorsTri::init(motor_frame_class frame_class, motor_frame_type frame_ty
_pitch_reversed = true;
}
_mav_type = MAV_TYPE_TRICOPTER;
// record successful initialisation if what we setup was the desired frame_class
set_initialised_ok(frame_class == MOTOR_FRAME_TRI);
}

4
libraries/AP_Motors/AP_Motors_Class.h

@ -204,6 +204,8 @@ public: @@ -204,6 +204,8 @@ public:
PWM_TYPE_DSHOT1200 = 7};
pwm_type get_pwm_type(void) const { return (pwm_type)_pwm_type.get(); }
MAV_TYPE get_frame_mav_type() const { return _mav_type; }
protected:
// output functions that should be overloaded by child classes
virtual void output_armed_stabilizing() = 0;
@ -265,6 +267,8 @@ protected: @@ -265,6 +267,8 @@ protected:
bool _thrust_balanced; // true when output thrust is well balanced
float _thrust_boost_ratio; // choice between highest and second highest motor output for output mixing (0 ~ 1). Zero is normal operation
MAV_TYPE _mav_type; // MAV_TYPE_GENERIC = 0;
private:
bool _armed; // 0 if disarmed, 1 if armed

Loading…
Cancel
Save