private boolean executeBehavior(final AbstractBehavior behavior, double trajectoryTime) throws SimulationExceededMaximumTimeException { final double simulationRunTime = trajectoryTime + EXTRA_SIM_TIME_FOR_SETTLING; if (DEBUG) { System.out.println("\n"); PrintTools.debug( this, "starting behavior: " + behavior.getName() + " t = " + yoTime.getDoubleValue()); } Thread behaviorThread = new Thread() { public void run() { { double startTime = Double.NaN; boolean simStillRunning = true; boolean initalized = false; while (simStillRunning) { if (!initalized) { startTime = yoTime.getDoubleValue(); initalized = true; } double timeSpentSimulating = yoTime.getDoubleValue() - startTime; simStillRunning = timeSpentSimulating < simulationRunTime; robotDataReceiver.updateRobotModel(); behavior.doControl(); } } } }; behaviorThread.start(); boolean ret = drcSimulationTestHelper.simulateAndBlockAndCatchExceptions(simulationRunTime); PrintTools.debug( this, "done with behavior: " + behavior.getName() + " t = " + yoTime.getDoubleValue()); return ret; }
@ContinuousIntegrationTest( estimatedDuration = 50.0, categoriesOverride = IntegrationCategory.EXCLUDE) @Test(timeout = 300000) public void testWalkForwardsX() throws SimulationExceededMaximumTimeException { BambooTools.reportTestStartedMessage(simulationTestingParameters.getShowWindows()); boolean success = drcSimulationTestHelper.simulateAndBlockAndCatchExceptions(1.0); assertTrue(success); double walkDistance = RandomTools.generateRandomDouble(new Random(), 1.0, 2.0); Vector2d walkDirection = new Vector2d(1, 0); double trajectoryTime = walkDistance / ASSUMED_WALKING_SPEED_mPerSec; WalkToGoalBehavior walkToGoalBehavior = testWalkToGoalBehavior(walkDistance, walkDirection, trajectoryTime); assertTrue(walkToGoalBehavior.isDone()); BambooTools.reportTestFinishedMessage(simulationTestingParameters.getShowWindows()); }