Search in sources :

Example 1 with IPidControlNamespace

use of com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace in project java-bowler by NeuronRobotics.

the class AbstractKinematicsNR method disconnectDeviceImp.

public void disconnectDeviceImp() {
    getFactory().removeLinkListener(this);
    IPidControlNamespace device = getFactory().getPid();
    if (device != null)
        device.removePIDEventListener(this);
    disconnectDevice();
}
Also used : IPidControlNamespace(com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace)

Example 2 with IPidControlNamespace

use of com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace in project java-bowler by NeuronRobotics.

the class LinkFactory method getLinkLocal.

private AbstractLink getLinkLocal(LinkConfiguration c) {
    if (dyio == null)
        dyio = (DyIO) DeviceManager.getSpecificDevice(DyIO.class, c.getDeviceScriptingName());
    if (pid == null)
        pid = (IPidControlNamespace) DeviceManager.getSpecificDevice(IPidControlNamespace.class, c.getDeviceScriptingName());
    AbstractLink tmp = null;
    Log.info("Loading link: " + c.getName() + " type = " + c.getType() + " device= " + c.getDeviceScriptingName());
    switch(c.getType()) {
        case ANALOG_PRISMATIC:
            if (dyio != null) {
                tmp = new AnalogPrismaticLink(new AnalogInputChannel(dyio.getChannel(c.getHardwareIndex())), c);
                tmp.setUseLimits(false);
            }
            break;
        case ANALOG_ROTORY:
            if (dyio != null) {
                tmp = new AnalogRotoryLink(new AnalogInputChannel(dyio.getChannel(c.getHardwareIndex())), c);
                tmp.setUseLimits(false);
            }
            break;
        case PID_TOOL:
        case PID:
            if (pid != null) {
                tmp = new PidRotoryLink(pid.getPIDChannel(c.getHardwareIndex()), c);
            }
            break;
        case PID_PRISMATIC:
            if (pid != null) {
                tmp = new PidPrismaticLink(pid.getPIDChannel(c.getHardwareIndex()), c);
            }
            break;
        case SERVO_PRISMATIC:
            if (dyio != null) {
                tmp = new ServoPrismaticLink(new ServoChannel(dyio.getChannel(c.getHardwareIndex())), c);
            }
            break;
        case SERVO_ROTORY:
        case SERVO_TOOL:
            if (dyio != null) {
                tmp = new ServoRotoryLink(new ServoChannel(dyio.getChannel(c.getHardwareIndex())), c);
            }
            break;
        case STEPPER_PRISMATIC:
            if (dyio != null) {
                tmp = new StepperPrismaticLink(new CounterOutputChannel(dyio.getChannel(c.getHardwareIndex())), c);
            }
            break;
        case STEPPER_TOOL:
        case STEPPER_ROTORY:
            if (dyio != null) {
                tmp = new StepperRotoryLink(new CounterOutputChannel(dyio.getChannel(c.getHardwareIndex())), c);
            }
            break;
        case DUMMY:
        case VIRTUAL:
            String myVirtualDevName = c.getDeviceScriptingName();
            virtual = (VirtualGenericPIDDevice) DeviceManager.getSpecificDevice(VirtualGenericPIDDevice.class, myVirtualDevName);
            if (virtual == null) {
                virtual = new VirtualGenericPIDDevice();
                DeviceManager.addConnection(virtual, myVirtualDevName);
            }
            tmp = new PidRotoryLink(virtual.getPIDChannel(c.getHardwareIndex()), c);
            break;
    }
    if (tmp == null) {
        String myVirtualDevName = "virtual_" + c.getDeviceScriptingName();
        virtual = (VirtualGenericPIDDevice) DeviceManager.getSpecificDevice(VirtualGenericPIDDevice.class, myVirtualDevName);
        if (virtual == null) {
            virtual = new VirtualGenericPIDDevice();
            DeviceManager.addConnection(virtual, myVirtualDevName);
        }
        if (!c.getType().isPrismatic()) {
            tmp = new PidRotoryLink(virtual.getPIDChannel(c.getHardwareIndex()), c);
        } else {
            tmp = new PidPrismaticLink(virtual.getPIDChannel(c.getHardwareIndex()), c);
        }
    }
    tmp.setLinkConfiguration(c);
    links.add(tmp);
    if (!getLinkConfigurations().contains(c))
        getLinkConfigurations().add(c);
    return tmp;
}
Also used : CounterOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel) IPidControlNamespace(com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace) AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel) ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) DyIO(com.neuronrobotics.sdk.dyio.DyIO) VirtualGenericPIDDevice(com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)

Example 3 with IPidControlNamespace

use of com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace in project java-bowler by NeuronRobotics.

the class AbstractKinematicsNR method setDevice.

protected void setDevice(LinkFactory f, ArrayList<LinkConfiguration> linkConfigs) {
    Log.info("Loading device: " + f.getClass() + " " + f);
    setFactory(f);
    // Log.enableDebugPrint(true);
    for (int i = 0; i < linkConfigs.size(); i++) {
        LinkConfiguration c = linkConfigs.get(i);
        c.setLinkIndex(i);
        getFactory().getLink(c);
        Log.info("\nAxis #" + i + " Configuration:\n" + c);
        if (c.getType() == LinkType.PID) {
            IPidControlNamespace device = getFactory().getPid();
            try {
                PIDConfiguration tmpConf = device.getPIDConfiguration(c.getHardwareIndex());
                tmpConf.setGroup(c.getHardwareIndex());
                tmpConf.setKP(c.getKP());
                tmpConf.setKI(c.getKI());
                tmpConf.setKD(c.getKD());
                tmpConf.setEnabled(true);
                tmpConf.setInverted(c.isInverted());
                tmpConf.setAsync(false);
                tmpConf.setUseLatch(false);
                tmpConf.setIndexLatch(c.getIndexLatch());
                tmpConf.setStopOnIndex(false);
                Log.info("\nAxis #" + i + " " + tmpConf);
                getAxisPidConfiguration().add(tmpConf);
                setLinkCurrentConfiguration(i, tmpConf);
                // Send configuration for ONE axis
                device.ConfigurePIDController(tmpConf);
            } catch (Exception ex) {
                Log.error("Configuration #" + i + " failed!!");
                ex.printStackTrace();
            }
            device.addPIDEventListener(this);
        }
    }
    getCurrentTaskSpaceTransform();
    getFactory().addLinkListener(this);
    getDhParametersChain().setFactory(getFactory());
    // filling up the d-h parameters so the chain sizes match
    while (getDhParametersChain().getLinks().size() < linkConfigs.size()) {
        getDhParametersChain().addLink(new DHLink(0, 0, 0, 0));
    }
}
Also used : IPidControlNamespace(com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace) PIDConfiguration(com.neuronrobotics.sdk.pid.PIDConfiguration) InvalidConnectionException(com.neuronrobotics.sdk.common.InvalidConnectionException) RuntimeErrorException(javax.management.RuntimeErrorException)

Aggregations

IPidControlNamespace (com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace)3 InvalidConnectionException (com.neuronrobotics.sdk.common.InvalidConnectionException)1 DyIO (com.neuronrobotics.sdk.dyio.DyIO)1 AnalogInputChannel (com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel)1 CounterOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel)1 ServoChannel (com.neuronrobotics.sdk.dyio.peripherals.ServoChannel)1 PIDConfiguration (com.neuronrobotics.sdk.pid.PIDConfiguration)1 VirtualGenericPIDDevice (com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)1 RuntimeErrorException (javax.management.RuntimeErrorException)1