Search in sources :

Example 1 with VirtualGenericPIDDevice

use of com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice 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 2 with VirtualGenericPIDDevice

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

the class VirtualPuckBot method init.

private void init(VirtualWorld w, int botStartX, int botStartY) {
    world = w;
    world.addRobot(this, botStartX, botStartY);
    controller = new VirtualGenericPIDDevice(getMaxTicksPerSeconds());
    controller.addPIDEventListener(new IPIDEventListener() {

        public void onPIDReset(int group, int currentValue) {
        }

        public void onPIDLimitEvent(PIDLimitEvent e) {
        }

        public void onPIDEvent(PIDEvent e) {
            world.updateMap();
        }
    });
    setPIDChanels(controller.getPIDChannel(0), controller.getPIDChannel(1));
}
Also used : PIDLimitEvent(com.neuronrobotics.sdk.pid.PIDLimitEvent) IPIDEventListener(com.neuronrobotics.sdk.pid.IPIDEventListener) VirtualGenericPIDDevice(com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice) PIDEvent(com.neuronrobotics.sdk.pid.PIDEvent)

Example 3 with VirtualGenericPIDDevice

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

the class VirtualAckermanBot method init.

private void init(VirtualWorld w, int botStartX, int botStartY) {
    world = w;
    world.addRobot(this, botStartX, botStartY);
    controller = new VirtualGenericPIDDevice(getMaxTicksPerSecond());
    controller.addPIDEventListener(new IPIDEventListener() {

        public void onPIDReset(int group, int currentValue) {
        }

        public void onPIDLimitEvent(PIDLimitEvent e) {
        }

        public void onPIDEvent(PIDEvent e) {
            world.updateMap();
        }
    });
    setPIDChanel(controller.getPIDChannel(0));
}
Also used : PIDLimitEvent(com.neuronrobotics.sdk.pid.PIDLimitEvent) IPIDEventListener(com.neuronrobotics.sdk.pid.IPIDEventListener) VirtualGenericPIDDevice(com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice) PIDEvent(com.neuronrobotics.sdk.pid.PIDEvent)

Example 4 with VirtualGenericPIDDevice

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

the class PidDeviceServer method main.

public static void main(String[] args) {
    Log.enableInfoPrint();
    PidDeviceServer srv = new PidDeviceServer(new MACAddress(), new VirtualGenericPIDDevice(10000));
}
Also used : MACAddress(com.neuronrobotics.sdk.common.MACAddress) VirtualGenericPIDDevice(com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)

Aggregations

VirtualGenericPIDDevice (com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)4 IPIDEventListener (com.neuronrobotics.sdk.pid.IPIDEventListener)2 PIDEvent (com.neuronrobotics.sdk.pid.PIDEvent)2 PIDLimitEvent (com.neuronrobotics.sdk.pid.PIDLimitEvent)2 MACAddress (com.neuronrobotics.sdk.common.MACAddress)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 IPidControlNamespace (com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace)1