Merge pull request #721 from JoePfeiffer/fix-718

Assure rocket has left the ground before it is considered as having cleared launch rod
This commit is contained in:
Joe Pfeiffer 2020-07-29 10:05:19 -06:00 committed by GitHub
commit 2e14aa8b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,6 +162,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// Avoid sinking into ground before liftoff // Avoid sinking into ground before liftoff
if (relativePosition.z < 0) { if (relativePosition.z < 0) {
currentStatus.setRocketPosition(origin); currentStatus.setRocketPosition(origin);
relativePosition = Coordinate.ZERO;
currentStatus.setRocketVelocity(originVelocity); currentStatus.setRocketVelocity(originVelocity);
} }
// Detect lift-off // Detect lift-off
@ -181,7 +182,8 @@ public class BasicEventSimulationEngine implements SimulationEngine {
} }
// Check for launch guide clearance // Check for launch guide clearance
if (!currentStatus.isLaunchRodCleared() && if (currentStatus.isLiftoff() &&
!currentStatus.isLaunchRodCleared() &&
relativePosition.length() > currentStatus.getSimulationConditions().getLaunchRodLength()) { relativePosition.length() > currentStatus.getSimulationConditions().getLaunchRodLength()) {
addEvent(new FlightEvent(FlightEvent.Type.LAUNCHROD, currentStatus.getSimulationTime(), null)); addEvent(new FlightEvent(FlightEvent.Type.LAUNCHROD, currentStatus.getSimulationTime(), null));
} }