Package lejos.robotics.mapping
Class EV3NavigationModel
- java.lang.Object
-
- lejos.robotics.mapping.NavigationModel
-
- lejos.robotics.mapping.EV3NavigationModel
-
- All Implemented Interfaces:
MoveListener,NavigationListener,WaypointListener,FeatureListener
public class EV3NavigationModel 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
Fields Modifier and Type Field Description protected booleanautoSendPoseprotected floatclearanceprotected java.util.ArrayList<FeatureDetector>detectorsprotected PathFinderfinderprotected NavEventListenerlistenerprotected floatmaxDistanceprotected Navigatornavigatorprotected MoveControllerpilotprotected PoseProviderppprotected RangeScannerscannerprotected booleansendMoveStartprotected booleansendMoveStop-
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
Constructors Constructor Description EV3NavigationModel()Create the model and start the receiver thread
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFeatureDetector(FeatureDetector detector)Add a feature detector to the modelvoidaddListener(NavEventListener listener)voidaddNavigator(Navigator navigator)Add a navigator to the modelvoidaddPilot(MoveController pilot)Add a pilot to the modelvoidaddPoseProvider(PoseProvider pp)Add a pose provider (which might be MCL) to the modelvoidaddRangeScanner(RangeScanner scanner)Add a range scanner to the modelvoidaddWaypoint(Waypoint wp)Send a waypoint generated on the NXT to the PCvoidatWaypoint(Waypoint waypoint, Pose pose, int sequence)Called when a waypoint has been reachedvoiderror(java.lang.String message)Display an error message to the uservoidfatal(java.lang.String message)Display a fatal error and shut down the programvoidfeatureDetected(Feature feature, FeatureDetector detector)Called when a feature is detected.voidlog(java.lang.String message)Log a messagevoidmoveStarted(Move event, MoveProvider mp)Called when the pilot starts a movevoidmoveStopped(Move event, MoveProvider mp)Called when a move stopsvoidpathComplete(Waypoint waypoint, Pose pose, int sequence)Called when a path has been completedvoidpathGenerated()Called when a path finder has finished generating a pathvoidpathInterrupted(Waypoint waypoint, Pose pose, int sequence)Called when a path has been interruptedvoidsetAutoSendPose(boolean on)Set or unset automatic sending of the robot pose to the PC when a move stopsvoidsetRandomMoveParameters(float maxDistance, float clearance)Set parameters for a random movevoidsetSendMoveStart(boolean on)Sets whether events are sent to the PC when a move stopsvoidsetSendMoveStop(boolean on)Sets whether events are sent to the PC when a move startsvoidshutDown()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
-
-
-
-
Field Detail
-
navigator
protected Navigator navigator
-
pilot
protected MoveController pilot
-
pp
protected PoseProvider pp
-
detectors
protected java.util.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
-
-
Method Detail
-
log
public void log(java.lang.String message)
Log a message- Parameters:
message- the message
-
error
public void error(java.lang.String message)
Display an error message to the user- Parameters:
message- the error message
-
fatal
public void fatal(java.lang.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 moveclearance- the clearance distance around the robot
-
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:
moveStartedin interfaceMoveListener- Parameters:
event- the movementmp- the movement provider
-
moveStopped
public void moveStopped(Move event, MoveProvider mp)
Called when a move stops- Specified by:
moveStoppedin interfaceMoveListener- Parameters:
event- the movementmp- movement provider
-
featureDetected
public void featureDetected(Feature feature, FeatureDetector detector)
Called when a feature is detected. Only range features currently supported- Specified by:
featureDetectedin interfaceFeatureListener- 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:
addWaypointin interfaceWaypointListener- Parameters:
wp- the new waypoint
-
atWaypoint
public void atWaypoint(Waypoint waypoint, Pose pose, int sequence)
Called when a waypoint has been reached- Specified by:
atWaypointin interfaceNavigationListener- Parameters:
waypoint- where the robotpose- of the robotsequence- 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:
pathCompletein interfaceNavigationListener- Parameters:
waypoint- where the robotpose- of the robotsequence- 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:
pathInterruptedin interfaceNavigationListener- Parameters:
waypoint- toward which the robot was movingpose- current pose of the robotsequence- number of the next Waypoint
-
pathGenerated
public void pathGenerated()
Called when a path finder has finished generating a path- Specified by:
pathGeneratedin interfaceWaypointListener
-
-