Search in sources :

Example 16 with MechModel

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

the class SkinDemo method build.

public void build(String[] args) {
    model = new MechModel("Arm");
    addModel(model);
    model.setIntegrator(MechSystemSolver.Integrator.RungeKutta4);
    model.setMaxStepSize(0.01);
    setupRenderProps();
    addRigidBodies();
    addJoint();
    addMuscle();
    // addAntagonist();
    addEndPoint();
    addSkinMesh();
    addFiberMesh();
    addProbes();
    addPanel();
}
Also used : MechModel(artisynth.core.mechmodels.MechModel)

Example 17 with MechModel

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

the class SpringMeshDemo method setAttachment.

public void setAttachment(boolean enable) {
    if (models().size() > 0) {
        MechModel model = (MechModel) models().getByNumber(0);
        Particle pntA = model.particles().get("pntA");
        Particle pntB = model.particles().get("pntB");
        // make sure model is consistent
        if (pntA.isAttached() && !enable) {
            model.detachPoint(pntA);
        } else if (!pntA.isAttached() && enable) {
            model.attachPoint(pntA, pntB);
        }
    }
    pointsAttached = enable;
}
Also used : Particle(artisynth.core.mechmodels.Particle) MechModel(artisynth.core.mechmodels.MechModel)

Example 18 with MechModel

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

the class SpringMeshDemo method build.

public void build(String[] args) {
    MechModel msmod = new MechModel("msmod");
    // PropertyInfoList list = msmod.getAllPropertyInfo();
    // for (PropertyInfo info : list)
    // { System.out.println (info.getName());
    // }
    msmod.setGravity(0, 0, -9.8);
    // msmod.setGravity (0, 0, 0);
    msmod.setPointDamping(1.0);
    // msmod.setIntegrator (new ForwardEuler());
    // // set view so tha points upwards
    // X.R.setAxisAngle (1, 0, 0, -Math.PI/2);
    // viewer.setTransform (X);
    RenderProps.setPointStyle(msmod, Renderer.PointStyle.SPHERE);
    RenderProps.setPointRadius(msmod, 2);
    RenderProps.setPointColor(msmod, Color.RED);
    RenderProps.setLineRadius(msmod, 0.5);
    RenderProps.setLineStyle(msmod, Renderer.LineStyle.CYLINDER);
    // PlaneCollider collider =
    // new PlaneCollider("plane",
    // new Plane(0, 0, 1, planeZ), 200, 50);
    // collider.setRenderPosition (new Point3d(0, 0, 0), 25);
    // collider.addMechModel (msmod);
    RenderProps props = (new Particle()).createRenderProps();
    props.setPointRadius(2);
    props.setPointStyle(Renderer.PointStyle.SPHERE);
    props.setPointColor(Color.GREEN);
    Particle p0 = new Particle(5, -10, 0, 20);
    p0.setRenderProps(props);
    p0.setDynamic(false);
    Particle p1 = new Particle(5, 0, 0, 25);
    p1.setRenderProps(props);
    Particle p2 = new Particle(5, 0, 0, 15);
    p2.setRenderProps(props);
    Particle p3 = new Particle(5, 10, 0, 20);
    p3.setRenderProps(props);
    AxialSpring[] springs = new AxialSpring[10];
    for (int i = 0; i < springs.length; i++) {
        springs[i] = new AxialSpring(50, 20, 10);
    }
    msmod.particles().addNumbered(p0, 5);
    msmod.particles().addNumbered(p1, 4);
    msmod.particles().addNumbered(p2, 0);
    msmod.particles().addNumbered(p3, 1);
    // msmod.particles().add (p0);
    // msmod.particles().add (p1);
    // msmod.particles().add (p2);
    // msmod.particles().add (p3);
    msmod.attachAxialSpring(p0, p1, springs[0]);
    msmod.attachAxialSpring(p0, p2, springs[1]);
    msmod.attachAxialSpring(p1, p2, springs[2]);
    msmod.attachAxialSpring(p1, p3, springs[3]);
    msmod.attachAxialSpring(p2, p3, springs[4]);
    Particle p10 = new Particle(5, 10, 0, 20);
    Particle p11 = new Particle(5, 5, 0, 10);
    Particle p12 = new Particle(5, 15, 0, 10);
    Particle p13 = new Particle(5, 10, 0, 0);
    msmod.addParticle(p10);
    msmod.addParticle(p11);
    msmod.addParticle(p12);
    msmod.addParticle(p13);
    // add names to some particles so they can be found for probing and
    // attachment
    p0.setName("pnt0");
    p3.setName("pntA");
    p10.setName("pntB");
    p13.setName("pnt7");
    msmod.attachAxialSpring(p10, p11, springs[5]);
    msmod.attachAxialSpring(p10, p12, springs[6]);
    msmod.attachAxialSpring(p11, p12, springs[7]);
    msmod.attachAxialSpring(p11, p13, springs[8]);
    msmod.attachAxialSpring(p12, p13, springs[9]);
    // test for bad component insertion:
    // Particle px = new Particle (5, 10, 0, 0);
    // Particle py = new Particle (5, 10, 0, 0);
    // msmod.attachAxialSpring (px, py, new AxialSpring (50, 20, 10));
    msmod.setBounds(new Point3d(0, 0, -25), new Point3d(0, 0, 25));
    addModel(msmod);
    msmod.scaleMass(4);
    setAttachment(true);
    // int numWays = 10;
    // double res = 1;
    // for (int i=0; i<numWays; i++)
    // { Main.getWorkspace().addWayPoint (
    // new WayPoint(TimeBase.secondsToTicks((i+1)*res), true));
    // }
    addControlPanel();
    addProbes(msmod);
    addWayPoint(0.5);
    // addBreakPoint (1.0);
    addWayPoint(1.0);
    addWayPoint(1.5);
    ReferenceList refs = new ReferenceList("refs");
    refs.addReference(p0);
    refs.addReference(p1);
    refs.addReference(p10);
    refs.addReference(p11);
    refs.addReference(msmod.particles());
    msmod.add(refs);
// msmod.setProfiling (true);
}
Also used : Particle(artisynth.core.mechmodels.Particle) MechModel(artisynth.core.mechmodels.MechModel) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 19 with MechModel

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

the class LinearAuxiliaryTest method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = new MechModel("mech");
    addModel(mech);
    double h = 0.1;
    double r = 0.005;
    LinearMaterial lmat = new LinearMaterial(50000, 0.45, true);
    FemModel3d fem1 = createCylinder(h, r);
    fem1.setName("auxiliary");
    mech.addModel(fem1);
    fem1.setMaterial(new NullMaterial());
    AuxMaterialBundle bundle = new AuxMaterialBundle("mat");
    for (FemElement3d elem : fem1.getElements()) {
        bundle.addElement(new AuxMaterialElementDesc(elem));
    }
    fem1.addMaterialBundle(bundle);
    bundle.setMaterial(lmat);
    FemModel3d fem2 = createCylinder(h, r);
    fem2.setName("linear");
    fem2.setMaterial(lmat);
    mech.addModel(fem2);
    RigidTransform3d rot = new RigidTransform3d(Vector3d.ZERO, AxisAngle.ROT_Y_90);
    fem1.transformGeometry(rot);
    fem2.transformGeometry(rot);
    fem2.transformGeometry(new RigidTransform3d(new Vector3d(0, 2 * r, 0), AxisAngle.IDENTITY));
    RenderProps.setFaceColor(fem2, Color.MAGENTA);
    addMonitor(new StiffnessErrorMonitor(fem1, fem2));
}
Also used : NullMaterial(artisynth.core.materials.NullMaterial) MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) FemElement3d(artisynth.core.femmodels.FemElement3d) Vector3d(maspack.matrix.Vector3d) AuxMaterialElementDesc(artisynth.core.femmodels.AuxMaterialElementDesc) AuxMaterialBundle(artisynth.core.femmodels.AuxMaterialBundle) LinearMaterial(artisynth.core.materials.LinearMaterial)

Example 20 with MechModel

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

the class ForceTargetDemo method build.

public void build(String[] args) throws IOException {
    // create MechModel and add to RootModel
    mech = new MechModel("mech");
    addModel(mech);
    // create the components
    p1 = new Particle("p1", /*mass=*/
    2, /*x,y,z=*/
    0, 0, 0.15);
    p2 = new Particle("p2", 2, 10, 0, 0.15);
    p3 = new Particle("p3", 2, 5, 5, 0);
    p4 = new Particle("p4", 2, 5, -5, 0);
    p5 = new Particle("p5", 0, 5, 0, 5);
    p6 = new Particle("p6", 0, 5, 0, -5);
    box = RigidBody.createBox("box", /*wx,wy,wz=*/
    0.5, 0.3, 0.3, /*density=*/
    1);
    box.setPose(new RigidTransform3d(/*x,y,z=*/
    5, 0, -0.15));
    // create marker point and connect it to the box:
    FrameMarker mkr = new FrameMarker(/*x,y,z=*/
    0, 0, 0.15);
    mkr.setFrame(box);
    // create the muscle:
    muscle = new Muscle("mus1", /*restLength=*/
    5);
    muscle.setPoints(p1, mkr);
    muscle.setMaterial(new SimpleAxialMuscle(/*stiffness=*/
    0, /*damping=*/
    10, /*maxf=*/
    1000));
    muscle2 = new Muscle("mus2", /*restLength=*/
    5);
    muscle2.setPoints(p2, mkr);
    muscle2.setMaterial(new SimpleAxialMuscle(/*stiffness=*/
    0, /*damping=*/
    10, /*maxf=*/
    1000));
    muscle3 = new Muscle("mus3", /*restLength=*/
    5);
    muscle3.setPoints(p3, mkr);
    muscle3.setMaterial(new SimpleAxialMuscle(/*stiffness=*/
    0, /*damping=*/
    10, /*maxf=*/
    4000));
    muscle4 = new Muscle("mus4", /*restLength=*/
    5);
    muscle4.setPoints(p4, mkr);
    muscle4.setMaterial(new SimpleAxialMuscle(/*stiffness=*/
    0, /*damping=*/
    10, /*maxf=*/
    4000));
    muscle5 = new Muscle("mus5", /*restLength=*/
    5);
    muscle5.setPoints(p5, mkr);
    muscle5.setMaterial(new SimpleAxialMuscle(/*stiffness=*/
    0, /*damping=*/
    10, /*maxf=*/
    4000));
    muscle6 = new Muscle("mus6", /*restLength=*/
    5);
    muscle6.setPoints(p6, mkr);
    muscle6.setMaterial(new SimpleAxialMuscle(/*stiffness=*/
    0, /*damping=*/
    10, /*maxf=*/
    4000));
    if (two_cons == true) {
        RigidTransform3d XPW = new RigidTransform3d(5, 0, 0);
        XPW.R.mulAxisAngle(1, 0, 0, Math.toRadians(90));
        // Connection on the corner
        // PlanarConnector connector =
        // new PlanarConnector (box, new Vector3d (lenx/2, -2.5, 1.5), XPW);
        // Connection in the center
        con = new PlanarConnector(box, new Vector3d(0, 0, 0.15), XPW);
        con.setUnilateral(false);
        con.setPlaneSize(2);
        RenderProps props = con.createRenderProps();
        props.setPointColor(Color.blue);
        props.setPointStyle(Renderer.PointStyle.SPHERE);
        props.setPointRadius(0.06);
        con.setRenderProps(props);
        // con = new ParticlePlaneConstraint(p5, pl);
        // RenderProps.setDrawEdges (con, true);
        // RenderProps.setVisible (con, true);
        RigidTransform3d XPW2 = new RigidTransform3d(5, 0, 0);
        XPW2.R.mulAxisAngle(1, 0, 0, 0);
        // Connection on the corner
        // PlanarConnector connector =
        // new PlanarConnector (box, new Vector3d (lenx/2, -2.5, 1.5), XPW);
        // Connection in the center
        con2 = new PlanarConnector(box, new Vector3d(0, 0, 0.15), XPW2);
        con2.setUnilateral(false);
        con2.setPlaneSize(2);
        con2.setRenderProps(props);
    } else {
        RigidTransform3d XPW = new RigidTransform3d(5, 0, 0);
        XPW.R.mulAxisAngle(1, 0, 0, Math.toRadians(45));
        con = new PlanarConnector(box, new Vector3d(0, 0, 0.15), XPW);
        con.setUnilateral(false);
        con.setPlaneSize(2);
        RenderProps props = con.createRenderProps();
        props.setPointColor(Color.blue);
        props.setPointStyle(Renderer.PointStyle.SPHERE);
        props.setPointRadius(0.06);
        con.setRenderProps(props);
    }
    // con.setRenderProps (myRenderProps);
    // add components to the mech model
    mech.addParticle(p1);
    mech.addParticle(p2);
    mech.addParticle(p3);
    mech.addParticle(p4);
    mech.addParticle(p5);
    mech.addParticle(p6);
    mech.addRigidBody(box);
    mech.addFrameMarker(mkr);
    // mech.addParticle (p5);
    mech.addAxialSpring(muscle);
    mech.addAxialSpring(muscle2);
    mech.addAxialSpring(muscle3);
    mech.addAxialSpring(muscle4);
    mech.addAxialSpring(muscle5);
    mech.addAxialSpring(muscle6);
    con.setName("con1");
    if (two_cons == true) {
        con2.setName("con2");
    }
    if (cons == true) {
        mech.addBodyConnector(con);
        ConnectorForceRenderer rend = new ConnectorForceRenderer(con);
        myRenderProps = rend.createRenderProps();
        myRenderProps.setLineStyle(LineStyle.CYLINDER);
        myRenderProps.setLineRadius(0.175);
        myRenderProps.setLineColor(Color.BLUE);
        rend.setRenderProps(myRenderProps);
        rend.setArrowSize(0.1);
        addMonitor(rend);
    }
    if (two_cons == true) {
        mech.addBodyConnector(con2);
    }
    // first particle set to be fixed
    p1.setDynamic(false);
    p2.setDynamic(false);
    p3.setDynamic(false);
    p4.setDynamic(false);
    p5.setDynamic(false);
    p6.setDynamic(false);
    // increase model bounding box for the viewer
    mech.setBounds(/*min=*/
    -1, 0, -1, /*max=*/
    1, 0, 0);
    // set render properties for the components
    setPointRenderProps(p1);
    setPointRenderProps(p2);
    setPointRenderProps(p3);
    setPointRenderProps(p4);
    setPointRenderProps(p5);
    setPointRenderProps(p6);
    setPointRenderProps(mkr);
    setLineRenderProps(muscle);
    setLineRenderProps(muscle2);
    setLineRenderProps(muscle3);
    setLineRenderProps(muscle4);
    setLineRenderProps(muscle5);
    setLineRenderProps(muscle6);
    addTrackingController(mkr);
    if (cons = true) {
        addConForceProbe(10, 0.1);
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) ConnectorForceRenderer(artisynth.core.inverse.ConnectorForceRenderer) FrameMarker(artisynth.core.mechmodels.FrameMarker) Vector3d(maspack.matrix.Vector3d) PlanarConnector(artisynth.core.mechmodels.PlanarConnector) RenderProps(maspack.render.RenderProps) SimpleAxialMuscle(artisynth.core.materials.SimpleAxialMuscle) Muscle(artisynth.core.mechmodels.Muscle) SimpleAxialMuscle(artisynth.core.materials.SimpleAxialMuscle)

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