Search in sources :

Example 51 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class ArticulatedDemo method addBox.

private RigidBody addBox(MechModel mechMod, double mass, double wx, double wy, double wz, double px, double py, double pz) {
    RigidBody box = new RigidBody(null);
    box.setInertia(SpatialInertia.createBoxInertia(mass, wx, wy, wz));
    box.setMesh(MeshFactory.createBox(wx, wy, wz), null);
    RigidTransform3d XBoxToWorld = new RigidTransform3d();
    XBoxToWorld.p.set(px, py, pz);
    box.setPose(XBoxToWorld);
    mechMod.addRigidBody(box);
    return box;
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody)

Example 52 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class ArticulatedDemo method create3LinkLoop.

void create3LinkLoop(MechModel mech) {
    RigidBody box = addBox(mech, /* mass= */
    10, 20, 10, 2, 0, 0, 10);
    box.setDynamic(false);
    Point3d base0 = new Point3d(-5, 0, 9);
    Point3d tip0 = new Point3d(-8, 0, 0);
    Point3d base1 = new Point3d(5, 0, 9);
    Point3d tip1 = new Point3d(2, -2, 0);
    double radius = 1.0;
    RigidBody link0 = addSphericalLinkage(mech, radius, ground, base0, null, tip0);
    RigidBody link1 = addSphericalLinkage(mech, radius, ground, base1, null, tip1);
    RigidBody link2 = addSphericalLinkage(mech, radius, link0, tip0, link1, tip1);
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody)

Example 53 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class ArticulatedDemo method addSphericalLinkage.

private RigidBody addSphericalLinkage(MechModel mechMod, double radius, RigidBody body0, Point3d pnt0, RigidBody body1, Point3d pnt1) {
    // set up the position of the link
    Vector3d u = new Vector3d();
    u.sub(pnt1, pnt0);
    double len = u.norm();
    u.scale(1 / len);
    RigidTransform3d XLinkToWorld = new RigidTransform3d();
    XLinkToWorld.p.scaledAdd(0.5 * len, u, pnt0);
    XLinkToWorld.R.setZDirection(u);
    // create the link
    PolygonalMesh mesh = MeshFactory.createRoundedCylinder(radius, len, /*nslices=*/
    12, /*nsegs=*/
    1, /*flatBottom=*/
    false);
    SpatialInertia inertia = SpatialInertia.createBoxInertia(/* mass= */
    10, radius, radius, len);
    RigidBody link = new RigidBody(null);
    link.setInertia(inertia);
    link.setMesh(mesh, null);
    link.setPose(XLinkToWorld);
    mechMod.addRigidBody(link);
    // create the spherical joint(s)
    RigidTransform3d TCW = new RigidTransform3d();
    RigidTransform3d TCA = new RigidTransform3d();
    if (body0 != null) {
        TCA.setIdentity();
        TCA.p.set(0, 0, -len / 2);
        TCW.mul(XLinkToWorld, TCA);
        SphericalJoint joint0;
        if (body0 == ground) {
            joint0 = new SphericalJoint(link, TCA, TCW);
        } else {
            RigidTransform3d TCB = new RigidTransform3d();
            TCB.mulInverseLeft(body0.getPose(), TCW);
            joint0 = new SphericalJoint(link, TCA, body0, TCB);
        }
        mechMod.addBodyConnector(joint0);
    }
    if (body1 != null) {
        TCA.setIdentity();
        TCA.p.set(0, 0, len / 2);
        TCW.mul(XLinkToWorld, TCA);
        SphericalJoint joint1;
        if (body1 == ground) {
            joint1 = new SphericalJoint(link, TCA, TCW);
        } else {
            RigidTransform3d TCB = new RigidTransform3d();
            TCB.mulInverseLeft(body1.getPose(), TCW);
            joint1 = new SphericalJoint(link, TCA, body1, TCB);
        }
        mechMod.addBodyConnector(joint1);
    }
    if (usePlanarContacts) {
        // set up a unilateral constraint at the tip
        TCW.setIdentity();
        TCW.p.set(0, 0, zPlane);
        Point3d pCA = new Point3d(0, 0, len / 2);
        PlanarConnector contact = new PlanarConnector(link, pCA, TCW);
        contact.setUnilateral(true);
        contact.setPlaneSize(20);
        mechMod.addBodyConnector(contact);
    }
    return link;
}
Also used : SphericalJoint(artisynth.core.mechmodels.SphericalJoint) PlanarConnector(artisynth.core.mechmodels.PlanarConnector) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 54 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class ArticulatedFem method makeBox.

private RigidBody makeBox() {
    RigidBody box = new RigidBody();
    box.setInertia(SpatialInertia.createBoxInertia(boxMass, boxLength, boxHeight, boxHeight));
    box.setMesh(MeshFactory.createBox(boxLength, boxHeight, boxHeight), null);
    return box;
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody)

Example 55 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class SimpleCollide method createAndAddControlPanel.

ControlPanel createAndAddControlPanel(String name, ModelComponent comp) {
    ControlPanel panel = new ControlPanel(name);
    if (comp instanceof FemModel3d) {
        panel.addWidget(comp, "material");
        panel.addWidget(comp, "density");
        panel.addWidget(comp, "incompressible");
        panel.addWidget(comp, "volume");
    } else if (comp instanceof RigidBody) {
        panel.addWidget(comp, "position");
        panel.addWidget(comp, "orientation");
    } else {
        throw new InternalErrorException("No control panel code for components of type " + comp.getClass());
    }
    ControlPanel existingPanel = getControlPanels().get(name);
    if (existingPanel != null) {
        int idx = getControlPanels().indexOf(existingPanel);
        removeControlPanel(existingPanel);
        existingPanel.dispose();
        addControlPanel(panel, idx);
        Main.getMain().arrangeControlPanels(this);
    } else {
        addControlPanel(panel);
    }
    return panel;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) ControlPanel(artisynth.core.gui.ControlPanel) RigidBody(artisynth.core.mechmodels.RigidBody) InternalErrorException(maspack.util.InternalErrorException)

Aggregations

RigidBody (artisynth.core.mechmodels.RigidBody)55 MechModel (artisynth.core.mechmodels.MechModel)25 RigidTransform3d (maspack.matrix.RigidTransform3d)18 FrameMarker (artisynth.core.mechmodels.FrameMarker)11 RenderProps (maspack.render.RenderProps)11 Point3d (maspack.matrix.Point3d)10 PolygonalMesh (maspack.geometry.PolygonalMesh)9 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)8 Vector3d (maspack.matrix.Vector3d)8 FemModel3d (artisynth.core.femmodels.FemModel3d)7 FemNode3d (artisynth.core.femmodels.FemNode3d)7 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)7 WayPoint (artisynth.core.probes.WayPoint)6 AxialSpring (artisynth.core.mechmodels.AxialSpring)5 Particle (artisynth.core.mechmodels.Particle)5 Color (java.awt.Color)5 CollisionManager (artisynth.core.mechmodels.CollisionManager)4 File (java.io.File)4 IOException (java.io.IOException)4 AxisAngle (maspack.matrix.AxisAngle)4