use of artisynth.core.probes.NumericInputProbe in project artisynth_core by artisynth.
the class InverseManager method configureTargetMotionProbe.
private void configureTargetMotionProbe(NumericProbeBase probe, ArrayList<MotionTargetComponent> targets, String filename) {
// System.out.println ("configuring motion probe");
ArrayList<Property> props = new ArrayList<Property>();
for (ModelComponent target : targets) {
if (target instanceof Point) {
props.add(target.getProperty("position"));
} else if (target instanceof Frame) {
props.add(target.getProperty("position"));
props.add(target.getProperty("orientation"));
} else {
System.err.println("Unknown target component type: " + target.getClass().toString());
}
}
// probe.setModel(myController.getMech());
probe.setAttachedFileName(filename);
if (probe instanceof NumericInputProbe) {
((NumericInputProbe) probe).setInputProperties(props.toArray(new Property[props.size()]));
} else if (probe instanceof NumericOutputProbe) {
((NumericOutputProbe) probe).setOutputProperties(props.toArray(new Property[props.size()]));
}
if (probe instanceof NumericInputProbe) {
File file = probe.getAttachedFile();
if (file == null || !file.exists()) {
((NumericInputProbe) probe).loadEmpty();
probe.setActive(false);
} else {
try {
probe.load();
probe.setActive(true);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
use of artisynth.core.probes.NumericInputProbe in project artisynth_core by artisynth.
the class SkinDemo method addProbes.
public void addProbes() {
NumericInputProbe ip;
NumericOutputProbe op;
double rate = 0.01;
try {
String path = ArtisynthPath.getHomeRelativePath("src/artisynth/demos/mech/", ".");
ip = new NumericInputProbe(model, "axialSprings/muscle:excitation", path + "muscleArmActivation.txt");
ip.setStartStopTimes(0, 10.0);
ip.setName("Muscle Activation");
ip.setActive(false);
addInputProbe(ip);
} catch (Exception e) {
System.out.println("Error adding probe:");
e.printStackTrace();
}
}
use of artisynth.core.probes.NumericInputProbe in project artisynth_core by artisynth.
the class SpringMeshDemo method addProbes.
public void addProbes(MechModel mech) {
try {
NumericInputProbe inprobe = new NumericInputProbe(mech, "particles/pnt0:targetPosition", ArtisynthPath.getSrcRelativePath(SpringMeshDemo.class, // inprobe.setDefaultDisplayRange (-10, 10);
"springMeshIn.txt"));
inprobe.setStopTime(10);
// NumericInputProbe inprobe =
// new NumericInputProbe (
// mech, "particles/0" + sep + "targetPosition", 0, 10);
// inprobe.addData (
// new double[] { 0, 2, -2, 0, 5, 2, -2, 0, 10, 2, -2, 0 },
// NumericInputProbe.EXPLICIT_TIME);
addInputProbe(inprobe);
// for (int i=0; i<3; i++) {
// inprobe = new NumericInputProbe (
// mech, "particles/0:targetPosition", i*2.2, i*2.2+2);
// addInputProbe (inprobe);
// }ply
NumericOutputProbe collector = new NumericOutputProbe(mech, "particles/pnt7:position", ArtisynthPath.getSrcRelativePath(this, "springMeshOut.txt"), 0.01);
collector.setDefaultDisplayRange(-40, 20);
collector.setStartTime(0);
collector.setStopTime(10);
addOutputProbe(collector);
} catch (Exception e) {
e.printStackTrace();
}
}
use of artisynth.core.probes.NumericInputProbe in project artisynth_core by artisynth.
the class ForceTargetDemo method loadForceInputProbe.
public void loadForceInputProbe(ForceTargetTerm mft) throws IOException {
ArtisynthPath.setWorkingDir(new File(ArtisynthPath.getSrcRelativePath(this, "data/")));
Property[] proparr = new Property[mft.getForceTargets().size()];
for (int i = 0; i < mft.getForceTargets().size(); i++) {
System.out.println(mft.getForceTargets().get(i).getConnector().getName());
proparr[i] = mft.getForceTargets().get(i).getProperty("targetLambda");
}
NumericInputProbe forprobe = new NumericInputProbe();
forprobe.setModel(mech);
forprobe.setInputProperties(proparr);
forprobe.setInterval(0, 1);
forprobe.setName("Force Target");
if (two_cons == true) {
forprobe.setAttachedFileName("inputforcetarget3.txt");
} else {
forprobe.setAttachedFileName("inputforcetarget2.txt");
}
forprobe.setStartStopTimes(0, 10);
addInputProbe(forprobe);
forprobe.load();
}
use of artisynth.core.probes.NumericInputProbe in project artisynth_core by artisynth.
the class SimpleCollide method build.
public void build(String[] args) {
MechModel mechMod = new MechModel("mechModel");
mechMod.setMaxStepSize(0.01);
mechMod.setIntegrator(Integrator.ConstrainedBackwardEuler);
addModel(mechMod);
// for block/block friction test
// mySeparation = 1.09;
// mySeparation = .615;
CollisionManager cm = mechMod.getCollisionManager();
cm.setColliderType(ColliderType.SIGNED_DISTANCE);
cm.setDrawIntersectionContours(true);
RenderProps.setEdgeWidth(cm, 2);
RenderProps.setEdgeColor(cm, Color.YELLOW);
RenderProps.setVisible(cm, true);
setTopObject(ObjectType.FemEllipsoid);
setBottomObject(ObjectType.Box);
// for block/block friction test
// mechMod.transformGeometry (
// new RigidTransform3d (0, 0, 0, 0, 1, 0, Math.toRadians(20)));
mechMod.setProfiling(false);
ControlPanel panel = new ControlPanel("controls");
panel.addWidget(this, "topObject");
panel.addWidget(this, "bottomObject");
panel.addWidget(mechMod, "integrator");
panel.addWidget(this, "friction");
panel.addWidget(mechMod, "collisionManager:compliance");
panel.addWidget(mechMod, "collisionManager:damping");
addControlPanel(panel, 0);
// mechMod.transformGeometry (
// new RigidTransform3d (0, 0, 0, 0, 1, 0, Math.PI));
Main.getMain().arrangeControlPanels(this);
// panel.pack();
// panel.setVisible (true);
// java.awt.Point loc = Main.getMainFrame().getLocation();
// panel.setLocation(loc.x + Main.getMainFrame().getWidth(), loc.y);
// addControlPanel (panel);
NumericInputProbe iprobe = new NumericInputProbe(mechMod, "rigidBodies/bottomObject:targetOrientation", 0, 6);
// new NumericInputProbe (
// mechMod, "rigidBodies/bottomObject:targetPosition", 0, 6);
iprobe.addData(new double[] { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 3, 0, 1, 0, 90, 5, 0, 1, 0, 180, 6, 0, 1, 0, 180 }, NumericInputProbe.EXPLICIT_TIME);
// iprobe.addData (
// new double[] { 0, 0, 0, 0, 1, 0, 0, 2, 2, 0, 0, 0, 3, 0, 0,
// 2, 4, 0, 0, 0,},
// NumericInputProbe.EXPLICIT_TIME);
//
//
iprobe.setActive(true);
addInputProbe(iprobe);
addBreakPoint(1.34);
}
Aggregations