Search in sources :

Example 1 with AbstractKinematicsNR

use of com.neuronrobotics.sdk.addons.kinematics.AbstractKinematicsNR 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)

Aggregations

Matrix (Jama.Matrix)1 AbstractKinematicsNR (com.neuronrobotics.sdk.addons.kinematics.AbstractKinematicsNR)1 IRegistrationListenerNR (com.neuronrobotics.sdk.addons.kinematics.IRegistrationListenerNR)1 TransformNR (com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 TableModelEvent (javax.swing.event.TableModelEvent)1 TableModelListener (javax.swing.event.TableModelListener)1 MigLayout (net.miginfocom.swing.MigLayout)1