Search in sources :

Example 16 with AxialSpring

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

the class PointModel method add2dLabeledMuscles.

public void add2dLabeledMuscles(String[] labels) {
    double[] muscleFs;
    double muscleFmult;
    if (applyDisturbance) {
        muscleFs = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
        muscleFmult = 100;
    } else {
        muscleFs = new double[] { 5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1 };
        muscleFmult = 10;
    }
    addMuscles(new RigidTransform3d(), labels.length, 0.0);
    int i = 0;
    for (AxialSpring s : model.axialSprings()) {
        if (s instanceof Muscle) {
            s.setName(labels[i]);
            // ((Muscle) s).setMaxForce(muscleFmult * muscleFs[i]);
            // RenderProps.setLineRadius(s, 0.1 * muscleFs[i]);
            i += 1;
        }
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) LinearAxialMuscle(artisynth.core.materials.LinearAxialMuscle) Muscle(artisynth.core.mechmodels.Muscle) Point(artisynth.core.mechmodels.Point) SphericalJoint(artisynth.core.mechmodels.SphericalJoint) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 17 with AxialSpring

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

the class PointModel method addAxialSpring.

private AxialSpring addAxialSpring(Point p0, Point p1) {
    AxialSpring s = new AxialSpring(springK, springD, springRestLen);
    s.setFirstPoint(p0);
    s.setSecondPoint(p1);
    model.addAxialSpring(s);
    RenderProps.setLineColor(s, Color.GRAY);
    RenderProps.setLineStyle(s, LineStyle.LINE);
    RenderProps.setLineWidth(s, 4);
    return s;
}
Also used : AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 18 with AxialSpring

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

the class PointModel method addTrackingController.

public void addTrackingController() {
    TrackingController myTrackingController = new TrackingController(model, "tcon");
    for (AxialSpring s : model.axialSprings()) {
        if (s instanceof Muscle) {
            myTrackingController.addExciter((Muscle) s);
        }
    }
    // myTrackingController.addTerm(new StiffnessTerm(model, center));
    // StiffnessTerm kTerm = TrackingController.addStiffnessTarget(center, new int[]{0,2});
    // kTerm.setStiffnessTargetType(StiffnessTargetType.DIAG);
    // ComplianceTerm2d cterm = new ComplianceTerm2d(TrackingController, center, new int[]{0,2});
    // cterm.setComplianceTargetType(StiffnessTargetType.DIAG);
    // TrackingController.addTerm(cterm);
    myTrackingController.addL2RegularizationTerm();
    // myTrackingController.addTerm(new DampingTerm(TrackingController));
    // myTrackingController.addTerm(new StaticMotionTargetTerm(TrackingController));
    MotionTargetComponent target = myTrackingController.addMotionTarget(center);
    RenderProps.setPointRadius((Renderable) target, 0.525);
    if (useReactionForceTargetP) {
        ForceTargetTerm forceTerm = new ForceTargetTerm(myTrackingController);
        ForceTarget ft = forceTerm.addForceTarget(model.bodyConnectors().get("center_constraint"));
        ft.setArrowSize(2);
        RenderProps.setLineStyle(ft, LineStyle.CYLINDER);
        RenderProps.setLineRadius(ft, 0.25);
        forceTerm.setWeight(1d);
        myTrackingController.addForceTargetTerm(forceTerm);
    }
    // myTrackingController.getSolver().setBounds(0.01, 0.99);
    myTrackingController.createProbesAndPanel(this);
    addController(myTrackingController);
}
Also used : LinearAxialMuscle(artisynth.core.materials.LinearAxialMuscle) Muscle(artisynth.core.mechmodels.Muscle) ForceTargetTerm(artisynth.core.inverse.ForceTargetTerm) ForceTarget(artisynth.core.inverse.ForceTarget) MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent) AxialSpring(artisynth.core.mechmodels.AxialSpring) TrackingController(artisynth.core.inverse.TrackingController)

Example 19 with AxialSpring

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

the class PointModel1d method setProperties.

public void setProperties() {
    double springK = 100.0;
    double passiveFraction = 0.5;
    double muscleD = 0.0;
    double pointDamping = 0.1;
    for (AxialSpring s : model.axialSprings()) {
        if (s instanceof AxialSpring) {
            if (s.getMaterial() instanceof LinearAxialMaterial) {
                LinearAxialMaterial mat = (LinearAxialMaterial) s.getMaterial().clone();
                mat.setStiffness(springK);
                s.setMaterial(mat);
            }
        }
        if (s instanceof Muscle) {
            Muscle m = (Muscle) s;
            if (m.getMaterial() instanceof AxialMuscleMaterial) {
                AxialMuscleMaterial mat = (AxialMuscleMaterial) m.getMaterial().clone();
                mat.setPassiveFraction(passiveFraction);
                mat.setDamping(muscleD);
                m.setMaterial(mat);
            }
        }
    }
    for (Particle p : model.particles()) {
        p.setPointDamping(pointDamping);
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Muscle(artisynth.core.mechmodels.Muscle) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 20 with AxialSpring

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

the class PointModel2d method addTrackingController.

public void addTrackingController() {
    super.addTrackingController();
    for (AxialSpring s : model.axialSprings()) {
        if (s instanceof Muscle) {
            ((Muscle) s).setExcitationColor(Color.RED);
            RenderProps.setLineColor(s, new Color(0, 0, 219));
        }
    }
    model.setMaxColoredExcitation(0.1);
}
Also used : Color(java.awt.Color) Muscle(artisynth.core.mechmodels.Muscle) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Aggregations

AxialSpring (artisynth.core.mechmodels.AxialSpring)20 Particle (artisynth.core.mechmodels.Particle)10 Muscle (artisynth.core.mechmodels.Muscle)8 Point3d (maspack.matrix.Point3d)8 RigidBody (artisynth.core.mechmodels.RigidBody)5 FrameMarker (artisynth.core.mechmodels.FrameMarker)4 MechModel (artisynth.core.mechmodels.MechModel)4 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)3 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)3 Color (java.awt.Color)3 RenderProps (maspack.render.RenderProps)3 ForceTarget (artisynth.core.inverse.ForceTarget)2 ForceTargetTerm (artisynth.core.inverse.ForceTargetTerm)2 TrackingController (artisynth.core.inverse.TrackingController)2 Point (artisynth.core.mechmodels.Point)2 WayPoint (artisynth.core.probes.WayPoint)2 RigidTransform3d (maspack.matrix.RigidTransform3d)2 FemElement (artisynth.core.femmodels.FemElement)1 FemMarker (artisynth.core.femmodels.FemMarker)1 FemNode (artisynth.core.femmodels.FemNode)1