15 package com.neuronrobotics.sdk.addons.irobot;
 
   17 import java.util.ArrayList;
 
   19 import com.neuronrobotics.sdk.common.ByteList;
 
   20 import com.neuronrobotics.sdk.common.Log;
 
   21 import com.neuronrobotics.sdk.dyio.DyIOChannelEvent;
 
   22 import com.neuronrobotics.sdk.dyio.peripherals.DyIOPeripheralException;
 
   23 import com.neuronrobotics.sdk.dyio.peripherals.IUARTStreamListener;
 
   24 import com.neuronrobotics.sdk.dyio.peripherals.UARTChannel;
 
   52     private byte []
sensor  = 
new byte[26];
 
   58     private ArrayList<ICreateSensorListener> 
listeners = 
new ArrayList<ICreateSensorListener>();
 
   69         byte [] init = {(byte) 128,(
byte) 131};
 
   72         } 
catch (Exception e) {
 
   82         byte [] init = {(byte) 128,(
byte) 132};
 
   85         } 
catch (Exception e) {
 
   94         byte [] init = {(byte) 128,(
byte) 131};
 
   97         } 
catch (Exception e) {
 
  108         byte [] init = {(byte) 128,(
byte) 131};
 
  112                 Log.
info(
"Initializing Create..");
 
  115             } 
catch (Exception e) {
 
  132     public void move(
short velocity,
short radius){
 
  137         byte[] drv = {(byte) 137,(
byte) (velocity>>8),(
byte) velocity,(byte) (radius>>8),(byte) radius};
 
  140         } 
catch (Exception e) {
 
  159         if((distance > 0 && velocity < 0) || (distance < 0 && velocity > 0)){
 
  162         byte[] drv = {(byte) 152,13,
 
  163                       (
byte) 137,(byte) (velocity>>8),(byte) velocity,(
byte) (128),0,
 
  164                       (
byte) 156,(byte) (distance>>8),(byte) (distance),
 
  169         } 
catch (Exception e) {
 
  189         } 
catch (Exception e) {
 
  198                     Log.
info(
"Trying to get a good sensor reading");
 
  202                 } 
catch (Exception e) {
 
  206             Log.
info(
"Driving Attempt "+Integer.toBinaryString(tries));
 
  208                 Log.
info(
"Re attempting to send command");
 
  212                 } 
catch (Exception e) {
 
  229         turn((
short)0x7fff,angle);
 
  236     public void turn(
short velocity,
short angle){
 
  240         short turn = (short) ((angle>0)? 1:-1);
 
  241         byte[] drv = {(byte) 152,13,
 
  242                       (
byte) 137,(byte) (velocity>>8),(byte) velocity,(
byte) (
turn>>8),(
byte) (
turn),
 
  243                       (
byte) 157,(byte) (angle>>8),(byte) (angle),
 
  249         } 
catch (Exception e) {
 
  263     public boolean turnBlocking(
int timeout,
short velocity,
short angle) 
throws InterruptedException{
 
  267             turn(velocity,angle);
 
  268         } 
catch (Exception e) {
 
  277                     Log.
info(
"Trying to get a good sensor reading");
 
  281                 } 
catch (Exception e) {
 
  286             Log.
info(
"Driving Attempt "+Integer.toBinaryString(tries));
 
  288                 Log.
info(
"Re attempting to send command");
 
  291                     turn(velocity,angle);
 
  292                 } 
catch (Exception e) {
 
  308     public void setLed(
boolean max,
boolean spot){
 
  342         byte []all={(byte)142,req.
getValue()};
 
  345         } 
catch (Exception e) {
 
  356         } 
catch (Exception e) {
 
  367     private void send(
byte[]b) 
throws Exception{
 
  377         } 
catch (InterruptedException e1) {
 
  385                 for (
int i=0;i<26;i++){
 
  396                 for (
int i=0;i<10;i++){
 
  408                 for (
int i=0;i<6;i++){
 
  419                 for (
int i=0;i<10;i++){
 
  480             l.onCreateSensor(packet);
 
void removeCreateSensorListener(ICreateSensorListener l)
 
void requestSensors(CreateSensorRequest req)
 
void move(short velocity, short radius)
 
void driveStraight(short velocity, short distance)
 
CreateSensorRequest senReq
 
void InitCreateBlocking(int timeout)
 
void fireCreatePacket(CreateSensors packet)
 
void addCreateSensorListener(ICreateSensorListener l)
 
void setStatusLed(int color, int intensity)
 
boolean driveStraightBlocking(int timeout, short velocity, short distance)
 
void removeAllCreateSensorListeners()
 
void driveStraight(short distance)
 
ArrayList< ICreateSensorListener > listeners
 
void onChannelEvent(DyIOChannelEvent e)
 
boolean turnBlocking(int timeout, short velocity, short angle)
 
void setLed(boolean max, boolean spot)
 
void turn(short velocity, short angle)
 
static void info(String message)
 
static void error(String message)
 
boolean sendBytes(ByteList stream)
 
void addUARTStreamListener(IUARTStreamListener l)
 
boolean setUARTBaudrate(int baudrate)