use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project BowlerStudio by CommonWealthRobotics.
the class ParallelWidget method configure.
public void configure(MobileBase b, DHParameterKinematics dh, CreatureLab creatureLab) {
resetting = true;
this.base = b;
this.dh = dh;
this.creatureLab = creatureLab;
System.out.println("Configuring arm " + dh.getScriptingName());
robotToFiducialTransform = new TransformNR();
Platform.runLater(() -> groupName.setText(""));
Platform.runLater(() -> relativeName.getItems().clear());
Platform.runLater(() -> relIndex.getItems().clear());
Platform.runLater(() -> relIndex.setDisable(true));
Platform.runLater(() -> e.setDisable(true));
if (getGroup() == null) {
useParallel.setSelected(false);
box.setDisable(true);
} else {
useParallel.setSelected(true);
box.setDisable(false);
Platform.runLater(() -> groupName.setText(getGroup().getNameOfParallelGroup()));
for (DHParameterKinematics l : base.getAllDHChains()) {
if (!l.getScriptingName().contentEquals(dh.getScriptingName())) {
System.out.println("Adding Option " + l.getScriptingName());
Platform.runLater(() -> relativeName.getItems().add(l.getScriptingName()));
}
}
if (getGroup().getTipOffset(dh) != null) {
Platform.runLater(() -> useRelative.setSelected(true));
Platform.runLater(() -> relativeToControls.setDisable(false));
Platform.runLater(() -> relIndex.setDisable(false));
Platform.runLater(() -> e.setDisable(false));
robotToFiducialTransform = getGroup().getTipOffset(dh);
Platform.runLater(() -> e.updatePose(robotToFiducialTransform));
String refLimbName = getGroup().getTipOffsetRelativeName(dh);
setNewReferencedLimb(base, refLimbName);
Platform.runLater(() -> relativeName.setValue(refLimbName));
Platform.runLater(() -> relIndex.setValue(getGroup().getTipOffsetRelativeIndex(dh)));
} else {
Platform.runLater(() -> useRelative.setSelected(false));
Platform.runLater(() -> relativeToControls.setDisable(true));
}
}
e.updatePose(robotToFiducialTransform);
Platform.runLater(() -> resetting = false);
home();
}
use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project BowlerStudio by CommonWealthRobotics.
the class ParallelWidget method setNewReferencedLimb.
private void setNewReferencedLimb(MobileBase base, String refLimbName) {
DHParameterKinematics referencedLimb = null;
for (DHParameterKinematics lm : base.getAllDHChains()) {
if (lm.getScriptingName().toLowerCase().contentEquals(refLimbName.toLowerCase())) {
// FOund the referenced limb
referencedLimb = lm;
}
}
Platform.runLater(() -> relIndex.getItems().clear());
DHParameterKinematics rl = referencedLimb;
Platform.runLater(() -> {
for (int i = 0; i < rl.getNumberOfLinks(); i++) {
relIndex.getItems().add(i);
}
});
}
use of com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics in project BowlerStudio by CommonWealthRobotics.
the class AbstractBowlerStudioTab method setDevice.
public void setDevice(BowlerAbstractDevice pm) {
myNames = new ArrayList<>();
if (getMyNameSpaces().length > 0) {
for (int i = 0; i < getMyNameSpaces().length; i++) {
myNames.add(getMyNameSpaces()[i]);
}
if (!isMyNamespace(pm.getNamespaces())) {
throw new RuntimeException("Device and namespaces are incompatible ");
}
}
setOnCloseRequest(this);
initializeUI(pm);
pm.addConnectionEventListener(new IDeviceConnectionEventListener() {
@Override
public void onDisconnect(BowlerAbstractDevice source) {
// if the device disconnects, close the tab
if (source == pm && source != null) {
requestClose();
if (MobileBase.class.isInstance(pm)) {
MobileBase dev = (MobileBase) pm;
try {
for (CSG p : MobileBaseCadManager.get(dev).getBasetoCadMap().get(dev)) BowlerStudioController.removeObject(p);
for (DHParameterKinematics leg : dev.getAllDHChains()) for (CSG p : MobileBaseCadManager.get(dev).getDHtoCadMap().get(leg)) BowlerStudioController.removeObject(p);
} catch (Throwable e) {
}
}
} else {
// Not a bug, expected to ensure one device disconnects the rest of the dependent devices
// System.err.println("Device type was "+source.getClass()+" named "+source.getScriptingName()+" expected "+pm.getClass()+" named "+pm.getScriptingName());
// new Exception().printStackTrace();
}
}
@Override
public void onConnect(BowlerAbstractDevice source) {
// TODO Auto-generated method stub
}
});
}
Aggregations