Search in sources :

Example 6 with IssueReportingExceptionHandler

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();
}
Also used : CSG(eu.mihosoft.vrl.v3d.CSG) DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics) MobileBase(com.neuronrobotics.sdk.addons.kinematics.MobileBase) IssueReportingExceptionHandler(com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) TransportException(org.eclipse.jgit.api.errors.TransportException) InvalidRemoteException(org.eclipse.jgit.api.errors.InvalidRemoteException)

Aggregations

IssueReportingExceptionHandler (com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler)6 IOException (java.io.IOException)5 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)5 InvalidRemoteException (org.eclipse.jgit.api.errors.InvalidRemoteException)5 TransportException (org.eclipse.jgit.api.errors.TransportException)5 DHParameterKinematics (com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)2 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 Group (javafx.scene.Group)2 GHRepository (org.kohsuke.github.GHRepository)2 DHLink (com.neuronrobotics.sdk.addons.kinematics.DHLink)1 MobileBase (com.neuronrobotics.sdk.addons.kinematics.MobileBase)1 TransformNR (com.neuronrobotics.sdk.addons.kinematics.math.TransformNR)1 ParallelGroup (com.neuronrobotics.sdk.addons.kinematics.parallel.ParallelGroup)1 CSG (eu.mihosoft.vrl.v3d.CSG)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Insets (javafx.geometry.Insets)1 Node (javafx.scene.Node)1 ButtonType (javafx.scene.control.ButtonType)1