Search in sources :

Example 1 with AnalogInputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel in project java-bowler by NeuronRobotics.

the class DrivingTest method setupRealRobot.

private void setupRealRobot(DyIO dyio) {
    DyPIDConfiguration dypid = new // PID group 0
    DyPIDConfiguration(// PID group 0
    0, // Input channel number
    23, // Input mode
    DyIOChannelMode.COUNT_IN_INT, // Output Channel
    11, // Output mode
    DyIOChannelMode.SERVO_OUT);
    PIDConfiguration pid = new // PID group
    PIDConfiguration(// PID group
    0, // enabled
    true, // inverted
    false, // Async
    true, // Kp
    1, // Ki
    1, // Kd
    .5, // Value to latch on index pulse
    0, // Use the latch system
    false, // Stop PID controller on index latch event
    false);
    dyio.ConfigureDynamicPIDChannels(dypid);
    dyio.ConfigurePIDController(pid);
    PIDChannel drive = dyio.getPIDChannel(0);
    ServoChannel srv = new ServoChannel(dyio.getChannel(10));
    AckermanBot a = new AckermanBot(new ServoRotoryLink(srv, new LinkConfiguration(98, 51, 143, 1)), drive);
    ServoChannel sweeper = new ServoChannel(dyio.getChannel(9));
    range = new LaserRangeSensor(new NRSerialPort("/dev/ttyACM0", 115200));
    // range = new LinearRangeSensor(	sweeper,
    // new AnalogInputChannel(dyio.getChannel(12)));
    line = new LineSensor(new AnalogInputChannel(dyio.getChannel(13)), null, new AnalogInputChannel(dyio.getChannel(14)));
    // This flame sensor uses the same servo as the rangefinder
    flame = new LinearRangeSensor(sweeper, new AnalogInputChannel(dyio.getChannel(15)));
    mainRobot = a;
}
Also used : PIDChannel(com.neuronrobotics.sdk.pid.PIDChannel) ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) LinkConfiguration(com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration) VirtualLineSensor(com.neuronrobotics.addons.driving.virtual.VirtualLineSensor) AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel) PIDConfiguration(com.neuronrobotics.sdk.pid.PIDConfiguration) DyPIDConfiguration(com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration) VirtualAckermanBot(com.neuronrobotics.addons.driving.virtual.VirtualAckermanBot) NRSerialPort(gnu.io.NRSerialPort) DyPIDConfiguration(com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration) ServoRotoryLink(com.neuronrobotics.sdk.addons.kinematics.ServoRotoryLink)

Example 2 with AnalogInputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel in project java-bowler by NeuronRobotics.

the class RealLineTrack method main.

/**
 * @param args
 */
public static void main(String[] args) {
    final DyIO d = new DyIO();
    ConnectionDialog.getBowlerDevice(d);
    if (d.isAvailable()) {
        new Thread() {

            public void run() {
                DyPIDConfiguration dypid = new // PID group 0
                DyPIDConfiguration(// PID group 0
                0, // Input channel number
                23, // Input mode
                DyIOChannelMode.COUNT_IN_INT, // Output Channel
                11, // Output mode
                DyIOChannelMode.SERVO_OUT);
                PIDConfiguration pid = new // PID group
                PIDConfiguration(// PID group
                0, // enabled
                true, // inverted
                false, // Async
                true, // Kp
                1, // Ki
                1, .5, 0, false, // Kd
                false);
                d.ConfigureDynamicPIDChannels(dypid);
                d.ConfigurePIDController(pid);
                PIDChannel drive = d.getPIDChannel(0);
                ServoChannel srv = new ServoChannel(d.getChannel(10));
                AbstractRobotDrive mainRobot = new AckermanBot(new ServoRotoryLink(srv, new LinkConfiguration(98, 51, 143, 1)), drive);
                AbstractSensor line = new LineSensor(new AnalogInputChannel(d.getChannel(14), true), null, new AnalogInputChannel(d.getChannel(13), true));
            // new LineTrack().runTrack(mainRobot,line);
            }
        }.start();
    } else {
        System.out.println("Failed");
        d.disconnect();
    }
}
Also used : AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel) PIDConfiguration(com.neuronrobotics.sdk.pid.PIDConfiguration) DyPIDConfiguration(com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration) DyPIDConfiguration(com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration) PIDChannel(com.neuronrobotics.sdk.pid.PIDChannel) ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) LinkConfiguration(com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration) DyIO(com.neuronrobotics.sdk.dyio.DyIO) ServoRotoryLink(com.neuronrobotics.sdk.addons.kinematics.ServoRotoryLink)

Example 3 with AnalogInputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel in project java-bowler by NeuronRobotics.

the class AnalogInputTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO.disableFWCheck();
    Log.enableDebugPrint();
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    AnalogInputChannel ana = new AnalogInputChannel(dyio, 15);
    ana.setAsync(false);
    // Loop forever printing out the voltage on the pin
    ServoChannel servo = new ServoChannel(dyio, 1);
    servo.SetPosition(128);
    while (true) {
        // System.out.println(ana.getValue());
        int currentVoltageValue = ana.getValue();
        int scaledVoltageValue = currentVoltageValue / 4;
        servo.SetPosition(scaledVoltageValue);
    }
}
Also used : ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Example 4 with AnalogInputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel in project java-bowler by NeuronRobotics.

the class ServoOutputScheduleChannel method initInput.

private void initInput() {
    if (input == null || (input.getChannel().getChannelNumber() != getAnalogInputChannelNumber())) {
        input = new AnalogInputChannel(output.getChannel().getDevice().getChannel(analogInputChannelNumber), true);
    }
    if (input.getChannel().getChannelNumber() != analogInputChannelNumber) {
        System.out.println("Re-Setting analog input channel: " + analogInputChannelNumber);
        input.removeAllAnalogInputListeners();
        input = new AnalogInputChannel(output.getChannel().getDevice().getChannel(analogInputChannelNumber), true);
    }
    addAnalogInputListener(this);
}
Also used : AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel)

Example 5 with AnalogInputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel 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)

Aggregations

AnalogInputChannel (com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel)5 ServoChannel (com.neuronrobotics.sdk.dyio.peripherals.ServoChannel)4 DyIO (com.neuronrobotics.sdk.dyio.DyIO)3 LinkConfiguration (com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration)2 ServoRotoryLink (com.neuronrobotics.sdk.addons.kinematics.ServoRotoryLink)2 DyPIDConfiguration (com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration)2 PIDChannel (com.neuronrobotics.sdk.pid.PIDChannel)2 PIDConfiguration (com.neuronrobotics.sdk.pid.PIDConfiguration)2 VirtualAckermanBot (com.neuronrobotics.addons.driving.virtual.VirtualAckermanBot)1 VirtualLineSensor (com.neuronrobotics.addons.driving.virtual.VirtualLineSensor)1 CounterOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel)1 IPidControlNamespace (com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace)1 VirtualGenericPIDDevice (com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)1 NRSerialPort (gnu.io.NRSerialPort)1