Search in sources :

Example 51 with MechModel

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

the class FemSurfaceTargetDemo method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    mech = new MechModel("mech");
    mech.setGravity(Vector3d.ZERO);
    addModel(mech);
    fem = new FemMuscleModel("fem");
    fem.setStiffnessDamping(0.1);
    mech.addModel(fem);
    // boundary conditions
    FemFactory.createHexGrid(fem, l, w, w, nl, nw, nw);
    for (FemNode n : fem.getNodes()) {
        if (n.getPosition().x > l / 2 - eps) {
            n.setDynamic(false);
        }
    }
    // muscles
    addMuscle("vert", Color.RED, Vector3d.Z_UNIT);
    addMuscle("trans", Color.BLUE, Vector3d.Y_UNIT);
    body = new RigidBody("plate");
    body.setMesh(MeshFactory.createBox(l, l, l / 10));
    body.setPose(new RigidTransform3d(-1.2 * w - l / 20, 0, 0, 0, 1, 0, Math.PI / 2));
    body.setDynamic(false);
    mech.addRigidBody(body);
    mech.setCollisionBehavior(body, fem, true);
    addTrackingController();
    setupRenderProps();
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemNode(artisynth.core.femmodels.FemNode) RigidTransform3d(maspack.matrix.RigidTransform3d) FemMuscleModel(artisynth.core.femmodels.FemMuscleModel) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 52 with MechModel

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

the class HydrostatInvDemo method build.

public void build(Shape shape) throws IOException {
    super.build(shape);
    hydro.setMaxStepSize(stepsize);
    hydro.setIntegrator(Integrator.Trapezoidal);
    this.setMaxStepSize(stepsize);
    mech = new MechModel("mech");
    mech.setIntegrator(hydro.getIntegrator());
    mech.setMaxStepSize(hydro.getMaxStepSize());
    mech.setGravity(hydro.getGravity());
    removeModel(hydro);
    mech.addModel(hydro);
    addModel(mech);
    probeFilename = null;
    setupRenderProps();
// for (MuscleBundle b : hydro.getMuscleBundles()) {
// RenderProps.setLineColor(b, Color.RED);
// }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel)

Example 53 with MechModel

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

the class Fem3dBlock method build.

public void build(String type, int nz, int nxy, int options) {
    FemModel3d femMod = new FemModel3d("fem");
    femMod.setDensity(myDensity);
    if (type.equals("tet")) {
        FemFactory.createTetGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else if (type.equals("hex")) {
        FemFactory.createHexGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else if (type.equals("quadtet")) {
        FemFactory.createQuadtetGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else if (type.equals("quadhex")) {
        FemFactory.createQuadhexGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else {
        throw new UnsupportedOperationException("Unsupported element type " + type);
    }
    femMod.setBounds(new Point3d(-0.6, 0, 0), new Point3d(0.6, 0, 0));
    femMod.setLinearMaterial(200000, 0.4, true);
    femMod.setStiffnessDamping(0.002);
    Renderable elements = femMod.getElements();
    RenderProps.setLineWidth(elements, 2);
    RenderProps.setLineColor(elements, Color.BLUE);
    Renderable nodes = femMod.getNodes();
    RenderProps.setPointStyle(nodes, Renderer.PointStyle.SPHERE);
    RenderProps.setPointRadius(nodes, 0.01);
    RenderProps.setPointColor(nodes, new Color(153, 0, 204));
    // fix the leftmost nodes
    LinkedList<FemNode3d> leftNodes = getLeftNodes(femMod);
    LinkedList<FemNode3d> rightNodes = getRightNodes(femMod);
    myAttachNodes = rightNodes.toArray(new FemNode3d[0]);
    double wx, wy, wz;
    double mass;
    RigidTransform3d X = new RigidTransform3d();
    PolygonalMesh mesh;
    MechModel mechMod = new MechModel("mech");
    // mechMod.setPrintState ("%10.5f");
    wx = 0.1;
    wy = 0.3;
    wz = 0.3;
    RigidBody leftBody = new RigidBody("leftBody");
    mass = wx * wy * wz * myDensity;
    leftBody.setInertia(SpatialInertia.createBoxInertia(mass, wx, wy, wz));
    mesh = MeshFactory.createBox(wx, wy, wz);
    // mesh.setRenderMaterial (Material.createSpecial (Material.GRAY));
    leftBody.setMesh(mesh, /* fileName= */
    null);
    X.R.setIdentity();
    X.p.set(-0.35, 0, 0);
    leftBody.setPose(X);
    leftBody.setDynamic(true);
    mechMod.addRigidBody(leftBody);
    RenderProps.setPointStyle(mechMod, Renderer.PointStyle.SPHERE);
    RigidTransform3d TCW = new RigidTransform3d();
    RigidTransform3d TCA = new RigidTransform3d();
    TCA.p.set(0, 0, wz / 2);
    TCA.R.mulAxisAngle(1, 0, 0, Math.PI / 2);
    TCW.mul(X, TCA);
    RevoluteJoint joint = new RevoluteJoint(leftBody, TCA, TCW);
    RenderProps.setCylindricalLines(joint, 0.01, Color.BLUE);
    joint.setAxisLength(0.5);
    mechMod.addBodyConnector(joint);
    // right box
    RigidBody rightBody = new RigidBody("rightBody");
    rightBody.setInertia(SpatialInertia.createBoxInertia(mass, wx, wy, wz));
    mesh = MeshFactory.createBox(wx, wy, wz);
    // mesh.setRenderMaterial (Material.createSpecial (Material.GRAY));
    rightBody.setMesh(mesh, /* fileName= */
    null);
    X.p.set(0.35, 0, 0);
    rightBody.setPose(X);
    rightBody.setDynamic(true);
    mechMod.addRigidBody(rightBody);
    mechMod.addModel(femMod);
    for (FemNode3d n : leftNodes) {
        mechMod.attachPoint(n, leftBody);
    }
    // femMod.setProfile (true);
    mechMod.setIntegrator(Integrator.BackwardEuler);
    setConnected(true);
    addModel(mechMod);
    // mechMod.setProfiling (true);
    // int numWays = 10;
    // double res = 0.1;
    // for (int i = 0; i < numWays; i++) {
    // addWayPoint (new WayPoint (TimeBase.secondsToTicks ((i + 1) * res)));
    // }
    // addWayPoint (new WayPoint (TimeBase.secondsToTicks (5)));
    // addBreakPoint(5);
    // setupOutputProbes();
    addControlPanel(mechMod, femMod);
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) MechModel(artisynth.core.mechmodels.MechModel) FemNode3d(artisynth.core.femmodels.FemNode3d) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 54 with MechModel

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

the class FemMuscleArm method build.

public void build(String[] args) throws IOException {
    model = new MechModel("Arm");
    addModel(model);
    model.setIntegrator(MechSystemSolver.Integrator.BackwardEuler);
    model.setMaxStepSize(0.01);
    AxialSpring.myIgnoreCoriolisInJacobian = false;
    setupRenderProps();
    addRigidBodies();
    addJoint();
    // addFemMuscle(new Point3d(2.4, 0, 20), new Point3d(3, 0, -7));
    addFemMuscle(new Point3d(-1.5, 0.0, 18), new Point3d(-4, 0.0, -2));
    // addAntagonist();
    // addLoad();
    addEndPoint();
    setCollisions(true);
    addControlPanel();
    addProbes();
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) Point3d(maspack.matrix.Point3d)

Example 55 with MechModel

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

the class FemMuscleArm method getCollisions.

public boolean getCollisions() {
    MechModel mech = (MechModel) models().get(0);
    PointToPointMuscle muscle = (PointToPointMuscle) mech.findComponent("models/0");
    RigidBody upperArm = (RigidBody) mech.findComponent("rigidBodies/upper");
    if (muscle == null || upperArm == null) {
        return false;
    }
    CollisionBehavior cb = mech.getCollisionBehavior(muscle, upperArm);
    return cb != null && cb.isEnabled();
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) CollisionBehavior(artisynth.core.mechmodels.CollisionBehavior) PointToPointMuscle(artisynth.core.femmodels.PointToPointMuscle) RigidBody(artisynth.core.mechmodels.RigidBody)

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