/** * Performs a deep copy of the subtree that starts off {@code originalSubtreeStart}. * <p> * The clone of the subtree has its own root body which reference frame is child of the frame after * the parent joint of {@code originalSubtreeStartBody}. As a result, the clone is an independent * multi-body system but its root is following the original multi-body system. * </p> * * @param originalSubtreeStartBody the rigid-body holding the subtree to be cloned. Not modified. * @param cloneSuffix suffix to append to the cloned joints and rigid-bodies. * @return the clone subtree. * @throws IllegalArgumentException if {@code originalSubtreeStartBody} is a root body, in which * case * {@link #cloneMultiBodySystem(RigidBodyReadOnly, ReferenceFrame, String, RigidBodyBuilder, JointBuilder)} * should be used. */ public static RigidBodyBasics cloneSubtree(RigidBodyReadOnly originalSubtreeStartBody, String cloneSuffix) { return cloneSubtree(originalSubtreeStartBody, cloneSuffix, null, null); }
/** * Performs a deep copy of an entire multi-body system. * <p> * The clone of the multi-body system has its own root body which reference frame shares the same * parent as {@code originalRootBody.getBodyFixedFrame()}. * </p> * * @param originalRootBody the root of the multi-body system to clone. Not modified. * @param cloneStationaryFrame the reference frame to which the cloned system is attached to. The * given frame is expected to be stationary. * @param cloneSuffix suffix to append to the cloned joints and rigid-bodies. * @param rigidBodyBuilder the builder to use for creating rigid-bodies. If {@code null}, * {@link #DEFAULT_RIGID_BODY_BUILDER} is used. * @param jointBuilder the builder to use for creating joints. If {@code null}, * {@link #DEFAULT_JOINT_BUILDER} is used. * @return the clone multi-body system. * @throws IllegalArgumentException if the given {@code originalRootBody} is not the root body of * its system. */ public static RigidBodyBasics cloneMultiBodySystem(RigidBodyReadOnly originalRootBody, ReferenceFrame cloneStationaryFrame, String cloneSuffix, RigidBodyBuilder rigidBodyBuilder, JointBuilder jointBuilder) { if (!originalRootBody.isRootBody()) throw new IllegalArgumentException("The given rigid-body is not the root-body of its multi-body system: " + originalRootBody.getName()); RigidBodyBasics cloneSubtreeStartBody = cloneRigidBody(originalRootBody, cloneStationaryFrame, cloneSuffix, null, rigidBodyBuilder); cloneSubtree(originalRootBody, cloneSubtreeStartBody, cloneSuffix, rigidBodyBuilder, jointBuilder); return cloneSubtreeStartBody; }
originalSubtreeStartBody.getParentJoint().getFrameAfterJoint()); cloneSubtree(originalSubtreeStartBody, cloneSubtreeStartBody, cloneSuffix, rigidBodyBuilder, jointBuilder); return cloneSubtreeStartBody;