javaclient
Class Position2DInterface

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

public class Position2DInterface
extends AbstractPositionDevice

The position2d interface is used to control a planar mobile robot base. This interface is the same as the position interface, but uses different units (e.g., mrad instead of deg). The position2d interface will probably replace the position interface (eventually).

Version:
Author:
Radu Bogdan Rusu

Field Summary
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_POSITION2D_GET_GEOM_REQ
           
protected  short PLAYER_POSITION2D_MOTOR_POWER_REQ
           
protected  short PLAYER_POSITION2D_POSITION_MODE_REQ
           
protected  short PLAYER_POSITION2D_POSITION_PID_REQ
           
protected  short PLAYER_POSITION2D_RESET_ODOM_REQ
           
protected  short PLAYER_POSITION2D_RMP_ACCEL_SCALE
           
protected  short PLAYER_POSITION2D_RMP_CURRENT_LIMIT
           
protected  short PLAYER_POSITION2D_RMP_GAIN_SCHEDULE
           
protected  short PLAYER_POSITION2D_RMP_RST_INTEGRATORS
           
protected  short PLAYER_POSITION2D_RMP_SHUTDOWN
           
protected  short PLAYER_POSITION2D_RMP_TURN_SCALE
           
protected  short PLAYER_POSITION2D_RMP_VELOCITY_SCALE
           
protected  short PLAYER_POSITION2D_SET_ODOM_REQ
           
protected  short PLAYER_POSITION2D_SPEED_PID_REQ
           
protected  short PLAYER_POSITION2D_SPEED_PROF_REQ
           
protected  short PLAYER_POSITION2D_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
Position2DInterface(PlayerClient pc, short indexOfDevice)
          Constructor for Position2DInterface.
 
Method Summary
 PlayerPosition2DGeomT 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 mrad.
 int getYawSpeed()
          Get angular velocity in mrad/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 (xPos, yPos, yaw, xSpeed, ySpeed, yawSpeed, stalls).
 void resetOdometry()
          Configuration request: Reset odometry.
 void setControlMode(int mode)
          Configuration request: Change position control.
 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 setSpeed(int speed, int turnrate)
          Set speed and turnrate.
 void setSpeed(int speed, int turnrate, int sideSpeed)
          Set speed, turnrate and sideSpeed.
 void setSpeedProfileParams(int sp, int acc)
          Configuration request: Set speed profile parameters.
 void setVelocityControl(byte 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_POSITION2D_GET_GEOM_REQ

protected final short PLAYER_POSITION2D_GET_GEOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_MOTOR_POWER_REQ

protected final short PLAYER_POSITION2D_MOTOR_POWER_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_VELOCITY_MODE_REQ

protected final short PLAYER_POSITION2D_VELOCITY_MODE_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_RESET_ODOM_REQ

protected final short PLAYER_POSITION2D_RESET_ODOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_POSITION_MODE_REQ

protected final short PLAYER_POSITION2D_POSITION_MODE_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_SPEED_PID_REQ

protected final short PLAYER_POSITION2D_SPEED_PID_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_POSITION_PID_REQ

protected final short PLAYER_POSITION2D_POSITION_PID_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_SPEED_PROF_REQ

protected final short PLAYER_POSITION2D_SPEED_PROF_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_SET_ODOM_REQ

protected final short PLAYER_POSITION2D_SET_ODOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_VELOCITY_SCALE

protected final short PLAYER_POSITION2D_RMP_VELOCITY_SCALE
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_ACCEL_SCALE

protected final short PLAYER_POSITION2D_RMP_ACCEL_SCALE
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_TURN_SCALE

protected final short PLAYER_POSITION2D_RMP_TURN_SCALE
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_GAIN_SCHEDULE

protected final short PLAYER_POSITION2D_RMP_GAIN_SCHEDULE
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_CURRENT_LIMIT

protected final short PLAYER_POSITION2D_RMP_CURRENT_LIMIT
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_RST_INTEGRATORS

protected final short PLAYER_POSITION2D_RMP_RST_INTEGRATORS
See Also:
Constant Field Values

PLAYER_POSITION2D_RMP_SHUTDOWN

protected final short PLAYER_POSITION2D_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

Position2DInterface

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

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 (xPos, yPos, yaw, xSpeed, ySpeed, yawSpeed, stalls).

Overrides:
readData in class PlayerDevice

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 mrad.

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

getStall

public byte getStall()
Get motors status.

Returns:
stalled or not?

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 mrad/sec.

Returns:
angular velocity in mrad/sec

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_position2d_cmd structure from player.h

Parameters:
xP - X position2d in mm
yP - Y position2d in mm
yawT - Yaw in mrad
xS - X translational velocity in mm/sec
yS - Y translational velocity in mm/sec
yawS - angular velocity in mrad/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 mrad

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 mrad/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 mrad/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 PlayerPosition2DGeomT getGeom()
Get the geometry data.

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

handleResponse

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

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

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(byte 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 position control.

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 mm
theta - Heading in mrad

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(int sp,
                                  int acc)
Configuration request: Set speed profile parameters.

Parameters:
sp - max speed
acc - max acceleration

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