|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.robotics.navigation.NavPathController
public class NavPathController
This class can cause the robot to follow a route - a sequence of WayPoint
;
The way points are stored in a queue (actually, a Collection).
This class uses an inner class running its own thread to issue movement commands to its
MoveController
,
which can be either a DifferentialPilot
or SteeringPilot
.
It also uses a PoseProvider
to keep its pose updated, and calls its WayPointListener
when a way point is reached.
Nested Class Summary | |
---|---|
protected class |
NavPathController.Nav
This inner class runs the thread that processes the waypoint queue |
Field Summary | |
---|---|
protected WayPoint |
_destination
|
protected boolean |
_keepGoing
|
protected NavPathController.Nav |
_nav
|
protected MoveController |
_pilot
|
protected Pose |
_pose
|
protected double |
_radius
|
protected ArrayList<WayPoint> |
_route
|
protected ArrayList<WayPointListener> |
listeners
|
protected PathFinder |
pathFinder
|
protected PoseProvider |
poseProvider
|
protected ArrayList<WayPointListener> |
targetListeners
|
Constructor Summary | |
---|---|
NavPathController(MoveController pilot)
Can use any pilot that implements the ArcMoveController interface. |
|
NavPathController(MoveController pilot,
PoseProvider poseProvider)
Creates a PathController using a custom poseProvider, rather than the default tachometer pose provider. |
|
NavPathController(MoveController pilot,
PoseProvider poseProvider,
PathFinder pathFinder)
Creates a PathController which will navigate to a point via goTo() using a PathFinder to provide assistance to create a path. |
Method Summary | |
---|---|
void |
addListener(WayPointListener aListener)
Adds a WayPointListener
that will be notified with the actual waypoint it reached. |
void |
addTargetListener(WayPointListener targetListener)
Adds a waypoint listener that will be notified with the theoretical target waypoint it reached. |
void |
addWayPoint(WayPoint aWayPoint)
Adds a WayPoint to the route. |
void |
flushQueue()
Stops the robot and empties the queue of waypoints (the route) |
void |
followRoute(Collection<WayPoint> aRoute,
boolean immediateReturn)
Moves the robot through the sequence of waypoints contained in the route. |
MoveController |
getMoveController()
Returns a reference to the MoveController. |
PathFinder |
getPathFinder()
|
PoseProvider |
getPoseProvider()
Get a reference to the PoseProvider being used as a localizer. |
WayPoint |
getWayPoint()
Returns the waypoint to which the robot is moving |
void |
goTo(double x,
double y)
This method will navigate to a point. |
void |
goTo(WayPoint destination)
This method will navigate to a point. |
void |
goTo(WayPoint destination,
boolean immediateReturn)
This method will navigate to a point. |
void |
interrupt()
Stops the robot immediately; preserves the rest of the queue |
boolean |
isGoing()
returns false if the the final waypoint has been reached or interrupt() has been called |
void |
resume()
Resumes following the route |
void |
setPathFinder(PathFinder pathFinder)
|
void |
setPoseProvider(PoseProvider aProvider)
Sets a new PoseProvider for the PathController robot to use. |
void |
waitForDestinationReached()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected NavPathController.Nav _nav
protected ArrayList<WayPoint> _route
protected ArrayList<WayPointListener> listeners
protected ArrayList<WayPointListener> targetListeners
protected boolean _keepGoing
protected MoveController _pilot
protected PoseProvider poseProvider
protected PathFinder pathFinder
protected Pose _pose
protected WayPoint _destination
protected double _radius
Constructor Detail |
---|
public NavPathController(MoveController pilot)
pilot
- public NavPathController(MoveController pilot, PoseProvider poseProvider)
pilot
- poseProvider
- public NavPathController(MoveController pilot, PoseProvider poseProvider, PathFinder pathFinder)
pilot
- poseProvider
- pathFinder
- Method Detail |
---|
public void setPathFinder(PathFinder pathFinder)
public PathFinder getPathFinder()
public boolean isGoing()
false
if the the final waypoint has been reached or interrupt() has been called
public void followRoute(Collection<WayPoint> aRoute, boolean immediateReturn)
PathController
followRoute
in interface PathController
immediateReturn
- ; if false the method returns when the route is emptypublic void goTo(WayPoint destination, boolean immediateReturn)
goTo
in interface PathController
destination
- the destination MoveController
immediateReturn
- true for non-blocking, false for blockingpublic void goTo(WayPoint destination)
goTo
in interface PathController
destination
- the destination waypointpublic void goTo(double x, double y)
goTo
in interface PathController
x
- The x coordinatey
- The y coordinatepublic void addListener(WayPointListener aListener)
PathController
WayPointListener
that will be notified with the actual waypoint it reached.
addListener
in interface PathController
public void addTargetListener(WayPointListener targetListener)
PathController
addTargetListener
in interface PathController
public MoveController getMoveController()
getMoveController
in interface PathController
public void addWayPoint(WayPoint aWayPoint)
PathController
addWayPoint
in interface PathController
public void interrupt()
PathController
interrupt
in interface PathController
public void resume()
PathController
resume
in interface PathController
public void flushQueue()
PathController
flushQueue
in interface PathController
public WayPoint getWayPoint()
public void setPoseProvider(PoseProvider aProvider)
PathController
setPoseProvider
in interface PathController
aProvider
- the new PoseProviderpublic PoseProvider getPoseProvider()
PathController
getPoseProvider
in interface PathController
public void waitForDestinationReached()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |