Skip to content

Instantly share code, notes, and snippets.

@MazonDel
Last active August 29, 2015 14:21
Show Gist options
  • Save MazonDel/1b43fbe4abb0dc856340 to your computer and use it in GitHub Desktop.
Save MazonDel/1b43fbe4abb0dc856340 to your computer and use it in GitHub Desktop.
import com.neuronrobotics.sdk.serial.SerialConnection; // Needed for serial.
import com.neuronrobotics.jniloader.OpenCVImageProvider
import com.neuronrobotics.replicator.driver.BowlerBoardDevice; // Bowler talk.
import gnu.io.NRSerialPort; // Needed for the laser range finder.
import com.neuronrobotics.addons.driving.HokuyoURGDevice; // Needed for the laser range finder.
import com.neuronrobotics.sdk.common.NonBowlerDevice
import com.neuronrobotics.sdk.dyio.DyIO
import com.neuronrobotics.sdk.dyio.peripherals.DigitalOutputChannel
import com.neuronrobotics.sdk.dyio.peripherals.ServoChannel
import com.neuronrobotics.sdk.pid.PIDChannel; // Needed for PID.
class Rover extends NonBowlerDevice
{
DyIO dyio;
BowlerBoardDevice bowler;
OpenCVImageProvider clawCam;
OpenCVImageProvider mainCam;
HokuyoURGDevice laser;
PIDChannel driveWheel;
PIDChannel rightWheel;
PIDChannel leftWheel;
PIDChannel armBase;
PIDChannel armElbow;
PIDChannel armTurret;
DigitalOutputChannel motOne;
DigitalOutputChannel motTwo;
DigitalOutputChannel motThree;
ServoChannel wristBend;
ServoChannel claw;
ServoChannel wristTwist;
DigitalOutputChannel servoEnable;
public Rover(DyIO dyio,
BowlerBoardDevice bowler,
OpenCVImageProvider clawCam,
OpenCVImageProvider mainCam,
HokuyoURGDevice laser,
PIDChannel driveWheel,
PIDChannel rightWheel,
PIDChannel leftWheel,
PIDChannel armBase,
PIDChannel armElbow,
PIDChannel armTurret,
DigitalOutputChannel motOne,
DigitalOutputChannel motTwo,
DigitalOutputChannel motThree,
ServoChannel wristBend,
ServoChannel claw,
ServoChannel wristTwist,
DigitalOutputChannel servoEnable){
this.dyio = dyio;
this.bowler = bowler;
this.clawCam = clawCam;
this.mainCam = mainCam;
this.laser = laser;
this.driveWheel = driveWheel;
this.rightWheel = rightWheel;
this.leftWheel = leftWheel;
this.armBase = armBase;
this.armElbow = armElbow;
this.armTurret = armTurret;
this.motOne = motOne;
this.motTwo = motTwo;
this.motThree = motThree;
this.wristBend = wristBend;
this.claw = claw;
this.wristTwist = wristTwist;
this.servoEnable = servoEnable;
}
@Override
public void disconnectDeviceImp()
{ // BOWLER DEVICES ONLY!
dyio.disconnect(); //disconnect
bowler.disconnect();
clawCam.disconnect();
mainCam.disconnect();
laser.disconnect();
}
@Override
public boolean connectDeviceImp()
{
//connect
// LEAVE ME BLANK!
// DON'T DELETE ME!
return false;
}
@Override
public ArrayList<String> getNamespacesImp()
{
// no namespaces on dummy
// LEAVE ME BLANK!
// DON'T DELETE ME!
return null;
}
}
// Adding in the DyIO.
DyIO dyio = new DyIO(new SerialConnection("/dev/BowlerDevice.74F7260B06F7")); // This is the DyIO to talk to.
dyio.connect(); // Connect to it.
dyio.setScriptingName("dyio"); // This is the name of the DyIO device.
//Adding the Bowler.
BowlerBoardDevice bowler = new BowlerBoardDevice() // new Bowler board.
bowler.setConnection(new SerialConnection("/dev/BowlerDevice.74F726000000")); // Connecting to the board.
bowler.connect(); // Connect to it.
bowler.setScriptingName("bowler"); // Naming the board.
// Adding the camera
OpenCVImageProvider clawCam = new OpenCVImageProvider(0);
clawCam.setScriptingName("clawCam"); // Eye in hand.
// Adding the main camera
OpenCVImageProvider mainCam = new OpenCVImageProvider(1);
mainCam.setScriptingName("mainCam"); // main camera.
// Adding the Laser.
//HokuyoURGDevice laser = new HokuyoURGDevice(new NRSerialPort("/dev/ttyACM2", 115200));
//laser.connect();
//laser.setScriptingName("laser"); // Laser Range Finder.
// Adding the driveWheel.
PIDChannel driveWheel = bowler.getPIDChannel(0);
// Adding the rightWheel.
PIDChannel rightWheel = bowler.getPIDChannel(1);
// Adding the leftWheel.
PIDChannel leftWheel = bowler.getPIDChannel(2);
// Adding the armBase.
PIDChannel armBase = bowler.getPIDChannel(4);
// Adding the armElbow.
PIDChannel armElbow = bowler.getPIDChannel(5);
// Adding the armTurret.
PIDChannel armTurret = bowler.getPIDChannel(6);
// Adding part of the motor controller
DigitalOutputChannel motOne = new DigitalOutputChannel(dyio.getChannel(0)); // The first pin for the motor control.
// Adding part of the motor controller
DigitalOutputChannel motTwo = new DigitalOutputChannel(dyio.getChannel(1)); // The first pin for the motor control.
// Adding part of the motor controller
DigitalOutputChannel motThree = new DigitalOutputChannel(dyio.getChannel(2)); // The first pin for the motor control.
// Adding the wrist-bend
ServoChannel wristBend = new ServoChannel (dyio.getChannel(9));
// Adding the claw
ServoChannel claw = new ServoChannel (dyio.getChannel(10));
// Adding the wrist-twist
ServoChannel wristTwist = new ServoChannel (dyio.getChannel(11));
// Adding part of the servoEnable
DigitalOutputChannel servoEnable = new DigitalOutputChannel(dyio.getChannel(12)); // Enables outputs to the servos.
Rover rover = new Rover(dyio, bowler, clawCam, mainCam,
null, driveWheel, rightWheel, leftWheel,
armBase, armElbow, armTurret, motOne,
motTwo, motThree, wristBend, claw, wristTwist, servoEnable);
rover.setScriptingName("moonrover");
ArrayList<Object> back = new ArrayList<Object>(); // This is the arraylist of hardware sending to OS.
back.add(dyio); // Adding the DyIO.
back.add(bowler); // Adding the Bowler.
back.add(clawCam); // Adding the claw camera.
back.add(mainCam); // Adding the main camera.
//back.add(laser); // Adding the Laser Range Finder.
back.add(rover);
return back;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment