public static Point3D nextPoint3DWithEdgeCases(Random random, double probabilityForEdgeCase) { double x = RandomNumbers.nextDouble(random, probabilityForEdgeCase); double y = RandomNumbers.nextDouble(random, probabilityForEdgeCase); double z = RandomNumbers.nextDouble(random, probabilityForEdgeCase); return new Point3D(x, y, z); }
public static FootstepPlannerType generateRandomPlannerType(Random random) { return values[RandomNumbers.nextInt(random, 0, values.length - 1)]; }
public static HandJointAnglePacket nextHandJointAnglePacket(Random random) { HandJointAnglePacket next = new HandJointAnglePacket(); next.setRobotSide(RandomNumbers.nextEnum(random, RobotSide.class).toByte()); next.getJointAngles().add(RandomNumbers.nextDoubleArray(random, random.nextInt(1000), 1.0)); next.setConnected(random.nextBoolean()); next.setCalibrated(random.nextBoolean()); return next; }
public static GoHomeMessage nextGoHomeMessage(Random random) { GoHomeMessage next = new GoHomeMessage(); next.setHumanoidBodyPart(RandomNumbers.nextEnum(random, HumanoidBodyPart.class).toByte()); next.setRobotSide(RandomNumbers.nextEnum(random, RobotSide.class).toByte()); next.setTrajectoryTime(RandomNumbers.nextDoubleWithEdgeCases(random, 0.01)); return next; }
public static HeatMapPacket nextHeatMapPacket(Random random) { HeatMapPacket next = new HeatMapPacket(); next.setHeight(RandomNumbers.nextInt(random, -100, 100)); next.setWidth(RandomNumbers.nextInt(random, -100, 100)); next.getData().add(RandomNumbers.nextFloatArray(random, next.getHeight() * next.getWidth(), 1.0f)); next.setName(Integer.toHexString(random.nextInt())); return next; }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testScaleTranspose() throws Exception { Random random = new Random(165156L); for (int i = 0; i < 200; i++) { int numRows = RandomNumbers.nextInt(random, 1, 100); int numCols = RandomNumbers.nextInt(random, 1, 100); DenseMatrix64F randomMatrix = RandomMatrices.createRandom(numRows, numCols, 1.0, 100.0, random); double randomAlpha = RandomNumbers.nextDouble(random, 100.0); DenseMatrix64F expectedMatrix = new DenseMatrix64F(numCols, numRows); DenseMatrix64F actualMatrix = new DenseMatrix64F(numCols, numRows); CommonOps.transpose(randomMatrix, expectedMatrix); CommonOps.scale(randomAlpha, expectedMatrix); MatrixTools.scaleTranspose(randomAlpha, randomMatrix, actualMatrix); boolean areMatricesEqual = MatrixFeatures.isEquals(expectedMatrix, actualMatrix, 1.0e-10); assertTrue(areMatricesEqual); } }
private AngularMomentumTrajectory generateRandomAngularMomentumTrajectory(Random random, int numberOfSegments, int numberOfCoefficients) { AngularMomentumTrajectory trajectoryToSet = new AngularMomentumTrajectory(numberOfSegments, numberOfCoefficients); for (int i = 0; i < trajectoryToSet.getMaxNumberOfSegments(); i++) { FrameTrajectory3D randomTrajectory = trajectoryToSet.add(); randomTrajectory.getTrajectoryX().setDirectly(RandomNumbers.nextDoubleArray(random, numberOfCoefficients, 10.0)); randomTrajectory.getTrajectoryY().setDirectly(RandomNumbers.nextDoubleArray(random, numberOfCoefficients, 10.0)); randomTrajectory.getTrajectoryZ().setDirectly(RandomNumbers.nextDoubleArray(random, numberOfCoefficients, 10.0)); double startTime = RandomNumbers.nextDouble(random, 10.0); double duration = RandomNumbers.nextDouble(random, 0.0, 100.0); randomTrajectory.setInitialTime(startTime); randomTrajectory.setFinalTime(startTime + duration); } return trajectoryToSet; } }
@ContinuousIntegrationTest(estimatedDuration = 0.1) @Test(timeout = 30000) public void testWithFixedSizeDoubleArrays() throws Exception { for (int i = 0; i < 100; i++) { YoVariableRegistry registry = new YoVariableRegistry("Blop"); Random random = new Random(6541654L); int windowSize = RandomNumbers.nextInt(random, 1, 1000); SimpleMovingAverageFilteredYoVariable sma = new SimpleMovingAverageFilteredYoVariable("tested", windowSize, registry); double amplitude = 100.0; double[] randomArray = RandomNumbers.nextDoubleArray(random, windowSize, amplitude); double expected = 0.0; for (double val : randomArray) expected += val / windowSize; for (int j = 0; j < randomArray.length; j++) { assertFalse(sma.getHasBufferWindowFilled()); sma.update(randomArray[j]); } assertTrue(sma.getHasBufferWindowFilled()); assertEquals(expected, sma.getDoubleValue(), 1.0e-10); } } }
public static IntrinsicParametersMessage nextIntrinsicParametersMessage(Random random) { IntrinsicParametersMessage next = new IntrinsicParametersMessage(); next.setWidth(random.nextInt()); next.setHeight(random.nextInt()); next.setFx(random.nextDouble()); next.setFy(random.nextDouble()); next.setSkew(random.nextDouble()); next.setCx(random.nextDouble()); next.setCy(random.nextDouble()); next.getRadial().add(RandomNumbers.nextDoubleArray(random, random.nextInt(1000), 1.0)); next.setT1(random.nextDouble()); next.setT2(random.nextDouble()); return next; }
public static TrajectoryPoint1DMessage nextTrajectoryPoint1DMessage(Random random) { TrajectoryPoint1DMessage next = new TrajectoryPoint1DMessage(); next.setTime(RandomNumbers.nextDoubleWithEdgeCases(random, 0.01)); next.setPosition(RandomNumbers.nextDoubleWithEdgeCases(random, 0.01)); next.setVelocity(RandomNumbers.nextDoubleWithEdgeCases(random, 0.01)); return next; }
@ContinuousIntegrationTest(estimatedDuration = 0.1) @Test(timeout = 30000) public void testReset() { Random random = new Random(10L); for (int i = 0; i < 1000; i++) { int size = RandomNumbers.nextInt(random, 1, 200); int numberOfConstraints = RandomNumbers.nextInt(random, 1, 200); ICPInequalityInput input = new ICPInequalityInput(numberOfConstraints, size); CommonOps.fill(input.Aineq, RandomNumbers.nextDouble(random, -1000.0, 1000.0)); CommonOps.fill(input.bineq, RandomNumbers.nextDouble(random, -1000.0, 1000.0)); Assert.assertNotEquals(CommonOps.elementSum(input.Aineq), 0.0, 1e-7); Assert.assertNotEquals(CommonOps.elementSum(input.bineq), 0.0, 1e-7); input.reset(); Assert.assertEquals(CommonOps.elementSum(input.Aineq), 0.0, 1e-7); Assert.assertEquals(CommonOps.elementSum(input.bineq), 0.0, 1e-7); } }
public static QueueableMessage nextQueueableMessage(Random random) { QueueableMessage next = new QueueableMessage(); next.setExecutionMode(RandomNumbers.nextEnum(random, ExecutionMode.class).toByte()); next.setPreviousMessageId(random.nextLong()); next.setExecutionDelayTime(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); return next; }
public static DesiredAccelerationsMessage nextDesiredAccelerationsMessage(Random random) { DesiredAccelerationsMessage next = new DesiredAccelerationsMessage(); next.getDesiredJointAccelerations().add(RandomNumbers.nextDoubleArray(random, random.nextInt(16) + 1, 1.0)); next.getQueueingProperties().set(nextQueueableMessage(random)); return next; }
public static WeightMatrix3DMessage nextWeightMatrix3DMessage(Random random) { WeightMatrix3DMessage next = new WeightMatrix3DMessage(); next.setWeightFrameId(random.nextLong()); next.setXWeight(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); next.setYWeight(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); next.setZWeight(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); return next; }
public static Point3D nextPoint3D(Random random, double min, double max) { double x = RandomNumbers.nextDouble(random, min, max); double y = RandomNumbers.nextDouble(random, min, max); double z = RandomNumbers.nextDouble(random, min, max); return new Point3D(x, y, z); }
@ContinuousIntegrationTest(estimatedDuration = 0.5) @Test(timeout = 40000) public void testRandomMultAddInner() { Random random = new Random(124L); int iters = 100; for (int i = 0; i < iters; i++) { int variables = RandomNumbers.nextInt(random, 1, 100); int taskSize = RandomNumbers.nextInt(random, 1, 100); double scale = RandomNumbers.nextDouble(random, 100.0); DenseMatrix64F randomMatrix = RandomMatrices.createRandom(taskSize, variables, -50.0, 50.0, random); DenseMatrix64F solution = RandomMatrices.createRandom(variables, variables, -50, 50, random); DenseMatrix64F expectedSolution = new DenseMatrix64F(solution); DenseMatrix64F tempJtW = new DenseMatrix64F(variables, taskSize); CommonOps.transpose(randomMatrix, tempJtW); CommonOps.multAdd(scale, tempJtW, randomMatrix, expectedSolution); MatrixTools.multAddInner(scale, randomMatrix, solution); JUnitTools.assertMatrixEquals(expectedSolution, solution, 1e-6); } } }
public static FootstepPlanningResult generateRandomResult(Random random) { return values[RandomNumbers.nextInt(random, 0, values.length - 1)]; }
private static FootstepDataListMessage nextFootstepDataListMessage(Random random) { FootstepDataListMessage next = new FootstepDataListMessage(); MessageTools.copyData(nextFootstepDataMessages(random), next.getFootstepDataList()); next.setExecutionTiming(RandomNumbers.nextEnum(random, ExecutionTiming.class).toByte()); next.setDefaultSwingDuration(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); next.setDefaultTransferDuration(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); next.setFinalTransferDuration(RandomNumbers.nextDoubleWithEdgeCases(random, 0.1)); next.setTrustHeightOfFootsteps(random.nextBoolean()); next.setAreFootstepsAdjustable(random.nextBoolean()); next.setOffsetFootstepsWithExecutionError(random.nextBoolean()); return next; }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void test() { Random random = new Random(); ReferenceFrame worldFrame = ReferenceFrame.getWorldFrame(); double[] xyz = RandomNumbers.nextDoubleArray(random, 3, Double.MAX_VALUE); FramePoint3D positionExpected = new FramePoint3D(worldFrame, xyz); FramePoint3D positionActual = new FramePoint3D(positionExpected); ConstantPositionProvider constantPositionProvider = new ConstantPositionProvider(positionActual); constantPositionProvider.getPosition(positionActual); assertTrue(positionActual.epsilonEquals(positionExpected, EPS)); }
public SO3TrajectoryControllerCommand(Random random) { int randomNumberOfPoints = random.nextInt(16) + 1; for (int i = 0; i < randomNumberOfPoints; i++) { trajectoryPointList.addTrajectoryPoint(RandomNumbers.nextDoubleWithEdgeCases(random, 0.01), RandomGeometry.nextQuaternion(random), RandomGeometry.nextVector3D(random)); } trajectoryFrame = EuclidFrameRandomTools.nextReferenceFrame("trajectoryFrame", random, ReferenceFrame.getWorldFrame()); controlFramePoseInBodyFrame.set(RandomGeometry.nextQuaternion(random), RandomGeometry.nextVector3D(random)); useCustomControlFrame = random.nextBoolean(); }