mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-23 09:08:30 -04:00
AP_MotorsSingle: use calc_pwm_output_1to1 instead of local calc_pivot_radio_output
This commit is contained in:
parent
ef5dbae707
commit
af9b18329c
@ -135,10 +135,10 @@ void AP_MotorsSingle::output_to_motors()
|
|||||||
case SHUT_DOWN:
|
case SHUT_DOWN:
|
||||||
// sends minimum values out to the motors
|
// sends minimum values out to the motors
|
||||||
hal.rcout->cork();
|
hal.rcout->cork();
|
||||||
rc_write(AP_MOTORS_MOT_1, calc_pivot_radio_output(constrain_float(_roll_radio_passthrough+_yaw_radio_passthrough, -1.0f, 1.0f), _servo1));
|
rc_write(AP_MOTORS_MOT_1, calc_pwm_output_1to1(_roll_radio_passthrough+_yaw_radio_passthrough, _servo1));
|
||||||
rc_write(AP_MOTORS_MOT_2, calc_pivot_radio_output(constrain_float(_pitch_radio_passthrough+_yaw_radio_passthrough, -1.0f, 1.0f), _servo2));
|
rc_write(AP_MOTORS_MOT_2, calc_pwm_output_1to1(_pitch_radio_passthrough+_yaw_radio_passthrough, _servo2));
|
||||||
rc_write(AP_MOTORS_MOT_3, calc_pivot_radio_output(constrain_float(-_roll_radio_passthrough+_yaw_radio_passthrough, -1.0f, 1.0f), _servo3));
|
rc_write(AP_MOTORS_MOT_3, calc_pwm_output_1to1(-_roll_radio_passthrough+_yaw_radio_passthrough, _servo3));
|
||||||
rc_write(AP_MOTORS_MOT_4, calc_pivot_radio_output(constrain_float(-_pitch_radio_passthrough+_yaw_radio_passthrough, -1.0f, 1.0f), _servo4));
|
rc_write(AP_MOTORS_MOT_4, calc_pwm_output_1to1(-_pitch_radio_passthrough+_yaw_radio_passthrough, _servo4));
|
||||||
rc_write(AP_MOTORS_MOT_5, _throttle_radio_min);
|
rc_write(AP_MOTORS_MOT_5, _throttle_radio_min);
|
||||||
rc_write(AP_MOTORS_MOT_6, _throttle_radio_min);
|
rc_write(AP_MOTORS_MOT_6, _throttle_radio_min);
|
||||||
hal.rcout->push();
|
hal.rcout->push();
|
||||||
@ -146,10 +146,10 @@ void AP_MotorsSingle::output_to_motors()
|
|||||||
case SPIN_WHEN_ARMED:
|
case SPIN_WHEN_ARMED:
|
||||||
// sends output to motors when armed but not flying
|
// sends output to motors when armed but not flying
|
||||||
hal.rcout->cork();
|
hal.rcout->cork();
|
||||||
rc_write(AP_MOTORS_MOT_1, calc_pivot_radio_output(_throttle_low_end_pct * _actuator_out[0], _servo1));
|
rc_write(AP_MOTORS_MOT_1, calc_pwm_output_1to1(_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_2, calc_pwm_output_1to1(_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_3, calc_pwm_output_1to1(_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_4, calc_pwm_output_1to1(_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_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));
|
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();
|
hal.rcout->push();
|
||||||
@ -159,10 +159,10 @@ void AP_MotorsSingle::output_to_motors()
|
|||||||
case SPOOL_DOWN:
|
case SPOOL_DOWN:
|
||||||
// set motor output based on thrust requests
|
// set motor output based on thrust requests
|
||||||
hal.rcout->cork();
|
hal.rcout->cork();
|
||||||
rc_write(AP_MOTORS_MOT_1, calc_pivot_radio_output(_actuator_out[0], _servo1));
|
rc_write(AP_MOTORS_MOT_1, calc_pwm_output_1to1(_actuator_out[0], _servo1));
|
||||||
rc_write(AP_MOTORS_MOT_2, calc_pivot_radio_output(_actuator_out[1], _servo2));
|
rc_write(AP_MOTORS_MOT_2, calc_pwm_output_1to1(_actuator_out[1], _servo2));
|
||||||
rc_write(AP_MOTORS_MOT_3, calc_pivot_radio_output(_actuator_out[2], _servo3));
|
rc_write(AP_MOTORS_MOT_3, calc_pwm_output_1to1(_actuator_out[2], _servo3));
|
||||||
rc_write(AP_MOTORS_MOT_4, calc_pivot_radio_output(_actuator_out[3], _servo4));
|
rc_write(AP_MOTORS_MOT_4, calc_pwm_output_1to1(_actuator_out[3], _servo4));
|
||||||
rc_write(AP_MOTORS_MOT_5, calc_thrust_to_pwm(_thrust_out));
|
rc_write(AP_MOTORS_MOT_5, calc_thrust_to_pwm(_thrust_out));
|
||||||
rc_write(AP_MOTORS_MOT_6, calc_thrust_to_pwm(_thrust_out));
|
rc_write(AP_MOTORS_MOT_6, calc_thrust_to_pwm(_thrust_out));
|
||||||
hal.rcout->push();
|
hal.rcout->push();
|
||||||
@ -347,21 +347,3 @@ void AP_MotorsSingle::output_test(uint8_t motor_seq, int16_t pwm)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// calc_yaw_radio_output - calculate final radio output for yaw channel
|
|
||||||
int16_t AP_MotorsSingle::calc_pivot_radio_output(float yaw_input, const RC_Channel& servo)
|
|
||||||
{
|
|
||||||
int16_t ret;
|
|
||||||
|
|
||||||
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.radio_trim - servo.radio_min)) + servo.radio_trim);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
@ -63,9 +63,6 @@ protected:
|
|||||||
// output - sends commands to the motors
|
// output - sends commands to the motors
|
||||||
void output_armed_stabilizing();
|
void output_armed_stabilizing();
|
||||||
|
|
||||||
// calc_yaw_radio_output - calculate final pwm output for yaw channel
|
|
||||||
int16_t calc_pivot_radio_output(float yaw_input, const RC_Channel& servo);
|
|
||||||
|
|
||||||
// servo speed
|
// servo speed
|
||||||
AP_Int16 _servo_speed;
|
AP_Int16 _servo_speed;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user