Exemplo n.º 1
0
  /** Set the path to be followed. */
  @Override
  public void setPath(Path path) {
    forward.clear();
    this.path.clear();
    nav.clearPath();
    for (int i = 0; i < path.size(); i++) {
      forward.add(new Waypoint(path.get(i)));
      this.path.add(new Waypoint(path.get(i)));
    }
    for (int i = path.size() - 2; i > -1; i--) {
      this.path.add(new Waypoint(path.get(i)));
    }

    this.path.add(new Waypoint(0, 0));

    for (Waypoint wp : this.path) {
      nav.addWaypoint(wp);
    }
  }
Exemplo n.º 2
0
  /** The method used for immediate mode. Robot goes to the point. */
  @Override
  public void goToImmediate(Waypoint wp) {
    if (path != null) {
      path.clear();
      nav.clearPath();
    }
    nav.addWaypoint(wp);
    path.add(wp);

    Thread t =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                nav.followPath();
                nav.waitForStop();
                path.clear();
                nav.clearPath();
              }
            });

    t.start();
  }
Exemplo n.º 3
0
 /** The constructor instantiates the pilot and navigator. Single step is false. */
 public RobotControllerLejos() {
   path = new Path();
   pilot = new DifferentialPilot(5.6, 18, Motor.A, Motor.B);
   nav = new Navigator(pilot);
   nav.singleStep(false);
 }
Exemplo n.º 4
0
 /** Stops the robot right away. */
 @Override
 public void stopImmediate() {
   nav.stop();
   Logger.INSTANCE.log(this.getClass().getSimpleName(), "Emergency stopped");
 }
Exemplo n.º 5
0
 /** Stops the robot when it hits the next waypoint. */
 @Override
 public void stop() {
   nav.singleStep(true);
 }
Exemplo n.º 6
0
 /**
  * Returns a waypoint of the current location.
  *
  * @return Waypoint, current location
  */
 @Override
 public Waypoint getLocation() {
   PoseProvider provider = nav.getPoseProvider();
   Pose pose = provider.getPose();
   return (Waypoint) pose.getLocation();
 }
Exemplo n.º 7
0
 /** Sets the robot to single step mode. */
 @Override
 public void singleStep(boolean setting) {
   check = setting;
   nav.singleStep(setting);
 }