Search in sources :

Example 6 with NumericInputProbe

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();
            }
        }
    }
}
Also used : Frame(artisynth.core.mechmodels.Frame) ModelComponent(artisynth.core.modelbase.ModelComponent) NumericInputProbe(artisynth.core.probes.NumericInputProbe) ArrayList(java.util.ArrayList) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) Point(artisynth.core.mechmodels.Point) WayPoint(artisynth.core.probes.WayPoint) IOException(java.io.IOException) Property(maspack.properties.Property) File(java.io.File)

Example 7 with NumericInputProbe

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();
    }
}
Also used : NumericInputProbe(artisynth.core.probes.NumericInputProbe) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) IOException(java.io.IOException)

Example 8 with NumericInputProbe

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();
    }
}
Also used : NumericInputProbe(artisynth.core.probes.NumericInputProbe) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe)

Example 9 with NumericInputProbe

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();
}
Also used : NumericInputProbe(artisynth.core.probes.NumericInputProbe) File(java.io.File) Property(maspack.properties.Property) TargetPoint(artisynth.core.inverse.TargetPoint)

Example 10 with NumericInputProbe

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);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) CollisionManager(artisynth.core.mechmodels.CollisionManager) ControlPanel(artisynth.core.gui.ControlPanel) NumericInputProbe(artisynth.core.probes.NumericInputProbe)

Aggregations

NumericInputProbe (artisynth.core.probes.NumericInputProbe)19 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)9 IOException (java.io.IOException)8 Property (maspack.properties.Property)5 File (java.io.File)4 ArrayList (java.util.ArrayList)3 ModelComponent (artisynth.core.modelbase.ModelComponent)2 WayPoint (artisynth.core.probes.WayPoint)2 ControlPanel (artisynth.core.gui.ControlPanel)1 Displayable (artisynth.core.gui.Displayable)1 AddComponentsCommand (artisynth.core.gui.editorManager.AddComponentsCommand)1 InputNumericProbeEditor (artisynth.core.gui.probeEditor.InputNumericProbeEditor)1 NumericProbeEditor (artisynth.core.gui.probeEditor.NumericProbeEditor)1 OutputNumericProbeEditor (artisynth.core.gui.probeEditor.OutputNumericProbeEditor)1 TargetPoint (artisynth.core.inverse.TargetPoint)1 CollisionManager (artisynth.core.mechmodels.CollisionManager)1 Frame (artisynth.core.mechmodels.Frame)1 MechModel (artisynth.core.mechmodels.MechModel)1 Point (artisynth.core.mechmodels.Point)1 NumericProbeBase (artisynth.core.probes.NumericProbeBase)1