use of com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler 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();
}
Aggregations