lejos.robotics.mapping
Class NXTNavigationModel

java.lang.Object
  extended by lejos.robotics.mapping.NavigationModel
      extended by lejos.robotics.mapping.NXTNavigationModel
All Implemented Interfaces:
MoveListener, NavigationListener, WaypointListener, FeatureListener

public class NXTNavigationModel
extends NavigationModel
implements MoveListener, NavigationListener, WaypointListener, FeatureListener

NXT version of the navigation model. All local navigation objects, including pilots, navigators, path finders, feature detectors, and range scanners can be added to the model. Where possible, the model registers itself as an event listener and when the event occurs, updates the model and sends the event and the updates to the PC. A receiver thread receives events from the PC, updates the local model, and uses the navigation objects to implement the event if it involves robot behaviour. There are set methods to set various navigation parameters.

Author:
Lawrie Griffiths

Nested Class Summary
 
Nested classes/interfaces inherited from class lejos.robotics.mapping.NavigationModel
NavigationModel.NavEvent
 
Field Summary
protected  boolean autoSendPose
           
protected  float clearance
           
protected  ArrayList<FeatureDetector> detectors
           
protected  PathFinder finder
           
protected  NavEventListener listener
           
protected  float maxDistance
           
protected  Navigator navigator
           
protected  MoveController pilot
           
protected  PoseProvider pp
           
protected  RangeScanner scanner
           
protected  boolean sendMoveStart
           
protected  boolean sendMoveStop
           
 
Fields inherited from class lejos.robotics.mapping.NavigationModel
currentPose, debug, dis, dos, feature, lastMove, lastPlannedMove, map, mcl, numReadings, nxtName, particles, path, readings, target
 
Constructor Summary
NXTNavigationModel()
          Create the model and start the receiver thread
 
Method Summary
 void addFeatureDetector(FeatureDetector detector)
          Add a feature detector to the model
 void addListener(NavEventListener listener)
           
 void addNavigator(Navigator navigator)
          Add a navigator to the model
 void addPilot(MoveController pilot)
          Add a pilot to the model
 void addPoseProvider(PoseProvider pp)
          Add a pose provider (which might be MCL) to the model
 void addRangeScanner(RangeScanner scanner)
          Add a range scanner to the model
 void addWaypoint(Waypoint wp)
          Send a waypoint generated on the NXT to the PC
 void atWaypoint(Waypoint waypoint, Pose pose, int sequence)
          Called when a waypoint has been reached
 void error(String message)
          Display an error message to the user
 void fatal(String message)
          Display a fatal error and shut down the program
 void featureDetected(Feature feature, FeatureDetector detector)
          Called when a feature is detected.
 void log(String message)
          Log a message
 void moveStarted(Move event, MoveProvider mp)
          Called when the pilot starts a move
 void moveStopped(Move event, MoveProvider mp)
          Called when a move stops
 void pathComplete(Waypoint waypoint, Pose pose, int sequence)
          Called when a path has been completed
 void pathGenerated()
          Called when a path finder has finished generating a path
 void pathInterrupted(Waypoint waypoint, Pose pose, int sequence)
          Called when a path has been interrupted
 void setAutoSendPose(boolean on)
          Set or unset automatic sending of the robot pose to the PC when a move stops
 void setRandomMoveParameters(float maxDistance, float clearance)
          Set parameters for a random move
 void setSendMoveStart(boolean on)
          Sets whether events are sent to the PC when a move stops
 void setSendMoveStop(boolean on)
          Sets whether events are sent to the PC when a move starts
 void shutDown()
          Shut down the receiver thread
 
Methods inherited from class lejos.robotics.mapping.NavigationModel
getMap, getParticles, getPath, getReadings, getRobotPose, getTarget, hasMap, setDebug, setNumReadings, setParticleSet, setRobotPose, setTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

navigator

protected Navigator navigator

pilot

protected MoveController pilot

pp

protected PoseProvider pp

detectors

protected ArrayList<FeatureDetector> detectors

finder

protected PathFinder finder

scanner

protected RangeScanner scanner

listener

protected NavEventListener listener

clearance

protected float clearance

maxDistance

protected float maxDistance

autoSendPose

protected boolean autoSendPose

sendMoveStart

protected boolean sendMoveStart

sendMoveStop

protected boolean sendMoveStop
Constructor Detail

NXTNavigationModel

public NXTNavigationModel()
Create the model and start the receiver thread

Method Detail

log

public void log(String message)
Log a message

Parameters:
message - the message

error

public void error(String message)
Display an error message to the user

Parameters:
message - the error message

fatal

public void fatal(String message)
Display a fatal error and shut down the program

Parameters:
message - the error message

addNavigator

public void addNavigator(Navigator navigator)
Add a navigator to the model

Parameters:
navigator - the path controller

addPilot

public void addPilot(MoveController pilot)
Add a pilot to the model

Parameters:
pilot - the move controller

addPoseProvider

public void addPoseProvider(PoseProvider pp)
Add a pose provider (which might be MCL) to the model

Parameters:
pp - the pose provider

addRangeScanner

public void addRangeScanner(RangeScanner scanner)
Add a range scanner to the model

Parameters:
scanner - the range scanner

addFeatureDetector

public void addFeatureDetector(FeatureDetector detector)
Add a feature detector to the model

Parameters:
detector - the feature detector

setRandomMoveParameters

public void setRandomMoveParameters(float maxDistance,
                                    float clearance)
Set parameters for a random move

Parameters:
maxDistance - the maximum distance of the move
projection - the projection of the robot forward from its mid point
border - the border around the wall that the robot should not move into

setAutoSendPose

public void setAutoSendPose(boolean on)
Set or unset automatic sending of the robot pose to the PC when a move stops

Parameters:
on - true if the pose is to be sent, else false

setSendMoveStart

public void setSendMoveStart(boolean on)
Sets whether events are sent to the PC when a move stops

Parameters:
on - true iff an event should be sent

setSendMoveStop

public void setSendMoveStop(boolean on)
Sets whether events are sent to the PC when a move starts

Parameters:
on - true iff an event should be sent

shutDown

public void shutDown()
Shut down the receiver thread


addListener

public void addListener(NavEventListener listener)

moveStarted

public void moveStarted(Move event,
                        MoveProvider mp)
Called when the pilot starts a move

Specified by:
moveStarted in interface MoveListener
Parameters:
event - the movement
mp - the movement provider

moveStopped

public void moveStopped(Move event,
                        MoveProvider mp)
Called when a move stops

Specified by:
moveStopped in interface MoveListener
Parameters:
event - the movement
mp - movement provider

featureDetected

public void featureDetected(Feature feature,
                            FeatureDetector detector)
Called when a feature is detected. Only range features currently supported

Specified by:
featureDetected in interface FeatureListener
Parameters:
feature - The RangeReading, which contains angle and range.

addWaypoint

public void addWaypoint(Waypoint wp)
Send a waypoint generated on the NXT to the PC

Specified by:
addWaypoint in interface WaypointListener
Parameters:
wp - the new waypoint

atWaypoint

public void atWaypoint(Waypoint waypoint,
                       Pose pose,
                       int sequence)
Called when a waypoint has been reached

Specified by:
atWaypoint in interface NavigationListener
Parameters:
waypoint - where the robot
pose - of the robot
sequence - of the Waypoint in the path

pathComplete

public void pathComplete(Waypoint waypoint,
                         Pose pose,
                         int sequence)
Called when a path has been completed

Specified by:
pathComplete in interface NavigationListener
Parameters:
waypoint - where the robot
pose - of the robot
sequence - of the Waypoint in the path

pathInterrupted

public void pathInterrupted(Waypoint waypoint,
                            Pose pose,
                            int sequence)
Called when a path has been interrupted

Specified by:
pathInterrupted in interface NavigationListener
Parameters:
waypoint - toward which the robot was moving
pose - current pose of the robot
sequence - number of the next Waypoint

pathGenerated

public void pathGenerated()
Called when a path finder has finished generating a path

Specified by:
pathGenerated in interface WaypointListener