|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--khepera.Khepera
Provides a simple representation of the Khepera-robot making it easy to read the sensors and
control the behaviour of the motors.
Currently a Khepera base whith a
Gripper and
K213 Vision turret is supported. Since
this class is supposed to be a simple abstraction not all of the available commands to the base and turrets
have been implemented.
The wheels (motors)
The Khepera has two wheels using one motor each. These motors are reffered to as left and right wheels in
this text. The speed of the robot is set at one time and will then be used whenever a motion command is
issued. Each motor also has a separate motion counter which is used to put the robot in a local coordinate
system.
The LEDs
On the top of the base-unit are two LEDs. These can be turned on and off and are reffered to as frontal and
lateral LEDs (see below) in this text.




class MyController {
Khepera myRobot;
public MyController(Khepera robot) {
myRobot=robot;
// set the speed at which the robot will move
myRobot.setSpeed(20d);
}
public void start() {
// make the robot go forward
myRobot.moveForward();
}
public static void main(String args[]) {
Khepera robot=new Khepera("Charlie");
try {
// establish connection to the robot
robot.connect();
// create controller and assign the robot to it
MyController controller=new MyController(robot);
controller.start();
// wait 10 seconds
try {
Thread.sleep(10000);
}
catch (InterruptedException exception) {
}
// close connection to the robot
robot.disconnect();
}
catch (KheperaException exception) {
System.out.println(exception);
}
}
}
As you can see the robot instance is plugged into the custom controller class. Use the above class as a
template when you need to implement controllers.
| Fields inherited from interface khepera.KheperaConstants |
BL10, BR10, FL10, FL45, FL90, FLED, FR10, FR45, FR90, HEADING, LLED, LOWERED, OFF, ON, RAISED, RDIAMETER, RRADIUS, TOGGLE, UNCHANGED, XPOS, YPOS |
| Constructor Summary | |
Khepera(java.lang.String robotName)
Creates a new Khepera robot representation with the given name. |
|
Khepera(java.lang.String robotName,
KheperaConnection robotConnection)
Creates a new Khepera robot representation with the given name and. connection instance. Example: Khepera robot=new Khepera("Charlie",new SerialConnection("/dev/modem",19200)); |
|
| Method Summary | |
boolean |
cameraPresent()
Checks if a linear camera turret is mounted on the robot. |
void |
closeGripper()
Tries to close the gripper. |
void |
connect()
Initializes the communication with the robot and must be called before all other commands. |
void |
disconnect()
It is recommended to always call this method at the end of a controller program to end the communication with the robot and clean up. |
double |
getArmPosition()
Checks the current position of the gripper arm. |
java.lang.String |
getBIOSVersion()
Returns the BIOS version of the robot. |
double[] |
getCameraImage()
Downloads the pixels of the linear camera (assumed to be) mounted on the top of the robot. |
java.lang.String |
getCameraRevision()
Checks the revision of the camera software. |
java.lang.String |
getCameraVersion()
Checks the version of the camera software. |
java.lang.String |
getGripperRevision()
Checks the revision of the gripper software. |
java.lang.String |
getGripperVersion()
Checks the version of the gripper software. |
double[] |
getLightReadings()
Retreives the light sensor values by downloading the from the robot. |
double[] |
getLocation()
Returns the current local positon and heading of the robot. |
java.lang.String |
getName()
Simple method to ge the name of the robot. |
java.lang.String |
getProtocolVersion()
Returns the protocol version of the robot. |
double[] |
getProxyReadings()
Retreives the proximity sensor values by downloading them from the robot. |
boolean |
gripperIsOpen()
Checks if the gripper is currently open |
boolean |
gripperPresent()
Checks if the robot has a gripper turret mounted. |
boolean |
objectInGripper()
Checks the light-beam between the grippers. |
void |
openGripper()
Tries to open the gripper. |
void |
reset()
Puts the robot in an initial stopped position where both wheels are stopped and with both LEDs off. |
void |
setArmPosition(double armPosition)
Moves the arm to the corresonding position. |
void |
setLED(int ledNr,
int status)
Sets the status of a LED. |
void |
setLocation(double x,
double y,
double heading)
Sets the local position and heading of the robot. |
void |
setSpeed(int leftWheelSpeed,
int rightWheelSpeed)
Sets the speed at which the robot will move when given a motion command. |
void |
stop()
Stops the robot weels. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Khepera(java.lang.String robotName,
KheperaConnection robotConnection)
Khepera robot=new Khepera("Charlie",new SerialConnection("/dev/modem",19200));
robotName - The name of your robot.robotConnection - An instance of KheperaConnection representing the connection to your robot.KheperaConnection,
SerialConnection,
RoboWorldConnection,
TestConnectionpublic Khepera(java.lang.String robotName)
robotName - The name of your robot.Khepera(String,KheperaConnection)| Method Detail |
public void connect()
throws KheperaException
KheperaException - If a communications error with the robot occurs.reset()
public void disconnect()
throws KheperaException
KheperaException - If a communications error with the robot occurs.reset()
public void reset()
throws KheperaException
KheperaException - If a communications error with the robot occurs.public java.lang.String getName()
public void setLocation(double x,
double y,
double heading)
x - The horizontal position in millimeters.y - The vertical position in millimeters.heading - New heading of the robot in radians.KheperaConstants.XPOS,
KheperaConstants.YPOS,
KheperaConstants.HEADING,
KheperaConstants.UNCHANGED
public double[] getLocation()
throws KheperaException
// get the location from the robot double location[]=robot.getLocation(); // put the values in appropriate variables (this not // necessary, only here to show how it is done) double xPos=location[XPOS]; double yPos=location[YPOS]; double heading=location[HEADING];
KheperaConstants.XPOS,
KheperaConstants.YPOS,
KheperaConstants.HEADING
public java.lang.String getBIOSVersion()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public java.lang.String getProtocolVersion()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public void setSpeed(int leftWheelSpeed,
int rightWheelSpeed)
throws KheperaException
speed - The speed of the motors in mm/s (the speed will be rounded to the nearest 8 mm multiple).KheperaException - If a communications error with the robot occurs.#moveForward(),
#moveBackward(),
#spinLeft(),
#spinRight(),
#turnLeft(double),
#turnRight(double)
public void stop()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public double[] getProxyReadings()
throws KheperaException
// download the sensor readings double proxyReadings[]=robot.getProxyReadings(); // act using the sensor data if (proxyReadings[FL10]>0.5&&proxyReadings[FL10]>0.5) robot.stop(); ...
KheperaException - If a communications error with the robot occurs.KheperaConstants.FL90,
KheperaConstants.FL45,
KheperaConstants.FL10,
KheperaConstants.FR10,
KheperaConstants.FR45,
KheperaConstants.FR90,
KheperaConstants.BL10,
KheperaConstants.BR10
public double[] getLightReadings()
throws KheperaException
// download the sensor readings double lightReadings[]=robot.getLightReadings(); // act using the sensor data if (lightReadings[FL45]>0.5) robot.turnLeft(0.7); if (lightReadings[FR45]>0.5) robot.turnRight(0.7); ...
KheperaException - If a communications error with the robot occurs.KheperaConstants.FL90,
KheperaConstants.FL45,
KheperaConstants.FL10,
KheperaConstants.FR10,
KheperaConstants.FR45,
KheperaConstants.FR90,
KheperaConstants.BL10,
KheperaConstants.BR10
public void setLED(int ledNr,
int status)
throws KheperaException
// turn on the frontal LED robot.setLED(FLED,ON);
ledNr - Selects the LED to be affected.active - Sets the status of the selected LED.KheperaException - If a communications error with the robot occurs.KheperaConstants.FLED,
KheperaConstants.LLED,
KheperaConstants.ON,
KheperaConstants.OFF,
KheperaConstants.TOGGLE,
LEDControllerpublic boolean cameraPresent()
public java.lang.String getCameraVersion()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public java.lang.String getCameraRevision()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public double[] getCameraImage()
throws KheperaException
KheperaException - If a communications error with the robot occurs.public boolean gripperPresent()
public java.lang.String getGripperVersion()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public java.lang.String getGripperRevision()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public void openGripper()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public void closeGripper()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public boolean objectInGripper()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public void setArmPosition(double armPosition)
throws KheperaException
// make the robot ready to pick up an object in front robot.setArmPosition(LOWERED);
armPosition - A value in the range [0..1] where 1 is all way in front and 0 is all the way back.KheperaException - If a communications error with the robot occurs.KheperaConstants.LOWERED,
KheperaConstants.RAISED
public boolean gripperIsOpen()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
public double getArmPosition()
throws KheperaException
KheperaException - If a communications error with the robot occurs.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||