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");
}
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;
}
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);
}
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));
}
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;
}
Aggregations