Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
WaypointEngine< MAX_WAY > Class Template Reference#include <WaypointEngine.h>
Inheritance diagram for WaypointEngine< MAX_WAY >: ![]() Detailed Descriptiontemplate<unsigned int MAX_WAY>
Provides computation and management of a desired path through a series of waypoints.
|
Public Types | |
typedef ListMemBuf< Waypoint, MAX_WAYPOINTS > | WaypointList_t |
convenient shorthand | |
typedef ListMemBuf< Waypoint, MAX_WAYPOINTS >::index_t | WaypointListIter_t |
convenient shorthand | |
Public Member Functions | |
WaypointEngine () | |
constructor | |
WaypointEngine (char *f) | |
constructor | |
virtual unsigned int | getBinSize () const |
returns a rough overestimate of the size needed | |
virtual unsigned int | LoadBuffer (const char buf[], unsigned int len) |
Load from a saved buffer. | |
virtual unsigned int | SaveBuffer (char buf[], unsigned int len) const |
Save to a given buffer. | |
virtual void | go () |
starts walking towards the first waypoint | |
virtual void | pause () |
halts execution of waypoint list | |
virtual void | unpause () |
resumes execution of waypoint list from last paused location | |
virtual void | setIsLooping (bool isl) |
sets isLooping | |
virtual bool | getIsLooping () const |
returns isLooping | |
virtual WaypointList_t & | getWaypointList () |
returns a reference to waypoints | |
virtual const WaypointList_t & | getWaypointList () const |
returns a const reference to waypoints | |
virtual WaypointListIter_t | getCurWaypointID () const |
returns id value of current waypoint (curWaypoint) | |
virtual float | getCurX () const |
returns current x position | |
virtual float | getCurY () const |
returns current y position | |
virtual float | getCurA () const |
virtual void | setCurPos (float x, float y, float a) |
sets the current position (for instance your localization module has an update) | |
virtual bool | cycle () |
call this on each opportunity to check current location and correct velocities | |
virtual void | setTargetWaypoint (WaypointListIter_t iter) |
will set the currently active waypoint to another waypoint; correctly calculates location of intermediate waypoints so target location will be the same as if the intervening waypoints had actually been executed | |
Waypoint | calcAbsoluteCoords (WaypointListIter_t it) |
if it follows the current waypoint, applies all the waypoints between curWaypoint and it and returns result as an absolute position (angle field stores heading); otherwise calls the other calcAbsoluteCoords(WaypointListIter_t, float, float, float) | |
Waypoint | calcAbsoluteCoords (WaypointListIter_t it, float sx, float sy, float sa) |
starts at (sx, sy, heading=sa) and then applies all the waypoints up through it and returns result as an absolute position (angle field stores heading) | |
Adding Waypoints | |
these are for convenience - can also directly edit the waypoint list using access from getWaypointList() | |
virtual void | addEgocentricWaypoint (float forward, float left, float angle, bool angleIsRelative, float speed) |
adds a waypoint to the end of the list, allows you to specify turtle-style instructions | |
virtual void | addOffsetWaypoint (float x, float y, float angle, bool angleIsRelative, float speed) |
adds a waypoint to the end of the list, allows you to set locations relative to the location of the previous waypoint (or starting position) | |
virtual void | addAbsoluteWaypoint (float x, float y, float angle, bool angleIsRelative, float speed) |
adds a waypoint to the end of the list, allows you to set locations relative to the location of the previous waypoint (or starting position) | |
virtual void | addEgocentricArc (float forward, float left, float angle, bool angleIsRelative, float speed, float arc) |
adds a waypoint to the end of the list, using an arcing path to get there, allows you to specify turtle-style instructions to specify the focus of the arc | |
virtual void | addOffsetArc (float x, float y, float angle, bool angleIsRelative, float speed, float arc) |
adds a waypoint to the end of the list, using an arcing path to get there, allows you to specify locations relative to previous waypoint to specify the focus of the arc | |
virtual void | addAbsoluteArc (float x, float y, float angle, bool angleIsRelative, float speed, float arc) |
adds a waypoint to the end of the list, using an arcing path to get there, allows you to specify absolute locations to specify the focus of the arc | |
Static Public Attributes | |
static const unsigned int | MAX_WAYPOINTS = MAX_WAY |
for external access to maximum waypoints | |
Protected Member Functions | |
void | init () |
if next is a relative waypoint (offset or egocentric), it is added to the location held in cur; otherwise if next is absolute, cur is set to next | |
void | applyWaypoint (Waypoint &cur, const Waypoint &next) |
void | fixArc (float arc) |
assumes the last waypoint is actually center of circle, adjusts it to be the endpoint of following arc radians around that circle instead | |
void | computeCurrentPosition (unsigned int t) |
based on current velocity and time since last call, dead reckons current location in curPos | |
void | checkNextWaypoint (unsigned int t) |
checks to see if curPos is within eps of targetPos; if so, setTargetWaypoint() to next waypoint | |
void | computeIdeal (unsigned int t) |
computes the ideal location (idealPos) if we were following the intended path at the intended speed | |
void | computeNewVelocity (unsigned int t) |
computes the velocity which should be used given the current position (curPos) relative to the ideal position (idealPos) | |
Static Protected Member Functions | |
static float | normalizeAngle (float a) |
will set a to be between (-pi,pi) (inclusive), just like atan2() | |
static float | clipRange (float x, float min, float max) |
returns x such that it is at most max and at minimum min | |
Protected Attributes | |
WaypointList_t | waypoints |
storage for the waypoints | |
bool | isRunning |
true if we're currently executing the path | |
bool | isLooping |
true if we should loop when done | |
bool | isTracking |
new waypoints will use trackPath mode | |
unsigned int | curWaypoint |
index of current waypoint | |
unsigned int | waypointTime |
time we started working on current waypoint | |
float | waypointDistance |
distance from sourcePos to targetPos | |
float | pathLength |
distance to be traveled from sourcePos to targetPos (may differ from waypointDistance due to arcing) | |
float | arcRadius |
radius of current arc, may be inf or NaN if using a straight line; can also be negative depending on direction! | |
unsigned int | lastUpdateTime |
time we last updated curPos | |
float | pathStartPos [3] |
position when started execution of current path (aka origin offset for relative positions which preceed an absolute waypoint) | |
float | sourcePos [3] |
source position of the robot relative to the origin, aka absolute position of previous waypoint | |
float | targetPos [3] |
target position of the robot relative to the origin, aka absolute position of next waypoint | |
float | idealPos [4] |
ideal position of the robot relative to the origin, (x, y, heading, last element is desired direction of motion) | |
float | curPos [3] |
current position of the robot relative to the origin | |
float | curVel [3] |
current velocity | |
float | eps [3] |
epsilon - "close enough" to register a hit on the waypoint | |
float | Pcorr |
proportional correction factor for tracking path | |
float | turnSpeed |
maximum turning speed for new waypoints | |
Classes | |
struct | Waypoint |
Holds information about each waypoint, see WaypointEngine for overview. More... |
|
convenient shorthand
Definition at line 85 of file WaypointEngine.h. |
|
convenient shorthand
Definition at line 86 of file WaypointEngine.h. |
|
constructor
Definition at line 89 of file WaypointEngine.h. |
|
constructor
Definition at line 95 of file WaypointEngine.h. |
|
adds a waypoint to the end of the list, using an arcing path to get there, allows you to specify absolute locations to specify the focus of the arc If you would rather specify the ending point and then "bow" the path, try addAbsoluteWaypoint() followed by setting the Waypoint::arc field directly
Definition at line 195 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::LoadBuffer(). |
|
adds a waypoint to the end of the list, allows you to set locations relative to the location of the previous waypoint (or starting position)
Definition at line 159 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::addAbsoluteArc(), and WaypointEngine< MAX_WAY >::LoadBuffer(). |
|
adds a waypoint to the end of the list, using an arcing path to get there, allows you to specify turtle-style instructions to specify the focus of the arc If you would rather specify the ending point and then "bow" the path, try addEgocentricWaypoint() followed by setting the Waypoint::arc field directly
Definition at line 171 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::LoadBuffer(). |
|
adds a waypoint to the end of the list, allows you to specify turtle-style instructions
Definition at line 141 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::addEgocentricArc(), and WaypointEngine< MAX_WAY >::LoadBuffer(). |
|
adds a waypoint to the end of the list, using an arcing path to get there, allows you to specify locations relative to previous waypoint to specify the focus of the arc If you would rather specify the ending point and then "bow" the path, try addOffsetWaypoint() followed by setting the Waypoint::arc field directly
Definition at line 183 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::LoadBuffer(). |
|
adds a waypoint to the end of the list, allows you to set locations relative to the location of the previous waypoint (or starting position)
Definition at line 150 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::addOffsetArc(), and WaypointEngine< MAX_WAY >::LoadBuffer(). |
|
the Waypoint::angle field is used to store the headings Definition at line 556 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::calcAbsoluteCoords(), and WaypointEngine< MAX_WAY >::go(). |
|
starts at (sx, sy, heading=sa) and then applies all the waypoints up through it and returns result as an absolute position (angle field stores heading)
Definition at line 275 of file WaypointEngine.h. |
|
if it follows the current waypoint, applies all the waypoints between curWaypoint and it and returns result as an absolute position (angle field stores heading); otherwise calls the other calcAbsoluteCoords(WaypointListIter_t, float, float, float)
Definition at line 253 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::fixArc(), and WaypointEngine< MAX_WAY >::setTargetWaypoint(). |
|
checks to see if curPos is within eps of targetPos; if so, setTargetWaypoint() to next waypoint
Definition at line 631 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::cycle(). |
|
returns x such that it is at most max and at minimum min
Definition at line 313 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeNewVelocity(). |
|
based on current velocity and time since last call, dead reckons current location in curPos doesn't take acceleration into account, but should... :( Definition at line 612 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::cycle(). |
|
computes the ideal location (idealPos) if we were following the intended path at the intended speed
Definition at line 642 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::cycle(). |
|
computes the velocity which should be used given the current position (curPos) relative to the ideal position (idealPos)
Definition at line 711 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::cycle(). |
|
call this on each opportunity to check current location and correct velocities
Definition at line 377 of file WaypointEngine.h. Referenced by WaypointWalk< MAX_WAY >::updateOutputs(). |
|
assumes the last waypoint is actually center of circle, adjusts it to be the endpoint of following arc radians around that circle instead
Definition at line 591 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::addAbsoluteArc(), WaypointEngine< MAX_WAY >::addEgocentricArc(), and WaypointEngine< MAX_WAY >::addOffsetArc(). |
|
returns a rough overestimate of the size needed pretends we need to switch max_turn_speed and track_path on every point, and the longest options are given for every point Implements LoadSave. Definition at line 395 of file WaypointEngine.h. |
|
returns current heading Definition at line 122 of file WaypointEngine.h. |
|
returns id value of current waypoint (curWaypoint)
Definition at line 118 of file WaypointEngine.h. |
|
returns current x position
Definition at line 120 of file WaypointEngine.h. |
|
returns current y position
Definition at line 121 of file WaypointEngine.h. |
|
returns isLooping
Definition at line 113 of file WaypointEngine.h. |
|
returns a const reference to waypoints
Definition at line 116 of file WaypointEngine.h. |
|
returns a reference to waypoints
Definition at line 115 of file WaypointEngine.h. |
|
starts walking towards the first waypoint
Definition at line 345 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::unpause(). |
|
if next is a relative waypoint (offset or egocentric), it is added to the location held in cur; otherwise if next is absolute, cur is set to next
Definition at line 546 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
Load from a saved buffer.
Implements LoadSave. Definition at line 409 of file WaypointEngine.h. |
|
will set a to be between (-pi,pi) (inclusive), just like atan2()
Definition at line 304 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::applyWaypoint(), WaypointEngine< MAX_WAY >::computeCurrentPosition(), WaypointEngine< MAX_WAY >::computeIdeal(), and WaypointEngine< MAX_WAY >::computeNewVelocity(). |
|
halts execution of waypoint list
Definition at line 362 of file WaypointEngine.h. |
|
Save to a given buffer.
Implements LoadSave. Definition at line 496 of file WaypointEngine.h. |
|
sets the current position (for instance your localization module has an update)
Definition at line 124 of file WaypointEngine.h. |
|
sets isLooping
Definition at line 112 of file WaypointEngine.h. |
|
will set the currently active waypoint to another waypoint; correctly calculates location of intermediate waypoints so target location will be the same as if the intervening waypoints had actually been executed
Definition at line 203 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::checkNextWaypoint(), and WaypointEngine< MAX_WAY >::go(). |
|
resumes execution of waypoint list from last paused location
Definition at line 367 of file WaypointEngine.h. |
|
radius of current arc, may be inf or NaN if using a straight line; can also be negative depending on direction!
Definition at line 331 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::computeNewVelocity(), WaypointEngine< MAX_WAY >::setTargetWaypoint(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
current position of the robot relative to the origin
Definition at line 337 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::checkNextWaypoint(), WaypointEngine< MAX_WAY >::computeCurrentPosition(), WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::computeNewVelocity(), WaypointEngine< MAX_WAY >::getCurA(), WaypointEngine< MAX_WAY >::getCurX(), WaypointEngine< MAX_WAY >::getCurY(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::init(), WaypointEngine< MAX_WAY >::setCurPos(), and WaypointEngine< MAX_WAY >::setTargetWaypoint(). |
|
current velocity
Definition at line 338 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeCurrentPosition(), WaypointEngine< MAX_WAY >::computeNewVelocity(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::init(), WaypointEngine< MAX_WAY >::setTargetWaypoint(), and WaypointEngine< MAX_WAY >::unpause(). |
|
|
epsilon - "close enough" to register a hit on the waypoint
Definition at line 339 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::applyWaypoint(), WaypointEngine< MAX_WAY >::checkNextWaypoint(), WaypointEngine< MAX_WAY >::computeIdeal(), and WaypointEngine< MAX_WAY >::init(). |
|
ideal position of the robot relative to the origin, (x, y, heading, last element is desired direction of motion)
Definition at line 336 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::computeNewVelocity(), and WaypointEngine< MAX_WAY >::init(). |
|
true if we should loop when done
Definition at line 325 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::getIsLooping(), WaypointEngine< MAX_WAY >::setIsLooping(), WaypointEngine< MAX_WAY >::setTargetWaypoint(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
true if we're currently executing the path
Definition at line 324 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::cycle(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::pause(), WaypointEngine< MAX_WAY >::setTargetWaypoint(), WaypointEngine< MAX_WAY >::unpause(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
new waypoints will use trackPath mode
Definition at line 326 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::addAbsoluteWaypoint(), WaypointEngine< MAX_WAY >::addEgocentricWaypoint(), WaypointEngine< MAX_WAY >::addOffsetWaypoint(), WaypointEngine< MAX_WAY >::calcAbsoluteCoords(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::LoadBuffer(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
time we last updated curPos
Definition at line 332 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeCurrentPosition(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::unpause(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
for external access to maximum waypoints
Reimplemented in WaypointWalk< MAX_WAY >. Definition at line 58 of file WaypointEngine.h. |
|
distance to be traveled from sourcePos to targetPos (may differ from waypointDistance due to arcing)
Definition at line 330 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::setTargetWaypoint(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
position when started execution of current path (aka origin offset for relative positions which preceed an absolute waypoint)
Definition at line 333 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::calcAbsoluteCoords(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::init(), and WaypointEngine< MAX_WAY >::setTargetWaypoint(). |
|
proportional correction factor for tracking path
Definition at line 340 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeNewVelocity(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
source position of the robot relative to the origin, aka absolute position of previous waypoint
Definition at line 334 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::init(), and WaypointEngine< MAX_WAY >::setTargetWaypoint(). |
|
target position of the robot relative to the origin, aka absolute position of next waypoint
Definition at line 335 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::calcAbsoluteCoords(), WaypointEngine< MAX_WAY >::checkNextWaypoint(), WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::computeNewVelocity(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::init(), and WaypointEngine< MAX_WAY >::setTargetWaypoint(). |
|
maximum turning speed for new waypoints
Definition at line 341 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::addAbsoluteWaypoint(), WaypointEngine< MAX_WAY >::addEgocentricWaypoint(), WaypointEngine< MAX_WAY >::addOffsetWaypoint(), WaypointEngine< MAX_WAY >::calcAbsoluteCoords(), WaypointEngine< MAX_WAY >::go(), WaypointEngine< MAX_WAY >::LoadBuffer(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
distance from sourcePos to targetPos
Definition at line 329 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::setTargetWaypoint(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
|
|
time we started working on current waypoint
Definition at line 328 of file WaypointEngine.h. Referenced by WaypointEngine< MAX_WAY >::computeIdeal(), WaypointEngine< MAX_WAY >::setTargetWaypoint(), and WaypointEngine< MAX_WAY >::WaypointEngine(). |
Tekkotsu v2.2.2 |
Generated Tue Jan 4 15:45:35 2005 by Doxygen 1.4.0 |