Search in sources :

Example 21 with TransformNR

use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project java-bowler by NeuronRobotics.

the class SampleGuiNR method populate.

private void populate() {
    removeAll();
    setHomeAll(new JButton("Home All"));
    getHomeAll().addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            new Thread() {

                public void run() {
                    setName("Bowler Platform Homing thread");
                    getModel().homeAllLinks();
                    getHomeAll().setText("Homed");
                    setButtonEnabled(true);
                }
            }.start();
            getHomeAll().setText("Homing...");
            setButtonEnabled(false);
        }
    });
    estop.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            model.emergencyStop();
        }
    });
    for (int i = 0; i < model.getNumberOfLinks(); i++) {
        SampleGuiAxisWidgetNR w = new SampleGuiAxisWidgetNR(i, model);
        links.add(w, "wrap");
        axis.add(w);
    }
    setRas(new MatrixDisplayNR("Global to Base"));
    getRas().setEditable(true);
    getRas().setTransform(getModel().getFiducialToGlobalTransform());
    getRas().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            TransformNR m = new TransformNR(new Matrix(getRas().getTableData()));
            System.out.println("Setting ras transform: " + m);
            getModel().setGlobalToFiducialTransform(m);
        }
    });
    getModel().addRegistrationListener(new IRegistrationListenerNR() {

        public void onFiducialToGlobalUpdate(AbstractKinematicsNR source, TransformNR registration) {
            getRas().setTransform(registration);
        }

        public void onBaseToFiducialUpdate(AbstractKinematicsNR source, TransformNR registration) {
        }
    });
    setRobReg(new MatrixDisplayNR("Base to Robot"));
    getRobReg().setEditable(true);
    getRobReg().setTransform(getModel().getRobotToFiducialTransform());
    getModel().addRegistrationListener(new IRegistrationListenerNR() {

        public void onFiducialToGlobalUpdate(AbstractKinematicsNR source, TransformNR registration) {
        }

        public void onBaseToFiducialUpdate(AbstractKinematicsNR source, TransformNR registration) {
            getRobReg().setTransform(registration);
        }
    });
    JPanel poses = new JPanel(new MigLayout());
    JPanel registration = new JPanel(new MigLayout());
    registration.add(new JLabel("Robot Registration"), "wrap");
    registration.add(getRas(), "wrap");
    registration.add(getRobReg(), "wrap");
    poses.add(registration);
    poses.add(new PosePanelNR(getModel(), true, true, "Current Actual Pose"));
    poses.add(new PosePanelNR(getModel(), false, true, "Current Target Pose"));
    setPanel = new PosePanelNR(getModel(), false, false, "New Target Pose");
    poses.add(setPanel, "wrap");
    JPanel buttons = new JPanel(new MigLayout());
    buttons.add(estop);
    buttons.add(getHomeAll());
    JPanel standard = new JPanel(new MigLayout());
    standard.add(poses, "wrap");
    standard.add(buttons, "wrap");
    standard.add(links, "wrap");
    add(extra, "wrap");
    add(standard, "wrap");
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) TableModelEvent(javax.swing.event.TableModelEvent) MigLayout(net.miginfocom.swing.MigLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TransformNR(com.neuronrobotics.sdk.addons.kinematics.math.TransformNR) AbstractKinematicsNR(com.neuronrobotics.sdk.addons.kinematics.AbstractKinematicsNR) Matrix(Jama.Matrix) ActionListener(java.awt.event.ActionListener) TableModelListener(javax.swing.event.TableModelListener) IRegistrationListenerNR(com.neuronrobotics.sdk.addons.kinematics.IRegistrationListenerNR)

Example 22 with TransformNR

use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project java-bowler by NeuronRobotics.

the class MobileBase method getEmbedableXml.

/*
	 * 
	 * Generate the xml configuration to generate an XML of this robot. 
	 */
public String getEmbedableXml() {
    TransformNR location = getFiducialToGlobalTransform();
    setGlobalToFiducialTransform(new TransformNR());
    String xml = "<mobilebase>\n";
    xml += "\n<driveType>" + getDriveType() + "</driveType>\n";
    xml += "\t<cadEngine>\n";
    xml += "\t\t<gist>" + getCadEngine()[0] + "</gist>\n";
    xml += "\t\t<file>" + getCadEngine()[1] + "</file>\n";
    xml += "\t</cadEngine>\n";
    xml += "\t<driveEngine>\n";
    xml += "\t\t<gist>" + getWalkingEngine()[0] + "</gist>\n";
    xml += "\t\t<file>" + getWalkingEngine()[1] + "</file>\n";
    xml += "\t</driveEngine>\n";
    xml += "\n<name>" + getScriptingName() + "</name>\n";
    for (DHParameterKinematics l : legs) {
        xml += "<leg>\n";
        xml += "\n<name>" + l.getScriptingName() + "</name>\n";
        xml += l.getEmbedableXml();
        xml += "\n</leg>\n";
    }
    for (DHParameterKinematics l : appendages) {
        xml += "<appendage>\n";
        xml += "\n<name>" + l.getScriptingName() + "</name>\n";
        xml += l.getEmbedableXml();
        xml += "\n</appendage>\n";
    }
    for (DHParameterKinematics l : steerable) {
        xml += "<steerable>\n";
        xml += "\n<name>" + l.getScriptingName() + "</name>\n";
        xml += l.getEmbedableXml();
        xml += "\n</steerable>\n";
    }
    for (DHParameterKinematics l : drivable) {
        xml += "<drivable>\n";
        xml += "\n<name>" + l.getScriptingName() + "</name>\n";
        xml += l.getEmbedableXml();
        xml += "\n</drivable>\n";
    }
    xml += "\n<ZframeToRAS>\n";
    xml += getFiducialToGlobalTransform().getXml();
    xml += "\n</ZframeToRAS>\n";
    xml += "\n<baseToZframe>\n";
    xml += getRobotToFiducialTransform().getXml();
    xml += "\n</baseToZframe>\n";
    xml += "\n</mobilebase>\n";
    setGlobalToFiducialTransform(location);
    return xml;
}
Also used : TransformNR(com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)

Example 23 with TransformNR

use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project bowler-script-kernel by CommonWealthRobotics.

the class TransformFactory method affineToBullet.

public static void affineToBullet(Affine affine, com.bulletphysics.linearmath.Transform bullet) {
    TransformNR nr = affineToNr(affine);
    nrToBullet(nr, bullet);
}
Also used : TransformNR(com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)

Example 24 with TransformNR

use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project bowler-script-kernel by CommonWealthRobotics.

the class TransformFactory method csgToNR.

public static TransformNR csgToNR(eu.mihosoft.vrl.v3d.Transform csg) {
    Matrix4d rotation = csg.getInternalMatrix();
    Quat4d q1 = new Quat4d();
    rotation.get(q1);
    Vector3d t1 = new Vector3d();
    rotation.get(t1);
    return new TransformNR(t1.x, t1.y, t1.z, new RotationNR(q1.w, q1.x, q1.y, q1.z));
}
Also used : Matrix4d(javax.vecmath.Matrix4d) Quat4d(javax.vecmath.Quat4d) Vector3d(javax.vecmath.Vector3d) RotationNR(com.neuronrobotics.sdk.addons.kinematics.math.RotationNR) TransformNR(com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)

Example 25 with TransformNR

use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project java-bowler by NeuronRobotics.

the class AbstractKinematicsNR method setDesiredJointAxisValue.

/**
 * Sets an individual target joint position
 * @param axis the joint index to set
 * @param value the value to set it to
 * @param seconds the time for the transition to take from current position to target, unit seconds
 * @throws Exception If there is a workspace error
 */
public void setDesiredJointAxisValue(int axis, double value, double seconds) throws Exception {
    LinkConfiguration c = getLinkConfiguration(axis);
    Log.info("Setting single target joint in mm/deg, axis=" + axis + " value=" + value);
    currentJointSpaceTarget[axis] = value;
    try {
        getFactory().getLink(c).setTargetEngineeringUnits(value);
    } catch (Exception ex) {
        throw new Exception("Joint hit software bound, index " + axis + " attempted: " + value + " boundes: U=" + c.getUpperLimit() + ", L=" + c.getLowerLimit());
    }
    if (!isNoFlush()) {
        int except = 0;
        Exception e = null;
        do {
            try {
                getFactory().getLink(c).flush(seconds);
                except = 0;
                e = null;
            } catch (Exception ex) {
                except++;
                e = ex;
            }
        } while (except > 0 && except < getRetryNumberBeforeFail());
        if (e != null)
            throw e;
    }
    TransformNR fwd = forwardKinematics(currentJointSpaceTarget);
    fireTargetJointsUpdate(currentJointSpaceTarget, fwd);
    return;
}
Also used : TransformNR(com.neuronrobotics.sdk.addons.kinematics.math.TransformNR) InvalidConnectionException(com.neuronrobotics.sdk.common.InvalidConnectionException) RuntimeErrorException(javax.management.RuntimeErrorException)

Aggregations

TransformNR (com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)43 RotationNR (com.neuronrobotics.sdk.addons.kinematics.math.RotationNR)13 Matrix (Jama.Matrix)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 Affine (javafx.scene.transform.Affine)4 RuntimeErrorException (javax.management.RuntimeErrorException)4 InvalidConnectionException (com.neuronrobotics.sdk.common.InvalidConnectionException)3 CSG (eu.mihosoft.vrl.v3d.CSG)3 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)3 ParallelGroup (com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup)2 File (java.io.File)2 Group (javafx.scene.Group)2 Quat4f (javax.vecmath.Quat4f)2 Vector3f (javax.vecmath.Vector3f)2 InvalidRemoteException (org.eclipse.jgit.api.errors.InvalidRemoteException)2 TransportException (org.eclipse.jgit.api.errors.TransportException)2 Transform (com.bulletphysics.linearmath.Transform)1 IssueReportingExceptionHandler (com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler)1 CodeHandler (com.neuronrobotics.replicator.driver.interpreter.CodeHandler)1