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;
}
}
}
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;
}
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);
}
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);
}
}
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);
}
Aggregations