Fawkes API
Fawkes Development Version
|
Topological map graph. More...
#include <>>
Classes | |
class | ChangeListener |
Topological graph change listener. More... | |
Public Types | |
enum | ConnectionMode { CLOSEST_NODE, CLOSEST_EDGE, CLOSEST_EDGE_OR_NODE } |
Connect mode enum for connect_node_* methods. More... | |
enum | EdgeMode { EDGE_FORCE, EDGE_NO_INTERSECTION, EDGE_SPLIT_INTERSECTION } |
Mode to use to add edges. More... | |
Public Member Functions | |
NavGraph (const std::string &graph_name) | |
Constructor. More... | |
virtual | ~NavGraph () |
Virtual empty destructor. More... | |
std::string | name () const |
Get graph name. More... | |
const std::vector< NavGraphNode > & | nodes () const |
Get nodes of the graph. More... | |
const std::vector< NavGraphEdge > & | edges () const |
Get edges of the graph. More... | |
fawkes::LockPtr< NavGraphConstraintRepo > | constraint_repo () const |
Get locked pointer to constraint repository. More... | |
const std::map< std::string, std::string > & | default_properties () const |
Get all default properties. More... | |
bool | has_default_property (const std::string &property) const |
Check if graph has specified default property. More... | |
std::string | default_property (const std::string &prop) const |
Get specified default property as string. More... | |
float | default_property_as_float (const std::string &prop) const |
Get property converted to float. More... | |
int | default_property_as_int (const std::string &prop) const |
Get property converted to int. More... | |
bool | default_property_as_bool (const std::string &prop) const |
Get property converted to bol. More... | |
void | set_default_property (const std::string &property, const std::string &value) |
Set property. More... | |
void | set_default_property (const std::string &property, float value) |
Set property. More... | |
void | set_default_property (const std::string &property, int value) |
Set property. More... | |
void | set_default_property (const std::string &property, bool value) |
Set property. More... | |
void | set_default_properties (const std::map< std::string, std::string > &properties) |
Set default properties. More... | |
void | apply_default_properties (NavGraphNode &node) |
Set default properties on node for which no local value exists. More... | |
NavGraphNode | node (const std::string &name) const |
Get a specified node. More... | |
NavGraphNode | closest_node (float pos_x, float pos_y, const std::string &property="") const |
Get node closest to a specified point with a certain property. More... | |
NavGraphNode | closest_node_to (const std::string &node_name, const std::string &property="") const |
Get node closest to another node with a certain property. More... | |
NavGraphNode | closest_node (float pos_x, float pos_y, bool consider_unconnected, const std::string &property="") const |
Get node closest to a specified point with a certain property. More... | |
NavGraphNode | closest_node_to (const std::string &node_name, bool consider_unconnected, const std::string &property="") const |
Get node closest to another node with a certain property. More... | |
NavGraphNode | closest_node_with_unconnected (float pos_x, float pos_y, const std::string &property="") const |
Get node closest to a specified point with a certain property. More... | |
NavGraphNode | closest_node_to_with_unconnected (const std::string &node_name, const std::string &property="") const |
Get node closest to another node with a certain property. More... | |
NavGraphEdge | edge (const std::string &from, const std::string &to) const |
Get a specified edge. More... | |
NavGraphEdge | closest_edge (float pos_x, float pos_y) const |
Get edge closest to a specified point. More... | |
std::vector< NavGraphNode > | search_nodes (const std::string &property) const |
Search nodes for given property. More... | |
std::vector< std::string > | reachable_nodes (const std::string &node_name) const |
Get nodes reachable from specified nodes. More... | |
fawkes::NavGraphPath | search_path (const std::string &from, const std::string &to, bool use_constraints=true, bool compute_constraints=true) |
Search for a path between two nodes with default distance costs. More... | |
fawkes::NavGraphPath | search_path (const std::string &from, const std::string &to, navgraph::EstimateFunction estimate_func, navgraph::CostFunction cost_func, bool use_constraints=true, bool compute_constraints=true) |
Search for a path between two nodes. More... | |
fawkes::NavGraphPath | search_path (const NavGraphNode &from, const NavGraphNode &to, bool use_constraints=true, bool compute_constraints=true) |
Search for a path between two nodes with default distance costs. More... | |
fawkes::NavGraphPath | search_path (const NavGraphNode &from, const NavGraphNode &to, navgraph::EstimateFunction estimate_func, navgraph::CostFunction cost_func, bool use_constraints=true, bool compute_constraints=true) |
Search for a path between two nodes. More... | |
void | add_node (const NavGraphNode &node) |
Add a node. More... | |
void | add_node_and_connect (const NavGraphNode &node, ConnectionMode conn_mode) |
Add a node and connect it to the graph. More... | |
void | connect_node_to_closest_node (const NavGraphNode &n) |
Connect node to closest node. More... | |
void | connect_node_to_closest_edge (const NavGraphNode &n) |
Connect node to closest edge. More... | |
void | add_edge (const NavGraphEdge &edge, EdgeMode mode=EDGE_NO_INTERSECTION, bool allow_existing=false) |
Add an edge. More... | |
void | remove_node (const NavGraphNode &node) |
Remove a node. More... | |
void | remove_node (const std::string &node_name) |
Remove a node. More... | |
void | remove_edge (const NavGraphEdge &edge) |
Remove an edge. More... | |
void | remove_edge (const std::string &from, const std::string &to) |
Remove an edge. More... | |
void | clear () |
Remove all nodes and edges from navgraph. More... | |
void | update_node (const NavGraphNode &node) |
Update a given node. More... | |
void | update_edge (const NavGraphEdge &edge) |
Update a given edge. More... | |
bool | node_exists (const NavGraphNode &node) const |
Check if a certain node exists. More... | |
bool | node_exists (const std::string &name) const |
Check if a certain node exists. More... | |
bool | edge_exists (const NavGraphEdge &edge) const |
Check if a certain edge exists. More... | |
bool | edge_exists (const std::string &from, const std::string &to) const |
Check if a certain edge exists. More... | |
void | calc_reachability (bool allow_multi_graph=false) |
Calculate eachability relations. More... | |
NavGraph & | operator= (const NavGraph &g) |
Assign/copy structures from another graph. More... | |
void | set_notifications_enabled (bool enabled) |
Enable or disable notifications. More... | |
void | notify_of_change () throw () |
Notify all listeners of a change. More... | |
void | add_change_listener (ChangeListener *listener) |
Add a change listener. More... | |
void | remove_change_listener (ChangeListener *listener) |
Remove a change listener. More... | |
bool | uses_default_search () const |
Check if the default euclidean distance search is used. More... | |
void | set_search_funcs (navgraph::EstimateFunction estimate_func, navgraph::CostFunction cost_func) |
Set cost and cost estimation function for searching paths. More... | |
void | unset_search_funcs () |
Reset actual and estimated cost function to defaults. More... | |
float | cost (const NavGraphNode &from, const NavGraphNode &to) const |
Calculate cost between two adjacent nodes. More... | |
std::string | gen_unique_name (const char *prefix="U-") |
Generate a unique node name for the given prefix. More... | |
Static Public Member Functions | |
static std::string | format_name (const char *format,...) |
Create node name from a format string. More... | |
Topological map graph.
This class represents a topological graph using 2D map coordinates with nodes and edges. Both can be annotated with certain free-form properties which can be used at run-time for example to instruct the robot behavior.
The class supports change listeners. These are called whenever the graph is changed, that is if a node or edge is added or if the graph is assigned from another one (i.e. graph := new_graph).
This class is based on KBSG RCSoft's MapGraph but has been abstracted and improved.
Definition at line 57 of file navgraph.h.
Connect mode enum for connect_node_* methods.
Enumerator | |
---|---|
CLOSEST_NODE | Connect to closest node. |
CLOSEST_EDGE | Connect to closest edge. |
CLOSEST_EDGE_OR_NODE | try to connect to closest edge, if that fails, connect to closest node |
Definition at line 61 of file navgraph.h.
Mode to use to add edges.
Definition at line 69 of file navgraph.h.
fawkes::NavGraph::NavGraph | ( | const std::string & | graph_name | ) |
Constructor.
graph_name | Name of the graph, for example to handle multiple graphs, e.g. for multiple levels of a building. |
Definition at line 69 of file navgraph.cpp.
References fawkes::NavGraphSearchState::euclidean_cost(), and fawkes::NavGraphSearchState::straight_line_estimate().
|
virtual |
Virtual empty destructor.
Definition at line 83 of file navgraph.cpp.
void fawkes::NavGraph::add_change_listener | ( | ChangeListener * | listener | ) |
Add a change listener.
listener | listener to add |
Definition at line 1452 of file navgraph.cpp.
Referenced by NavGraphThread::init().
void fawkes::NavGraph::add_edge | ( | const NavGraphEdge & | edge, |
NavGraph::EdgeMode | mode = EDGE_NO_INTERSECTION , |
||
bool | allow_existing = false |
||
) |
Add an edge.
edge | edge to add |
mode | edge add mode |
allow_existing | if true allow an edge with the given parameters to exist. In that case the method silently returns. Note that you might loose edge properties in that case. If false, an exception is thrown if a similar edge exists. |
Exception | thrown if an edge for the same nodes already exist unless allow_existing is set true, then simply returns. Takes directed edges into account. So if a directed edge from p1 to p2 exists, it is ok to add a (directed or undirected) edge from p2 to p1. |
Definition at line 592 of file navgraph.cpp.
References fawkes::NavGraphEdge::from(), and fawkes::NavGraphEdge::to().
Referenced by fawkes::NavGraphGeneratorVoronoi::compute(), and fawkes::load_yaml_navgraph().
void fawkes::NavGraph::add_node | ( | const NavGraphNode & | node | ) |
Add a node.
node | node to add |
Exception | thrown if node with the same name as node already exists |
Definition at line 461 of file navgraph.cpp.
References fawkes::NavGraphNode::name().
Referenced by fawkes::NavGraphGeneratorVoronoi::compute(), and fawkes::load_yaml_navgraph().
INTERNAL void fawkes::NavGraph::add_node_and_connect | ( | const NavGraphNode & | node, |
ConnectionMode | conn_mode | ||
) |
Add a node and connect it to the graph.
The node is added similar to add_node(). Then, an edge is added connecting the node to the graph. There are two principal methods available: CLOSEST_NODE: simply connect to an existing node closest to the given node CLOSEST_EDGE: connect node to the edge in which segment it lies, i.e. search for an edge where we can find a perpendicular line going through the given node and any point on the edge's line segment. If no such segment is found, the node cannot be added. CLOSEST_EDGE_OR_NODE: first try CLOSEST_EDGE method, if that fails use CLOSEST_NODE.
node | node to add |
conn_mode | connection mode to use |
Definition at line 500 of file navgraph.cpp.
void fawkes::NavGraph::apply_default_properties | ( | NavGraphNode & | node | ) |
Set default properties on node for which no local value exists.
This sets all default properties on the node, for which no property of the same name has been set on the node.
node | node to apply default properties to |
Definition at line 861 of file navgraph.cpp.
References fawkes::NavGraphNode::has_property(), and fawkes::NavGraphNode::set_property().
Referenced by NavGraphThread::loop().
void fawkes::NavGraph::calc_reachability | ( | bool | allow_multi_graph = false | ) |
Calculate eachability relations.
This will set the directly reachable nodes on each of the graph nodes.
allow_multi_graph | if true, allows multiple disconnected graph segments. |
Definition at line 1387 of file navgraph.cpp.
Referenced by fawkes::NavGraphGeneratorVoronoi::compute(), and fawkes::load_yaml_navgraph().
void fawkes::NavGraph::clear | ( | void | ) |
Remove all nodes and edges from navgraph.
Use with caution, this means that no more searches etc. are possible.
Definition at line 731 of file navgraph.cpp.
NavGraphEdge fawkes::NavGraph::closest_edge | ( | float | pos_x, |
float | pos_y | ||
) | const |
Get edge closest to a specified point.
The point must be within an imaginery line segment parallel to the edge, that is a line perpendicular to the edge must go through the point and a point on the edge line segment.
pos_x | X coordinate in global (map) frame of point |
pos_y | X coordinate in global (map) frame of point |
Definition at line 349 of file navgraph.cpp.
References fawkes::distance().
NavGraphNode fawkes::NavGraph::closest_node | ( | float | pos_x, |
float | pos_y, | ||
const std::string & | property = "" |
||
) | const |
Get node closest to a specified point with a certain property.
This search does NOT consider unconnected nodes.
pos_x | X coordinate in global (map) frame |
pos_y | X coordinate in global (map) frame |
property | property the node must have to be considered, empty string to not check for any property |
Definition at line 181 of file navgraph.cpp.
Referenced by NavGraphThread::loop(), and fawkes::EclExternalRCSoftMapGraph::map_graph().
NavGraphNode fawkes::NavGraph::closest_node | ( | float | pos_x, |
float | pos_y, | ||
bool | consider_unconnected, | ||
const std::string & | property = "" |
||
) | const |
Get node closest to a specified point with a certain property.
pos_x | X coordinate in global (map) frame |
pos_y | X coordinate in global (map) frame |
consider_unconnected | consider unconnected node for the search of the closest node |
property | property the node must have to be considered, empty string to not check for any property |
Definition at line 246 of file navgraph.cpp.
NavGraphNode fawkes::NavGraph::closest_node_to | ( | const std::string & | node_name, |
const std::string & | property = "" |
||
) | const |
Get node closest to another node with a certain property.
This search does NOT consider unconnected nodes.
node_name | the name of the node from which to start |
property | property the node must have to be considered, empty string to not check for any property |
node_name
. Definition at line 213 of file navgraph.cpp.
NavGraphNode fawkes::NavGraph::closest_node_to | ( | const std::string & | node_name, |
bool | consider_unconnected, | ||
const std::string & | property = "" |
||
) | const |
Get node closest to another node with a certain property.
node_name | the name of the node from which to start |
consider_unconnected | consider unconnected node for the search of the closest node |
property | property the node must have to be considered, empty string to not check for any property |
node_name
. Definition at line 285 of file navgraph.cpp.
References fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().
NavGraphNode fawkes::NavGraph::closest_node_to_with_unconnected | ( | const std::string & | node_name, |
const std::string & | property = "" |
||
) | const |
Get node closest to another node with a certain property.
This search does consider unconnected nodes.
node_name | the name of the node from which to start |
property | property the node must have to be considered, empty string to not check for any property |
node_name
. Definition at line 229 of file navgraph.cpp.
NavGraphNode fawkes::NavGraph::closest_node_with_unconnected | ( | float | pos_x, |
float | pos_y, | ||
const std::string & | property = "" |
||
) | const |
Get node closest to a specified point with a certain property.
This search does consider unconnected nodes.
pos_x | X coordinate in global (map) frame |
pos_y | X coordinate in global (map) frame |
property | property the node must have to be considered, empty string to not check for any property |
Definition at line 197 of file navgraph.cpp.
void fawkes::NavGraph::connect_node_to_closest_edge | ( | const NavGraphNode & | n | ) |
Connect node to closest edge.
n | node to connect to closest node |
Definition at line 540 of file navgraph.cpp.
References fawkes::NavGraphEdge::closest_point_on_edge(), fawkes::NavGraphNode::distance(), format_name(), fawkes::NavGraphEdge::from(), fawkes::NavGraphNode::name(), fawkes::NavGraphEdge::properties(), fawkes::NavGraphEdge::set_properties(), fawkes::NavGraphEdge::set_property(), fawkes::NavGraphEdge::to(), fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().
Referenced by fawkes::load_yaml_navgraph().
void fawkes::NavGraph::connect_node_to_closest_node | ( | const NavGraphNode & | n | ) |
Connect node to closest node.
n | node to connect to closest node |
Definition at line 526 of file navgraph.cpp.
References fawkes::NavGraphNode::name(), and fawkes::NavGraphEdge::set_property().
Referenced by fawkes::load_yaml_navgraph().
fawkes::LockPtr< NavGraphConstraintRepo > fawkes::NavGraph::constraint_repo | ( | ) | const |
Get locked pointer to constraint repository.
Definition at line 145 of file navgraph.cpp.
Referenced by NavGraphThread::init().
float fawkes::NavGraph::cost | ( | const NavGraphNode & | from, |
const NavGraphNode & | to | ||
) | const |
Calculate cost between two adjacent nodes.
It is not verified whether the nodes are actually adjacent, but the cost function is simply applied. This is done to increase performance. The calculation will use the currently registered cost function.
from | first node |
to | second node |
from
to to
Definition at line 1107 of file navgraph.cpp.
References fawkes::NavGraphEdge::from(), fawkes::NavGraphEdge::is_directed(), fawkes::NavGraphNode::name(), fawkes::point_dist(), fawkes::points_different(), fawkes::NavGraphEdge::properties(), fawkes::NavGraphNode::reachable_nodes(), fawkes::NavGraphEdge::set_property(), fawkes::NavGraphEdge::to(), fawkes::NavGraphNode::unconnected(), fawkes::Exception::what_no_backtrace(), fawkes::NavGraphNode::x(), fawkes::cart_coord_2d_struct::x, fawkes::NavGraphNode::y(), and fawkes::cart_coord_2d_struct::y.
Referenced by NavGraphThread::loop(), and fawkes::NavGraphPath::Traversal::remaining_cost().
const std::map< std::string, std::string > & fawkes::NavGraph::default_properties | ( | ) | const |
Get all default properties.
Definition at line 743 of file navgraph.cpp.
Referenced by NavGraphVisualizationThread::loop(), and fawkes::save_yaml_navgraph().
std::string fawkes::NavGraph::default_property | ( | const std::string & | prop | ) | const |
Get specified default property as string.
prop | property key |
Definition at line 763 of file navgraph.cpp.
bool fawkes::NavGraph::default_property_as_bool | ( | const std::string & | prop | ) | const |
Get property converted to bol.
prop | property key |
Definition at line 798 of file navgraph.cpp.
References fawkes::StringConversions::to_bool().
float fawkes::NavGraph::default_property_as_float | ( | const std::string & | prop | ) | const |
Get property converted to float.
prop | property key |
Definition at line 778 of file navgraph.cpp.
References fawkes::StringConversions::to_float().
Referenced by NavGraphThread::init().
int fawkes::NavGraph::default_property_as_int | ( | const std::string & | prop | ) | const |
Get property converted to int.
prop | property key |
Definition at line 788 of file navgraph.cpp.
References fawkes::StringConversions::to_int().
NavGraphEdge fawkes::NavGraph::edge | ( | const std::string & | from, |
const std::string & | to | ||
) | const |
Get a specified edge.
from | originating node name |
to | target node name |
Definition at line 323 of file navgraph.cpp.
bool fawkes::NavGraph::edge_exists | ( | const NavGraphEdge & | edge | ) | const |
Check if a certain edge exists.
edge | edge to look for (will check for a node with the same originating and target node) |
Definition at line 432 of file navgraph.cpp.
bool fawkes::NavGraph::edge_exists | ( | const std::string & | from, |
const std::string & | to | ||
) | const |
Check if a certain edge exists.
from | originating node name |
to | target node name |
Definition at line 445 of file navgraph.cpp.
const std::vector< NavGraphEdge > & fawkes::NavGraph::edges | ( | ) | const |
Get edges of the graph.
Definition at line 134 of file navgraph.cpp.
Referenced by NavGraphThread::fam_event(), NavGraphVisualizationThread::loop(), NavGraphInteractiveThread::loop(), and fawkes::save_yaml_navgraph().
|
static |
Create node name from a format string.
format | format for the name according to sprintf arguments |
... | parameters according to format |
Definition at line 1434 of file navgraph.cpp.
Referenced by connect_node_to_closest_edge().
std::string fawkes::NavGraph::gen_unique_name | ( | const char * | prefix = "U-" | ) |
Generate a unique node name for the given prefix.
Will simply add a number and tries from 0 to MAXINT. Note that to add a unique name you must protect the navgraph from concurrent modification.
prefix | the node name prefix |
Definition at line 1416 of file navgraph.cpp.
bool fawkes::NavGraph::has_default_property | ( | const std::string & | property | ) | const |
Check if graph has specified default property.
property | property key |
Definition at line 753 of file navgraph.cpp.
Referenced by NavGraphThread::init().
std::string fawkes::NavGraph::name | ( | ) | const |
Get graph name.
Definition at line 114 of file navgraph.cpp.
Referenced by NavGraphInteractiveThread::loop(), fawkes::read_default_properties(), and fawkes::save_yaml_navgraph().
NavGraphNode fawkes::NavGraph::node | ( | const std::string & | name | ) | const |
Get a specified node.
name | name of the node to get |
Definition at line 156 of file navgraph.cpp.
Referenced by fawkes::NavGraphSearchState::is_goal(), NavGraphThread::loop(), and fawkes::EclExternalRCSoftMapGraph::map_graph().
bool fawkes::NavGraph::node_exists | ( | const NavGraphNode & | node | ) | const |
Check if a certain node exists.
node | node to look for (will check for a node with the same name) |
Definition at line 404 of file navgraph.cpp.
bool fawkes::NavGraph::node_exists | ( | const std::string & | name | ) | const |
Check if a certain node exists.
name | name of the node to look for |
Definition at line 417 of file navgraph.cpp.
const std::vector< NavGraphNode > & fawkes::NavGraph::nodes | ( | ) | const |
Get nodes of the graph.
Definition at line 124 of file navgraph.cpp.
Referenced by fawkes::NavGraphGeneratorVoronoi::compute(), NavGraphThread::fam_event(), fawkes::load_yaml_navgraph(), NavGraphVisualizationThread::loop(), NavGraphInteractiveThread::loop(), fawkes::EclExternalRCSoftMapGraph::map_graph(), and fawkes::save_yaml_navgraph().
void fawkes::NavGraph::notify_of_change | ( | ) | ||
throw | ( | |||
) |
Notify all listeners of a change.
Definition at line 1483 of file navgraph.cpp.
Assign/copy structures from another graph.
This method will remove internal data like nodes, and edges and copy the data from the passed instance. The change listeners will not be copied. The assignment operator will trigger all registered change listeners to be called.
g | graph from which to copy the data |
Definition at line 97 of file navgraph.cpp.
std::vector< std::string > fawkes::NavGraph::reachable_nodes | ( | const std::string & | node_name | ) | const |
Get nodes reachable from specified nodes.
node_name | name of the node to get reachable nodes for |
Definition at line 876 of file navgraph.cpp.
References fawkes::NavGraphNode::is_valid().
void fawkes::NavGraph::remove_change_listener | ( | ChangeListener * | listener | ) |
Remove a change listener.
listener | listener to remove |
Definition at line 1461 of file navgraph.cpp.
Referenced by NavGraphThread::finalize().
void fawkes::NavGraph::remove_edge | ( | const NavGraphEdge & | edge | ) |
Remove an edge.
edge | edge to remove |
Definition at line 660 of file navgraph.cpp.
References fawkes::NavGraphEdge::from(), and fawkes::NavGraphEdge::to().
void fawkes::NavGraph::remove_edge | ( | const std::string & | from, |
const std::string & | to | ||
) |
Remove an edge.
from | originating node name |
to | target node name |
Definition at line 677 of file navgraph.cpp.
void fawkes::NavGraph::remove_node | ( | const NavGraphNode & | node | ) |
Remove a node.
node | node to remove |
Definition at line 624 of file navgraph.cpp.
References fawkes::NavGraphNode::name().
void fawkes::NavGraph::remove_node | ( | const std::string & | node_name | ) |
Remove a node.
node_name | name of node to remove |
Definition at line 640 of file navgraph.cpp.
std::vector< NavGraphNode > fawkes::NavGraph::search_nodes | ( | const std::string & | property | ) | const |
Search nodes for given property.
property | property name to look for |
Definition at line 382 of file navgraph.cpp.
Referenced by fawkes::EclExternalRCSoftMapGraph::map_graph().
fawkes::NavGraphPath fawkes::NavGraph::search_path | ( | const std::string & | from, |
const std::string & | to, | ||
bool | use_constraints = true , |
||
bool | compute_constraints = true |
||
) |
Search for a path between two nodes with default distance costs.
This function executes an A* search to find an (optimal) path from node from
to node to
. By default (unless set otherwise, confirm using uses_default_search()), the cost and estimated costs are calculated as the spatial euclidean distance between nodes. The cost is the sum of costs of all edges along the way from one node to another. The estimate is the straight line distance from any given node to the goal node (which is provably admissible).
from | name of node to search from |
to | name of the goal node |
use_constraints | true to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever. |
compute_constraints | if true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes. |
from
to to
. Note that the vector is empty if no path could be found (i.e. there is non or it was prohibited when using constraints. Definition at line 987 of file navgraph.cpp.
Referenced by NavGraphThread::loop().
fawkes::NavGraphPath fawkes::NavGraph::search_path | ( | const std::string & | from, |
const std::string & | to, | ||
navgraph::EstimateFunction | estimate_func, | ||
navgraph::CostFunction | cost_func, | ||
bool | use_constraints = true , |
||
bool | compute_constraints = true |
||
) |
Search for a path between two nodes.
This function executes an A* search to find an (optimal) path from node from
to node to
.
from | name of node to search from |
to | name of the goal node |
estimate_func | function to estimate the cost from any node to the goal. Note that the estimate function must be admissible for optimal A* search. That means that for no query may the calculated estimate be higher than the actual cost. |
cost_func | function to calculate the cost from a node to another adjacent node. Note that the cost function is directly related to the estimate function. For example, the cost can be calculated in terms of distance between nodes, or in time that it takes to travel from one node to the other. The estimate function must match the cost function to be admissible. |
use_constraints | true to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever. |
compute_constraints | if true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes. |
from
to to
. Note that the vector is empty if no path could be found (i.e. there is non or it was prohibited when using constraints. Definition at line 1019 of file navgraph.cpp.
fawkes::NavGraphPath fawkes::NavGraph::search_path | ( | const NavGraphNode & | from, |
const NavGraphNode & | to, | ||
bool | use_constraints = true , |
||
bool | compute_constraints = true |
||
) |
Search for a path between two nodes with default distance costs.
This function executes an A* search to find an (optimal) path from node from
to node to
. By default (unless set otherwise, confirm using uses_default_search()), the cost and estimated costs are calculated as the spatial euclidean distance between nodes. The cost is the sum of costs of all edges along the way from one node to another. The estimate is the straight line distance from any given node to the goal node (which is provably admissible).
from | node to search from |
to | goal node |
use_constraints | true to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever. |
compute_constraints | if true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes. |
from
to to
. Note that the vector is empty if no path could be found (i.e. there is non or it was prohibited when using constraints. Definition at line 959 of file navgraph.cpp.
fawkes::NavGraphPath fawkes::NavGraph::search_path | ( | const NavGraphNode & | from, |
const NavGraphNode & | to, | ||
navgraph::EstimateFunction | estimate_func, | ||
navgraph::CostFunction | cost_func, | ||
bool | use_constraints = true , |
||
bool | compute_constraints = true |
||
) |
Search for a path between two nodes.
This function executes an A* search to find an (optimal) path from node from
to node to
.
from | node to search from |
to | goal node |
estimate_func | function to estimate the cost from any node to the goal. Note that the estimate function must be admissible for optimal A* search. That means that for no query may the calculated estimate be higher than the actual cost. |
cost_func | function to calculate the cost from a node to another adjacent node. Note that the cost function is directly related to the estimate function. For example, the cost can be calculated in terms of distance between nodes, or in time that it takes to travel from one node to the other. The estimate function must match the cost function to be admissible. |
use_constraints | true to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever. |
compute_constraints | if true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes. |
from
to to
. Note that the vector is empty if no path could be found (i.e. there is non or it was prohibited when using constraints. Definition at line 1054 of file navgraph.cpp.
References fawkes::AStar::solve().
void fawkes::NavGraph::set_default_properties | ( | const std::map< std::string, std::string > & | properties | ) |
Set default properties.
This overwrites all existing properties.
properties | map of property name to value as string |
Definition at line 818 of file navgraph.cpp.
Referenced by fawkes::read_default_properties().
void fawkes::NavGraph::set_default_property | ( | const std::string & | property, |
const std::string & | value | ||
) |
Set property.
property | property key |
value | property value |
Definition at line 808 of file navgraph.cpp.
void fawkes::NavGraph::set_default_property | ( | const std::string & | property, |
float | value | ||
) |
Set property.
property | property key |
value | property value |
Definition at line 829 of file navgraph.cpp.
References fawkes::StringConversions::to_string().
void fawkes::NavGraph::set_default_property | ( | const std::string & | property, |
int | value | ||
) |
Set property.
property | property key |
value | property value |
Definition at line 839 of file navgraph.cpp.
References fawkes::StringConversions::to_string().
void fawkes::NavGraph::set_default_property | ( | const std::string & | property, |
bool | value | ||
) |
Set property.
property | property key |
value | property value |
Definition at line 849 of file navgraph.cpp.
void fawkes::NavGraph::set_notifications_enabled | ( | bool | enabled | ) |
Enable or disable notifications.
When performing many operations in a row, processing the individual events can be overwhelming, especially if there are many listeners. Therefore, in such situations notifications should be disabled and later re-enabled, followed by a call to notify_of_change().
enabled | true to enable notifications, false to disable |
Definition at line 1476 of file navgraph.cpp.
void fawkes::NavGraph::set_search_funcs | ( | navgraph::EstimateFunction | estimate_func, |
navgraph::CostFunction | cost_func | ||
) |
Set cost and cost estimation function for searching paths.
Note that this will influence each and every search (unless custom functions are passed for the search). So use with caution. We recommend to encapsulate different search modes as a plugin that can be loaded to enable to new search functions. Make sure to call unset_search_funcs() to restore the defaults. The function points must obviously be valid for the whole lifetime of the NavGraph or until unset.
estimate_func | cost estimation function |
cost_func | actual cost function |
Exception | if search functions have already been set. |
Definition at line 918 of file navgraph.cpp.
void fawkes::NavGraph::unset_search_funcs | ( | ) |
Reset actual and estimated cost function to defaults.
Definition at line 932 of file navgraph.cpp.
References fawkes::NavGraphSearchState::euclidean_cost(), and fawkes::NavGraphSearchState::straight_line_estimate().
void fawkes::NavGraph::update_edge | ( | const NavGraphEdge & | edge | ) |
Update a given edge.
Will search for an edge with the same originating and target node as the given edge and will then call the assignment operator. This is intended to update properties of an edge.
edge | edge to update |
Definition at line 714 of file navgraph.cpp.
References fawkes::NavGraphEdge::from(), and fawkes::NavGraphEdge::to().
void fawkes::NavGraph::update_node | ( | const NavGraphNode & | node | ) |
Update a given node.
Will search for a node with the same name as the given node and will then call the assignment operator. This is intended to update properties of a node.
node | node to update |
Definition at line 696 of file navgraph.cpp.
References fawkes::NavGraphNode::name().
Referenced by fawkes::load_yaml_navgraph().
|
inline |
Check if the default euclidean distance search is used.
Definition at line 189 of file navgraph.h.