robot3
Class Controller

java.lang.Object
  |
  +--robot3.Controller

class Controller
extends java.lang.Object

This is the main class used to control the robot. This is my third version after some trial and error -testing. :) My first version based on the robot replying to the messages, but I realized that because I'm going to have the IR-tower on the robot there's no need for the robot to send anything, as communication is as good as 100% and the robots replies will only disturb the PCs sendings.

The JavaLNP interface by Fabien Bergeret (fabien.bergeret@laposte.net) is used for communicating with the robot via IR-Tower.

I compiled it (so that Matlab can use it) with the following commandline:

javac -g -target 1.1 -d C:\asoinio\java\classes -sourcepath C:\asoinio\java\sources\ *.java

---------------

These messages are also used by the RCX program robot3.c
--

Messages, PC => RCX:
--
R = reset, motor powers to 0 and motors to float
S = stop (brake, full voltage to motors)

Mxaybzc = Set motor state and speed, x=speed for A, a=state for A,
y=speed for B, b=state for B...

Ax = set motor A's power to the value of x (binary, 0..255)
Bx = set motor B's power to the value of x (binary)
Cx = set motor C's power to the value of x (binary)

1x = set motor A state to x, (0=off (float), 1=forward, 2=reverse, 3=brake;
defined in robot2.Controller.[FLOAT|FORWARD|REVERSE|BRAKE] )
2x = set motor B state to x
3x = set motor C state to x

-----------------------------------------------------------------------------

When the bumper (SENSOR_2) hits something, the robot will also stop (brake).


Field Summary
static int BRAKE
           
static boolean DEBUG
           
static int FLOAT
           
static int FORWARD
           
(package private)  ControllerInputWindow inputWindow
           
(package private)  LNPManager manager
           
static int MOTOR_LEVELS
           
(package private)  int[] motorLevel
           
static int MOTORS
           
(package private)  int[] motorState
           
(package private)  ControllerOutputWindow outputWindow
           
static int REVERSE
           
(package private) static java.lang.String[] STATE_NAMES
           
(package private) static int STATES
           
 
Constructor Summary
Controller(boolean interActive)
           
 
Method Summary
 void brakeAll()
           
 void brakeAllNoSend()
           
 void decreaseMotorLevel(int motor, boolean allowReverse)
           
protected  int getInputWindowX()
           
 int getMotorLevel(int motor)
           
 int getMotorState(int motor)
           
 void hide()
           
 void increaseMotorLevel(int motor, boolean allowReverse)
           
 boolean isBraking()
           
static void main(java.lang.String[] args)
           
 void setAllMotors(int levelA, int stateA, int levelB, int stateB, int levelC, int stateC)
           
 void setDebug(boolean debug)
           
 void setMotorLevel(int motor, int level)
           
 void setMotorState(int motor, int state)
           
 void show()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

MOTOR_LEVELS

public static final int MOTOR_LEVELS
See Also:
Constant Field Values

MOTORS

public static final int MOTORS
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

FORWARD

public static final int FORWARD
See Also:
Constant Field Values

REVERSE

public static final int REVERSE
See Also:
Constant Field Values

BRAKE

public static final int BRAKE
See Also:
Constant Field Values

STATE_NAMES

static final java.lang.String[] STATE_NAMES

STATES

static final int STATES

outputWindow

ControllerOutputWindow outputWindow

inputWindow

ControllerInputWindow inputWindow

manager

LNPManager manager

motorLevel

int[] motorLevel

motorState

int[] motorState
Constructor Detail

Controller

public Controller(boolean interActive)
Method Detail

hide

public void hide()

show

public void show()

setDebug

public void setDebug(boolean debug)

getMotorLevel

public int getMotorLevel(int motor)

getMotorState

public int getMotorState(int motor)

isBraking

public boolean isBraking()

brakeAll

public void brakeAll()

brakeAllNoSend

public void brakeAllNoSend()

setAllMotors

public void setAllMotors(int levelA,
                         int stateA,
                         int levelB,
                         int stateB,
                         int levelC,
                         int stateC)

setMotorState

public void setMotorState(int motor,
                          int state)

setMotorLevel

public void setMotorLevel(int motor,
                          int level)

increaseMotorLevel

public void increaseMotorLevel(int motor,
                               boolean allowReverse)

decreaseMotorLevel

public void decreaseMotorLevel(int motor,
                               boolean allowReverse)

getInputWindowX

protected int getInputWindowX()

main

public static void main(java.lang.String[] args)