@ -67,6 +67,14 @@ const AP_Param::GroupInfo AP_MotorsTri::var_info[] = {
@@ -67,6 +67,14 @@ const AP_Param::GroupInfo AP_MotorsTri::var_info[] = {
// @User: Standard
AP_GROUPINFO ( " YAW_SV_MAX " , 34 , AP_MotorsTri , _yaw_servo_max , 1750 ) ,
// @Param: YAW_SV_ANGLE
// @DisplayName: Yaw Servo Max Lean Angle
// @Description: Yaw servo's maximum lean angle
// @Range: 0 90
// @Units: Degrees
// @Increment: 1
// @User: Standard
AP_GROUPINFO ( " YAW_SV_ANGLE " , 35 , AP_MotorsTri , _yaw_servo_angle_max_deg , 30 ) ,
AP_GROUPEND
} ;
@ -151,7 +159,7 @@ void AP_MotorsTri::output_to_motors()
@@ -151,7 +159,7 @@ void AP_MotorsTri::output_to_motors()
rc_write ( AP_MOTORS_MOT_1 , calc_thrust_to_pwm ( _thrust_right ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_thrust_to_pwm ( _thrust_left ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_thrust_to_pwm ( _thrust_rear ) ) ;
rc_write ( AP_MOTORS_CH_TRI_YAW , calc_yaw_radio_output ( _pivot_angle , _pivot_angle_max ) ) ;
rc_write ( AP_MOTORS_CH_TRI_YAW , calc_yaw_radio_output ( _pivot_angle , radians ( _yaw_servo_angle_max_deg ) ) ) ;
hal . rcout - > push ( ) ;
break ;
}
@ -187,7 +195,7 @@ void AP_MotorsTri::output_armed_stabilizing()
@@ -187,7 +195,7 @@ void AP_MotorsTri::output_armed_stabilizing()
// apply voltage and air pressure compensation
roll_thrust = _roll_in * get_compensation_gain ( ) ;
pitch_thrust = _pitch_in * get_compensation_gain ( ) ;
yaw_thrust = _yaw_in * get_compensation_gain ( ) * sinf ( _pivot_angle_max ) ; // we scale this so a thrust request of 1.0f will ask for full servo deflection at full rear throttle
yaw_thrust = _yaw_in * get_compensation_gain ( ) * sinf ( radians ( _yaw_servo_angle_max_deg ) ) ; // we scale this so a thrust request of 1.0f will ask for full servo deflection at full rear throttle
throttle_thrust = get_throttle ( ) * get_compensation_gain ( ) ;
float pivot_angle_request_max = asin ( yaw_thrust ) ;
float pivot_thrust_max = cosf ( pivot_angle_request_max ) ;
@ -276,17 +284,17 @@ void AP_MotorsTri::output_armed_stabilizing()
@@ -276,17 +284,17 @@ void AP_MotorsTri::output_armed_stabilizing()
if ( is_zero ( _thrust_rear ) ) {
limit . yaw = true ;
if ( yaw_thrust > 0.0f ) {
_pivot_angle = _pivot_angle_max ;
_pivot_angle = radians ( _yaw_servo_angle_max_deg ) ;
} else if ( yaw_thrust < 0.0f ) {
_pivot_angle = - _pivot_angle_max ;
_pivot_angle = - radians ( _yaw_servo_angle_max_deg ) ;
} else {
_pivot_angle = 0.0f ;
}
} else {
_pivot_angle = atan ( yaw_thrust / _thrust_rear ) ;
if ( fabsf ( _pivot_angle ) > _pivot_angle_max ) {
if ( fabsf ( _pivot_angle ) > radians ( _yaw_servo_angle_max_deg ) ) {
limit . yaw = true ;
_pivot_angle = constrain_float ( _pivot_angle , - _pivot_angle_max , _pivot_angle_max ) ;
_pivot_angle = constrain_float ( _pivot_angle , - radians ( _yaw_servo_angle_max_deg ) , radians ( _yaw_servo_angle_max_deg ) ) ;
}
}
// scale pivot thrust to account for pivot angle