mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 17:55:28 +03:00
Fix premature completion of launch sequence
This commit is contained in:
parent
ca923c49da
commit
f44b101888
1 changed files with 31 additions and 23 deletions
|
@ -142,34 +142,42 @@ void applyFixedWingLaunchController(timeUs_t currentTimeUs)
|
||||||
// Called at PID rate
|
// Called at PID rate
|
||||||
|
|
||||||
if (launchState.launchDetected) {
|
if (launchState.launchDetected) {
|
||||||
// If launch detected we are in launch procedure - control airplane
|
bool applyLaunchIdleLogic = true;
|
||||||
const float timeElapsedSinceLaunchMs = US2MS(currentTimeUs- launchState.launchStartedTime);
|
|
||||||
|
|
||||||
// If user moves the stick - finish the launch
|
if (launchState.motorControlAllowed) {
|
||||||
if ((ABS(rcCommand[ROLL]) > rcControlsConfig()->pos_hold_deadband) || (ABS(rcCommand[PITCH]) > rcControlsConfig()->pos_hold_deadband)) {
|
// If launch detected we are in launch procedure - control airplane
|
||||||
launchState.launchFinished = true;
|
const float timeElapsedSinceLaunchMs = US2MS(currentTimeUs - launchState.launchStartedTime);
|
||||||
}
|
|
||||||
|
|
||||||
// Abort launch after a pre-set time
|
// If user moves the stick - finish the launch
|
||||||
if (timeElapsedSinceLaunchMs >= navConfig()->fw.launch_timeout) {
|
if ((ABS(rcCommand[ROLL]) > rcControlsConfig()->pos_hold_deadband) || (ABS(rcCommand[PITCH]) > rcControlsConfig()->pos_hold_deadband)) {
|
||||||
launchState.launchFinished = true;
|
launchState.launchFinished = true;
|
||||||
}
|
|
||||||
|
|
||||||
// Motor control enabled
|
|
||||||
if (launchState.motorControlAllowed && (timeElapsedSinceLaunchMs >= navConfig()->fw.launch_motor_timer)) {
|
|
||||||
// Increase throttle gradually over `launch_motor_spinup_time` milliseconds
|
|
||||||
if (navConfig()->fw.launch_motor_spinup_time > 0) {
|
|
||||||
const float timeSinceMotorStartMs = constrainf(timeElapsedSinceLaunchMs - navConfig()->fw.launch_motor_timer, 0.0f, navConfig()->fw.launch_motor_spinup_time);
|
|
||||||
const uint16_t minIdleThrottle = MAX(motorConfig()->minthrottle, navConfig()->fw.launch_idle_throttle);
|
|
||||||
rcCommand[THROTTLE] = scaleRangef(timeSinceMotorStartMs,
|
|
||||||
0.0f, navConfig()->fw.launch_motor_spinup_time,
|
|
||||||
minIdleThrottle, navConfig()->fw.launch_throttle);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
rcCommand[THROTTLE] = navConfig()->fw.launch_throttle;
|
// Abort launch after a pre-set time
|
||||||
|
if (timeElapsedSinceLaunchMs >= navConfig()->fw.launch_timeout) {
|
||||||
|
launchState.launchFinished = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Motor control enabled
|
||||||
|
if (timeElapsedSinceLaunchMs >= navConfig()->fw.launch_motor_timer) {
|
||||||
|
// Don't apply idle logic anymore
|
||||||
|
applyLaunchIdleLogic = false;
|
||||||
|
|
||||||
|
// Increase throttle gradually over `launch_motor_spinup_time` milliseconds
|
||||||
|
if (navConfig()->fw.launch_motor_spinup_time > 0) {
|
||||||
|
const float timeSinceMotorStartMs = constrainf(timeElapsedSinceLaunchMs - navConfig()->fw.launch_motor_timer, 0.0f, navConfig()->fw.launch_motor_spinup_time);
|
||||||
|
const uint16_t minIdleThrottle = MAX(motorConfig()->minthrottle, navConfig()->fw.launch_idle_throttle);
|
||||||
|
rcCommand[THROTTLE] = scaleRangef(timeSinceMotorStartMs,
|
||||||
|
0.0f, navConfig()->fw.launch_motor_spinup_time,
|
||||||
|
minIdleThrottle, navConfig()->fw.launch_throttle);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rcCommand[THROTTLE] = navConfig()->fw.launch_throttle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (applyLaunchIdleLogic) {
|
||||||
// Launch idle logic - low throttle and zero out PIDs
|
// Launch idle logic - low throttle and zero out PIDs
|
||||||
applyFixedWingLaunchIdleLogic();
|
applyFixedWingLaunchIdleLogic();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue