EDU.cmu.cs.coral.cye
Class JCyeSrv

java.lang.Object
  |
  +--EDU.cmu.cs.coral.cye.JCyeSrv

public class JCyeSrv
extends java.lang.Object

The JCyeSrv class acts as an interactive server for the Cye mobile robot. All user interaction with Cye should take place through this class.

See Also:
edu.cmu.cs.JavaCye.JCyeComm, edu.cmu.cs.JavaCye.JCyeMsg, edu.cmu.cs.JavaCye.JCyeStatus

Constructor Summary
JCyeSrv(java.lang.String d, int b, int c, byte i)
          The constructor for class JCyeSrv.
 
Method Summary
 void ClearObstacle()
          Clears Cye's obstacle detector.
 double encoderToRadian(int e)
          Convert a heading from robot coordinates (encoder values) to world coordinates (radians).
 double GetLastB()
          Return the last reported battery charge of Cye.
 double GetLastH()
          Return the last reported Heading of Cye.
 double GetLastX()
          Return the last reported X position of Cye.
 double GetLastY()
          Return the last reported Y position of Cye.
 boolean GetObstacle()
          Return the state of Cye's obstacle detector.
 byte InttoByte(int l, int i)
          Return a specific byte (8 bits) ripped out of an integer (32 bits).
 int radianToEncoder(double h)
          Convert a heading from world coordinates (radians) to robot coordinates (encoder values).
 double robotToWorld(int r)
          Convert a position value from robot coordinates (encoder ticks) to world coordinates (inches).
 void SendBuzzerFrequency(int Frequency)
          Wanna play a tune? Set the buzzer frequency to a specific value.
 void SendBuzzerOn(boolean OnOff)
          Turn on or off Cye's buzzer.
 void SendHandleLength(int Length)
          Set the length of the "bungee-cord" virtual handle on the front of Cye.
 void SendHeading(double h)
          Tell Cye its true heading, overwriting dead-reckoned value.
 void SendHeadingCorrectionFactor(int Correction)
          Instruct Cye to set the internal heading correction factor.
 void SendHeadingDestination(double heading, int velocity)
          Instruct Cye to rotate to a specifed heading at a specified velocity.
 void SendMaxPWM(int MaxPWM)
          Instruct Cye to set the maximum PWM value.
 void SendMaxSpeed(int MaxSpeed)
          Instruct Cye to set its maximum speed.
 void SendMotorControlConstants(byte Kp, byte Ki, byte Kd, byte Kb, byte Kpwm)
          Not implemented.
 void SendMotorsPWM(int m0PWM, int m1PWM)
          Instruct Cye to set the motors to specific PWM values
 void SendMotorVelocities(int M0Vel, int M1Vel)
          Instruct Cye to move with specified motor velocities.
 JCyeMsg SendMsg(JCyeMsg Msg)
          Sends a JCyeMsg to Cye using the JCyeComm object
 void SendPoll()
          Send a poll message to the robot.
 void SendPosition(double x, double y)
          Tell Cye its true position, overwriting dead-reckoned value.
 void SendPositionDestination(double x, double y)
          Instruct Cye to move to a specified location
 void SendPositionVelocityDestination(double x, double y, int v)
          Instruct Cye to move to a specific (x,y) position at a specified velocity.
 void SendPowerOff()
          Instruct Cye to commit ritual suicide.
 void SendRequestState()
          Request state information from Cye.
 void SendSensitiveObstacleDetection(int Sensitive)
          Not implemented.
 void SendStopMotors()
          Instruct Cye to stop its motors.
 void SendStraightVelocity(int v, double h)
          Instruct Cye to move straight with a specified velocity at a specified heading.
 void SendTurn(double Heading, int Velocity, int Diameter)
          Not implemented.
 void SendVelocityDirection(double Heading, int Velocity)
          Not implemented.
 void Wait(int ms)
          Wait for ms milliseconds
 int worldToRobot(double w)
          Convert a position value from world coordinates (inches) to robot coordinates (encoder ticks).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCyeSrv

public JCyeSrv(java.lang.String d,
               int b,
               int c,
               byte i)
The constructor for class JCyeSrv. Creates a new JCyeComm object to handle robot interaction, and issues a start command to it.
Parameters:
d - the device to open to the robot.
b - the baud rate to open to the robot.
c - connection to the robot (WIRED or OLD_RADIO or NEW_RADIO).
i - the id number of the robot.
Method Detail

Wait

public void Wait(int ms)
Wait for ms milliseconds
Parameters:
ms - the number of milliseconds to wait

SendMsg

public JCyeMsg SendMsg(JCyeMsg Msg)
Sends a JCyeMsg to Cye using the JCyeComm object
Parameters:
Msg - the message (of type JCyeMsg) to be sent
Returns:
the JCyeMsg reply from Cye

SendPositionDestination

public void SendPositionDestination(double x,
                                    double y)
Instruct Cye to move to a specified location
Parameters:
x - the desired X position, in world coordinates(inches)
y - the desired Y position, in world coordinates(inches)

SendMotorsPWM

public void SendMotorsPWM(int m0PWM,
                          int m1PWM)
Instruct Cye to set the motors to specific PWM values
Parameters:
m0PWM - the PWM value for Motor 0 (right)
m1PWM - the PWM value for Motor 1 (left)

SendStopMotors

public void SendStopMotors()
Instruct Cye to stop its motors.

SendHeadingDestination

public void SendHeadingDestination(double heading,
                                   int velocity)
Instruct Cye to rotate to a specifed heading at a specified velocity.
Parameters:
heading - the commanded heading, in world coordinates (radians).
velocity - the velocity at which to turn.

SendMaxPWM

public void SendMaxPWM(int MaxPWM)
Instruct Cye to set the maximum PWM value. I have no idea what this does.
Parameters:
MaxPWM - the maximum PWM value...????

SendHeadingCorrectionFactor

public void SendHeadingCorrectionFactor(int Correction)
Instruct Cye to set the internal heading correction factor.
Parameters:
Correction - the correction value

SendMotorVelocities

public void SendMotorVelocities(int M0Vel,
                                int M1Vel)
Instruct Cye to move with specified motor velocities.
Parameters:
M0Vel - the velocity command value for Motor 0 (right)
M1Vel - the velocity command value for Motor 1 (left)

SendPosition

public void SendPosition(double x,
                         double y)
Tell Cye its true position, overwriting dead-reckoned value.
Parameters:
x - Cye's true X position, in world coordinates (inches)
y - Cye's true Y position, in world coordinates (inches)

SendHeading

public void SendHeading(double h)
Tell Cye its true heading, overwriting dead-reckoned value.
Parameters:
H - Cye's true heading, in world coordinates (radians)

SendMaxSpeed

public void SendMaxSpeed(int MaxSpeed)
Instruct Cye to set its maximum speed. I have no idea what this does either.
Parameters:
MaxSpeed - the maximum speed value

SendPositionVelocityDestination

public void SendPositionVelocityDestination(double x,
                                            double y,
                                            int v)
Instruct Cye to move to a specific (x,y) position at a specified velocity.
Parameters:
x - the commanded x position, in world coordinates (inches)
y - the commanded y position, in world coordinates (inches)
v - the velocity at which to move

SendStraightVelocity

public void SendStraightVelocity(int v,
                                 double h)
Instruct Cye to move straight with a specified velocity at a specified heading.
Parameters:
v - the commanded velocity
h - the commanded heading, in world coordinates (radians)

SendSensitiveObstacleDetection

public void SendSensitiveObstacleDetection(int Sensitive)
Not implemented. What does this do?

SendTurn

public void SendTurn(double Heading,
                     int Velocity,
                     int Diameter)
Not implemented. What does this do?

SendMotorControlConstants

public void SendMotorControlConstants(byte Kp,
                                      byte Ki,
                                      byte Kd,
                                      byte Kb,
                                      byte Kpwm)
Not implemented. What does this do?

SendHandleLength

public void SendHandleLength(int Length)
Set the length of the "bungee-cord" virtual handle on the front of Cye.
Parameters:
Length - the length of the handle

SendBuzzerOn

public void SendBuzzerOn(boolean OnOff)
Turn on or off Cye's buzzer.
Parameters:
OnOff - duh

SendBuzzerFrequency

public void SendBuzzerFrequency(int Frequency)
Wanna play a tune? Set the buzzer frequency to a specific value.
Parameters:
Frequency - the frequency

SendVelocityDirection

public void SendVelocityDirection(double Heading,
                                  int Velocity)
Not implemented. What does this do?

SendRequestState

public void SendRequestState()
Request state information from Cye.

SendPowerOff

public void SendPowerOff()
Instruct Cye to commit ritual suicide.

SendPoll

public void SendPoll()
Send a poll message to the robot. This normally does not need to be called by the user; automatic idle polling is implemented at a lower level.

InttoByte

public byte InttoByte(int l,
                      int i)
Return a specific byte (8 bits) ripped out of an integer (32 bits).
Parameters:
l - the integer
i - the byte position (0..3)
Returns:
the specified byte from l

GetLastX

public double GetLastX()
Return the last reported X position of Cye.
Returns:
the last known X position of Cye, according to its dead-reckoning, in world coordinates (inches).

GetLastY

public double GetLastY()
Return the last reported Y position of Cye.
Returns:
the last known Y position of Cye, according to its dead-reckoning, in world coordinates (inches).

GetLastH

public double GetLastH()
Return the last reported Heading of Cye.
Returns:
the last known Heading of Cye, according to its dead-reckoning, in world coordinates (radians).

GetLastB

public double GetLastB()
Return the last reported battery charge of Cye.
Returns:
the last known battery charge, in volts.

GetObstacle

public boolean GetObstacle()
Return the state of Cye's obstacle detector. Returns true if Cye has hit an obstacle since the last call to ClearObstacle, false otherwise.
Returns:
the state of Cye's obstacle detector.

ClearObstacle

public void ClearObstacle()
Clears Cye's obstacle detector. Use this method to reset the obstacle detection logic.

radianToEncoder

public int radianToEncoder(double h)
Convert a heading from world coordinates (radians) to robot coordinates (encoder values).
Parameters:
h - a heading in radians
Returns:
the heading converted to robot coordinates

encoderToRadian

public double encoderToRadian(int e)
Convert a heading from robot coordinates (encoder values) to world coordinates (radians).
Parameters:
e - a heading in robot coordinates
Returns:
the heading converted to radians

robotToWorld

public double robotToWorld(int r)
Convert a position value from robot coordinates (encoder ticks) to world coordinates (inches).
Parameters:
r - a position value in robot coordinates
Returns:
the position value converted to inches

worldToRobot

public int worldToRobot(double w)
Convert a position value from world coordinates (inches) to robot coordinates (encoder ticks).
Parameters:
w - a position value in world coordinates (inches)
Returns:
the position value converted to robot coordinates