Skip to content

Commit

Permalink
Plane: Stage control surface wiggles one after another
Browse files Browse the repository at this point in the history
  • Loading branch information
ohitstarik committed Oct 1, 2024
1 parent 9d6190b commit e699cac
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions ArduPlane/servos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,28 +359,41 @@ void ModeAuto::wiggle_servos()
return;
}

int16_t servo_value;
// move over full range for 2 seconds
int16_t servo_valueElevator;
int16_t servo_valueAileronRudder;
// Wiggle the control surfaces in stages: elevators first, then rudders + ailerons, through the full range over 4 seconds
if (wiggle.stage != 0) {
wiggle.stage += 2;
wiggle.stage += 1;
}
if (wiggle.stage == 0) {
servo_value = 0;
} else if (wiggle.stage < 50) {
servo_value = wiggle.stage * (4500 / 50);
servo_valueElevator = 0;
servo_valueAileronRudder = 0;
} else if (wiggle.stage < 25) {
servo_valueElevator = wiggle.stage * (4500 / 25);
servo_valueAileronRudder = 0;
} else if (wiggle.stage < 75) {
servo_valueElevator = (50 - wiggle.stage) * (4500 / 25);
servo_valueAileronRudder = 0;
} else if (wiggle.stage < 100) {
servo_value = (100 - wiggle.stage) * (4500 / 50);
} else if (wiggle.stage < 150) {
servo_value = (100 - wiggle.stage) * (4500 / 50);
servo_valueElevator = (wiggle.stage - 100) * (4500 / 25);
servo_valueAileronRudder = 0;
} else if (wiggle.stage < 125) {
servo_valueElevator = 0;
servo_valueAileronRudder = (wiggle.stage - 100) * (4500 / 25);
} else if (wiggle.stage < 175) {
servo_valueElevator = 0;
servo_valueAileronRudder = (150 - wiggle.stage) * (4500 / 25);
} else if (wiggle.stage < 200) {
servo_value = (wiggle.stage-200) * (4500 / 50);
servo_valueElevator = 0;
servo_valueAileronRudder = (wiggle.stage - 200) * (4500 / 25);
} else {
wiggle.stage = 0;
servo_value = 0;
servo_valueElevator = 0;
servo_valueAileronRudder = 0;
}
SRV_Channels::set_output_scaled(SRV_Channel::k_aileron, servo_value);
SRV_Channels::set_output_scaled(SRV_Channel::k_elevator, servo_value);
SRV_Channels::set_output_scaled(SRV_Channel::k_rudder, servo_value);
SRV_Channels::set_output_scaled(SRV_Channel::k_aileron, servo_valueAileronRudder);
SRV_Channels::set_output_scaled(SRV_Channel::k_elevator, servo_valueElevator);
SRV_Channels::set_output_scaled(SRV_Channel::k_rudder, servo_valueAileronRudder);

}

Expand Down

0 comments on commit e699cac

Please sign in to comment.