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 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 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; }
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.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)); }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testRemoveNullspaceComponent() { int matrixSize = 10; boolean makeLargestComponentPositive = true; SVDNullspaceCalculator nullspaceCalculator = new SVDNullspaceCalculator(matrixSize, makeLargestComponentPositive); Random random = new Random(); double[] singularValues = RandomNumbers.nextDoubleArray(random, matrixSize, 1.0, 2.0); // singularValues[0] = 0.0; DenseMatrix64F matrix = RandomMatrices.createSingularValues(matrixSize, matrixSize, random, singularValues); nullspaceCalculator.setMatrix(matrix, 1); DenseMatrix64F nullspace = nullspaceCalculator.getNullspace(); DenseMatrix64F matrixCopy = new DenseMatrix64F(matrix); nullspaceCalculator.removeNullspaceComponent(matrixCopy); assertTrue(isNullspaceComponentZero(matrixCopy, nullspace)); }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testRemoveNullspaceComponent2() { int matrixSize = 6; boolean makeLargestComponentPositive = true; SVDNullspaceCalculator nullspaceCalculator = new SVDNullspaceCalculator(matrixSize, makeLargestComponentPositive); Random random = new Random(); double[] singularValues = RandomNumbers.nextDoubleArray(random, matrixSize, 1.0, 2.0); singularValues[matrixSize / 2] = 0.0; DenseMatrix64F matrix1 = RandomMatrices.createSingularValues(matrixSize, matrixSize, random, singularValues); nullspaceCalculator.setMatrix(matrix1, 1); DenseMatrix64F nullspace = nullspaceCalculator.getNullspace(); DenseMatrix64F matrix2 = RandomMatrices.createRandom(matrixSize, matrixSize, random); nullspaceCalculator.removeNullspaceComponent(matrix2); assertTrue(isNullspaceComponentZero(matrix2, nullspace)); }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testDerivativeOnRandomTrajectories() { int maximumNumberOfCoefficients = 10; Trajectory trajectory = new Trajectory(maximumNumberOfCoefficients); Trajectory derivative = new Trajectory(maximumNumberOfCoefficients - 1); int iterations = 50; for (int i = 0; i < iterations; i++) { int numberOfCoefficients = 2 + random.nextInt(maximumNumberOfCoefficients - 1); double[] coefficients = RandomNumbers.nextDoubleArray(random, numberOfCoefficients, 10.0); trajectory.setDirectly(coefficients); TrajectoryMathTools.getDerivative(derivative, trajectory); for (int j = 0; j < numberOfCoefficients - 1; j++) { Assert.assertEquals(derivative.getCoefficient(j), coefficients[j + 1] * (j + 1), epsilon); } } }
public static ManualHandControlPacket nextManualHandControlPacket(Random random) { ManualHandControlPacket next = new ManualHandControlPacket(); next.setRobotSide(RobotSide.generateRandomRobotSide(random).toByte()); double[] angles = RandomNumbers.nextDoubleArray(random, 4, 0, 1); next.setIndex(angles[0]); next.setMiddle(angles[1]); next.setThumb(angles[2]); next.setSpread(angles[3]); next.setControlType(0); return next; }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testNullspace() { int matrixSize = 10; boolean makeLargestComponentPositive = true; SVDNullspaceCalculator nullspaceCalculator = new SVDNullspaceCalculator(matrixSize, makeLargestComponentPositive); Random random = new Random(); double[] singularValues = RandomNumbers.nextDoubleArray(random, matrixSize, 1.0, 2.0); singularValues[0] = 0.0; DenseMatrix64F matrix = RandomMatrices.createSingularValues(matrixSize, matrixSize, random, singularValues); nullspaceCalculator.setMatrix(matrix, 1); DenseMatrix64F nullspace = nullspaceCalculator.getNullspace(); DenseMatrix64F matrixTimesNullspace = new DenseMatrix64F(matrix.getNumRows(), nullspace.getNumCols()); CommonOps.mult(matrix, nullspace, matrixTimesNullspace); assertTrue(MatrixFeatures.isConstantVal(matrixTimesNullspace, 0.0, 1e-12)); }
@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); } } }
double[] Jvalues = RandomNumbers.nextDoubleArray(random, Jrows * Jcolumns, 10.0); double[] Avalues = RandomNumbers.nextDoubleArray(random, ARows * Jcolumns, 10.0);
double[] Jvalues = RandomNumbers.nextDoubleArray(random, 200, 10.0); double[] Avalues = RandomNumbers.nextDoubleArray(random, 100, 10.0);
RigidBodyBasics chest = fullRobotModel.getChest(); OneDoFJointBasics[] spineJoints = MultiBodySystemTools.createOneDoFJointPath(pelvis, chest); double[] chestDesiredJointAccelerations = RandomNumbers.nextDoubleArray(random, spineJoints.length, 0.1); SpineDesiredAccelerationsMessage desiredAccelerationsMessage = HumanoidMessageTools.createSpineDesiredAccelerationsMessage(chestDesiredJointAccelerations);
double[] armDesiredJointAccelerations = RandomNumbers.nextDoubleArray(random, armJoints.length, 0.1); ArmDesiredAccelerationsMessage armDesiredAccelerationsMessage = HumanoidMessageTools.createArmDesiredAccelerationsMessage(robotSide, armDesiredJointAccelerations);
Random random = new Random(56416456L); Vector3D randomRotationAxis = RandomGeometry.nextVector3D(random, 1.0); double[] randomAngles = RandomNumbers.nextDoubleArray(random, 100, Math.PI);
double[] JValues = RandomNumbers.nextDoubleArray(random, JRows * JCols, 10.0); double[] AValues = RandomNumbers.nextDoubleArray(random, ARows * JCols, 10.0);
assertTrue(success); double[] neckDesiredJointAccelerations = RandomNumbers.nextDoubleArray(random, neckJoints.length, 0.1); NeckDesiredAccelerationsMessage neckDesiredAccelerationsMessage = HumanoidMessageTools.createNeckDesiredAccelerationsMessage(neckDesiredJointAccelerations);
double[] JValues = RandomNumbers.nextDoubleArray(random, JRows * JCols, 10.0); double[] AValues = RandomNumbers.nextDoubleArray(random, ARows * JCols, 10.0);
assertTrue(frameOrientationActual.epsilonEquals(frameOrientationExpected, EPS)); double[] yawPitchRollExpected = RandomNumbers.nextDoubleArray(random, 3, 2.0 * Math.PI); yoFrameQuaternion.setYawPitchRoll(yawPitchRollExpected[0], yawPitchRollExpected[1], yawPitchRollExpected[2]); double[] yawPitchRollActual = new double[3];