use of com.neuronrobotics.sdk.addons.kinematics.MobileBase in project BowlerStudio by CommonWealthRobotics.
the class CreatureLab method initializeUI.
@SuppressWarnings({ "restriction", "restriction" })
@Override
public void initializeUI(BowlerAbstractDevice pm) {
setGraphic(AssetFactory.loadIcon("CreatureLab-Tab.png"));
this.pm = pm;
autoRegen.setSelected(true);
autoRegen.setOnAction(event -> {
baseManager.setAutoRegen(autoRegen.isSelected());
if (autoRegen.isSelected()) {
generateCad();
}
});
// TODO Auto-generated method stub
setText(pm.getScriptingName());
try {
ScriptingEngine.setAutoupdate(true);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MobileBase device = (MobileBase) pm;
// Button save = new Button("Save Configuration");
FXMLLoader loader;
try {
loader = AssetFactory.loadLayout("layout/CreatureLabControlsTab.fxml", true);
Platform.runLater(() -> {
loader.setController(tab);
// This is needed when loading on MAC
loader.setClassLoader(getClass().getClassLoader());
try {
root = loader.load();
finishLoading(device);
} catch (Exception e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}
});
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
use of com.neuronrobotics.sdk.addons.kinematics.MobileBase in project bowler-script-kernel by CommonWealthRobotics.
the class RobotHelper method inlineScriptRun.
@Override
public Object inlineScriptRun(File code, ArrayList<Object> args) {
byte[] bytes;
try {
bytes = Files.readAllBytes(code.toPath());
String s = new String(bytes, "UTF-8");
MobileBase mb;
try {
mb = new MobileBase(IOUtils.toInputStream(s, "UTF-8"));
mb.setGitSelfSource(ScriptingEngine.findGitTagFromFile(code));
return MobileBaseLoader.get(mb).getBase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// System.out.println("Clojure returned of type="+ret.getClass()+" value="+ret);
return null;
}
use of com.neuronrobotics.sdk.addons.kinematics.MobileBase in project bowler-script-kernel by CommonWealthRobotics.
the class MobileBaseCadManager method generateBody.
public ArrayList<CSG> generateBody(MobileBase base) {
getProcesIndictor().set(0);
setAllCad(new ArrayList<>());
// DHtoCadMap = new HashMap<>();
// private HashMap<MobileBase, ArrayList<CSG>> BasetoCadMap = new
// HashMap<>();
MobileBase device = base;
if (getBasetoCadMap().get(device) == null) {
getBasetoCadMap().put(device, new ArrayList<CSG>());
}
if (cadEngine == null) {
try {
setDefaultLinkLevelCadEngine();
} catch (Exception e) {
getUi().highlightException(null, e);
}
if (getCadScript() != null) {
try {
cadEngine = ScriptingEngine.inlineFileScriptRun(getCadScript(), null);
} catch (Exception e) {
getUi().highlightException(getCadScript(), e);
}
}
}
getProcesIndictor().set(0.1);
try {
getAllCad().clear();
if (showingStl) {
// skip the regen
for (CSG c : getBasetoCadMap().get(device)) {
getAllCad().add(c);
}
} else {
if (!bail) {
ArrayList<CSG> newcad = getIgenerateBody().generateBody(device);
for (CSG c : newcad) {
getAllCad().add(c);
}
ui.addCSG(newcad, getCadScript());
} else
new Exception().printStackTrace();
ArrayList<CSG> arrayList = getBasetoCadMap().get(device);
arrayList.clear();
for (CSG c : getAllCad()) {
arrayList.add(c);
}
new Thread(() -> {
Thread.currentThread().setUncaughtExceptionHandler(new IssueReportingExceptionHandler());
// load the cad union in a thread to
localGetBaseCad(device);
// make it ready for physics
}).start();
}
} catch (Exception e) {
getUi().highlightException(getCadScript(), e);
}
System.out.println("Displaying Body");
getProcesIndictor().set(0.35);
// clears old robot and places base
getUi().setAllCSG(getBasetoCadMap().get(device), getCadScript());
System.out.println("Rendering limbs");
getProcesIndictor().set(0.4);
ArrayList<DHParameterKinematics> limbs = base.getAllDHChains();
double numLimbs = limbs.size();
int i = 0;
for (DHParameterKinematics l : limbs) {
if (getDHtoCadMap().get(l) == null) {
getDHtoCadMap().put(l, new ArrayList<CSG>());
}
ArrayList<CSG> arrayList = getDHtoCadMap().get(l);
int j = 0;
if (showingStl || !device.isAvailable()) {
for (CSG csg : arrayList) {
getAllCad().add(csg);
getUi().addCsg(csg, getCadScript());
set(base, (int) i, (int) j);
j += 1;
}
} else {
arrayList.clear();
ArrayList<CSG> linksCad = generateCad(l);
for (CSG csg : linksCad) {
getAllCad().add(csg);
arrayList.add(csg);
getUi().addCsg(csg, getCadScript());
j += 1;
}
}
i += 1;
}
showingStl = false;
getProcesIndictor().set(1);
// return PhysicsEngine.getCsgFromEngine();
return getAllCad();
}
use of com.neuronrobotics.sdk.addons.kinematics.MobileBase in project bowler-script-kernel by CommonWealthRobotics.
the class MobileBaseCadManager method getConfigurationDisplay.
private static ICadGenerator getConfigurationDisplay() {
if (cadEngineConfiguration == null) {
try {
File confFile = ScriptingEngine.fileFromGit("https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", "dhcad.groovy");
cadEngineConfiguration = (ICadGenerator) ScriptingEngine.inlineFileScriptRun(confFile, null);
FileChangeWatcher watcher = FileChangeWatcher.watch(confFile);
watcher.addIFileChangeListener(new IFileChangeListener() {
@Override
public void onFileChange(File fileThatChanged, WatchEvent event) {
// TODO Auto-generated method stub
try {
cadEngineConfiguration = (ICadGenerator) ScriptingEngine.gitScriptRun("https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", "dhcad.groovy", null);
for (MobileBase manager : cadmap.keySet()) {
MobileBaseCadManager mobileBaseCadManager = cadmap.get(manager);
if (mobileBaseCadManager.autoRegen)
if (mobileBaseCadManager.configMode)
mobileBaseCadManager.generateCad();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return cadEngineConfiguration;
}
use of com.neuronrobotics.sdk.addons.kinematics.MobileBase in project bowler-script-kernel by CommonWealthRobotics.
the class MobileBaseLoader method fromGit.
public static MobileBase fromGit(String id, String file) throws Exception {
String xmlContent = ScriptingEngine.codeFromGit(id, file)[0];
MobileBase mb = new MobileBase(IOUtils.toInputStream(xmlContent, "UTF-8"));
mb.setGitSelfSource(new String[] { id, file });
// ConnectionManager.addConnection(mb, mb.getScriptingName());
return initializeScripts(mb);
}
Aggregations