diff --git a/flight/modules/Stabilization/altitudeloop.c b/flight/modules/Stabilization/altitudeloop.c index 329990d0e..f54ed5740 100644 --- a/flight/modules/Stabilization/altitudeloop.c +++ b/flight/modules/Stabilization/altitudeloop.c @@ -163,11 +163,13 @@ static void altitudeHoldTask(void) dT = PIOS_DELTATIME_GetAverageSeconds(&timeval); switch (thrustMode) { case ALTITUDEHOLD: + { // altitude control loop // No scaling. - pid_scaler scaler = { .p = 1.0f, .i = 1.0f, .d = 1.0f }; + const pid_scaler scaler = { .p = 1.0f, .i = 1.0f, .d = 1.0f }; altitudeHoldStatus.VelocityDesired = pid_apply_setpoint(&pid0, &scaler, thrustSetpoint, positionStateDown, dT); - break; + } + break; case ALTITUDEVARIO: altitudeHoldStatus.VelocityDesired = thrustSetpoint; break; @@ -183,12 +185,13 @@ static void altitudeHoldTask(void) thrustDemand = thrustSetpoint; break; default: + { // velocity control loop // No scaling. - pid_scaler scaler = { .p = 1.0f, .i = 1.0f, .d = 1.0f }; + const pid_scaler scaler = { .p = 1.0f, .i = 1.0f, .d = 1.0f }; thrustDemand = startThrust - pid_apply_setpoint(&pid1, &scaler, altitudeHoldStatus.VelocityDesired, velocityStateDown, dT); - - break; + } + break; } }