use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project BowlerStudio by CommonWealthRobotics.
the class LinkSliderWidget method enable.
public void enable() {
if (linkGaugeController3d == null) {
linkGaugeController3d = new LinkGaugeController();
BowlerStudioController.addUserNode(linkGaugeController3d.getGauge());
offsetGauge = new Affine();
offsetGaugeTranslate = new Affine();
linkGaugeController3d.setSIZE(60);
}
double d = (((double) linkGaugeController3d.getSIZE())) / 2.0;
TransformNR offsetter2 = new TransformNR().translateX(-d).translateY(-d);
Platform.runLater(() -> TransformFactory.nrToAffine(offsetter2, offsetGaugeTranslate));
TransformNR offsetter = new TransformNR();
double theta = Math.toDegrees(device.getDhParametersChain().getLinks().get(linkIndex).getTheta());
offsetter.setRotation(new RotationNR(0, 90 + theta, 0));
Platform.runLater(() -> TransformFactory.nrToAffine(offsetter, offsetGauge));
linkGaugeController3d.getGauge().getTransforms().clear();
linkGaugeController3d.setLink(conf, getAbstractLink());
if (linkIndex == 0)
linkGaugeController3d.getGauge().getTransforms().add((Affine) device.getRootListener());
else
linkGaugeController3d.getGauge().getTransforms().add((Affine) device.getAbstractLink(linkIndex - 1).getGlobalPositionListener());
linkGaugeController3d.getGauge().getTransforms().add(offsetGauge);
linkGaugeController3d.getGauge().getTransforms().add(offsetGaugeTranslate);
}
use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project BowlerStudio by CommonWealthRobotics.
the class MobleBaseMenueFactory method load.
@SuppressWarnings("unchecked")
public static void load(MobileBase device, TreeView<String> view, TreeItem<String> rootItem, HashMap<TreeItem<String>, Runnable> callbackMapForTreeitems, HashMap<TreeItem<String>, Group> widgetMapForTreeitems, CreatureLab creatureLab, boolean root, boolean creatureIsOwnedByUser) {
// boolean creatureIsOwnedByUser = false;
callbackMapForTreeitems.put(rootItem, () -> {
BowlerStudio.select(device);
});
TreeItem<String> editXml = new TreeItem<String>("Edit Robot XML..", AssetFactory.loadIcon("Script-Tab-RobotXML.png"));
callbackMapForTreeitems.put(editXml, () -> {
try {
File code = ScriptingEngine.fileFromGit(device.getGitSelfSource()[0], device.getGitSelfSource()[1]);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> physics = new TreeItem<String>("Physics Simulation", AssetFactory.loadIcon("Physics-Creature-Simulation.png"));
callbackMapForTreeitems.put(physics, () -> {
if (widgetMapForTreeitems.get(physics) == null) {
widgetMapForTreeitems.put(physics, new Group(new CreaturePhysicsWidget(device)));
}
});
TreeItem<String> publish;
publish = new TreeItem<String>("Publish", AssetFactory.loadIcon("Publish.png"));
if (!(device.getGitSelfSource()[0] == null || device.getGitSelfSource()[1] == null)) {
try {
File source = ScriptingEngine.fileFromGit(device.getGitSelfSource()[0], device.getGitSelfSource()[1]);
callbackMapForTreeitems.put(publish, () -> {
CommitWidget.commit(source, device.getXml());
});
} catch (Exception e) {
Log.error(device.getGitSelfSource()[0] + " " + device.getGitSelfSource()[1] + " failed to load");
e.printStackTrace();
}
}
if (creatureIsOwnedByUser) {
if (root)
rootItem.getChildren().addAll(publish);
}
TreeItem<String> makeCopy = new TreeItem<>("Make Copy of Creature", AssetFactory.loadIcon("Make-Copy-of-Creature.png"));
if (root)
rootItem.getChildren().addAll(makeCopy);
callbackMapForTreeitems.put(makeCopy, () -> {
Platform.runLater(() -> {
String oldname = device.getScriptingName();
TextInputDialog dialog = new TextInputDialog(oldname + "_copy");
dialog.setTitle("Making a copy of " + oldname);
dialog.setHeaderText("Set the scripting name for this creature");
dialog.setContentText("Set the name of the new creature:");
// Traditional way to get the response value.
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
view.getSelectionModel().select(rootItem);
System.out.println("Your new creature: " + result.get());
String newName = result.get();
makeACopyOfACreature(device, oldname, newName).start();
}
});
});
try {
TreeItem<String> legs = loadLimbs(device, view, device.getLegs(), "Legs", rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
TreeItem<String> arms = loadLimbs(device, view, device.getAppendages(), "Arms", rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
TreeItem<String> steer = loadLimbs(device, view, device.getSteerable(), "Steerable Wheels", rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
TreeItem<String> drive = loadLimbs(device, view, device.getDrivable(), "Fixed Wheels", rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
ArrayList<DHParameterKinematics> paraGroups = device.getAllParallelGroups();
TreeItem<String> paralell = loadLimbs(device, view, paraGroups, "Paralell", rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
TreeItem<String> addleg;
try {
addleg = new TreeItem<String>("Add Leg", AssetFactory.loadIcon("Add-Leg.png"));
} catch (Exception e1) {
addleg = new TreeItem<String>("Add Leg");
}
boolean creatureIsOwnedByUserTmp = creatureIsOwnedByUser;
callbackMapForTreeitems.put(addleg, () -> {
// TODO Auto-generated method stub
System.out.println("Adding Leg");
String xmlContent;
try {
xmlContent = ScriptingEngine.codeFromGit("https://gist.github.com/b5b9450f869dd0d2ea30.git", "defaultleg.xml")[0];
DHParameterKinematics newLeg = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8"));
System.out.println("Leg has " + newLeg.getNumberOfLinks() + " links");
addAppendage(device, view, device.getLegs(), newLeg, legs, rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUserTmp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> regnerate = new TreeItem<String>("Generate Cad", AssetFactory.loadIcon("Generate-Cad.png"));
callbackMapForTreeitems.put(regnerate, () -> {
creatureLab.generateCad();
});
TreeItem<String> kinematics = new TreeItem<String>("Kinematic STL", AssetFactory.loadIcon("Printable-Cad.png"));
callbackMapForTreeitems.put(kinematics, () -> {
File defaultStlDir = new File(System.getProperty("user.home") + "/bowler-workspace/STL/");
if (!defaultStlDir.exists()) {
defaultStlDir.mkdirs();
}
Platform.runLater(() -> {
DirectoryChooser chooser = new DirectoryChooser();
chooser.setTitle("Select Output Directory For .STL files");
chooser.setInitialDirectory(defaultStlDir);
File baseDirForFiles = chooser.showDialog(BowlerStudioModularFrame.getPrimaryStage());
new Thread() {
public void run() {
MobileBaseCadManager baseManager = MobileBaseCadManager.get(device);
if (baseDirForFiles == null) {
return;
}
ArrayList<File> files;
try {
files = baseManager.generateStls((MobileBase) device, baseDirForFiles, true);
Platform.runLater(() -> {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Stl Export Success!");
alert.setHeaderText("Stl Export Success");
alert.setContentText("All SLT's for the Creature Generated at\n" + files.get(0).getAbsolutePath());
alert.setWidth(500);
alert.initModality(Modality.APPLICATION_MODAL);
alert.show();
});
} catch (Exception e) {
BowlerStudioController.highlightException(baseManager.getCadScript(), e);
}
}
}.start();
});
});
TreeItem<String> printable = new TreeItem<String>("Printable Cad", AssetFactory.loadIcon("Printable-Cad.png"));
callbackMapForTreeitems.put(printable, () -> {
File defaultStlDir = new File(System.getProperty("user.home") + "/bowler-workspace/STL/");
if (!defaultStlDir.exists()) {
defaultStlDir.mkdirs();
}
Platform.runLater(() -> {
DirectoryChooser chooser = new DirectoryChooser();
chooser.setTitle("Select Output Directory For .STL files");
chooser.setInitialDirectory(defaultStlDir);
File baseDirForFiles = chooser.showDialog(BowlerStudioModularFrame.getPrimaryStage());
new Thread() {
public void run() {
MobileBaseCadManager baseManager = MobileBaseCadManager.get(device);
if (baseDirForFiles == null) {
return;
}
ArrayList<File> files;
try {
files = baseManager.generateStls((MobileBase) device, baseDirForFiles, false);
Platform.runLater(() -> {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Stl Export Success!");
alert.setHeaderText("Stl Export Success");
alert.setContentText("All SLT's for the Creature Generated at\n" + files.get(0).getAbsolutePath());
alert.setWidth(500);
alert.initModality(Modality.APPLICATION_MODAL);
alert.show();
});
} catch (Exception e) {
BowlerStudioController.highlightException(baseManager.getCadScript(), e);
}
}
}.start();
});
});
TreeItem<String> setCAD = new TreeItem<>("Set CAD Engine...", AssetFactory.loadIcon("Set-CAD-Engine.png"));
callbackMapForTreeitems.put(setCAD, () -> {
PromptForGit.prompt("Select a CAD Engine From a Gist", device.getGitCadEngine()[0], (gitsId, file) -> {
Log.warn("Loading cad engine");
try {
creatureLab.setGitCadEngine(gitsId, file, device);
File code = ScriptingEngine.fileFromGit(gitsId, file);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
});
TreeItem<String> editCAD = new TreeItem<>("Edit CAD Engine...", AssetFactory.loadIcon("Edit-CAD-Engine.png"));
callbackMapForTreeitems.put(editCAD, () -> {
try {
File code = ScriptingEngine.fileFromGit(device.getGitCadEngine()[0], device.getGitCadEngine()[1]);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> resetWalking = new TreeItem<>("Set Walking Engine...", AssetFactory.loadIcon("Set-Walking-Engine.png"));
callbackMapForTreeitems.put(resetWalking, () -> {
PromptForGit.prompt("Select a Walking Engine From a Gist", device.getGitWalkingEngine()[0], (gitsId, file) -> {
Log.warn("Loading walking engine");
try {
creatureLab.setGitWalkingEngine(gitsId, file, device);
File code = ScriptingEngine.fileFromGit(gitsId, file);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
});
TreeItem<String> editWalking = new TreeItem<>("Edit Walking Engine...", AssetFactory.loadIcon("Edit-Walking-Engine.png"));
callbackMapForTreeitems.put(editWalking, () -> {
try {
File code = ScriptingEngine.fileFromGit(device.getGitWalkingEngine()[0], device.getGitWalkingEngine()[1]);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> addFixed = new TreeItem<>("Add Fixed Wheel", AssetFactory.loadIcon("Add-Fixed-Wheel.png"));
callbackMapForTreeitems.put(addFixed, () -> {
// TODO Auto-generated method stub
System.out.println("Adding Fixed Wheel");
try {
String xmlContent = ScriptingEngine.codeFromGit("https://gist.github.com/b5b9450f869dd0d2ea30.git", "defaultFixed.xml")[0];
DHParameterKinematics newArm = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8"));
System.out.println("Arm has " + newArm.getNumberOfLinks() + " links");
addAppendage(device, view, device.getDrivable(), newArm, drive, rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUserTmp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> addsteerable = new TreeItem<>("Add Steerable Wheel", AssetFactory.loadIcon("Add-Steerable-Wheel.png"));
callbackMapForTreeitems.put(addsteerable, () -> {
// TODO Auto-generated method stub
System.out.println("Adding Steerable Wheel");
try {
String xmlContent = ScriptingEngine.codeFromGit("https://gist.github.com/b5b9450f869dd0d2ea30.git", "defaultSteerable.xml")[0];
DHParameterKinematics newArm = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8"));
System.out.println("Arm has " + newArm.getNumberOfLinks() + " links");
addAppendage(device, view, device.getSteerable(), newArm, steer, rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUserTmp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> imuCenter = new TreeItem<>("Imu center", AssetFactory.loadIcon("Advanced-Configuration.png"));
callbackMapForTreeitems.put(imuCenter, () -> {
TransformWidget imu = new TransformWidget("IMU center", device.getIMUFromCentroid(), new IOnTransformChange() {
@Override
public void onTransformChaging(TransformNR newTrans) {
}
@Override
public void onTransformFinished(TransformNR newTrans) {
MobileBaseCadManager manager = MobileBaseCadManager.get(device);
if (manager != null)
manager.generateCad();
device.setIMUFromCentroid(newTrans);
}
});
if (widgetMapForTreeitems.get(imuCenter) == null) {
widgetMapForTreeitems.put(imuCenter, new Group(imu));
}
});
TreeItem<String> bodymass = new TreeItem<>("Adjust Body Mass", AssetFactory.loadIcon("Advanced-Configuration.png"));
callbackMapForTreeitems.put(bodymass, () -> {
if (widgetMapForTreeitems.get(bodymass) == null) {
widgetMapForTreeitems.put(bodymass, new AdjustbodyMassWidget(device));
}
});
TreeItem<String> addArm = new TreeItem<>("Add Arm", AssetFactory.loadIcon("Add-Arm.png"));
callbackMapForTreeitems.put(addArm, () -> {
// TODO Auto-generated method stub
System.out.println("Adding Arm");
try {
String xmlContent = ScriptingEngine.codeFromGit("https://gist.github.com/b5b9450f869dd0d2ea30.git", "defaultarm.xml")[0];
DHParameterKinematics newArm = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8"));
System.out.println("Arm has " + newArm.getNumberOfLinks() + " links");
addAppendage(device, view, device.getAppendages(), newArm, arms, rootItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUserTmp);
} catch (Exception e) {
new IssueReportingExceptionHandler().except(e);
}
});
rootItem.getChildren().addAll(bodymass, imuCenter);
if (root)
rootItem.getChildren().addAll(physics, regnerate, printable, kinematics);
rootItem.getChildren().addAll(addArm, addleg, addFixed, addsteerable);
if (creatureIsOwnedByUser) {
if (root)
rootItem.getChildren().addAll(editXml);
rootItem.getChildren().addAll(editWalking, editCAD, resetWalking, setCAD);
}
} catch (Exception e) {
new IssueReportingExceptionHandler().except(e);
}
}
use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project BowlerStudio by CommonWealthRobotics.
the class MobleBaseMenueFactory method loadSingleLimb.
@SuppressWarnings("unchecked")
private static void loadSingleLimb(MobileBase base, TreeView<String> view, DHParameterKinematics dh, TreeItem<String> rootItem, HashMap<TreeItem<String>, Runnable> callbackMapForTreeitems, HashMap<TreeItem<String>, Group> widgetMapForTreeitems, CreatureLab creatureLab, boolean creatureIsOwnedByUser) throws Exception {
TreeItem<String> dhItem = new TreeItem<>(dh.getScriptingName(), AssetFactory.loadIcon("Move-Limb.png"));
JogWidget widget = new JogWidget(dh, base);
callbackMapForTreeitems.put(dhItem, () -> {
if (widgetMapForTreeitems.get(dhItem) == null) {
// create the widget for the leg when looking at it for the
// first time
VBox jog = new VBox(10);
jog.getChildren().add(new Label("Jog Limb"));
jog.getChildren().add(widget);
widgetMapForTreeitems.put(dhItem, new Group(jog));
}
BowlerJInputDevice controller = creatureLab.getController();
if (controller != null) {
widget.setGameController(controller);
}
widget.setCurrent(dh.getCurrentPoseTarget());
BowlerStudio.select(base, dh);
});
TreeItem<String> remove = new TreeItem<>("Remove " + dh.getScriptingName(), AssetFactory.loadIcon("Remove-Limb.png"));
callbackMapForTreeitems.put(remove, () -> {
Platform.runLater(() -> {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirm removing limb");
alert.setHeaderText("This will remove " + dh.getScriptingName());
alert.setContentText("Are sure you wish to remove this limb?");
Optional<ButtonType> result = alert.showAndWait();
view.getSelectionModel().select(rootItem);
if (result.get() == ButtonType.OK) {
rootItem.getChildren().remove(dhItem);
if (base.getLegs().contains(dh)) {
base.getLegs().remove(dh);
}
if (base.getAppendages().contains(dh)) {
base.getAppendages().remove(dh);
}
if (base.getSteerable().contains(dh)) {
base.getSteerable().remove(dh);
}
if (base.getDrivable().contains(dh)) {
base.getDrivable().remove(dh);
}
if (base.getParallelGroup(dh) != null)
base.getParallelGroup(dh).removeLimb(dh);
creatureLab.generateCad();
}
});
});
int j = 0;
try {
for (LinkConfiguration conf : dh.getFactory().getLinkConfigurations()) {
loadSingleLink(j++, base, view, conf, dh, dhItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
}
TreeItem<String> addLink = new TreeItem<>("Add Link", AssetFactory.loadIcon("Add-Link.png"));
callbackMapForTreeitems.put(addLink, () -> {
// if(widgetMapForTreeitems.get(advanced)==null){
// //create the widget for the leg when looking at it for the first
// time
// widgetMapForTreeitems.put(advanced, new DhChainWidget(dh,
// creatureLab));
// }
Platform.runLater(() -> {
TextInputDialog dialog = new TextInputDialog("Link_" + dh.getLinkConfigurations().size());
dialog.setTitle("Add a new link of");
dialog.setHeaderText("Set the scripting name for this link");
dialog.setContentText("Please the name of the new link:");
// Traditional way to get the response value.
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
view.getSelectionModel().select(rootItem);
new Thread() {
public void run() {
System.out.println("Your new link: " + result.get());
LinkConfiguration newLink = new LinkConfiguration();
ArrayList<LinkConfiguration> linkConfigurations = dh.getFactory().getLinkConfigurations();
int numOfLinks = linkConfigurations.size();
String typeOfLink;
try {
typeOfLink = linkConfigurations.get(numOfLinks - 1).getTypeString();
} catch (Exception ex) {
typeOfLink = LinkType.VIRTUAL.getName();
}
if (typeOfLink == null)
typeOfLink = LinkType.VIRTUAL.getName();
// newLink.setType(typeOfLink);
newLink.setTypeString(typeOfLink.toString());
getNextChannel(base, newLink);
newLink.setName(result.get());
if (dh != null)
dh.addNewLink(newLink, new DHLink(0, 0, 100, 0));
try {
loadSingleLink(dh.getLinkConfigurations().size() - 1, base, view, newLink, dh, dhItem, callbackMapForTreeitems, widgetMapForTreeitems, creatureLab, creatureIsOwnedByUser);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
creatureLab.generateCad();
}
}.start();
}
});
});
dhItem.getChildren().addAll(addLink, remove);
} catch (Throwable T) {
T.printStackTrace();
}
TreeItem<String> parallel = new TreeItem<>("Parallel Settings", AssetFactory.loadIcon("Design-Parameter-Adjustment.png"));
callbackMapForTreeitems.put(parallel, () -> {
if (widgetMapForTreeitems.get(parallel) == null) {
// first time
try {
widgetMapForTreeitems.put(parallel, new ParallelWidget(base, dh, creatureLab));
} catch (Exception ex) {
BowlerStudio.printStackTrace(ex);
}
}
((ParallelWidget) widgetMapForTreeitems.get(parallel)).configure(base, dh, creatureLab);
});
dhItem.getChildren().addAll(parallel);
TreeItem<String> PlaceLimb = new TreeItem<>("Move Root Of Limb", AssetFactory.loadIcon("Design-Parameter-Adjustment.png"));
callbackMapForTreeitems.put(PlaceLimb, () -> {
if (widgetMapForTreeitems.get(PlaceLimb) == null) {
// first time
try {
widgetMapForTreeitems.put(PlaceLimb, new Group(new TransformWidget("Move place where limb is attached to body", dh.getRobotToFiducialTransform(), new IOnTransformChange() {
@Override
public void onTransformFinished(TransformNR newTrans) {
// Force a cad regeneration
creatureLab.onSliderDoneMoving(null, 0);
}
@Override
public void onTransformChaging(TransformNR newTrans) {
Log.debug("Limb to base" + newTrans.toString());
dh.setRobotToFiducialTransform(newTrans);
dh.refreshPose();
}
})));
} catch (Exception ex) {
BowlerStudio.printStackTrace(ex);
}
}
});
dhItem.getChildren().addAll(PlaceLimb);
// });
if (creatureIsOwnedByUser) {
// TreeItem<String> owner = new
// TreeItem<>("Scripts",AssetFactory.loadIcon("Owner.png"));
TreeItem<String> setCAD = new TreeItem<>("Set CAD Engine...", AssetFactory.loadIcon("Set-CAD-Engine.png"));
callbackMapForTreeitems.put(setCAD, () -> {
PromptForGit.prompt("Select a CAD Engine From Git", dh.getGitCadEngine()[0], (gitsId, file) -> {
Log.warn("Loading cad engine");
try {
creatureLab.setGitCadEngine(gitsId, file, dh);
openCadTab(creatureLab, gitsId, file);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
});
TreeItem<String> editCAD = new TreeItem<>("Edit CAD Engine...", AssetFactory.loadIcon("Edit-CAD-Engine.png"));
callbackMapForTreeitems.put(editCAD, () -> {
try {
openCadTab(creatureLab, dh.getGitCadEngine()[0], dh.getGitCadEngine()[1]);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
TreeItem<String> resetWalking = new TreeItem<>("Set Dh Kinematics Engine...", AssetFactory.loadIcon("Set-DH-Kinematics.png"));
callbackMapForTreeitems.put(resetWalking, () -> {
PromptForGit.prompt("Select a DH Solver Engine From Git", dh.getGitDhEngine()[0], (gitsId, file) -> {
Log.warn("Loading walking engine");
try {
creatureLab.setGitDhEngine(gitsId, file, dh);
File code = ScriptingEngine.fileFromGit(gitsId, file);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
});
TreeItem<String> editWalking = new TreeItem<>("Edit Kinematics Engine...", AssetFactory.loadIcon("Edit-Kinematics-Engine.png"));
callbackMapForTreeitems.put(editWalking, () -> {
try {
File code = ScriptingEngine.fileFromGit(dh.getGitDhEngine()[0], dh.getGitDhEngine()[1]);
BowlerStudio.createFileTab(code);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
dhItem.getChildren().addAll(editWalking, editCAD, resetWalking, setCAD);
}
rootItem.getChildren().add(dhItem);
double[] vect = dh.getCurrentJointSpaceVector();
for (int i = 0; i < vect.length; i++) {
vect[i] = 0;
}
try {
dh.setDesiredJointSpaceVector(vect, 1);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dh.updateCadLocations();
}
use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project BowlerStudio by CommonWealthRobotics.
the class TransformWidget method updatePose.
public void updatePose(TransformNR p) {
TransformNR pose = p;
Platform.runLater(() -> tx.setValue(pose.getX()));
Platform.runLater(() -> ty.setValue(pose.getY()));
Platform.runLater(() -> tz.setValue(pose.getZ()));
RotationNR rot = pose.getRotation();
double t = 0;
try {
t = Math.toDegrees(rot.getRotationTilt());
} catch (Exception ex) {
ex.printStackTrace();
}
double e = 0;
try {
e = Math.toDegrees(rot.getRotationElevation());
} catch (Exception ex) {
ex.printStackTrace();
}
double a = 0;
try {
a = Math.toDegrees(rot.getRotationAzimuth());
} catch (Exception ex) {
ex.printStackTrace();
}
double tiltVar = t;
double eVar = e;
double aVar = a;
Platform.runLater(() -> tilt.setValue(tiltVar));
Platform.runLater(() -> elevation.setValue(eVar));
Platform.runLater(() -> azimeth.setValue(aVar));
// Set the rotation after setting the UI so the read will load the rotation in its pure form
initialState = p;
}
use of com.neuronrobotics.sdk.addons.kinematics.math.TransformNR in project BowlerStudio by CommonWealthRobotics.
the class JogMobileBase method controllerLoop.
private void controllerLoop() {
new Thread(() -> {
// System.out.println("controllerLoop");
double seconds = .1;
if (stop == false) {
try {
seconds = Double.parseDouble(sec.getText());
if (!stop) {
double inc;
try {
// convert to mm
inc = Double.parseDouble(increment.getText()) * 1000 * seconds;
} catch (Exception e) {
inc = defauletSpeed;
Platform.runLater(() -> {
try {
increment.setText(Double.toString(defauletSpeed));
} catch (Exception ex) {
ex.printStackTrace();
}
});
}
// double rxl=0;
double ryl = inc / 20 * slider;
double rzl = inc / 2 * rz;
TransformNR current = new TransformNR(0, 0, 0, new RotationNR(0, rzl, 0));
current.translateX(inc * x);
current.translateY(inc * y);
current.translateZ(inc * slider);
try {
TransformNR toSet = current.copy();
double toSeconds = seconds;
JogThread.setTarget(mobilebase, toSet, toSeconds);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (seconds < .01) {
seconds = .01;
Platform.runLater(() -> sec.setText(".01"));
}
FxTimer.runLater(Duration.ofMillis((int) (seconds * 1000.0)), new Runnable() {
@Override
public void run() {
controllerLoop();
// System.out.println("Controller loop!");
}
});
}
}).start();
}
Aggregations