Search in sources :

Example 11 with RigidBody

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

the class HydrostatDemo method addContactBlock.

public void addContactBlock(MechModel mech) {
    RigidBody block = new RigidBody();
    block.setName("block");
    block.setMesh(MeshFactory.createQuadBox(100, 100, 20), null);
    block.setInertia(SpatialInertia.createBoxInertia(1, 100, 100, 20));
    block.setPose(new RigidTransform3d(new Vector3d(-50, 0, 40), new RotationMatrix3d()));
    mech.addRigidBody(block);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) RigidBody(artisynth.core.mechmodels.RigidBody) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Example 12 with RigidBody

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

the class SkinDemo method addLoad.

public void addLoad() {
    RigidBody lowerArm = model.rigidBodies().get("lower");
    if (lowerArm == null) {
        return;
    }
    double mass = 1.0;
    Particle load = new Particle(mass, new Point3d(-14.14, 0, -14.14));
    load.setName("load");
    // Particle load = new Particle(mass,new Point3d(0,0,0));
    RenderProps rp = new RenderProps(model.getRenderProps());
    rp.setShading(Renderer.Shading.SMOOTH);
    rp.setPointColor(Color.ORANGE);
    rp.setPointRadius(len / 20);
    load.setRenderProps(rp);
    model.addParticle(load);
    model.attachPoint(load, lowerArm, new Point3d(0, 0, len / 2));
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) RenderProps(maspack.render.RenderProps) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 13 with RigidBody

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

the class SkinDemo method addJoint.

public void addJoint() {
    RigidBody upperArm = model.rigidBodies().get("upper");
    RigidBody lowerArm = model.rigidBodies().get("lower");
    if (upperArm == null || lowerArm == null) {
        return;
    }
    RevoluteJoint j = new RevoluteJoint();
    j.setName("elbow");
    RigidTransform3d TCA = new RigidTransform3d();
    TCA.p.z = -len / 2;
    TCA.R.setAxisAngle(1, 0, 0, Math.PI / 2);
    RigidTransform3d TCW = new RigidTransform3d();
    TCW.R.setAxisAngle(1, 0, 0, Math.PI / 2);
    j.setBodies(lowerArm, TCA, null, TCW);
    j.setAxisLength(len / 3);
    model.addBodyConnector(j);
    upperArm.setDynamic(false);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 14 with RigidBody

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

the class PointModel method addCenter.

public void addCenter() {
    RigidBody body = new RigidBody("body");
    body.setInertia(SpatialInertia.createSphereInertia(mass, len / 25));
    model.addRigidBody(body);
    RenderProps.setVisible(body, false);
    RigidBody fixed = new RigidBody("fixed");
    fixed.setInertia(SpatialInertia.createSphereInertia(mass, len / 25));
    fixed.setDynamic(false);
    model.addRigidBody(fixed);
    RenderProps.setVisible(fixed, false);
    if (useReactionForceTargetP) {
        // add spherical joint for reaction force target testing
        SphericalJoint joint = new SphericalJoint(body, fixed, Point3d.ZERO);
        joint.setName("center_constraint");
        model.addBodyConnector(joint);
        addMonitor(new ConnectorForceRenderer(joint));
    }
    center = new FrameMarker();
    center.setName("center");
    center.setPointDamping(pointDamping);
    model.addFrameMarker(center, body, Point3d.ZERO);
}
Also used : SphericalJoint(artisynth.core.mechmodels.SphericalJoint) ConnectorForceRenderer(artisynth.core.inverse.ConnectorForceRenderer) FrameMarker(artisynth.core.mechmodels.FrameMarker) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 15 with RigidBody

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

the class SimpleCollide method removeObject.

private void removeObject(ModelComponent comp, ObjectType type) {
    MechModel mechMod = (MechModel) models().get(0);
    ComponentList<Probe> myProbes = getInputProbes();
    for (Probe p : myProbes) {
        System.out.println("type's name: " + type.name());
        System.out.println("probe's name: " + p.getName());
        if (type.name().equals(p.getName())) {
            removeInputProbe(p);
        }
    }
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
        case FemCube:
            {
                mechMod.removeModel((FemModel3d) comp);
                break;
            }
        case Box:
        case Molar:
        case Bin:
        case Paw:
        case House:
            {
                mechMod.removeRigidBody((RigidBody) comp);
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) RigidBody(artisynth.core.mechmodels.RigidBody) InternalErrorException(maspack.util.InternalErrorException) Probe(artisynth.core.probes.Probe) NumericInputProbe(artisynth.core.probes.NumericInputProbe)

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