Search in sources :

Example 6 with PIDLimitEvent

use of com.neuronrobotics.sdk.pid.PIDLimitEvent 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)

Example 7 with PIDLimitEvent

use of com.neuronrobotics.sdk.pid.PIDLimitEvent in project java-bowler by NeuronRobotics.

the class PidRotoryLink method setPIDChannel.

public void setPIDChannel(PIDChannel channel) {
    channel.addPIDEventListener(new IPIDEventListener() {

        @Override
        public void onPIDReset(int group, int currentValue) {
            fireLinkListener(currentValue);
        }

        @Override
        public void onPIDLimitEvent(PIDLimitEvent e) {
            fireLinkLimitEvent(e);
        }

        @Override
        public void onPIDEvent(PIDEvent e) {
            // Log.debug("\nRotory Link Async<<"+e);
            fireLinkListener(e.getValue());
        }
    });
    this.channel = channel;
}
Also used : PIDLimitEvent(com.neuronrobotics.sdk.pid.PIDLimitEvent) IPIDEventListener(com.neuronrobotics.sdk.pid.IPIDEventListener) PIDEvent(com.neuronrobotics.sdk.pid.PIDEvent)

Example 8 with PIDLimitEvent

use of com.neuronrobotics.sdk.pid.PIDLimitEvent in project java-bowler by NeuronRobotics.

the class LegacyPidNamespaceImp method onAsyncResponse.

public void onAsyncResponse(BowlerDatagram data) {
    // Log.debug("\nPID ASYNC<<"+data);
    if (data.getRPC().contains("_pid")) {
        PIDEvent e = new PIDEvent(data);
        firePIDEvent(e);
    }
    if (data.getRPC().contains("apid")) {
        int[] pos = new int[getNumberOfChannels()];
        for (int i = 0; i < getNumberOfChannels(); i++) {
            pos[i] = ByteList.convertToInt(data.getData().getBytes(i * 4, 4), true);
            PIDEvent e = new PIDEvent(i, pos[i], System.currentTimeMillis(), 0);
            firePIDEvent(e);
        }
    }
    if (data.getRPC().contains("pidl")) {
        firePIDLimitEvent(new PIDLimitEvent(data));
    }
}
Also used : PIDLimitEvent(com.neuronrobotics.sdk.pid.PIDLimitEvent) PIDEvent(com.neuronrobotics.sdk.pid.PIDEvent)

Aggregations

PIDLimitEvent (com.neuronrobotics.sdk.pid.PIDLimitEvent)8 PIDEvent (com.neuronrobotics.sdk.pid.PIDEvent)7 IPIDEventListener (com.neuronrobotics.sdk.pid.IPIDEventListener)5 VirtualGenericPIDDevice (com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)2 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 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