use of com.neuronrobotics.sdk.dyio.peripherals.ServoChannel 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;
}
use of com.neuronrobotics.sdk.dyio.peripherals.ServoChannel 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();
}
}
use of com.neuronrobotics.sdk.dyio.peripherals.ServoChannel 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);
}
}
use of com.neuronrobotics.sdk.dyio.peripherals.ServoChannel in project java-bowler by NeuronRobotics.
the class CoordinatedMotion method main.
public static void main(String[] args) throws InterruptedException {
DyIO dyio = new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)) {
System.exit(1);
}
dyio.connect();
int[] vals = dyio.getAllChannelValues();
// Set up the array of channels
ArrayList<ServoChannel> chans = new ArrayList<ServoChannel>();
Log.enableDebugPrint();
float time = 5;
for (int i = 0; i < 12; i++) {
chans.add(new ServoChannel(dyio.getChannel(i)));
}
// Set the DyIO into cached mode
dyio.setCachedMode(true);
int pos = 50;
for (int i = 0; i < 5; i++) {
pos = (pos == 50) ? 200 : 50;
for (ServoChannel s : chans) {
// Store the cached value
s.getChannel().setCachedValue(pos);
}
// Flush all values to the DyIO
dyio.flushCache(time);
Thread.sleep((long) (time * 1500));
}
System.exit(0);
}
use of com.neuronrobotics.sdk.dyio.peripherals.ServoChannel in project java-bowler by NeuronRobotics.
the class ServoPrismaticLink method setServoChannel.
public void setServoChannel(ServoChannel srv) {
// System.out.println("Setting new servo channel: "+srv.getChannel().getNumber());
srv.getChannel().setCachedMode(true);
srv.addIServoPositionUpdateListener(new IServoPositionUpdateListener() {
@Override
public void onServoPositionUpdate(ServoChannel srv, int position, double time) {
fireLinkListener(position);
}
});
this.srv = srv;
}
Aggregations