@ -59,6 +59,19 @@ const AP_Param::GroupInfo AP_MotorsCoax::var_info[] = {
@@ -59,6 +59,19 @@ const AP_Param::GroupInfo AP_MotorsCoax::var_info[] = {
// @Units: Hz
AP_GROUPINFO ( " SV_SPEED " , 43 , AP_MotorsCoax , _servo_speed , AP_MOTORS_SINGLE_SPEED_DIGITAL_SERVOS ) ,
// @Group: SV1_
// @Path: ../RC_Channel/RC_Channel.cpp
AP_SUBGROUPINFO ( _servo1 , " SV1_ " , 44 , AP_MotorsCoax , RC_Channel ) ,
// @Group: SV2_
// @Path: ../RC_Channel/RC_Channel.cpp
AP_SUBGROUPINFO ( _servo2 , " SV2_ " , 45 , AP_MotorsCoax , RC_Channel ) ,
// @Group: SV3_
// @Path: ../RC_Channel/RC_Channel.cpp
AP_SUBGROUPINFO ( _servo3 , " SV3_ " , 46 , AP_MotorsCoax , RC_Channel ) ,
// @Group: SV4_
// @Path: ../RC_Channel/RC_Channel.cpp
AP_SUBGROUPINFO ( _servo4 , " SV4_ " , 47 , AP_MotorsCoax , RC_Channel ) ,
AP_GROUPEND
} ;
// init
@ -136,10 +149,10 @@ void AP_MotorsCoax::output_to_motors()
@@ -136,10 +149,10 @@ void AP_MotorsCoax::output_to_motors()
case SHUT_DOWN :
// sends minimum values out to the motors
hal . rcout - > cork ( ) ;
rc_write ( AP_MOTORS_MOT_1 , calc_pivot_radio_output ( _roll_radio_passthrough * _servo_1_reverse , _servo_ 1_min , _servo_1_trim , _servo_1_max ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_pivot_radio_output ( _pitch_radio_passthrough * _servo_2_reverse , _servo_ 2_min , _servo_2_trim , _servo_2_max ) ) ;
rc_write ( AP_MOTORS_MOT_3 , calc_pivot_radio_output ( _roll_radio_passthrough * _servo_3_reverse , _servo_ 3_min , _servo_3_trim , _servo_3_max ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_pivot_radio_output ( _pitch_radio_passthrough * _servo_4_reverse , _servo_ 4_min , _servo_4_trim , _servo_4_max ) ) ;
rc_write ( AP_MOTORS_MOT_1 , calc_pivot_radio_output ( _roll_radio_passthrough , _servo1 ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_pivot_radio_output ( _pitch_radio_passthrough , _servo2 ) ) ;
rc_write ( AP_MOTORS_MOT_3 , calc_pivot_radio_output ( _roll_radio_passthrough , _servo3 ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_pivot_radio_output ( _pitch_radio_passthrough , _servo4 ) ) ;
rc_write ( AP_MOTORS_MOT_5 , _throttle_radio_min ) ;
rc_write ( AP_MOTORS_MOT_6 , _throttle_radio_min ) ;
hal . rcout - > push ( ) ;
@ -147,10 +160,10 @@ void AP_MotorsCoax::output_to_motors()
@@ -147,10 +160,10 @@ void AP_MotorsCoax::output_to_motors()
case SPIN_WHEN_ARMED :
// sends output to motors when armed but not flying
hal . rcout - > cork ( ) ;
rc_write ( AP_MOTORS_MOT_1 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 0 ] * _servo_1_reverse , _servo_ 1_min , _servo_1_trim , _servo_1_max ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 1 ] * _servo_2_reverse , _servo_ 2_min , _servo_2_trim , _servo_2_max ) ) ;
rc_write ( AP_MOTORS_MOT_3 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 2 ] * _servo_3_reverse , _servo_ 3_min , _servo_3_trim , _servo_3_max ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 3 ] * _servo_4_reverse , _servo_ 4_min , _servo_4_trim , _servo_4_max ) ) ;
rc_write ( AP_MOTORS_MOT_1 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 0 ] , _servo1 ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 1 ] , _servo2 ) ) ;
rc_write ( AP_MOTORS_MOT_3 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 2 ] , _servo3 ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_pivot_radio_output ( _throttle_low_end_pct * _actuator_out [ 3 ] , _servo4 ) ) ;
rc_write ( AP_MOTORS_MOT_5 , constrain_int16 ( _throttle_radio_min + _throttle_low_end_pct * _min_throttle , _throttle_radio_min , _throttle_radio_min + _min_throttle ) ) ;
rc_write ( AP_MOTORS_MOT_6 , constrain_int16 ( _throttle_radio_min + _throttle_low_end_pct * _min_throttle , _throttle_radio_min , _throttle_radio_min + _min_throttle ) ) ;
hal . rcout - > push ( ) ;
@ -160,10 +173,10 @@ void AP_MotorsCoax::output_to_motors()
@@ -160,10 +173,10 @@ void AP_MotorsCoax::output_to_motors()
case SPOOL_DOWN :
// set motor output based on thrust requests
hal . rcout - > cork ( ) ;
rc_write ( AP_MOTORS_MOT_1 , calc_pivot_radio_output ( _actuator_out [ 0 ] * _servo_1_reverse , _servo_ 1_min , _servo_1_trim , _servo_1_max ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_pivot_radio_output ( _actuator_out [ 1 ] * _servo_2_reverse , _servo_ 2_min , _servo_2_trim , _servo_2_max ) ) ;
rc_write ( AP_MOTORS_MOT_3 , calc_pivot_radio_output ( _actuator_out [ 2 ] * _servo_3_reverse , _servo_ 3_min , _servo_3_trim , _servo_3_max ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_pivot_radio_output ( _actuator_out [ 3 ] * _servo_4_reverse , _servo_ 4_min , _servo_4_trim , _servo_4_max ) ) ;
rc_write ( AP_MOTORS_MOT_1 , calc_pivot_radio_output ( _actuator_out [ 0 ] , _servo1 ) ) ;
rc_write ( AP_MOTORS_MOT_2 , calc_pivot_radio_output ( _actuator_out [ 1 ] , _servo2 ) ) ;
rc_write ( AP_MOTORS_MOT_3 , calc_pivot_radio_output ( _actuator_out [ 2 ] , _servo3 ) ) ;
rc_write ( AP_MOTORS_MOT_4 , calc_pivot_radio_output ( _actuator_out [ 3 ] , _servo4 ) ) ;
rc_write ( AP_MOTORS_MOT_5 , calc_thrust_to_pwm ( _thrust_yt_ccw ) ) ;
rc_write ( AP_MOTORS_MOT_6 , calc_thrust_to_pwm ( _thrust_yt_cw ) ) ;
hal . rcout - > push ( ) ;
@ -338,14 +351,18 @@ void AP_MotorsCoax::output_test(uint8_t motor_seq, int16_t pwm)
@@ -338,14 +351,18 @@ void AP_MotorsCoax::output_test(uint8_t motor_seq, int16_t pwm)
}
// calc_yaw_radio_output - calculate final radio output for yaw channel
int16_t AP_MotorsCoax : : calc_pivot_radio_output ( float yaw_input , int16_t servo_min , int16_t servo_trim , int16_t servo_max )
int16_t AP_MotorsCoax : : calc_pivot_radio_output ( float yaw_input , const RC_Channel & servo )
{
int16_t ret ;
if ( yaw_input > = 0 ) {
ret = ( ( yaw_input * ( servo_max - servo_trim ) ) + servo_trim ) ;
if ( servo . get_reverse ( ) ) {
yaw_input = - yaw_input ;
}
if ( yaw_input > = 0.0f ) {
ret = ( ( yaw_input * ( servo . radio_max - servo . radio_trim ) ) + servo . radio_trim ) ;
} else {
ret = ( ( yaw_input * ( servo_trim - servo_min ) ) + servo_trim ) ;
ret = ( ( yaw_input * ( servo . radio _trim - servo . radio _min) ) + servo . radi o_trim ) ;
}
return ret ;