/** * Generates a random kinematic chain composed of rigid-bodies and revolute joints. * <p> * The joints and rigid-bodies have random physical parameters. * </p> * <p> * The generated multi-body system is a kinematic chain, i.e. every rigid-body has only one child * joint. * </p> * * @param random the random generator to use. * @param numberOfJoints how many joints the kinematic chain should be composed of. * @return the list of all the joints composing the kinematic chain. */ public static List<RevoluteJoint> nextRevoluteJointChain(Random random, int numberOfJoints) { return nextRevoluteJointChain(random, "", numberOfJoints); }
/** * Generates a random kinematic chain composed of rigid-bodies and revolute joints. * <p> * The joints and rigid-bodies have random physical parameters. * </p> * <p> * The generated multi-body system is a kinematic chain, i.e. every rigid-body has only one child * joint. * </p> * * @param random the random generator to use. * @param rootBody the root to which the kinematic chain is to be attached. * @param numberOfJoints how many joints the kinematic chain should be composed of. * @return the list of all the joints composing the kinematic chain. */ public static List<RevoluteJoint> nextRevoluteJointChain(Random random, RigidBodyBasics rootBody, int numberOfJoints) { return nextRevoluteJointChain(random, "", rootBody, numberOfJoints); }
private void setUpRandomTree(RigidBodyBasics elevator) { joints = new ArrayList<RevoluteJoint>(); Vector3D[] jointAxes1 = {X, Y, Z, Y, X}; joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "chainA", elevator, jointAxes1)); Vector3D[] jointAxes2 = {Z, X, Y, X, X}; joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "chainB", elevator, jointAxes2)); Vector3D[] jointAxes3 = {Y, Y, X, X, X}; joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "chainC", elevator, jointAxes3)); }
/** * Generates a random kinematic chain composed of rigid-bodies and revolute joints. * <p> * The joints and rigid-bodies have random physical parameters. * </p> * <p> * The generated multi-body system is a kinematic chain, i.e. every rigid-body has only one child * joint. * </p> * * @param random the random generator to use. * @param prefix provides a common prefix used for all the joint and rigid-body names. * @param numberOfJoints how many joints the kinematic chain should be composed of. * @return the list of all the joints composing the kinematic chain. */ public static List<RevoluteJoint> nextRevoluteJointChain(Random random, String prefix, int numberOfJoints) { return nextRevoluteJointChain(random, prefix, MecanoRandomTools.nextVector3DArray(random, numberOfJoints, 1.0)); }
/** * Generates a random kinematic chain composed of rigid-bodies and revolute joints. * <p> * The joints and rigid-bodies have random physical parameters. * </p> * <p> * The generated multi-body system is a kinematic chain, i.e. every rigid-body has only one child * joint. * </p> * * @param random the random generator to use. * @param prefix provides a common prefix used for all the joint and rigid-body names. * @param rootBody the root to which the kinematic chain is to be attached. * @param numberOfJoints how many joints the kinematic chain should be composed of. * @return the list of all the joints composing the kinematic chain. */ public static List<RevoluteJoint> nextRevoluteJointChain(Random random, String prefix, RigidBodyBasics rootBody, int numberOfJoints) { return nextRevoluteJointChain(random, prefix, rootBody, MecanoRandomTools.nextVector3DArray(random, numberOfJoints, 1.0)); }
protected void setUpRandomChainRobot() { Random random = new Random(); joints = new ArrayList<RevoluteJoint>(); Vector3D[] jointAxes = {X, Y, Z, X, Z, Z, X, Y, Z, X}; joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "", elevator, jointAxes)); MultiBodySystemRandomTools.nextState(random, JointStateType.CONFIGURATION, -Math.PI / 2.0, Math.PI / 2.0, joints); elevator.updateFramesRecursively(); MultiBodySystemRandomTools.nextState(random, JointStateType.VELOCITY, joints); }
/** * Generates a random kinematic chain composed of rigid-bodies and revolute joints. * <p> * The joints and rigid-bodies have random physical parameters. * </p> * <p> * The generated multi-body system is a kinematic chain, i.e. every rigid-body has only one child * joint. * </p> * * @param random the random generator to use. * @param prefix provides a common prefix used for all the joint and rigid-body names. * @param jointAxes array containing in order the axis for each joint. The length of the array also * defines the number of joints for the generated kinematic chain. * @return the list of all the joints composing the kinematic chain. */ public static List<RevoluteJoint> nextRevoluteJointChain(Random random, String prefix, Vector3DReadOnly[] jointAxes) { ReferenceFrame worldFrame = ReferenceFrame.getWorldFrame(); RigidBody rootBody = new RigidBody(prefix + "RootBody", worldFrame); return nextRevoluteJointChain(random, prefix, rootBody, jointAxes); }
elevator = new RigidBody("elevator", worldFrame); Vector3D[] jointAxes = {X, Y, Z, Z, X, Z, Z, X, Y, Y}; joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "", elevator, jointAxes));
public static void main(String[] args) { Random random = new Random(); int numberOfJoints = 5; List<RevoluteJoint> randomChainRobot = MultiBodySystemRandomTools.nextRevoluteJointChain(random, numberOfJoints); TwistCalculator twistCalculator = new TwistCalculator(worldFrame, randomChainRobot.get(0).getPredecessor()); Twist dummyTwist = new Twist(); while (true) { twistCalculator.compute(); for (int i = 0; i < 100; i++) twistCalculator.getTwistOfBody(randomChainRobot.get(random.nextInt(numberOfJoints)).getSuccessor(), dummyTwist); } } }
/** * Creates a new random multi-body system. * * @param random the random generator to use. * @param jointAxes array containing in order the axis for each revolute joint. The length of the * array also defines the number of revolute joints for the generated kinematic chain. */ public RandomFloatingRevoluteJointChain(Random random, Vector3D[] jointAxes) { elevator = new RigidBody("elevator", ReferenceFrame.getWorldFrame()); rootJoint = new SixDoFJoint("rootJoint", elevator); RigidBody rootBody = nextRigidBody(random, "rootBody", rootJoint); revoluteJoints = nextRevoluteJointChain(random, "test", rootBody, jointAxes); joints.add(rootJoint); joints.addAll(revoluteJoints); }
for (int i = 0; i < jointAxes.length; i++) jointAxes[i] = RandomGeometry.nextVector3D(random, 1.0); revoluteJoints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "blop", rootBody, jointAxes)); final List<OneDoFJointBasics> oneDoFJoints = new ArrayList<>(); for (RevoluteJoint revoluteJoint : revoluteJoints)
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void chainTest() throws UnreasonableAccelerationException { Random random = new Random(12651L); ArrayList<RevoluteJoint> joints = new ArrayList<>(); RigidBodyBasics elevator = new RigidBody("elevator", worldFrame); int numberOfJoints = 10; Vector3D[] jointAxes = new Vector3D[numberOfJoints]; for (int i = 0; i < numberOfJoints; i++) jointAxes[i] = RandomGeometry.nextVector3D(random, 1.0); joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "blop", elevator, jointAxes)); SCSRobotFromInverseDynamicsRobotModel robot = new SCSRobotFromInverseDynamicsRobotModel("robot", elevator.getChildrenJoints().get(0)); assertAAndADotV(random, joints, elevator, robot,numberOfJoints); }
joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "randomChain", elevator, jointAxes)); JointBasics[] jointsArray = new RevoluteJoint[joints.size()]; joints.toArray(jointsArray);
joints.addAll(MultiBodySystemRandomTools.nextRevoluteJointChain(random, "test", floatingBody, jointAxes)); ReferenceFrame centerOfMassReferenceFrame = new CenterOfMassReferenceFrame("com", elevator.getBodyFixedFrame(), elevator);
List<RevoluteJoint> revoluteJoints = MultiBodySystemRandomTools.nextRevoluteJointChain(random, numberOfJoints); TwistCalculator twistCalculator = new TwistCalculator(worldFrame, revoluteJoints.get(random.nextInt(numberOfJoints)).getPredecessor());
List<RevoluteJoint> joints = MultiBodySystemRandomTools.nextRevoluteJointChain(random, numberOfJoints); RigidBodyBasics rootBody = joints.get(0).getPredecessor(); ReferenceFrame rootFrame = rootBody.getBodyFixedFrame();