javaclient2.extra
Class PositionControl

java.lang.Object
  extended by javaclient2.extra.Controller
      extended by javaclient2.extra.PIDController
          extended by javaclient2.extra.PositionControl

public class PositionControl
extends PIDController

Position control interface for Position, Position2D and Position3D Player interfaces. Uses methods from both player interfaces and PIDController.

Author:
Marius Borodi & Radu Bogdan Rusu

Field Summary
 
Fields inherited from class javaclient2.extra.PIDController
kd, ki, kp
 
Fields inherited from class javaclient2.extra.Controller
currE, eSum, goal, lastE
 
Constructor Summary
PositionControl(AbstractPositionDevice pd)
          Constructor for PositionControl.
PositionControl(AbstractPositionDevice pd, int minC, int maxC)
          Constructor for PositionControl.
PositionControl(AbstractPositionDevice pd, int kp, int ki, int kd)
          Constructor for PositionControl.
PositionControl(AbstractPositionDevice pd, int minC, int maxC, int kp, int ki, int kd)
          Constructor for PositionControl.
 
Method Summary
 java.awt.Point getRobotPosition()
          Get the current robot position as a Point (AWT).
 boolean moveRobot(int distance)
          Move the robot for a given distance to a new destination.
 void setAllowedError(int err)
          Set the maximum allowed error between the final goal and the current position.
 void setMaximumCommand(int maxC)
          Set the maximum admissible command for the robot's motors.
 void setMinimumCommand(int minC)
          Set the minimum admissible command for the robot's motors.
 void stopRobot()
          Stop the robot from moving.
 
Methods inherited from class javaclient2.extra.PIDController
getCommand, getKd, getKi, getKp, setKd, setKi, setKp
 
Methods inherited from class javaclient2.extra.Controller
deltaE, setGoal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PositionControl

public PositionControl(AbstractPositionDevice pd)
Constructor for PositionControl.

Parameters:
pd - a reference to a PlayerDevice interface (Position, Position2D or Position3D).

PositionControl

public PositionControl(AbstractPositionDevice pd,
                       int kp,
                       int ki,
                       int kd)
Constructor for PositionControl.

Parameters:
pd - a reference to a PlayerDevice interface (Position, Position2D or Position3D).
kp - the proportional constant
ki - the integral constant
kd - the derivative constant

PositionControl

public PositionControl(AbstractPositionDevice pd,
                       int minC,
                       int maxC)
Constructor for PositionControl.

Parameters:
pd - a reference to a PlayerDevice interface (Position, Position2D or Position3D).
minC - minimum admissible command for the robot's motors
maxC - maximum admissible command for the robot's motors

PositionControl

public PositionControl(AbstractPositionDevice pd,
                       int minC,
                       int maxC,
                       int kp,
                       int ki,
                       int kd)
Constructor for PositionControl.

Parameters:
pd - a reference to a PlayerDevice interface (Position, Position2D or Position3D).
minC - minimum admissible command for the robot's motors
maxC - maximum admissible command for the robot's motors
kp - the proportional constant
ki - the integral constant
kd - the derivative constant
Method Detail

setMinimumCommand

public void setMinimumCommand(int minC)
Set the minimum admissible command for the robot's motors.

Parameters:
minC - minimum admissible command as an integer

setMaximumCommand

public void setMaximumCommand(int maxC)
Set the maximum admissible command for the robot's motors.

Parameters:
maxC - maximum admissible command as an integer

setAllowedError

public void setAllowedError(int err)
Set the maximum allowed error between the final goal and the current position. (default error is 10)

Parameters:
err - maximum allowed error as an integer

stopRobot

public void stopRobot()
Stop the robot from moving.


getRobotPosition

public java.awt.Point getRobotPosition()
Get the current robot position as a Point (AWT).

Returns:
the current robot position

moveRobot

public boolean moveRobot(int distance)
Move the robot for a given distance to a new destination.

Parameters:
distance - the desired distance
Returns:
false in case the movement was interrupted, true otherwise