roboplayer.core.body
Class Body

java.lang.Object
  |
  +--roboplayer.core.body.Body
All Implemented Interfaces:
RobotCommands, java.lang.Runnable

public class Body
extends java.lang.Object
implements java.lang.Runnable, RobotCommands

This class represents robot body. It is used to communicate with the server. This class is the only thing which should be changed if we want to move the code to real robot.

Version:
1.0
Author:
Krzysztof Langner

Constructor Summary
Body(java.net.InetAddress host, int port)
          Standard constructor
 
Method Summary
 void addHearListener(HearListener l)
          This function registers HearListener interface
 void addParamsListener(ParamsListener l)
          This function registers ParamsListener interface
 void addSeeListener(SeeListener l)
          This function registers SeeListener interface
 void addTickListener(TickListener l)
          This function registers TickListener interface
 void bye()
          Disconnect from the server
 void catchBall(double dir)
          This function sends catch command to the server
 void changeView(java.lang.String angle, java.lang.String quality)
          This function sends chage_view command to the server
 void dash(double power)
          This function sends dash command to the server
 double getEfford()
          Player current efford
 double getHeadAngle()
          Player head angle
 double getLastTurnAngle()
          Get information about last turn command which was already send, but which was not included in any visual info yet.
 double getSpeed()
          Player current speed
 double getStamina()
          Player current stamina
 java.lang.String getViewAngle()
          Get information about view angle
 boolean init(java.lang.String teamName, boolean goalie)
          Connect to server
 void kick(double power, double direction)
          This function sends kick command to the server
 void move(double x, double y)
          This function sends move command to the server.
 void reconnect(java.lang.String teamName, int uniformNumber)
          Reconnect to the server
 void removeHearListener(HearListener l)
          This function unregisters HearListener interface
 void removeParamsListener(ParamsListener l)
          This function unregisters ParamsListener interface
 void removeSeeListener(SeeListener l)
          This function unregisters SeeListener interface
 void removeTickListener(TickListener l)
          This function unregisters TickListener interface
 void run()
          Main loop of the robot.
 void say(java.lang.String message)
          This function sends say command to the server
 void turn(double angle)
          This function sends turn command to the server
 void turnNeck(double angle)
          This function sends turn head command to the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Body

public Body(java.net.InetAddress host,
            int port)
     throws java.net.SocketException
Standard constructor

Parameters:
host - Server host
port - server port
Throws:
java.net.SocketException - when we can't connect to the server
Method Detail

init

public boolean init(java.lang.String teamName,
                    boolean goalie)
Connect to server

Parameters:
teamName - name of the team
goalie - true if goalkeeper
Returns:
true we received init message

reconnect

public void reconnect(java.lang.String teamName,
                      int uniformNumber)
Reconnect to the server

Parameters:
teamName - name of the team
uniformNumber - player number

bye

public void bye()
Disconnect from the server


getSpeed

public double getSpeed()
Player current speed

Returns:
current player speed

getStamina

public double getStamina()
Player current stamina

Returns:
player stamina

getEfford

public double getEfford()
Player current efford

Returns:
player efford

getHeadAngle

public double getHeadAngle()
Player head angle

Returns:
head angle

getLastTurnAngle

public double getLastTurnAngle()
Get information about last turn command which was already send, but which was not included in any visual info yet.

Returns:
last turn angle

getViewAngle

public java.lang.String getViewAngle()
Get information about view angle

Returns:
view angle

catchBall

public void catchBall(double dir)
This function sends catch command to the server

Specified by:
catchBall in interface RobotCommands
Parameters:
dir - catch direction

changeView

public void changeView(java.lang.String angle,
                       java.lang.String quality)
This function sends chage_view command to the server

Specified by:
changeView in interface RobotCommands
Parameters:
angle - view angle
quality - view quality

dash

public void dash(double power)
This function sends dash command to the server

Specified by:
dash in interface RobotCommands
Parameters:
power - dash power

kick

public void kick(double power,
                 double direction)
This function sends kick command to the server

Specified by:
kick in interface RobotCommands
Parameters:
power - kick power
direction - kick direction

move

public void move(double x,
                 double y)
This function sends move command to the server. This function can only be used to position player before game.

Specified by:
move in interface RobotCommands
Parameters:
x - move robot to this direction
y - move robot to this direction

say

public void say(java.lang.String message)
This function sends say command to the server

Specified by:
say in interface RobotCommands
Parameters:
message - message

turn

public void turn(double angle)
This function sends turn command to the server

Specified by:
turn in interface RobotCommands
Parameters:
angle - turn angle

turnNeck

public void turnNeck(double angle)
This function sends turn head command to the server

Specified by:
turnNeck in interface RobotCommands
Parameters:
angle - turn angle

removeTickListener

public void removeTickListener(TickListener l)
This function unregisters TickListener interface

Parameters:
l - listener

addTickListener

public void addTickListener(TickListener l)
This function registers TickListener interface

Parameters:
l - listener

removeSeeListener

public void removeSeeListener(SeeListener l)
This function unregisters SeeListener interface

Parameters:
l - listener

addSeeListener

public void addSeeListener(SeeListener l)
This function registers SeeListener interface

Parameters:
l - listener

removeHearListener

public void removeHearListener(HearListener l)
This function unregisters HearListener interface

Parameters:
l - listener

addHearListener

public void addHearListener(HearListener l)
This function registers HearListener interface

Parameters:
l - listener

removeParamsListener

public void removeParamsListener(ParamsListener l)
This function unregisters ParamsListener interface

Parameters:
l - listener

addParamsListener

public void addParamsListener(ParamsListener l)
This function registers ParamsListener interface

Parameters:
l - listener

run

public void run()
Main loop of the robot. Wait for information from SoccerServer and send it to registered listeners. How each information is processed: - sense_body is processed internally - see is send to each registered SeeListener interface - hear is send to each registered HearListener interface

Specified by:
run in interface java.lang.Runnable