javaclient
Class PositionInterface

java.lang.Object
  extended by javaclient.PlayerDevice
      extended by javaclient.AbstractPositionDevice
          extended by javaclient.PositionInterface

public class PositionInterface
extends AbstractPositionDevice

The position interface is used to control mobile robot bases in 2D.

Version:
Author:
Maxim A. Batalin & Radu Bogdan Rusu

Field Summary
protected  short PLAYER_POSITION_GET_GEOM_REQ
           
protected  short PLAYER_POSITION_MOTOR_POWER_REQ
           
protected  short PLAYER_POSITION_POSITION_MODE_REQ
           
protected  short PLAYER_POSITION_POSITION_PID_REQ
           
protected  short PLAYER_POSITION_RESET_ODOM_REQ
           
protected  short PLAYER_POSITION_RMP_ACCEL_SCALE
           
protected  short PLAYER_POSITION_RMP_CURRENT_LIMIT
           
protected  short PLAYER_POSITION_RMP_GAIN_SCHEDULE
           
protected  short PLAYER_POSITION_RMP_RST_INT_FOREAFT
           
protected  short PLAYER_POSITION_RMP_RST_INT_LEFT
           
protected  short PLAYER_POSITION_RMP_RST_INT_RIGHT
           
protected  short PLAYER_POSITION_RMP_RST_INT_YAW
           
protected  short PLAYER_POSITION_RMP_RST_INTEGRATORS
           
protected  short PLAYER_POSITION_RMP_SHUTDOWN
           
protected  short PLAYER_POSITION_RMP_TURN_SCALE
           
protected  short PLAYER_POSITION_RMP_VELOCITY_SCALE
           
protected  short PLAYER_POSITION_SET_ODOM_REQ
           
protected  short PLAYER_POSITION_SPEED_PID_REQ
           
protected  short PLAYER_POSITION_SPEED_PROF_REQ
           
protected  short PLAYER_POSITION_VELOCITY_MODE_REQ
           
 
Fields inherited from class javaclient.PlayerDevice
device, DIFFERENCE_SYNCH_FACTOR, index, is, os, pc, PLAYER_MAX_REQREP_SIZE, PLAYER_STXX, reserved, size, t_sec, t_usec, ts_sec, ts_usec
 
Constructor Summary
PositionInterface(PlayerClient pc, short indexOfDevice)
          Constructor for PositionInterface.
 
Method Summary
 PlayerPositionGeomT getGeom()
          Get the geometry data.
 byte getStall()
          Get motors status.
 int getX()
          Get X position in mm.
 int getXSpeed()
          Get X translational velocity in mm/sec.
 int getY()
          Get Y position in mm.
 int getYaw()
          Get Heading in degrees.
 int getYawSpeed()
          Get angular velocity in degrees/sec.
 int getYSpeed()
          Get Y translational velocity in mm/sec.
 void handleEARMessage()
          Handle Error Acknowledgement Response messages.
 void handleNARMessage()
          Handle Negative Acknowledgement Response messages.
 void handleResponse(int size)
          Handle acknowledgement response messages (threaded mode).
 boolean isGeomReady()
          Check if geometry data is available.
 void queryGeometry()
          Configuration request: Query geometry.
 void readData()
          Read the position data values (x, y, yaw, xSpeed, ySpeed, yawSpeed, stalls).
 void resetOdometry()
          Configuration request: Reset odometry.
 void setControlMode(int mode)
          Configuration request: Change control mode.
 void setHeading(int yawT)
          Send the heading of the robot.
 void setMotorPower(int state)
          Configuration request: Motor power.
 void setOdometry(int xT, int yT, int theta)
          Configuration request: Set odometry.
 void setPosition(int xP, int yP, int yawT)
          Send position commands.
 void setPosition(int xP, int yP, int yawT, int xS, int yS, int yawS, byte state, byte type)
          The position interface accepts new positions and/or velocities for the robot's motors (drivers may support position control, speed control or both).
 void setPositionPIDParams(int kp, int ki, int kd)
          Configuration request: Set position PID parameters.
 void setSegwayRPMparams(byte subtype, short value)
          Configuration request: Segway RMP-specific configuration.
 void setSpeed(int speed, int turnrate)
          Set speed and turnrate.
 void setSpeed(int speed, int turnrate, int sideSpeed)
          Set speed, turnrate and sideSpeed.
 void setSpeedProfileParams(short sp, short acc)
          Configuration request: Set speed profile parameters.
 void setVelocityControl(int mode)
          Configuration request: Change velocity control.
 void setVelocityPIDParams(int kp, int ki, int kd)
          Configuration request: Set velocity PID parameters.
 
Methods inherited from class javaclient.PlayerDevice
getTimeForDataSampled_sec, getTimeForDataSampled_usec, getTimeForDataSampled, getTimeForDataSent_sec, getTimeForDataSent_usec, getTimeForDataSent, readHeader, sendHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAYER_POSITION_GET_GEOM_REQ

protected final short PLAYER_POSITION_GET_GEOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION_MOTOR_POWER_REQ

protected final short PLAYER_POSITION_MOTOR_POWER_REQ
See Also:
Constant Field Values

PLAYER_POSITION_VELOCITY_MODE_REQ

protected final short PLAYER_POSITION_VELOCITY_MODE_REQ
See Also:
Constant Field Values

PLAYER_POSITION_RESET_ODOM_REQ

protected final short PLAYER_POSITION_RESET_ODOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION_POSITION_MODE_REQ

protected final short PLAYER_POSITION_POSITION_MODE_REQ
See Also:
Constant Field Values

PLAYER_POSITION_SPEED_PID_REQ

protected final short PLAYER_POSITION_SPEED_PID_REQ
See Also:
Constant Field Values

PLAYER_POSITION_POSITION_PID_REQ

protected final short PLAYER_POSITION_POSITION_PID_REQ
See Also:
Constant Field Values

PLAYER_POSITION_SPEED_PROF_REQ

protected final short PLAYER_POSITION_SPEED_PROF_REQ
See Also:
Constant Field Values

PLAYER_POSITION_SET_ODOM_REQ

protected final short PLAYER_POSITION_SET_ODOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION_RMP_VELOCITY_SCALE

protected final short PLAYER_POSITION_RMP_VELOCITY_SCALE
See Also:
Constant Field Values

PLAYER_POSITION_RMP_ACCEL_SCALE

protected final short PLAYER_POSITION_RMP_ACCEL_SCALE
See Also:
Constant Field Values

PLAYER_POSITION_RMP_TURN_SCALE

protected final short PLAYER_POSITION_RMP_TURN_SCALE
See Also:
Constant Field Values

PLAYER_POSITION_RMP_GAIN_SCHEDULE

protected final short PLAYER_POSITION_RMP_GAIN_SCHEDULE
See Also:
Constant Field Values

PLAYER_POSITION_RMP_CURRENT_LIMIT

protected final short PLAYER_POSITION_RMP_CURRENT_LIMIT
See Also:
Constant Field Values

PLAYER_POSITION_RMP_RST_INTEGRATORS

protected final short PLAYER_POSITION_RMP_RST_INTEGRATORS
See Also:
Constant Field Values

PLAYER_POSITION_RMP_SHUTDOWN

protected final short PLAYER_POSITION_RMP_SHUTDOWN
See Also:
Constant Field Values

PLAYER_POSITION_RMP_RST_INT_RIGHT

protected final short PLAYER_POSITION_RMP_RST_INT_RIGHT
See Also:
Constant Field Values

PLAYER_POSITION_RMP_RST_INT_LEFT

protected final short PLAYER_POSITION_RMP_RST_INT_LEFT
See Also:
Constant Field Values

PLAYER_POSITION_RMP_RST_INT_YAW

protected final short PLAYER_POSITION_RMP_RST_INT_YAW
See Also:
Constant Field Values

PLAYER_POSITION_RMP_RST_INT_FOREAFT

protected final short PLAYER_POSITION_RMP_RST_INT_FOREAFT
See Also:
Constant Field Values
Constructor Detail

PositionInterface

public PositionInterface(PlayerClient pc,
                         short indexOfDevice)
Constructor for PositionInterface.

Parameters:
pc - a reference to the PlayerClient object
indexOfDevice - the index of the device
Method Detail

readData

public void readData()
Read the position data values (x, y, yaw, xSpeed, ySpeed, yawSpeed, stalls).

Overrides:
readData in class PlayerDevice

setPosition

public void setPosition(int xP,
                        int yP,
                        int yawT,
                        int xS,
                        int yS,
                        int yawS,
                        byte state,
                        byte type)
The position interface accepts new positions and/or velocities for the robot's motors (drivers may support position control, speed control or both).

See the player_position_cmd structure from player.h

Parameters:
xP - X position in mm
yP - Y position in mm
yawT - Yaw in degrees
xS - X translational velocity in mm/sec
yS - Y translational velocity in mm/sec
yawS - angular velocity in degrees/sec
state - motor state (zero is either off or locked, depending on the driver)
type - command type; 0 = velocity, 1 = position

setPosition

public void setPosition(int xP,
                        int yP,
                        int yawT)
Send position commands.

Parameters:
xP - X position in mm
yP - Y position in mm
yawT - Yaw in degrees

setHeading

public void setHeading(int yawT)
Send the heading of the robot.

Parameters:
yawT - Yaw in degrees

setSpeed

public void setSpeed(int speed,
                     int turnrate)
Set speed and turnrate.

Specified by:
setSpeed in class AbstractPositionDevice
Parameters:
speed - X translational velocity in mm/sec
turnrate - angular velocity in degrees/sec

setSpeed

public void setSpeed(int speed,
                     int turnrate,
                     int sideSpeed)
Set speed, turnrate and sideSpeed.

Parameters:
speed - X translational velocity in mm/sec
turnrate - angular velocity in degrees/sec
sideSpeed - Y translational velocity in mm/sec

queryGeometry

public void queryGeometry()
Configuration request: Query geometry.


isGeomReady

public boolean isGeomReady()
Check if geometry data is available.

Returns:
true if ready, false if not ready

getGeom

public PlayerPositionGeomT getGeom()
Get the geometry data.

Returns:
an object of type PlayerPositionGeomT containing the required geometry data

getX

public int getX()
Get X position in mm.

Specified by:
getX in class AbstractPositionDevice
Returns:
X position in mm

getY

public int getY()
Get Y position in mm.

Specified by:
getY in class AbstractPositionDevice
Returns:
Y position in mm

getYaw

public int getYaw()
Get Heading in degrees.

Specified by:
getYaw in class AbstractPositionDevice
Returns:
heading in degrees

getXSpeed

public int getXSpeed()
Get X translational velocity in mm/sec.

Returns:
X translational velocity in mm/sec

getYSpeed

public int getYSpeed()
Get Y translational velocity in mm/sec.

Returns:
Y translational velocity in mm/sec

getYawSpeed

public int getYawSpeed()
Get angular velocity in degrees/sec.

Returns:
angular velocity in degrees/sec

getStall

public byte getStall()
Get motors status.

Returns:
stalled or not?

setMotorPower

public void setMotorPower(int state)
Configuration request: Motor power.

On some robots, the motor power can be turned on and off from software.

Be VERY careful with this command! You are very likely to start the robot running across the room at high speed with the battery charger still attached.

Parameters:
state - 0 for off, 1 for on

setVelocityControl

public void setVelocityControl(int mode)
Configuration request: Change velocity control.

Some robots offer different velocity control modes.

The p2os driver offers two modes of velocity control: separate translational and rotational control and direct wheel control. When in the separate mode, the robot's microcontroller internally computes left and right wheel velocities based on the currently commanded translational and rotational velocities and then attenuates these values to match a nice predefined acceleration profile. When in the direct mode, the microcontroller simply passes on the current left and right wheel velocities. Essentially, the separate mode offers smoother but slower (lower acceleration) control, and the direct mode offers faster but jerkier (higher acceleration) control. Player's default is to use the direct mode. Set mode to zero for direct control and non-zero for separate control.

For the reb driver, 0 is direct velocity control, 1 is for velocity-based heading PD controller.

Parameters:
mode - driver-specific mode

resetOdometry

public void resetOdometry()
Configuration request: Reset odometry.

Resets the robot's odometry to (x,y,theta) = (0,0,0).


setControlMode

public void setControlMode(int mode)
Configuration request: Change control mode.

Parameters:
mode - 0 for velocity mode, 1 for position mode

setOdometry

public void setOdometry(int xT,
                        int yT,
                        int theta)
Configuration request: Set odometry.

Parameters:
xT - X in mm
yT - Y in m
theta - Heading in degrees

setVelocityPIDParams

public void setVelocityPIDParams(int kp,
                                 int ki,
                                 int kd)
Configuration request: Set velocity PID parameters.

Parameters:
kp - P parameter
ki - I parameter
kd - D parameter

setPositionPIDParams

public void setPositionPIDParams(int kp,
                                 int ki,
                                 int kd)
Configuration request: Set position PID parameters.

Parameters:
kp - P parameter
ki - I parameter
kd - D parameter

setSpeedProfileParams

public void setSpeedProfileParams(short sp,
                                  short acc)
Configuration request: Set speed profile parameters.

Parameters:
sp - max speed
acc - max acceleration

setSegwayRPMparams

public void setSegwayRPMparams(byte subtype,
                               short value)
Configuration request: Segway RMP-specific configuration.

These are possible Segway RMP config commands; see the status command in the RMP manual:

Parameters:
subtype - must be of PLAYER_POSITION_RMP_*
value - holds various values depending on the type of config. See the "Status" command in the Segway manual.

handleResponse

public void handleResponse(int size)
Handle acknowledgement response messages (threaded mode).

Overrides:
handleResponse in class PlayerDevice
Parameters:
size - size of the payload

handleNARMessage

public void handleNARMessage()
Handle Negative Acknowledgement Response messages.

Overrides:
handleNARMessage in class PlayerDevice

handleEARMessage

public void handleEARMessage()
Handle Error Acknowledgement Response messages.

Overrides:
handleEARMessage in class PlayerDevice