Search in sources :

Example 1 with NumericOutputProbe

use of artisynth.core.probes.NumericOutputProbe in project artisynth_core by artisynth.

the class ProbeInfo method editProbe.

// edit the probe
private void editProbe() {
    NumericProbeEditor dialog;
    if (getProbe().isInput()) {
        dialog = new InputNumericProbeEditor((NumericInputProbe) getProbe());
    } else {
        dialog = new OutputNumericProbeEditor((NumericOutputProbe) getProbe());
    }
    dialog.setVisible(true);
    Point loc = getMain().getFrame().getLocation();
    dialog.setLocation(loc.x + getMain().getFrame().getWidth(), getMain().getFrame().getHeight());
    myController.addProbeEditor(dialog);
}
Also used : InputNumericProbeEditor(artisynth.core.gui.probeEditor.InputNumericProbeEditor) NumericInputProbe(artisynth.core.probes.NumericInputProbe) OutputNumericProbeEditor(artisynth.core.gui.probeEditor.OutputNumericProbeEditor) NumericProbeEditor(artisynth.core.gui.probeEditor.NumericProbeEditor) InputNumericProbeEditor(artisynth.core.gui.probeEditor.InputNumericProbeEditor) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) Point(java.awt.Point) WayPoint(artisynth.core.probes.WayPoint) OutputNumericProbeEditor(artisynth.core.gui.probeEditor.OutputNumericProbeEditor)

Example 2 with NumericOutputProbe

use of artisynth.core.probes.NumericOutputProbe in project artisynth_core by artisynth.

the class InverseManager method configureTargetForceProbe.

private void configureTargetForceProbe(NumericProbeBase probe, ArrayList<ForceTarget> targets, String filename) {
    // System.out.println ("configuring force probe");
    ArrayList<Property> props = new ArrayList<Property>();
    for (ForceTarget target : targets) {
        props.add(target.getProperty("targetLambda"));
    }
    // 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 : NumericInputProbe(artisynth.core.probes.NumericInputProbe) ArrayList(java.util.ArrayList) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) IOException(java.io.IOException) Property(maspack.properties.Property) File(java.io.File)

Example 3 with NumericOutputProbe

use of artisynth.core.probes.NumericOutputProbe 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 4 with NumericOutputProbe

use of artisynth.core.probes.NumericOutputProbe in project artisynth_core by artisynth.

the class OutputNumericProbeEditor method setOutputProbe.

private void setOutputProbe() {
    ArrayList<String> variableNames = new ArrayList<String>();
    for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
        variableNames.add(entry.getKey());
        System.out.println("variable: " + entry.getKey() + " added to list");
    }
    for (Property prop : myProperties) {
        System.out.println("property " + prop.getName() + " found");
    }
    // System.out.println("myProps size ="+myProperties.size());
    // System.out.println("myVars size ="+variableNames.size());
    NumericOutputProbe probeToSet;
    if (oldProbe == null) {
        probeToSet = new NumericOutputProbe();
    } else {
        probeToSet = oldProbe;
    }
    probeToSet.set(myProperties.toArray(new Property[0]), getDriverExpressions(), variableNames.toArray(new String[0]));
    probeToSet.setStartTime(startTimeField.getDoubleValue());
    probeToSet.setStopTime(endTimeField.getDoubleValue());
    probeToSet.setName(probeNameField.getStringValue());
    probeToSet.setUpdateInterval(intervalField.getDoubleValue());
    if (!rangeField.valueIsVoid()) {
        DoubleInterval range = rangeField.getRangeValue();
        probeToSet.setDefaultDisplayRange(range.getLowerBound(), range.getUpperBound());
    }
    // probeToSet.setDefaultDisplayRange(
    // dispLowerField.getDoubleValue(), dispUpperField.getDoubleValue());
    probeToSet.setAttachedFileName(attachedFileField.getText());
    if (oldProbe == null) {
        AddComponentsCommand cmd = new AddComponentsCommand("add output probe", probeToSet, myMain.getRootModel().getOutputProbes());
        myMain.getUndoManager().saveStateAndExecute(cmd);
    // System.out.println("track index: "+probeToSet.getTrack());
    // myMain.getRootModel().addOutputProbe(probeToSet);
    // myMain.getTimeline().addProbe(probeToSet);
    }
}
Also used : NumericProbeVariable(artisynth.core.probes.NumericProbeVariable) AddComponentsCommand(artisynth.core.gui.editorManager.AddComponentsCommand) ArrayList(java.util.ArrayList) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) DoubleInterval(maspack.util.DoubleInterval) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Property(maspack.properties.Property)

Example 5 with NumericOutputProbe

use of artisynth.core.probes.NumericOutputProbe 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)

Aggregations

NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)12 NumericInputProbe (artisynth.core.probes.NumericInputProbe)9 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)4 Property (maspack.properties.Property)4 WayPoint (artisynth.core.probes.WayPoint)2 File (java.io.File)2 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 BodyConnector (artisynth.core.mechmodels.BodyConnector)1 Frame (artisynth.core.mechmodels.Frame)1 Point (artisynth.core.mechmodels.Point)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 NumericProbeVariable (artisynth.core.probes.NumericProbeVariable)1 Probe (artisynth.core.probes.Probe)1 Point (java.awt.Point)1 LinkedHashMap (java.util.LinkedHashMap)1