Search in sources :

Example 1 with ILinkListener

use of com.neuronrobotics.sdk.addons.kinematics.ILinkListener in project bowler-script-kernel by CommonWealthRobotics.

the class MobileBaseCadManager method generateCad.

/**
 * This function iterates through the links generating them
 *
 * @param dh
 * @return
 */
public ArrayList<CSG> generateCad(DHParameterKinematics dh) {
    ArrayList<CSG> dhLinks = new ArrayList<>();
    if (cadEngine == null) {
        try {
            setDefaultLinkLevelCadEngine();
        } catch (Exception e) {
            getUi().highlightException(getCadScript(), e);
        }
    }
    try {
        IgenerateCad generatorToUse = getIgenerateCad();
        if (dhCadGen.get(dh) != null) {
            Object object = dhCadGen.get(dh);
            if (IgenerateCad.class.isInstance(object))
                generatorToUse = (IgenerateCad) object;
        }
        int j = 0;
        for (DHParameterKinematics dhtest : getMobileBase().getAllDHChains()) {
            if (dhtest == dh)
                break;
            j++;
        }
        for (int i = 0; i < dh.getNumberOfLinks(); i++) {
            set(base, (int) j, (int) i);
            if (!bail) {
                ArrayList<CSG> tmp = generatorToUse.generateCad(dh, i);
                getUi().addCSG(tmp, getCadScript());
                LinkConfiguration configuration = dh.getLinkConfiguration(i);
                if (getLinktoCadMap().get(configuration) == null) {
                    getLinktoCadMap().put(configuration, new ArrayList<>());
                } else
                    getLinktoCadMap().get(configuration).clear();
                for (CSG c : tmp) {
                    dhLinks.add(c);
                    // add to
                    getLinktoCadMap().get(configuration).add(c);
                // the
                // regestration
                // storage
                }
                AbstractLink link = dh.getFactory().getLink(configuration);
                link.addLinkListener(new ILinkListener() {

                    @Override
                    public void onLinkPositionUpdate(AbstractLink arg0, double arg1) {
                    // TODO Auto-generated method stub
                    }

                    @Override
                    public void onLinkLimit(AbstractLink arg0, PIDLimitEvent arg1) {
                        if (getAutoRegen())
                            selectCsgByLink(base, configuration);
                    }
                });
            }
        }
        return dhLinks;
    } catch (Exception e) {
        getUi().highlightException(getCadScript(), e);
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) 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) ILinkListener(com.neuronrobotics.sdk.addons.kinematics.ILinkListener) LinkConfiguration(com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration) CSG(eu.mihosoft.vrl.v3d.CSG) PIDLimitEvent(com.neuronrobotics.sdk.pid.PIDLimitEvent) DHParameterKinematics(com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics) AbstractLink(com.neuronrobotics.sdk.addons.kinematics.AbstractLink)

Aggregations

AbstractLink (com.neuronrobotics.sdk.addons.kinematics.AbstractLink)1 DHParameterKinematics (com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)1 ILinkListener (com.neuronrobotics.sdk.addons.kinematics.ILinkListener)1 LinkConfiguration (com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration)1 PIDLimitEvent (com.neuronrobotics.sdk.pid.PIDLimitEvent)1 CSG (eu.mihosoft.vrl.v3d.CSG)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 InvalidRemoteException (org.eclipse.jgit.api.errors.InvalidRemoteException)1 TransportException (org.eclipse.jgit.api.errors.TransportException)1