Search in sources :

Example 21 with RigidBody

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

the class ArticulatedDemo method createCollidingLinkage.

void createCollidingLinkage(MechModel mech) {
    Point3d base0 = new Point3d(-1, 2, 9);
    Point3d base1 = new Point3d(-1, -2, 9);
    Point3d tip0 = new Point3d(-3, 0, 5);
    Point3d tip1 = new Point3d(-7, 0, 3);
    double radius = 1.0;
    RigidBody link0 = addSphericalLinkage(mech, radius, ground, base0, null, tip0);
    RigidBody link1 = addSphericalLinkage(mech, radius, link0, tip0, null, tip1);
    RigidBody link2 = addSphericalLinkage(mech, radius, ground, base1, link0, tip0);
    Point3d base2 = new Point3d(1, 2, 9);
    Point3d base3 = new Point3d(1, -2, 9);
    Point3d tip2 = new Point3d(3, 0, 5);
    Point3d tip3 = new Point3d(7, 0, 3);
    RigidBody link3 = addSphericalLinkage(mech, radius, ground, base2, null, tip2);
    RigidBody link4 = addSphericalLinkage(mech, radius, link3, tip2, null, tip3);
    RigidBody link5 = addSphericalLinkage(mech, radius, ground, base3, link3, tip2);
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody)

Example 22 with RigidBody

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

the class ArticulatedDemo method create9LinkLoop.

void create9LinkLoop(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);
    Point3d tip3 = new Point3d(0, 0, -5);
    Point3d tip4 = new Point3d(5, 3, -5);
    RigidBody link3 = addSphericalLinkage(mech, radius, link0, tip0, null, tip3);
    RigidBody link4 = addSphericalLinkage(mech, radius, link1, tip1, null, tip4);
    RigidBody link5 = addSphericalLinkage(mech, radius, link3, tip3, link4, tip4);
    Point3d tip6 = new Point3d(-2, 0, -10);
    Point3d tip7 = new Point3d(-3, 0, -15);
    RigidBody link6 = addSphericalLinkage(mech, radius, link3, tip3, null, tip6);
    RigidBody link7 = addSphericalLinkage(mech, radius, link6, tip6, null, tip7);
    Point3d tip8 = new Point3d(6, 1, -10);
    Point3d tip9 = new Point3d(8, 2, -15);
    RigidBody link8 = addSphericalLinkage(mech, radius, link4, tip4, null, tip8);
    RigidBody link9 = addSphericalLinkage(mech, radius, link8, tip8, null, tip9);
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody)

Example 23 with RigidBody

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

the class ArticulatedDemo method createLongLinkage.

void createLongLinkage(MechModel mech, int nlinks) {
    Point3d base0 = new Point3d(0, 0, 9);
    RigidBody link = ground;
    Point3d lastTip = base0;
    double radius = 1.0;
    for (int i = 0; i < nlinks; i++) {
        Point3d tip = new Point3d((i + 1) * 5, 0, 9 - (i + 1) * 5);
        link = addSphericalLinkage(mech, radius, link, lastTip, null, tip);
        lastTip = tip;
    }
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody) SphericalJoint(artisynth.core.mechmodels.SphericalJoint)

Example 24 with RigidBody

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

the class ArticulatedDemo method create3LinkPlaneCollider.

void create3LinkPlaneCollider(MechModel mech) {
    usePlanarContacts = true;
    Point3d base0 = new Point3d(-5, 0, 9);
    Point3d tip0 = new Point3d(0, 0, 5);
    Point3d tip1 = new Point3d(5, 0, 3);
    Point3d tip2 = new Point3d(10, 0, 3);
    double radius = 1.0;
    RigidBody link0 = addSphericalLinkage(mech, radius, ground, base0, null, tip0);
    RigidBody link1 = addSphericalLinkage(mech, radius, link0, tip0, null, tip1);
    RigidBody link2 = addSphericalLinkage(mech, radius, link1, tip1, null, tip2);
}
Also used : RigidBody(artisynth.core.mechmodels.RigidBody)

Example 25 with RigidBody

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

the class CompliantConstraintDemo method build.

public void build(String[] args) {
    MechModel mechMod = new MechModel("mechMod");
    // mechMod.setProfiling (true);
    mechMod.setGravity(0, 0, -50);
    // mechMod.setRigidBodyDamper (new FrameDamper (1.0, 4.0));
    mechMod.setFrameDamping(1.0);
    mechMod.setRotaryDamping(4.0);
    mechMod.setIntegrator(MechSystemSolver.Integrator.SymplecticEuler);
    RigidTransform3d XMB = new RigidTransform3d();
    RigidTransform3d XLW = new RigidTransform3d();
    RigidTransform3d TCA = new RigidTransform3d();
    RigidTransform3d TCB = new RigidTransform3d();
    RigidTransform3d XAB = new RigidTransform3d();
    PolygonalMesh mesh;
    // number of slices for approximating a circle
    int nslices = 16;
    // // set view so tha points upwards
    // X.R.setAxisAngle (1, 0, 0, -Math.PI/2);
    // viewer.setTransform (X);
    double lenx0 = 15;
    double leny0 = 15;
    double lenz0 = 1.5;
    RenderProps props;
    double ks = 10;
    double ds = 10;
    // mechMod.addRigidBody (base);
    // first link
    double lenx1 = 10;
    double leny1 = 2;
    double lenz1 = 3;
    RigidBody link1 = new RigidBody("link1");
    link1.setInertia(SpatialInertia.createBoxInertia(10, lenx1, leny1, lenz1));
    mesh = MeshFactory.createRoundedBox(lenx1, leny1, lenz1, nslices / 2);
    XMB.setIdentity();
    XMB.R.setAxisAngle(1, 1, 1, 2 * Math.PI / 3);
    mesh.transform(XMB);
    // mesh.setRenderMaterial (Material.createSpecial (Material.GRAY));
    link1.setMesh(mesh, /* fileName= */
    null);
    XLW.R.setAxisAngle(1, 0, 0, Math.PI / 2);
    // XLW.R.mulAxisAngle (0, 1, 0, Math.PI/4);
    XLW.p.set(0, 0, 1.5 * lenx1);
    link1.setPose(XLW);
    mechMod.addRigidBody(link1);
    // joint 1
    BodyConnector joint1 = null;
    RevoluteJoint rjoint = null;
    TCA.setIdentity();
    TCA.p.set(-lenx1 / 2, 0, 0);
    // TCA.R.mulAxisAngle (0, 1, 0, Math.PI/4);
    TCB.set(link1.getPose());
    TCB.mul(TCA);
    rjoint = new RevoluteJoint(link1, TCA, TCB);
    rjoint.setName("joint1");
    rjoint.setAxisLength(4);
    RenderProps.setLineRadius(rjoint, 0.2);
    joint1 = rjoint;
    // second link
    double lenx2 = 10;
    double leny2 = 2;
    double lenz2 = 2;
    RigidBody link2 = new RigidBody("link2");
    if (// useSphericalJoint)
    false) {
        mesh = MeshFactory.createRoundedCylinder(leny2 / 2, lenx2, nslices, /*nsegs=*/
        1, /*flatBottom=*/
        false);
        link2.setInertia(SpatialInertia.createBoxInertia(10, leny2, leny2, lenx2));
        XLW.R.setAxisAngle(1, 0, 0, Math.PI / 2);
        XLW.p.set(lenx1 / 2, lenx2 / 2, lenx1);
        link2.setPose(XLW);
    }
    mesh = MeshFactory.createRoundedCylinder(leny2 / 2, lenx2, nslices, /*nsegs=*/
    1, /*flatBottom=*/
    false);
    mesh.transform(XMB);
    link2.setInertia(SpatialInertia.createBoxInertia(10, lenx2, leny2, lenz2));
    XLW.R.setAxisAngle(1, 0, 0, Math.PI / 2);
    XLW.p.set(lenx1 / 2 + lenx2 / 2, 0, 1.5 * lenx1);
    if (useSphericalJoint) {
        // Math.PI/4;
        double ang = 0;
        XLW.R.mulAxisAngle(0, 1, 0, ang);
        XLW.p.y += Math.sin(ang) * lenx2 / 2;
        XLW.p.x -= (1 - Math.cos(ang)) * lenx2 / 2;
    }
    link2.setPose(XLW);
    link2.setMesh(mesh, /* fileName= */
    null);
    mechMod.addRigidBody(link2);
    BodyConnector joint2 = null;
    // joint 2
    if (useSphericalJoint) {
        TCA.setIdentity();
        TCA.p.set(-lenx2 / 2, 0, 0);
        XAB.mulInverseLeft(link1.getPose(), link2.getPose());
        TCB.mul(XAB, TCA);
        SphericalJoint sjoint = new SphericalJoint(link2, TCA, link1, TCB);
        // RevoluteJoint joint2 = new RevoluteJoint (link2, TCA, TCB);
        sjoint.setName("joint2");
        // RenderProps.setLineRadius(sjoint, 0.2);
        sjoint.setAxisLength(4);
        joint2 = sjoint;
    } else {
        TCA.setIdentity();
        TCA.p.set(-lenx2 / 2, 0, 0);
        // TCA.R.mulAxisAngle (1, 0, 0, -Math.toRadians(90));
        XAB.mulInverseLeft(link1.getPose(), link2.getPose());
        TCB.mul(XAB, TCA);
        rjoint = new RevoluteJoint(link2, TCA, link1, TCB);
        rjoint.setName("joint2");
        rjoint.setAxisLength(4);
        RenderProps.setLineRadius(rjoint, 0.2);
        joint2 = rjoint;
    }
    mechMod.addBodyConnector(joint1);
    if (joint2 != null) {
        mechMod.addBodyConnector(joint2);
    }
    mechMod.transformGeometry(new RigidTransform3d(0, 0, 0, 0, Math.toRadians(75), 0));
    addModel(mechMod);
    addControlPanel(mechMod);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) SphericalJoint(artisynth.core.mechmodels.SphericalJoint) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) RigidBody(artisynth.core.mechmodels.RigidBody) BodyConnector(artisynth.core.mechmodels.BodyConnector) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) WayPoint(artisynth.core.probes.WayPoint) SphericalJoint(artisynth.core.mechmodels.SphericalJoint)

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