javaclient
Class Position3DInterface

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

public class Position3DInterface
extends AbstractPositionDevice

The position3d interface is used to control mobile robot bases in 3D (i.e., pitch and roll are important).

Version:
Author:
Radu Bogdan Rusu

Field Summary
protected  short PLAYER_POSITION3D_GET_GEOM_REQ
           
protected  short PLAYER_POSITION3D_MOTOR_POWER_REQ
           
protected  short PLAYER_POSITION3D_POSITION_MODE_REQ
           
protected  short PLAYER_POSITION3D_POSITION_PID_REQ
           
protected  short PLAYER_POSITION3D_RESET_ODOM_REQ
           
protected  short PLAYER_POSITION3D_SET_ODOM_REQ
           
protected  short PLAYER_POSITION3D_SPEED_PID_REQ
           
protected  short PLAYER_POSITION3D_SPEED_PROF_REQ
           
protected  short PLAYER_POSITION3D_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
Position3DInterface(PlayerClient pc, short indexOfDevice)
          Constructor for Position3DInterface.
 
Method Summary
 void changePositionControl(byte state)
          Configuration request: Change position control.
 PlayerPosition3DGeomT getGeom()
          Get the geometry data.
 int getPitch()
          Get angular velocity (pitch) in mrad.
 int getPitchSpeed()
          Get angular velocity (pitch) in mrad/sec.
 int getRoll()
          Get angular velocity (roll) in mrad.
 int getRollSpeed()
          Get angular velocity (roll) in mrad/sec.
 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 angular velocity (yaw) in mrad.
 int getYawSpeed()
          Get angular velocity (yaw) in mrad/sec.
 int getYSpeed()
          Get Y translational velocity in mm/sec.
 int getZ()
          Get Z position in mm.
 int getZSpeed()
          Get Z 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()
          This interface returns data regarding the odometric pose and velocity of the robot, as well as motor stall information (xPos, yPos, zPos, roll, pitch, yaw, xSpeed, ySpeed, zSpeed, rollSpeed, pitchSpeed, yawSpeed, stall).
 void resetOdometry()
          Configuration request: Reset odometry.
 void setMotorPower(int state)
          Configuration request: Motor power.
 void setOdometry(int xP, int yP, int zP, int rollP, int pitchP, int yawP)
          Configuration request: Set odometry.
 void setPosition(int xP, int yP, int zP)
          Send position commands.
 void setPosition(int xP, int yP, int zP, int pitchP, int rollP, int yawP)
          Send position commands.
 void setPosition(int xP, int yP, int zP, int pitchP, int rollP, int yawP, int xS, int yS, int zS, int pitchS, int rollS, 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 xS, int yS)
          Set speed and turnrate.
 void setSpeed(int xS, int yS, int zS)
          Set speed and turnrate.
 void setSpeed(int xS, int yS, int zS, int pitchS, int rollS, int yawS)
          Set speed, turnrate and sideSpeed.
 void setSpeedProfileParams(int sp, int acc)
          Configuration request: Set speed profile parameters.
 void setVelocityControl(byte value)
          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_POSITION3D_GET_GEOM_REQ

protected final short PLAYER_POSITION3D_GET_GEOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_MOTOR_POWER_REQ

protected final short PLAYER_POSITION3D_MOTOR_POWER_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_VELOCITY_MODE_REQ

protected final short PLAYER_POSITION3D_VELOCITY_MODE_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_RESET_ODOM_REQ

protected final short PLAYER_POSITION3D_RESET_ODOM_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_POSITION_MODE_REQ

protected final short PLAYER_POSITION3D_POSITION_MODE_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_SPEED_PID_REQ

protected final short PLAYER_POSITION3D_SPEED_PID_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_POSITION_PID_REQ

protected final short PLAYER_POSITION3D_POSITION_PID_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_SPEED_PROF_REQ

protected final short PLAYER_POSITION3D_SPEED_PROF_REQ
See Also:
Constant Field Values

PLAYER_POSITION3D_SET_ODOM_REQ

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

Position3DInterface

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

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

readData

public void readData()
This interface returns data regarding the odometric pose and velocity of the robot, as well as motor stall information (xPos, yPos, zPos, roll, pitch, yaw, xSpeed, ySpeed, zSpeed, rollSpeed, pitchSpeed, yawSpeed, stall).

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

getZ

public int getZ()
Get Z position in mm.

Returns:
Z position in mm

getRoll

public int getRoll()
Get angular velocity (roll) in mrad.

Returns:
angular velocity (roll) in mrad

getPitch

public int getPitch()
Get angular velocity (pitch) in mrad.

Returns:
angular velocity (pitch) in mrad

getYaw

public int getYaw()
Get angular velocity (yaw) in mrad.

Specified by:
getYaw in class AbstractPositionDevice
Returns:
angular velocity (yaw) in mrad

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

getZSpeed

public int getZSpeed()
Get Z translational velocity in mm/sec.

Returns:
Z translational velocity in mm/sec

getRollSpeed

public int getRollSpeed()
Get angular velocity (roll) in mrad/sec.

Returns:
angular velocity (roll) in mrad/sec

getPitchSpeed

public int getPitchSpeed()
Get angular velocity (pitch) in mrad/sec.

Returns:
angular velocity (pitch) in mrad/sec

getYawSpeed

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

Returns:
angular velocity (yaw) in mrad/sec

getStall

public byte getStall()
Get motors status.

Returns:
stalled or not?

setPosition

public void setPosition(int xP,
                        int yP,
                        int zP,
                        int pitchP,
                        int rollP,
                        int yawP,
                        int xS,
                        int yS,
                        int zS,
                        int pitchS,
                        int rollS,
                        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_position3d_cmd structure from player.h

Parameters:
xP - X position in mm
yP - Y position in mm
zP - Z position in mm
pitchP - angular velocity (pitch) in mrad
rollP - angular velocity (roll) in mrad
yawP - angular velocity (yaw) in mrad
xS - X translational velocity in mm/sec
yS - Y translational velocity in mm/sec
zS - Z translational velocity in mm/sec
pitchS - angular velocity (pitch) in mrad/sec
rollS - angular velocity (roll) in mrad/sec
yawS - angular velocity (yaw) 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 zP)
Send position commands.

Parameters:
xP - X position in mm
yP - Y position in mm
zP - Z position in mm

setPosition

public void setPosition(int xP,
                        int yP,
                        int zP,
                        int pitchP,
                        int rollP,
                        int yawP)
Send position commands.

Parameters:
xP - X position in mm
yP - Y position in mm
zP - Z position in mm
pitchP - angular velocity (pitch) in mrad
rollP - angular velocity (roll) in mrad
yawP - angular velocity (yaw) in mrad

setSpeed

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

Specified by:
setSpeed in class AbstractPositionDevice
Parameters:
xS - X translational velocity in mm/sec
yS - Y translational velocity in mm/sec

setSpeed

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

Parameters:
xS - X translational velocity in mm/sec
yS - Y translational velocity in mm/sec
zS - Z translational velocity in mm/sec

setSpeed

public void setSpeed(int xS,
                     int yS,
                     int zS,
                     int pitchS,
                     int rollS,
                     int yawS)
Set speed, turnrate and sideSpeed.

Parameters:
xS - X translational velocity in mm/sec
yS - Y translational velocity in mm/sec
zS - Z translational velocity in mm/sec
pitchS - angular velocity (pitch) in mrad/sec
rollS - angular velocity (roll) in mrad/sec
yawS - angular velocity (yaw) in mrad/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 PlayerPosition3DGeomT getGeom()
Get the geometry data.

Returns:
an object of type PlayerPosition3DGeomT 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

changePositionControl

public void changePositionControl(byte state)
Configuration request: Change position control.

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

setVelocityControl

public void setVelocityControl(byte value)
Configuration request: Change velocity control.

Some robots offer different velocity control modes. It can be changed by sending a request with the format given below, including the appropriate mode. No matter which mode is used, the external client interface to the position3d device remains the same.

Parameters:
value - driver-specific

setOdometry

public void setOdometry(int xP,
                        int yP,
                        int zP,
                        int rollP,
                        int pitchP,
                        int yawP)
Configuration request: Set odometry.

Parameters:
xP - X in mm
yP - Y in mm
zP - Z in mm
rollP - Heading in mrad
pitchP - Heading in mrad
yawP - Heading in mrad

resetOdometry

public void resetOdometry()
Configuration request: Reset odometry.

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


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 (in mrad/s)
acc - max acceleration (in mrad/s/s)

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