Search in sources :

Example 31 with Muscle

use of artisynth.core.mechmodels.Muscle 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 32 with Muscle

use of artisynth.core.mechmodels.Muscle 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 33 with Muscle

use of artisynth.core.mechmodels.Muscle 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 34 with Muscle

use of artisynth.core.mechmodels.Muscle 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)

Example 35 with Muscle

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

the class HydrostatModel method createMuscles.

public void createMuscles(Axis axis, MuscleBundle bundle) {
    RenderProps.setLineWidth(bundle, 4);
    Point3d p0 = new Point3d();
    Point3d p1 = new Point3d();
    for (double i = 0; i < (axis == Axis.X ? nl : nl + 1); i++) for (double j = 0; j < (axis == Axis.Y ? nr : nr + 1); j++) for (double k = 0; k < (axis == Axis.Z ? nr : nr + 1); k++) {
        if (periphLongP && axis == Axis.X && ((j != 0 && j != nr) && (k != 0 && k != nr)))
            continue;
        p0.set(l * (i / nl - 0.5), r * (j / nr - 0.5), r * (k / nr - 0.5));
        p1.set(l * ((axis == Axis.X ? i + 1 : i) / (nl) - 0.5), r * ((axis == Axis.Y ? j + 1 : j) / nr - 0.5), r * ((axis == Axis.Z ? k + 1 : k) / nr - 0.5));
        Muscle f = new Muscle(findPoint(p0), findPoint(p1));
        f.setConstantMuscleMaterial(muscleForce, 1);
        bundle.addFibre(f);
    }
}
Also used : Point3d(maspack.matrix.Point3d) Muscle(artisynth.core.mechmodels.Muscle) ConstantAxialMuscle(artisynth.core.materials.ConstantAxialMuscle)

Aggregations

Muscle (artisynth.core.mechmodels.Muscle)35 Point3d (maspack.matrix.Point3d)13 Point (artisynth.core.mechmodels.Point)10 ConstantAxialMuscle (artisynth.core.materials.ConstantAxialMuscle)9 AxialSpring (artisynth.core.mechmodels.AxialSpring)8 GenericMuscle (artisynth.core.materials.GenericMuscle)7 MuscleBundle (artisynth.core.femmodels.MuscleBundle)6 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)5 SimpleAxialMuscle (artisynth.core.materials.SimpleAxialMuscle)4 Particle (artisynth.core.mechmodels.Particle)4 RenderProps (maspack.render.RenderProps)4 FrameMarker (artisynth.core.mechmodels.FrameMarker)3 MuscleExciter (artisynth.core.mechmodels.MuscleExciter)3 Vector3d (maspack.matrix.Vector3d)3 FemMarker (artisynth.core.femmodels.FemMarker)2 ForceTarget (artisynth.core.inverse.ForceTarget)2 ForceTargetTerm (artisynth.core.inverse.ForceTargetTerm)2 TrackingController (artisynth.core.inverse.TrackingController)2 AxialMuscleMaterial (artisynth.core.materials.AxialMuscleMaterial)2 RigidBody (artisynth.core.mechmodels.RigidBody)2