Browse Source

AP_Motors: add reversed tricopter option

master
IamPete1 6 years ago committed by Andrew Tridgell
parent
commit
3b9a35da27
  1. 17
      libraries/AP_Motors/AP_MotorsTri.cpp
  2. 3
      libraries/AP_Motors/AP_MotorsTri.h

17
libraries/AP_Motors/AP_MotorsTri.cpp

@ -51,6 +51,11 @@ void AP_MotorsTri::init(motor_frame_class frame_class, motor_frame_type frame_ty @@ -51,6 +51,11 @@ void AP_MotorsTri::init(motor_frame_class frame_class, motor_frame_type frame_ty
// allow mapping of motor7
add_motor_num(AP_MOTORS_CH_TRI_YAW);
// check for reverse tricopter
if (frame_type == MOTOR_FRAME_TYPE_PLUSREV) {
_pitch_reversed = true;
}
// record successful initialisation if what we setup was the desired frame_class
_flags.initialised_ok = (frame_class == MOTOR_FRAME_TRI);
}
@ -58,6 +63,13 @@ void AP_MotorsTri::init(motor_frame_class frame_class, motor_frame_type frame_ty @@ -58,6 +63,13 @@ void AP_MotorsTri::init(motor_frame_class frame_class, motor_frame_type frame_ty
// set frame class (i.e. quad, hexa, heli) and type (i.e. x, plus)
void AP_MotorsTri::set_frame_class_and_type(motor_frame_class frame_class, motor_frame_type frame_type)
{
// check for reverse tricopter
if (frame_type == MOTOR_FRAME_TYPE_PLUSREV) {
_pitch_reversed = true;
} else {
_pitch_reversed = false;
}
_flags.initialised_ok = (frame_class == MOTOR_FRAME_TRI);
}
@ -153,6 +165,11 @@ void AP_MotorsTri::output_armed_stabilizing() @@ -153,6 +165,11 @@ void AP_MotorsTri::output_armed_stabilizing()
throttle_thrust = get_throttle() * compensation_gain;
throttle_avg_max = _throttle_avg_max * compensation_gain;
// check for reversed pitch
if (_pitch_reversed) {
pitch_thrust *= -1.0f;
}
// calculate angle of yaw pivot
_pivot_angle = safe_asin(yaw_thrust);
if (fabsf(_pivot_angle) > radians(_yaw_servo_angle_max_deg)) {

3
libraries/AP_Motors/AP_MotorsTri.h

@ -71,4 +71,7 @@ protected: @@ -71,4 +71,7 @@ protected:
float _thrust_right;
float _thrust_rear;
float _thrust_left;
// reverse pitch
bool _pitch_reversed;
};

Loading…
Cancel
Save