EDU.gatech.cc.is.abstractrobot
Class CommN150Hard

java.lang.Object
  |
  +--EDU.gatech.cc.is.abstractrobot.Simple
        |
        +--EDU.gatech.cc.is.abstractrobot.SimpleN150Hard
              |
              +--EDU.gatech.cc.is.abstractrobot.CommN150Hard

public class CommN150Hard
extends SimpleN150Hard
implements CommN150, HardObject

CommN150Hard implements SimpleN150 for Nomad 150 hardware using the Ndirect class. You should see the specifications in SimpleN150 and Ndirect class documentation for details.

Copyright (c)1998 Tucker Balch

See Also:
CommN150, Ndirect

Field Summary
protected  Vec2[] last_opponents
           
protected  Vec2[] last_teammates
           
protected  CircularBufferEnumeration rec_positions
          Channel for recieving other robot positions.
protected  TransceiverHard t
          The transceiver used to communicate with the rest of the robots.
 
Fields inherited from class EDU.gatech.cc.is.abstractrobot.SimpleN150Hard
base_speed, cycles, DEBUG, desired_heading, desired_speed, hard_command, in_reverse, keep_running, last_Obstacles, last_Position, last_SteerHeading, last_TurretHeading, nomad150_hardware, num_Obstacles, obstacle_rangeInch, old_desired_heading, old_desired_turret_heading, old_hard_command, run_time_sum, sonar_raw_data, time_sum
 
Fields inherited from class EDU.gatech.cc.is.abstractrobot.Simple
dictionary, displayVectors, unique_id
 
Fields inherited from interface EDU.gatech.cc.is.abstractrobot.SimpleN150
MAX_STEER, MAX_TRANSLATION, MAX_TURRET, RADIUS, SONAR_RADIUS
 
Constructor Summary
CommN150Hard(int serial_port, int baud, java.lang.String server, int id)
          Instantiate a CommN150Hard object.
 
Method Summary
 void broadcast(Message m)
          Broadcast a message to all teammates, except self.
 boolean connected()
          Check to see if the transceiver is connected to the server.
 java.awt.Color getBackgroundColor()
          Gets the background color of the robot.
 java.awt.Color getForegroundColor()
          Gets the foreground color of the robot.
 Vec2[] getOpponents(long timestamp)
          Get an array of Vec2s that represent the locations of opponents.
 int getPlayerNumber(long timestamp)
          Get the robot's player number, between 0 and the number of robots on the team.
 CircularBufferEnumeration getReceiveChannel()
          Get an enumeration of the incoming messages.
 Vec2[] getTeammates(long timestamp)
          Get an array of Vec2s that represent the locations of teammates (Kin).
 void multicast(int[] ids, Message m)
          Transmit a message to specific teammates.
 void setCommunicationMaxRange(double r)
          Set the maximum range at which communication can occur.
 void setKinMaxRange(double r)
          NOT IMPLEMENTED Set the maximum range at which kin may be sensed.
 void takeStep()
          Conduct periodic I/O with the robot.
 void unicast(int id, Message m)
          Transmit a message to just one teammate.
 
Methods inherited from class EDU.gatech.cc.is.abstractrobot.SimpleN150Hard
getObstacles, getPosition, getSteerHeading, getTime, getTurretHeading, quit, resetPosition, resetSteerHeading, resetTurretHeading, setBaseSpeed, setDisplayString, setObstacleMaxRange, setSpeed, setSteerHeading, setTurretHeading
 
Methods inherited from class EDU.gatech.cc.is.abstractrobot.Simple
getDictionary, getID, getID, setDictionary, setID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

t

protected TransceiverHard t
The transceiver used to communicate with the rest of the robots.

rec_positions

protected CircularBufferEnumeration rec_positions
Channel for recieving other robot positions.

last_teammates

protected Vec2[] last_teammates

last_opponents

protected Vec2[] last_opponents
Constructor Detail

CommN150Hard

public CommN150Hard(int serial_port,
                    int baud,
                    java.lang.String server,
                    int id)
             throws java.lang.Exception
Instantiate a CommN150Hard object. You should only instantiate one of these per robot connected to your computer. Standard call is CommN150Hard(1,38400);
Parameters:
serial_port - 1 = ttys0 (COM1), 2 = ttys1 (COM2) ...
baud - baud rate for communication.
Throws:
java.lang.Exception - If unable to configure the hardware.
Method Detail

takeStep

public void takeStep()
Conduct periodic I/O with the robot. It runs at most every SimpleN150Hard.MIN_CYCLE_TIME milliseconds to gather sensor data from the robot, and issue movement commands.
Specified by:
takeStep in interface HardObject
Overrides:
takeStep in class SimpleN150Hard

getTeammates

public Vec2[] getTeammates(long timestamp)
Get an array of Vec2s that represent the locations of teammates (Kin).
Parameters:
timestamp - only get new information if timestamp > than last call or timestamp == -1.
Returns:
the sensed teammates.
See Also:
Vec2

getOpponents

public Vec2[] getOpponents(long timestamp)
Get an array of Vec2s that represent the locations of opponents.
Parameters:
timestamp - only get new information if timestamp > than last call or timestamp == -1.
Returns:
the sensed opponents.
See Also:
Vec2

getPlayerNumber

public int getPlayerNumber(long timestamp)
Get the robot's player number, between 0 and the number of robots on the team. Don't confuse this with getID which returns a unique number for the object in the simulation as a whole, not on its individual team. On real hardware however, getID == PlayerNumber.
Parameters:
timestamp - only get new information if timestamp > than last call or timestamp == -1.
Returns:
the player number.

setKinMaxRange

public void setKinMaxRange(double r)
NOT IMPLEMENTED Set the maximum range at which kin may be sensed. Primarily for use in simulation.
Parameters:
r - double, the maximum range.

broadcast

public void broadcast(Message m)
Broadcast a message to all teammates, except self.
Parameters:
m - Message, the message to be broadcast.

unicast

public void unicast(int id,
                    Message m)
             throws CommunicationException
Transmit a message to just one teammate. Transmission to self is allowed.
Parameters:
id - int, the ID of the agent to receive the message.
m - Message, the message to transmit.
Throws:
CommunicationException - if the receiving agent does not exist.

multicast

public void multicast(int[] ids,
                      Message m)
               throws CommunicationException
Transmit a message to specific teammates. Transmission to self is allowed.
Parameters:
ids - int[], the IDs of the agents to receive the message.
m - Message, the message to transmit.
Throws:
CommunicationException - if one of the receiving agents does not exist.

getReceiveChannel

public CircularBufferEnumeration getReceiveChannel()
Get an enumeration of the incoming messages. The messages are automatically buffered by the implementation. Unless the implementation guarantees it, you cannot count on all messages being delivered. Example, to print all incoming messages:
 Transceiver c = new RobotComm();
 CircularBufferEnumeration r = c.getReceiveChannel();
 while (r.hasMoreElements())
      System.out.println(r.nextElement());
 
Returns:
the Enumeration.

setCommunicationMaxRange

public void setCommunicationMaxRange(double r)
Set the maximum range at which communication can occur. In simulation, this corresponds to a simulation of physical limits, on mobile robots it corresponds to a signal strength setting.
Parameters:
r - double, the maximum range.

connected

public boolean connected()
Check to see if the transceiver is connected to the server.

getForegroundColor

public java.awt.Color getForegroundColor()
Description copied from interface: SimpleInterface
Gets the foreground color of the robot.
Overrides:
getForegroundColor in class SimpleN150Hard

getBackgroundColor

public java.awt.Color getBackgroundColor()
Description copied from interface: SimpleInterface
Gets the background color of the robot.
Overrides:
getBackgroundColor in class SimpleN150Hard