Skip to content

Commit

Permalink
AP_Motors: smoother ramp down in output_motor_mask
Browse files Browse the repository at this point in the history
stop changing motors outside the given mask in output_motor_mask,
which gives smoother ramp down in tilt quadplanes when we are
transitioning to forward flight

thanks to Pete for the suggestion
  • Loading branch information
tridge committed Mar 5, 2024
1 parent 2b784e0 commit 171da3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions libraries/AP_Motors/AP_MotorsMulticopter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,20 +733,21 @@ void AP_MotorsMulticopter::output_motor_mask(float thrust, uint16_t mask, float
_motor_mask_override = mask;

for (uint8_t i = 0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) {
if (motor_enabled[i]) {
if ((mask & (1U << i)) && armed() && get_interlock()) {
if (motor_enabled[i] && (mask & (1U << i)) != 0) {
if (armed() && get_interlock()) {
/*
apply rudder mixing differential thrust
copter frame roll is plane frame yaw as this only
apples to either tilted motors or tailsitters
*/
float diff_thrust = get_roll_factor(i) * rudder_dt * 0.5f;
set_actuator_with_slew(_actuator[i], thrust + diff_thrust);
int16_t pwm_output = pwm_min + pwm_range * _actuator[i];
rc_write(i, pwm_output);
} else {
rc_write(i, pwm_min);
// zero throttle
_actuator[i] = 0.0;
}
int16_t pwm_output = pwm_min + pwm_range * _actuator[i];
rc_write(i, pwm_output);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_Motors/AP_MotorsTri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void AP_MotorsTri::output_to_motors()
// sends minimum values out to the motors
for (uint8_t i = 0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) {
if (motor_enabled_mask(i)) {
rc_write(AP_MOTORS_MOT_1+i, output_to_pwm(0));
_actuator[AP_MOTORS_MOT_1+i] = 0;
}
}
rc_write_angle(AP_MOTORS_CH_TRI_YAW, 0);
Expand Down

0 comments on commit 171da3d

Please sign in to comment.