Search in sources :

Example 41 with MechModel

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

the class SpinControlProbe method build.

public void build(String[] args) {
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // Create a parametrically controlled rigid body to spin:
    RigidBody body = RigidBody.createBox("box", 1.0, 1.0, 0.5, 1000.0);
    mech.addRigidBody(body);
    body.setDynamic(false);
    // Create a NumericControlProbe with size 1, initial spin data
    // with time step 2.0, start time 0, and stop time 8.
    NumericControlProbe spinProbe = new NumericControlProbe(/*vsize=*/
    1, new double[] { 0.0, 90.0, 0.0, -90.0, 0.0 }, 2.0, 0.0, 8.0);
    // set cubic interpolation for a smoother result
    spinProbe.setInterpolationOrder(Interpolation.Order.Cubic);
    // then set the data function:
    spinProbe.setDataFunction(new SpinFunction(body));
    addInputProbe(spinProbe);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) NumericControlProbe(artisynth.core.probes.NumericControlProbe) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 42 with MechModel

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

the class FemBeamTest method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    mech = new MechModel("mech");
    addModel(mech);
    fems = new RenderableComponentList<>(FemModel3d.class);
    FemModel3d tet = FemFactory.createTetGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    tet.setName("tet");
    fems.add(tet);
    FemModel3d pyr = FemFactory.createPyramidGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    pyr.setName("pyr");
    fems.add(pyr);
    FemModel3d wed = FemFactory.createWedgeGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    wed.setName("wed");
    fems.add(wed);
    FemModel3d hex = FemFactory.createHexGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    hex.setName("hex");
    fems.add(hex);
    FemModel3d qtet = FemFactory.createQuadtetGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qtet.setName("qtet");
    fems.add(qtet);
    FemModel3d qpyr = FemFactory.createQuadpyramidGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qpyr.setName("qpyr");
    fems.add(qpyr);
    FemModel3d qwed = FemFactory.createQuadwedgeGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qwed.setName("qwed");
    fems.add(qwed);
    FemModel3d qhex = FemFactory.createQuadhexGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qhex.setName("qhex");
    fems.add(qhex);
    // freeze lhs nodes
    double eps = 1e-10;
    for (FemModel3d fem : fems) {
        for (FemNode3d node : fem.getNodes()) {
            if (node.getRestPosition().x < -widthX / 2 + eps) {
                node.setDynamic(false);
            }
        }
    }
    // distribute
    double delta = widthY * 0.25;
    RigidTransform3d translate = new RigidTransform3d();
    for (FemModel3d fem : fems) {
        fem.transformGeometry(translate);
        translate.p.y += widthY + delta;
    }
    mech.add(fems);
    // render properties
    int nfems = fems.size();
    int ifem = 0;
    for (FemModel3d fem : fems) {
        fem.setSurfaceRendering(SurfaceRender.Shaded);
        float h = (float) ifem / nfems;
        RenderProps.setFaceColor(fem, Color.getHSBColor(h, 1.0f, 1.0f));
        ++ifem;
    }
    setMaterial(createDefaultMaterial());
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 43 with MechModel

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

the class FullPlanarJointDemo method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = (MechModel) models().get("mech");
    RigidBody lumbar1 = mech.rigidBodies().get("lumbar1");
    // constrain to mid-sagittal plane: medio-lateral direction is in world y-axis
    FullPlanarJoint planarJoint = new FullPlanarJoint(lumbar1, Vector3d.Y_UNIT);
    mech.addBodyConnector(planarJoint);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FullPlanarJoint(artisynth.core.mechmodels.FullPlanarJoint) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 44 with MechModel

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

the class JointedFemBeams method build.

public void build(String[] args) {
    MechModel mech = new MechModel("mechMod");
    addModel(mech);
    double stiffness = 5000;
    // create first fem beam and fix the leftmost nodes
    FemModel3d fem1 = addFem(mech, 2.4, 0.6, 0.4, stiffness);
    for (FemNode3d n : fem1.getNodes()) {
        if (n.getPosition().x <= -1.2) {
            n.setDynamic(false);
        }
    }
    // create the second fem beam and shift it 1.5 to the right
    FemModel3d fem2 = addFem(mech, 2.4, 0.4, 0.4, 0.1 * stiffness);
    fem2.transformGeometry(new RigidTransform3d(1.5, 0, 0));
    // create a slotted revolute joint that connects the two fem beams
    RigidTransform3d TDW = new RigidTransform3d(0.5, 0, 0, 0, 0, Math.PI / 2);
    SlottedRevoluteJoint joint = new SlottedRevoluteJoint(fem2, fem1, TDW);
    mech.addBodyConnector(joint);
    // set ranges and rendering properties for the joint
    joint.setAxisLength(0.8);
    joint.setMinX(-0.5);
    joint.setMaxX(0.5);
    joint.setSlotWidth(0.61);
    RenderProps.setLineColor(joint, myJointColor);
    RenderProps.setLineWidth(joint, 3);
    RenderProps.setLineRadius(joint, 0.04);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) SlottedRevoluteJoint(artisynth.core.mechmodels.SlottedRevoluteJoint) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 45 with MechModel

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

the class PenetrationRendererDemo method build.

public void build(String[] args) {
    // create MechModel and add to RootModel
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // create and add the ball and plate
    RigidBody ball = RigidBody.createIcosahedralSphere("ball", 0.8, 0.1, 1);
    // ball.setPose (new RigidTransform3d (0, 0, 2, 0.4, 0.1, 0.1));
    ball.setPose(new RigidTransform3d(0, 0, 0, 0.4, 0.1, 0.1));
    ball.setDynamic(false);
    mech.addRigidBody(ball);
    RigidBody plate = RigidBody.createBox("plate", 5, 5, 5, 1);
    plate.setPose(new RigidTransform3d(0, 0, 2.94, 1, 0, 0, 0));
    plate.setDynamic(false);
    mech.addRigidBody(plate);
    // turn on collisions
    mech.setDefaultCollisionBehavior(true, 0.20);
    // make ball transparent so that contacts can be seen more clearly
    RenderProps.setFaceStyle(ball, Renderer.FaceStyle.NONE);
    RenderProps.setDrawEdges(ball, true);
    RenderProps.setEdgeColor(ball, Color.WHITE);
    RenderProps.setVisible(plate, false);
    RenderProps.setAlpha(plate, 0.5);
    // enable rendering of contacts normals and contours
    CollisionManager cm = mech.getCollisionManager();
    RenderProps.setVisible(cm, true);
    RenderProps.setLineWidth(cm, 3);
    RenderProps.setLineColor(cm, Color.RED);
    RenderProps.setEdgeWidth(cm, 3);
    RenderProps.setEdgeColor(cm, Color.BLUE);
    cm.setContactNormalLen(0.5);
    cm.setDrawContactNormals(true);
    cm.setDrawIntersectionContours(true);
    cm.setDrawIntersectionFaces(true);
    cm.setDrawIntersectionPoints(true);
    CollisionResponse resp = mech.setCollisionResponse(ball, plate);
    addMonitor(new PenetrationRenderer(resp));
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) CollisionManager(artisynth.core.mechmodels.CollisionManager) RigidBody(artisynth.core.mechmodels.RigidBody) CollisionResponse(artisynth.core.mechmodels.CollisionResponse)

Aggregations

MechModel (artisynth.core.mechmodels.MechModel)59 RigidBody (artisynth.core.mechmodels.RigidBody)25 RigidTransform3d (maspack.matrix.RigidTransform3d)19 FemModel3d (artisynth.core.femmodels.FemModel3d)14 FemNode3d (artisynth.core.femmodels.FemNode3d)8 Particle (artisynth.core.mechmodels.Particle)8 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Vector3d (maspack.matrix.Vector3d)8 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)7 LinearMaterial (artisynth.core.materials.LinearMaterial)6 FrameMarker (artisynth.core.mechmodels.FrameMarker)6 CollisionManager (artisynth.core.mechmodels.CollisionManager)5 Color (java.awt.Color)5 AxialSpring (artisynth.core.mechmodels.AxialSpring)4 BodyConnector (artisynth.core.mechmodels.BodyConnector)4 WayPoint (artisynth.core.probes.WayPoint)4 Point3d (maspack.matrix.Point3d)4 MultiPointSpring (artisynth.core.mechmodels.MultiPointSpring)3 PlanarConnector (artisynth.core.mechmodels.PlanarConnector)3 FemElement3d (artisynth.core.femmodels.FemElement3d)2