mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 01:18:29 -04:00
Copter: implement safety spin for Tricopters
This commit is contained in:
parent
6477c746cd
commit
b709b90a59
@ -71,23 +71,30 @@ void AP_MotorsTri::output_min()
|
|||||||
// output_armed - sends commands to the motors
|
// output_armed - sends commands to the motors
|
||||||
void AP_MotorsTri::output_armed()
|
void AP_MotorsTri::output_armed()
|
||||||
{
|
{
|
||||||
int16_t out_min = _rc_throttle->radio_min;
|
int16_t out_min = _rc_throttle->radio_min + _min_throttle;
|
||||||
int16_t out_max = _rc_throttle->radio_max;
|
int16_t out_max = _rc_throttle->radio_max;
|
||||||
|
|
||||||
// Throttle is 0 to 1000 only
|
// Throttle is 0 to 1000 only
|
||||||
_rc_throttle->servo_out = constrain_int16(_rc_throttle->servo_out, 0, _max_throttle);
|
_rc_throttle->servo_out = constrain_int16(_rc_throttle->servo_out, 0, _max_throttle);
|
||||||
|
|
||||||
if(_rc_throttle->servo_out > 0)
|
|
||||||
out_min = _rc_throttle->radio_min + _min_throttle;
|
|
||||||
|
|
||||||
// capture desired roll, pitch, yaw and throttle from receiver
|
// capture desired roll, pitch, yaw and throttle from receiver
|
||||||
_rc_roll->calc_pwm();
|
_rc_roll->calc_pwm();
|
||||||
_rc_pitch->calc_pwm();
|
_rc_pitch->calc_pwm();
|
||||||
_rc_throttle->calc_pwm();
|
_rc_throttle->calc_pwm();
|
||||||
_rc_yaw->calc_pwm();
|
_rc_yaw->calc_pwm();
|
||||||
|
|
||||||
int roll_out = (float)_rc_roll->pwm_out * 0.866f;
|
// if we are not sending a throttle output, we cut the motors
|
||||||
int pitch_out = _rc_pitch->pwm_out / 2;
|
if(_rc_throttle->servo_out == 0) {
|
||||||
|
// range check spin_when_armed
|
||||||
|
if (_spin_when_armed < 0) {
|
||||||
|
_spin_when_armed = 0;
|
||||||
|
}
|
||||||
|
motor_out[AP_MOTORS_MOT_1] = _rc_throttle->radio_min + _spin_when_armed;
|
||||||
|
motor_out[AP_MOTORS_MOT_2] = _rc_throttle->radio_min + _spin_when_armed;
|
||||||
|
motor_out[AP_MOTORS_MOT_4] = _rc_throttle->radio_min + _spin_when_armed;
|
||||||
|
}else{
|
||||||
|
int16_t roll_out = (float)_rc_roll->pwm_out * 0.866f;
|
||||||
|
int16_t pitch_out = _rc_pitch->pwm_out / 2;
|
||||||
|
|
||||||
//left front
|
//left front
|
||||||
motor_out[AP_MOTORS_MOT_2] = _rc_throttle->radio_out + roll_out + pitch_out;
|
motor_out[AP_MOTORS_MOT_2] = _rc_throttle->radio_out + roll_out + pitch_out;
|
||||||
@ -126,15 +133,7 @@ void AP_MotorsTri::output_armed()
|
|||||||
motor_out[AP_MOTORS_MOT_1] = max(motor_out[AP_MOTORS_MOT_1], out_min);
|
motor_out[AP_MOTORS_MOT_1] = max(motor_out[AP_MOTORS_MOT_1], out_min);
|
||||||
motor_out[AP_MOTORS_MOT_2] = max(motor_out[AP_MOTORS_MOT_2], out_min);
|
motor_out[AP_MOTORS_MOT_2] = max(motor_out[AP_MOTORS_MOT_2], out_min);
|
||||||
motor_out[AP_MOTORS_MOT_4] = max(motor_out[AP_MOTORS_MOT_4], out_min);
|
motor_out[AP_MOTORS_MOT_4] = max(motor_out[AP_MOTORS_MOT_4], out_min);
|
||||||
|
|
||||||
#if CUT_MOTORS == ENABLED
|
|
||||||
// if we are not sending a throttle output, we cut the motors
|
|
||||||
if(_rc_throttle->servo_out == 0) {
|
|
||||||
motor_out[AP_MOTORS_MOT_1] = _rc_throttle->radio_min;
|
|
||||||
motor_out[AP_MOTORS_MOT_2] = _rc_throttle->radio_min;
|
|
||||||
motor_out[AP_MOTORS_MOT_4] = _rc_throttle->radio_min;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// send output to each motor
|
// send output to each motor
|
||||||
hal.rcout->write(_motor_to_channel_map[AP_MOTORS_MOT_1], motor_out[AP_MOTORS_MOT_1]);
|
hal.rcout->write(_motor_to_channel_map[AP_MOTORS_MOT_1], motor_out[AP_MOTORS_MOT_1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user