private boolean scsContainsTheRobot(SimulationConstructionSet scs, String robotName) { Robot[] robots = scs.getRobots(); boolean ret = false; for (int i = 0; i < robots.length; i++) { ret = ret || robots[i].getName().equals(robotName); } return ret; }
private boolean didSimulationsGetToEndTime(double simulationTime, ArrayList<SimulationConstructionSet> simulationConstructionSets) { double endTime0 = simulationConstructionSets.get(0).getRobots()[0].getTime(); double endTime1 = simulationConstructionSets.get(0).getRobots()[0].getTime(); double errorTime0 = Math.abs(simulationTime - endTime0); double errorTime1 = Math.abs(simulationTime - endTime1); // System.out.println("errorTime0 = " + errorTime0); // System.out.println("errorTime1 = " + errorTime1); if (errorTime0 > 1e-3) return false; if (errorTime1 > 1e-3) return false; return true; }
private FloatingJoint getRootJoint(SimulationConstructionSet scs0) { Joint firstRootJoint = scs0.getRobots()[0].getRootJoints().get(0); if (firstRootJoint instanceof FloatingJoint) return (FloatingJoint) firstRootJoint; throw new RuntimeException("first root joint is not a floating joint: " + firstRootJoint); }
@ContinuousIntegrationTest(estimatedDuration = 1.0) @Test(timeout = 30000) public void testDataExporterGraphCreator() throws IOException { SimulationConstructionSet sim = createSimulation(); TorqueSpeedDataExporterGraphCreator graphCreator = new TorqueSpeedDataExporterGraphCreator(sim.getRobots()[0], sim.getDataBuffer()); File path = new File(System.getProperty("java.io.tmpdir")); Path tmpPath = Files.createTempDirectory(Paths.get(path.getAbsolutePath()), "test"); graphCreator.createJointTorqueSpeedGraphs(tmpPath.toFile(), "", true, true); int fileCount = tmpPath.toFile().listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith("jpg") || name.endsWith("pdf"); } }).length; assertTrue(fileCount > 1); tmpPath.toFile().deleteOnExit(); }
private double getExpectedFinalTime(SimulationConstructionSet scs) { double initialTime = scs.getRobots()[0].getTime(); double recordFreq = scs.getRecordFreq(); double DT = scs.getDT(); return initialTime + recordFreq * DT; }
public FullRobotModelVisualizer(SimulationConstructionSet scs, FullRobotModel fullRobotModel, double updateDT) { this.fullRobot = fullRobotModel; this.scs = scs; this.robot = (FloatingRootJointRobot) scs.getRobots()[0]; this.name = robot.getName() + "Simulated"; this.updateDT = updateDT; this.robotRegistry = robot.getRobotsYoVariableRegistry(); this.setMainRegistry(robotRegistry, fullRobotModel, null); }
public FullRobotModelVisualizer(SimulationConstructionSet scs, FullRobotModel fullRobotModel, double updateDT) { fullRobot = fullRobotModel; this.scs = scs; robot = (FloatingRootJointRobot) scs.getRobots()[0]; name = robot.getName() + "Simulated"; this.updateDT = updateDT; robotRegistry = robot.getRobotsYoVariableRegistry(); rootJoint = fullRobotModel.getRootJoint(); revoluteJoints.clear(); OneDoFJointBasics[] revoluteJointsArray = fullRobotModel.getOneDoFJoints(); for (OneDoFJointBasics revoluteJoint : revoluteJointsArray) { String name = revoluteJoint.getName(); OneDegreeOfFreedomJoint oneDoFJoint = robot.getOneDegreeOfFreedomJoint(name); ImmutablePair<OneDegreeOfFreedomJoint,OneDoFJointBasics> jointPair = new ImmutablePair<OneDegreeOfFreedomJoint, OneDoFJointBasics>(oneDoFJoint, revoluteJoint); revoluteJoints.add(jointPair); } setMainRegistry(robotRegistry, null, null); }
BlockingSimulationRunner.waitForSimulationToFinish(scss.get(0), maximumClockRunTimeInSeconds, true); assertEquals("indices not the same", scss.get(0).getIndex(), scss.get(1).getIndex()); assertEquals("times not the same", scss.get(0).getRobots()[0].getTime(), scss.get(1).getRobots()[0].getTime(), epsilon); boolean result = comparer.compare(scss.get(0), scss.get(1));
Robot robotToUseForTime = simulationConstructionSets.get(0).getRobots()[0]; double time = robotToUseForTime.getTime(); while (!differenceFound && (time < maxSimulationTime))
public void concludeTesting(int additionalStackDepthForRelevantCallingMethod) { if (simulationTestingParameters.getKeepSCSUp()) { ThreadTools.sleepForever(); } if (simulationTestingParameters.getCreateSCSVideos()) { BambooTools.createVideoWithDateTimeClassMethodAndShareOnSharedDriveIfAvailable(scs.getRobots()[0].getName(), scs, additionalStackDepthForRelevantCallingMethod + 1); } ThreadTools.sleep(200); scs.closeAndDispose(); }
assertEquals(numberOfTicksBeforeUpdatingGraphs2, numberOfTicksBeforeUpdatingGraphsFromSCS2); double initialTime = scs.getRobots()[0].getTime(); double DT = scs.getDT(); callSCSMethodSimulateOneTimeStep(scs); double finalTime = scs.getRobots()[0].getTime(); assertEquals(initialTime + DT, finalTime, epsilon); double finalTime2 = scs.getRobots()[0].getTime(); assertEquals(expectedFinalTime2, finalTime2, epsilon); double finalTime3 = scs.getRobots()[0].getTime(); assertEquals(expectedFinalTime3, finalTime3, epsilon);
Robot[] robotFromSCS = scs.getRobots(); assertEquals(simpleRobot, robotFromSCS[0]);
YoVariableRegistry robotsYoVariableRegistry = scs.getRobots()[0].getRobotsYoVariableRegistry(); PlanarRegionsListDefinedEnvironment environment = new PlanarRegionsListDefinedEnvironment("ExamplePlanarRegionsListEnvironment", planarRegionsList, 1e-5, generateGroundPlane);