Java Reference
In-Depth Information
// front's coordinates according to the robot position
// intersects the laser beam with the obstacles'
// boundaries
for ( int i # 0; i < environment.obstacles.size(); i !! )
Class Robot is the container of the robot's devices. It maintains a Position
variable that records the current robot position with regard to the global
reference frame. This variable is modified by the mobile platform and is
passed to all the robot's devices to keep track of their position in the
package moro;
import java.util.*;
import java.awt.*;
public class Robot {
String name; // the robot name
Position position;
// the robot position in the global reference frame
Environment environment;
// a reference to the environment
Platform platform;
// a reference to the mobile platform
ArrayList sensors # new ArrayList();
// the list of sensor devices
public Robot(String name, double x, double y,
double t, Environment env) {
this .name # name;
this .environment # env;
position # new Position(x, y, Math.toRadians(t));
platform # new Platform("P1", this , env);
sensors.add( new Laser("L1", this ,
new Position(20.0, 0.0, 0.0), env));
public void paint(Graphics g) {
platform.paint(g); // paints all the mobile platform
... // paints the sensor devices
Class Obstacle encapsulates an object of class Polygon and implements the
methods for parsing the obstacle description from the XML input file and for
visualizing its geometric shape.
Search WWH ::

Custom Search