Skip to content

Instantly share code, notes, and snippets.

View madhephaestus's full-sized avatar

Kevin Harrington madhephaestus

View GitHub Profile
@madhephaestus
madhephaestus / ConnectionDialogTest.java
Last active August 29, 2015 14:11
ConnectionDialog
import com.neuronrobotics.sdk.dyio.DyIO;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
System.out.println("Starting");
DyIO dyio=new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)){
System.err.println("Dialog failed");
return;
}
dyio.ping();
package com.neuronrobotics.addons.driving;
import com.neuronrobotics.sdk.dyio.DyIO;
import com.neuronrobotics.sdk.dyio.DyIOChannelMode;
import com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration;
import com.neuronrobotics.sdk.pid.IPIDEventListener;
import com.neuronrobotics.sdk.pid.PIDConfiguration;
import com.neuronrobotics.sdk.pid.PIDEvent;
import com.neuronrobotics.sdk.pid.PIDLimitEvent;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
public class CounterInputTestAsync implements ICounterInputListener{
//The Counter channel is a property of the class
private CounterInputChannel dip;
public CounterInputTestAsync(){
//Instantiate a new Counter channel
//The second parameter tells the Counter channel that is it an asynchronous channel
dip = new CounterInputChannel(dyio.getChannel(23),true);
//Add this instance of the Tester class to the Counter channel
dip.addCounterInputListener(this);
//Run forever printing out Counter events
package com.neuronrobotics.addons.driving;
import gnu.io.NRSerialPort;
import java.util.ArrayList;
import com.neuronrobotics.addons.driving.virtual.ObsticleType;
public class HokuyoTest implements ISensorListener {
package com.neuronrobotics.test.nrdk;
import com.neuronrobotics.sdk.common.BowlerAbstractCommand;
import com.neuronrobotics.sdk.common.BowlerDatagram;
import com.neuronrobotics.sdk.common.BowlerMethod;
import com.neuronrobotics.sdk.common.ByteList;
import com.neuronrobotics.sdk.common.Log;
import com.neuronrobotics.sdk.pid.GenericPIDDevice;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
//Instantiate a new counter input
CounterInputChannel enc=new CounterInputChannel(dyio.getChannel(23));
//To reset the value of the encoder, simply set the channel value
enc.setValue(0);
while(!Thread.interrupted()){
System.out.println(enc.getValue());
}
PPMReaderChannel ppm = new PPMReaderChannel(dyio.getChannel(23));
int servoChan = 4;
new ServoChannel(dyio.getChannel(servoChan));//Sets up the output channel for PPM cross link
ppm.stopAllCrossLinks();
int [] cross = ppm.getCrossLink();
//cross[0]=PPMReaderChannel.NO_CROSSLINK;//shut off the cross link for a channel
cross[0]=servoChan;//link ppm signal 0 to DyIO channel servoChan
// Set up the analog channel
AnalogInputChannel ana = new AnalogInputChannel(dyio.getChannel(12));
//disable the async so we can read just this channel
ana.setAsync(false);
//Loop forever printing out the voltage on the pin
while(!Thread.interrupted()){
System.out.println(ana.getVoltage());
Thread.sleep(100);
}
package com.neuronrobotics.test.nrdk.network;
import java.io.IOException;
import com.neuronrobotics.sdk.common.Log;
import com.neuronrobotics.sdk.common.MACAddress;
import com.neuronrobotics.sdk.common.device.server.BowlerAbstractServer;
import com.neuronrobotics.sdk.network.BowlerUDPServer;
import com.neuronrobotics.sdk.util.ThreadUtil;
public class CounterOutputAsyncTest implements ICounterOutputListener {
CounterOutputChannel stepper;
public CounterOutputAsyncTest () {
//Instantiate a new counter input
stepper=new CounterOutputChannel(dyio.getChannel(21));
stepper.addCounterOutputListener(this);
// Move 5 steps
stepper.SetPosition(10000, 30);
ThreadUtil.wait(30000);
stepper.SetPosition(0, 0);