Merge pull request #2591 from JoePfeiffer/clamp-acceleration

Don't let vertical acceleration be negative before liftoff.
This commit is contained in:
Joe Pfeiffer 2024-11-14 10:01:07 -07:00 committed by GitHub
commit 4b2132cc4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -347,10 +347,17 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
store.coriolisAcceleration = status.getSimulationConditions().getGeodeticComputation()
.getCoriolisAcceleration(status.getRocketWorldPosition(), status.getRocketVelocity());
linearAcceleration = linearAcceleration.add(store.coriolisAcceleration);
// If still on the launch rod, project acceleration onto launch rod direction and
// set angular acceleration to zero.
if (!status.isLaunchRodCleared()) {
// If we haven't taken off yet, don't sink into the ground
if (!status.isLiftoff()) {
angularAcceleration = Coordinate.NUL;
if (linearAcceleration.z < 0) {
linearAcceleration = Coordinate.ZERO;
}
} else if (!status.isLaunchRodCleared()) {
// If still on the launch rod, project acceleration onto launch rod direction and
// set angular acceleration to zero.
linearAcceleration = store.launchRodDirection.multiply(linearAcceleration.dot(store.launchRodDirection));
angularAcceleration = Coordinate.NUL;