Search in sources :

Example 6 with MotionTargetComponent

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

the class MotionTargetComponentAgent method selectionChanged.

public void selectionChanged(SelectionEvent e) {
    ModelComponent c = e.getLastAddedComponent();
    if (isValidTarget(c)) {
        MotionTargetComponent comp = (MotionTargetComponent) c;
        if (myState == State.SelectingTargets && !myController.getMotionSources().contains(comp) && !myController.getMotionTargets().contains(comp)) {
            myController.addMotionTarget(comp, 1.0);
            DoubleField widget = createTargetWidget(comp, 1.0);
            myTargetPanel.addWidget(widget);
            myTargetPanel.mapWidgetToComponent(widget, comp);
            myTargetPanel.revalidate();
            myTargetPanel.repaint();
        }
    // else if (myExciter.findTarget(ex) != -1)
    // { mySelectedTargets.add (ex);
    // }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent) DoubleField(maspack.widgets.DoubleField)

Example 7 with MotionTargetComponent

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

the class MotionTargetTerm method createVelocityJacobian.

private void createVelocityJacobian() {
    myVelJacobian = myMech.createVelocityJacobian();
    for (int i = 0; i < mySources.size(); i++) {
        MotionTargetComponent target = mySources.get(i);
        target.addTargetJacobian(myVelJacobian, i);
    }
    // fold attachments into targets on dynamic components
    // (same as constraint jacobians)
    myMech.reduceVelocityJacobian(myVelJacobian);
}
Also used : MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent) Point(artisynth.core.mechmodels.Point)

Example 8 with MotionTargetComponent

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

the class MotionTargetTerm method updateTargetVelocityVec.

private void updateTargetVelocityVec() {
    if (myTargetVel == null || myTargetVel.size() != myTargetVelSize)
        myTargetVel = new VectorNd(myTargetVelSize);
    double[] buf = myTargetVel.getBuffer();
    int idx = 0;
    for (int i = 0; i < myTargets.size(); i++) {
        MotionTargetComponent target = myTargets.get(i);
        if (target instanceof Point) {
            Vector3d vel = ((Point) target).getVelocity();
            buf[idx++] = vel.x;
            buf[idx++] = vel.y;
            buf[idx++] = vel.z;
        } else if (target instanceof Frame) {
            Twist vel = ((Frame) target).getVelocity();
            buf[idx++] = vel.v.x;
            buf[idx++] = vel.v.y;
            buf[idx++] = vel.v.z;
            buf[idx++] = vel.w.x;
            buf[idx++] = vel.w.y;
            buf[idx++] = vel.w.z;
        }
    }
}
Also used : Twist(maspack.spatialmotion.Twist) Frame(artisynth.core.mechmodels.Frame) Vector3d(maspack.matrix.Vector3d) VectorNd(maspack.matrix.VectorNd) Point(artisynth.core.mechmodels.Point) MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent) Point(artisynth.core.mechmodels.Point)

Example 9 with MotionTargetComponent

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

the class MotionTargetTerm method fixTargetPositions.

private void fixTargetPositions() {
    for (MotionTargetComponent comp : myTargets) {
        if (comp instanceof Point) {
            Point p = (Point) comp;
            p.setPosition(p.getTargetPosition());
            p.setVelocity(p.getTargetVelocity());
        } else if (comp instanceof Frame) {
            Frame f = (Frame) comp;
            f.setVelocity(f.getTargetVelocity());
            f.setPose(f.getTargetPose());
        }
    }
}
Also used : Frame(artisynth.core.mechmodels.Frame) Point(artisynth.core.mechmodels.Point) MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent)

Example 10 with MotionTargetComponent

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

the class MotionTargetTerm method updateWeightsVector.

private void updateWeightsVector() {
    myTargetWgts = new VectorNd(myTargetVelSize);
    int idx = 0;
    for (int t = 0; t < mySources.size(); t++) {
        MotionTargetComponent target = mySources.get(t);
        double w = myTargetWeights.get(t);
        if (target instanceof Point) {
            for (int i = 0; i < POINT_VEL_SIZE; i++) {
                myTargetWgts.set(idx++, w);
            }
        } else if (target instanceof Frame) {
            for (int i = 0; i < FRAME_VEL_SIZE; i++) {
                myTargetWgts.set(idx++, w);
            }
        }
    }
}
Also used : Frame(artisynth.core.mechmodels.Frame) VectorNd(maspack.matrix.VectorNd) Point(artisynth.core.mechmodels.Point) MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent) Point(artisynth.core.mechmodels.Point)

Aggregations

MotionTargetComponent (artisynth.core.mechmodels.MotionTargetComponent)11 Point (artisynth.core.mechmodels.Point)6 Frame (artisynth.core.mechmodels.Frame)5 VectorNd (maspack.matrix.VectorNd)3 RenderableComponent (artisynth.core.modelbase.RenderableComponent)2 ForceTarget (artisynth.core.inverse.ForceTarget)1 ForceTargetTerm (artisynth.core.inverse.ForceTargetTerm)1 TrackingController (artisynth.core.inverse.TrackingController)1 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)1 AxialSpring (artisynth.core.mechmodels.AxialSpring)1 Muscle (artisynth.core.mechmodels.Muscle)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 JComponent (javax.swing.JComponent)1 Vector3d (maspack.matrix.Vector3d)1 Twist (maspack.spatialmotion.Twist)1 DoubleField (maspack.widgets.DoubleField)1