Fawkes API
Fawkes Development Version
|
Sub-class representing a navgraph path traversal. More...
#include <>>
Public Member Functions | |
Traversal () | |
Constructor. More... | |
Traversal (const NavGraphPath *path) | |
Constructor. More... | |
const NavGraphNode & | current () const |
Get current node in path. More... | |
const NavGraphNode & | peek_next () const |
Peek on the next node. More... | |
size_t | current_index () const |
Get index of current node in path. More... | |
bool | next () |
Move on traversal to next node. More... | |
void | reset () |
Reset an ongoing traversal. More... | |
bool | last () const |
Check if the current node is the last node in the path. More... | |
size_t | remaining () const |
Get the number of remaining nodes in path traversal. More... | |
float | remaining_cost () const |
Get the remaining cost to the goal. More... | |
bool | running () const |
Check if traversal is currently runnung. More... | |
void | invalidate () |
Invalidate this traversal. More... | |
void | set_current (size_t new_current) |
Set the current node. More... | |
const NavGraphPath & | path () const |
Get parent path the traversal belongs to. More... | |
operator bool () const | |
Check if traversal is initialized. More... | |
Friends | |
class | NavGraphPath |
Sub-class representing a navgraph path traversal.
A traversal is a step-by-step run through the node sequence (in order). There maybe any number of traversal open for a given path. But they become invalid should new nodes be set on the path. After creating a new traversal, you always need to call next for each new node including the first one. Code could look like this.
Definition at line 41 of file navgraph_path.h.
fawkes::NavGraphPath::Traversal::Traversal | ( | ) |
Constructor.
Definition at line 248 of file navgraph_path.cpp.
fawkes::NavGraphPath::Traversal::Traversal | ( | const NavGraphPath * | path | ) |
Constructor.
path | parent path to traverse |
Definition at line 257 of file navgraph_path.cpp.
const NavGraphNode & fawkes::NavGraphPath::Traversal::current | ( | ) | const |
Get current node in path.
Exception | if no traversal is active, i.e. next() has not been called after a traversal reset or if the path has already been traversed completley. |
Definition at line 287 of file navgraph_path.cpp.
Referenced by NavGraphThread::loop().
size_t fawkes::NavGraphPath::Traversal::current_index | ( | ) | const |
Get index of current node in path.
Exception | if no traversal is active, i.e. next() has not been called after a traversal reset or if the path has already been traversed completley. |
Definition at line 333 of file navgraph_path.cpp.
Referenced by NavGraphThread::fam_event(), and NavGraphThread::loop().
void fawkes::NavGraphPath::Traversal::invalidate | ( | ) |
Invalidate this traversal.
This will reset the parent path and the current node. This traversal can now longer be used afterwards other than assigning a new traversal.
Definition at line 269 of file navgraph_path.cpp.
Referenced by NavGraphThread::loop(), NavGraphVisualizationThread::reset_plan(), and NavGraphVisualizationThread::set_graph().
bool fawkes::NavGraphPath::Traversal::last | ( | ) | const |
Check if the current node is the last node in the path.
Definition at line 361 of file navgraph_path.cpp.
Referenced by NavGraphVisualizationThread::loop(), and NavGraphThread::loop().
bool fawkes::NavGraphPath::Traversal::next | ( | ) |
Move on traversal to next node.
Definition at line 347 of file navgraph_path.cpp.
Referenced by NavGraphThread::loop().
|
inline |
Check if traversal is initialized.
Definition at line 68 of file navgraph_path.h.
References fawkes::NavGraphPath::add_node(), fawkes::NavGraphPath::cost(), fawkes::NavGraphPath::get_node_names(), fawkes::NavGraphPath::get_path_as_string(), fawkes::NavGraphPath::goal(), fawkes::NavGraphPath::graph(), fawkes::NavGraphPath::nodes(), and fawkes::NavGraphPath::set_nodes().
|
inline |
Get parent path the traversal belongs to.
Definition at line 63 of file navgraph_path.h.
Referenced by NavGraphThread::fam_event(), NavGraphVisualizationThread::loop(), and NavGraphThread::loop().
const NavGraphNode & fawkes::NavGraphPath::Traversal::peek_next | ( | ) | const |
Peek on the next node.
Get the node following the current node without advancing the current index (the current node remains the same).
OutOfBoundsException | if the traversal has not been started with an initial call to next() or if the traversal has already ended or is currently at the last node. |
Definition at line 307 of file navgraph_path.cpp.
Referenced by NavGraphThread::loop().
size_t fawkes::NavGraphPath::Traversal::remaining | ( | ) | const |
Get the number of remaining nodes in path traversal.
The number of remaining nodes is the number of nodes including the current node up until the last node in the path.
Definition at line 374 of file navgraph_path.cpp.
Referenced by NavGraphThread::fam_event(), NavGraphVisualizationThread::loop(), and NavGraphThread::loop().
float fawkes::NavGraphPath::Traversal::remaining_cost | ( | ) | const |
Get the remaining cost to the goal.
This sums the costs from the current to the goal node using the default registered cost function of the parent navgraph.
Definition at line 388 of file navgraph_path.cpp.
References fawkes::NavGraphPath::cost(), and fawkes::NavGraph::cost().
Referenced by NavGraphThread::loop().
void fawkes::NavGraphPath::Traversal::reset | ( | void | ) |
Reset an ongoing traversal.
A new traversal afterwards will start the traversal from the beginning.
Definition at line 410 of file navgraph_path.cpp.
bool fawkes::NavGraphPath::Traversal::running | ( | ) | const |
Check if traversal is currently runnung.
Definition at line 322 of file navgraph_path.cpp.
Referenced by NavGraphThread::fam_event(), and NavGraphThread::loop().
void fawkes::NavGraphPath::Traversal::set_current | ( | size_t | new_current | ) |
Set the current node.
new_current | new current node |
OutOfBoundsException | thrown if new current node is beyond number of nodes in path. |
Definition at line 422 of file navgraph_path.cpp.
Referenced by NavGraphThread::loop().