koala
Class KatanaArm

java.lang.Object
  extended by koala.KatanaArm
All Implemented Interfaces:
koala.RobotArm

public class KatanaArm
extends java.lang.Object
implements koala.RobotArm

Class which provides control of the Katana robot arm, using jkatana.dll.

Katana gripper sensors


Field Summary
static KatanaLocation INFRONT
           
static KatanaLocation LEFT
           
static KatanaLocation RIGHT
           
static KatanaLocation TOP
           
 
Method Summary
 void calibrate()
          Calibrate the arm.
 void closeGripper()
          Close the arm's gripper.
 void disconnect()
          Disconnect from the arm.
protected  void finalize()
           
 int getGripperPosition()
          Get the gripper's position.
static KatanaArm getInstance()
          Get a reference to the arm.
 KatanaLocation getLocation()
          Get the location of the end of the gripper in (ideal) 3D space.
 double getMaximumSpeed()
          Get the maximum motor speed.
 int getMotorPosition(int motor)
          Get the position of a particular motor in terms of its rotary encoder.
 boolean gripperClosed()
          Returns true only if the gripper is fully closed.
 boolean grippingSomething()
          Observes the gripper sensors to infer if anything is being gripped.
static void main(java.lang.String[] args)
           
 void moveTo(KatanaLocation loc)
          Move the location of the end of the gripper.
 void moveToRestingPosition()
          Move the robot to the position in which it is stable if the power is switched off.
 void moveToWithoutBlocking(KatanaLocation loc)
           
 void openGripper()
          Open the arm's gripper.
 boolean pickUp()
          Pick up an object from the front of the robot (INFRONT).
 KoalaSensorReading readForceSensors()
          Read the 4 force sensors.
 KoalaSensorReading readProximitySensors()
          Read the 9 infra-red proximity sensors.
 KoalaSensorReading readSensors()
          Read the 16 sensors on the robot's gripper.
static KatanaLocation rotateAxes(KatanaLocation loc)
          Converts a location from "ideal" coodinate space to that of the arm.
 void rotateMotorTo(int motor, int angle)
          Rotate the specified motor (0-4) to the specified angle (in degrees).
 void rotateWristTo(int angle)
          Rotate the wrist to the specified angle (in degrees).
 void setMaximumSpeed(double max)
          Set the maximum motor speed.
 void unblock()
          Unblock the robot after a crash (stopping due to impact with something).
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP

public static final KatanaLocation TOP

LEFT

public static final KatanaLocation LEFT

RIGHT

public static final KatanaLocation RIGHT

INFRONT

public static final KatanaLocation INFRONT
Method Detail

getInstance

public static KatanaArm getInstance()
Get a reference to the arm.


disconnect

public void disconnect()
Disconnect from the arm.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

openGripper

public void openGripper()
Open the arm's gripper. This method does not block, so the gripper will not be "open" straight after the method returns.

Specified by:
openGripper in interface koala.RobotArm

closeGripper

public void closeGripper()
Close the arm's gripper. This method does not block, so the gripper will not be "closed" straight after the method returns.

Specified by:
closeGripper in interface koala.RobotArm

calibrate

public void calibrate()
Calibrate the arm. This should be performed once every time the arm is switched on, otherwise the robot may move to the wrong positions.

Specified by:
calibrate in interface koala.RobotArm

readSensors

public KoalaSensorReading readSensors()
Read the 16 sensors on the robot's gripper. Uninterpreted values are returned in a KoalaSensorReading. From the leftSensors array, indices 0, 1, 4 and 5 are infra-red proximity sensors on the left finger where 255 denotes an object is close to the sensor and 0 denotes clear space in front of the sensor. Indices 6 and 7 denote force sensors where 255 denotes "high force" and 0 denotes "no force". From the rightSensors array, indices 0, 1, 3, 4, 5 are infra-red sensors on the right finger. Indices 6 and 7 are force sensors. In the diagram above, right sensor 0 is labelled 8, and so on.

Specified by:
readSensors in interface koala.RobotArm

readForceSensors

public KoalaSensorReading readForceSensors()
Read the 4 force sensors. Values are uninterpreted, except that 255 denotes "high force" and 0 denotes "no force". Values are returned in the first two elements of the leftSensors and rightSensors arrays.

Specified by:
readForceSensors in interface koala.RobotArm

readProximitySensors

public KoalaSensorReading readProximitySensors()
Read the 9 infra-red proximity sensors. Returns interpreted values in millimetres. Indices 0 to 2 correspond to the three sensors on the "sides" of each finger (0, 1, 4 in the diagram). Index 3 corresponds to the sensor on the top of each finger (5 in the diagram). Index 4 contains the reading from the central sensor (11 in the diagram, and included in both left and right arrays).

Specified by:
readProximitySensors in interface koala.RobotArm

getGripperPosition

public int getGripperPosition()
Get the gripper's position. Values below 5000 indicate the gripper is closed and values around 27000 indicate it is fully open.

Specified by:
getGripperPosition in interface koala.RobotArm

gripperClosed

public boolean gripperClosed()
Returns true only if the gripper is fully closed. It returns false for all partial openings.

Specified by:
gripperClosed in interface koala.RobotArm

grippingSomething

public boolean grippingSomething()
Observes the gripper sensors to infer if anything is being gripped.

Specified by:
grippingSomething in interface koala.RobotArm

getMaximumSpeed

public double getMaximumSpeed()
Get the maximum motor speed.

Specified by:
getMaximumSpeed in interface koala.RobotArm

setMaximumSpeed

public void setMaximumSpeed(double max)
Set the maximum motor speed. 20 is quite slow, 60 is a good normal speed, and 100 is quite fast.

Specified by:
setMaximumSpeed in interface koala.RobotArm

getMotorPosition

public int getMotorPosition(int motor)
Get the position of a particular motor in terms of its rotary encoder. Values may be considerably inaccurate if a calibration has not been performed. Motor 0 is the base rotator, and motor 4 is the gripper.

Specified by:
getMotorPosition in interface koala.RobotArm

getLocation

public KatanaLocation getLocation()
Get the location of the end of the gripper in (ideal) 3D space.

Specified by:
getLocation in interface koala.RobotArm

moveTo

public void moveTo(KatanaLocation loc)
            throws KatanaOutOfRangeException
Move the location of the end of the gripper. This method blocks.

Specified by:
moveTo in interface koala.RobotArm
Throws:
KatanaOutOfRangeException

moveToWithoutBlocking

public void moveToWithoutBlocking(KatanaLocation loc)
Specified by:
moveToWithoutBlocking in interface koala.RobotArm

rotateWristTo

public void rotateWristTo(int angle)
                   throws KatanaOutOfRangeException
Rotate the wrist to the specified angle (in degrees). The wrist can only move to angles between 9 and 340 degrees, hence 180 degrees is the "normal" position. This method does not block.

Specified by:
rotateWristTo in interface koala.RobotArm
Throws:
KatanaOutOfRangeException

rotateMotorTo

public void rotateMotorTo(int motor,
                          int angle)
                   throws KatanaOutOfRangeException
Rotate the specified motor (0-4) to the specified angle (in degrees). This method does not block. Motor 0 (base) can move between 0 and 345 degrees. Motor 1 can move between 0 and 127 degrees. Motor 2 can move between 53 and 294 degrees. Motor 3 (wrist) can move between 9 and 340 degrees.

Specified by:
rotateMotorTo in interface koala.RobotArm
Throws:
KatanaOutOfRangeException

moveToRestingPosition

public void moveToRestingPosition()
Move the robot to the position in which it is stable if the power is switched off. This method does not block.

Specified by:
moveToRestingPosition in interface koala.RobotArm

unblock

public void unblock()
Unblock the robot after a crash (stopping due to impact with something).

Specified by:
unblock in interface koala.RobotArm

pickUp

public boolean pickUp()
Pick up an object from the front of the robot (INFRONT). Operates relatively blindly, using only the gripper sensors, but returns true if it thinks it has succeeded. This method blocks.

Specified by:
pickUp in interface koala.RobotArm

rotateAxes

public static KatanaLocation rotateAxes(KatanaLocation loc)
Converts a location from "ideal" coodinate space to that of the arm. Unfortunately, the coordinate axes of our Katana arm are rotated by 5 degrees around Z relative to the robot it is mounted on. Use this method to perform the necessary transformation, so you needn't worry about it.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception