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... | |
NavGraph (const NavGraph &g) | |
Copy 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_orphan_nodes () |
Remove orphan nodes. 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 () noexcept |
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 49 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 53 of file navgraph.h.
Mode to use to add edges.
Definition at line 61 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 65 of file navgraph.cpp.
References fawkes::NavGraphSearchState::euclidean_cost(), and fawkes::NavGraphSearchState::straight_line_estimate().
fawkes::NavGraph::NavGraph | ( | const NavGraph & | g | ) |
Copy constructor.
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 84 of file navgraph.cpp.
|
virtual |
Virtual empty destructor.
Definition at line 94 of file navgraph.cpp.
void fawkes::NavGraph::add_change_listener | ( | ChangeListener * | listener | ) |
Add a change listener.
listener | listener to add |
Definition at line 1475 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 584 of file navgraph.cpp.
References edge(), edge_exists(), EDGE_FORCE, EDGE_NO_INTERSECTION, EDGE_SPLIT_INTERSECTION, fawkes::NavGraphEdge::from(), node(), notify_of_change(), and fawkes::NavGraphEdge::to().
Referenced by fawkes::NavGraphGeneratorGrid::compute(), fawkes::NavGraphGeneratorVoronoi::compute(), connect_node_to_closest_edge(), connect_node_to_closest_node(), 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 460 of file navgraph.cpp.
References apply_default_properties(), fawkes::NavGraphNode::name(), node(), node_exists(), and notify_of_change().
Referenced by add_node_and_connect(), fawkes::NavGraphGeneratorGrid::compute(), fawkes::NavGraphGeneratorVoronoi::compute(), connect_node_to_closest_edge(), 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 499 of file navgraph.cpp.
References add_node(), CLOSEST_EDGE, CLOSEST_EDGE_OR_NODE, CLOSEST_NODE, connect_node_to_closest_edge(), connect_node_to_closest_node(), and node().
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 875 of file navgraph.cpp.
References fawkes::NavGraphNode::has_property(), node(), and fawkes::NavGraphNode::set_property().
Referenced by add_node().
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 1410 of file navgraph.cpp.
References node(), and reachable_nodes().
Referenced by fawkes::NavGraphGeneratorVoronoi::compute(), fawkes::load_yaml_navgraph(), and search_path().
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 747 of file navgraph.cpp.
References notify_of_change().
Referenced by FawkesRemotePlexilAdapter::fam_event().
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 353 of file navgraph.cpp.
References fawkes::distance(), edge(), fawkes::NavGraphEdge::from_node(), fawkes::NavGraphEdge::to_node(), fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().
Referenced by connect_node_to_closest_edge().
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 248 of file navgraph.cpp.
References nodes(), and search_nodes().
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 186 of file navgraph.cpp.
References closest_node().
Referenced by closest_node(), closest_node_with_unconnected(), and connect_node_to_closest_edge().
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 290 of file navgraph.cpp.
References node(), nodes(), search_nodes(), fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().
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 216 of file navgraph.cpp.
References closest_node_to().
Referenced by closest_node_to(), closest_node_to_with_unconnected(), and connect_node_to_closest_node().
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 231 of file navgraph.cpp.
References closest_node_to().
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 201 of file navgraph.cpp.
References closest_node().
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 532 of file navgraph.cpp.
References add_edge(), add_node(), closest_edge(), closest_node(), fawkes::NavGraphEdge::closest_point_on_edge(), fawkes::NavGraphNode::distance(), EDGE_SPLIT_INTERSECTION, format_name(), fawkes::NavGraphEdge::from(), fawkes::NavGraphNode::name(), node_exists(), fawkes::NavGraphEdge::properties(), remove_edge(), fawkes::NavGraphEdge::set_properties(), fawkes::NavGraphEdge::set_property(), fawkes::NavGraphEdge::to(), fawkes::NavGraphNode::x(), fawkes::cart_coord_2d_struct::x, fawkes::NavGraphNode::y(), and fawkes::cart_coord_2d_struct::y.
Referenced by add_node_and_connect(), and 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 519 of file navgraph.cpp.
References add_edge(), closest_node_to(), EDGE_SPLIT_INTERSECTION, fawkes::NavGraphNode::name(), and fawkes::NavGraphEdge::set_property().
Referenced by add_node_and_connect(), and fawkes::load_yaml_navgraph().
fawkes::LockPtr< NavGraphConstraintRepo > fawkes::NavGraph::constraint_repo | ( | ) | const |
Get locked pointer to constraint repository.
Definition at line 152 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 1123 of file navgraph.cpp.
Referenced by search_path().
const std::map< std::string, std::string > & fawkes::NavGraph::default_properties | ( | ) | const |
Get all default properties.
Definition at line 759 of file navgraph.cpp.
Referenced by 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 779 of file navgraph.cpp.
Referenced by default_property_as_bool(), default_property_as_float(), and default_property_as_int().
bool fawkes::NavGraph::default_property_as_bool | ( | const std::string & | prop | ) | const |
Get property converted to bol.
prop | property key |
Definition at line 814 of file navgraph.cpp.
References default_property(), and 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 794 of file navgraph.cpp.
References default_property(), and 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 804 of file navgraph.cpp.
References default_property(), and 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 329 of file navgraph.cpp.
References edge().
Referenced by add_edge(), closest_edge(), edge(), edge_exists(), remove_edge(), remove_node(), and update_edge().
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 433 of file navgraph.cpp.
References edge().
Referenced by add_edge().
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 142 of file navgraph.cpp.
Referenced by fawkes::NavGraphGeneratorGrid::compute(), 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 1457 of file navgraph.cpp.
Referenced by connect_node_to_closest_edge(), and gen_unique_name().
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 1440 of file navgraph.cpp.
References format_name(), name(), and node().
bool fawkes::NavGraph::has_default_property | ( | const std::string & | property | ) | const |
Check if graph has specified default property.
property | property key |
Definition at line 769 of file navgraph.cpp.
Referenced by NavGraphThread::init().
std::string fawkes::NavGraph::name | ( | ) | const |
Get graph name.
Definition at line 124 of file navgraph.cpp.
Referenced by gen_unique_name(), node(), node_exists(), 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 163 of file navgraph.cpp.
References name(), and node().
Referenced by add_edge(), add_node(), add_node_and_connect(), apply_default_properties(), calc_reachability(), closest_node_to(), gen_unique_name(), node(), node_exists(), reachable_nodes(), remove_node(), search_path(), and update_node().
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 408 of file navgraph.cpp.
References node().
Referenced by add_node(), and connect_node_to_closest_edge().
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 419 of file navgraph.cpp.
const std::vector< NavGraphNode > & fawkes::NavGraph::nodes | ( | ) | const |
Get nodes of the graph.
Definition at line 133 of file navgraph.cpp.
Referenced by closest_node(), closest_node_to(), fawkes::NavGraphGeneratorVoronoi::compute(), fawkes::load_yaml_navgraph(), fawkes::save_yaml_navgraph(), and search_nodes().
|
noexcept |
Notify all listeners of a change.
Definition at line 1505 of file navgraph.cpp.
Referenced by add_edge(), add_node(), clear(), FawkesRemotePlexilAdapter::fam_event(), operator=(), remove_edge(), and remove_node().
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 107 of file navgraph.cpp.
References notify_of_change().
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 889 of file navgraph.cpp.
References fawkes::NavGraphNode::is_valid(), and node().
Referenced by calc_reachability().
void fawkes::NavGraph::remove_change_listener | ( | ChangeListener * | listener | ) |
Remove a change listener.
listener | listener to remove |
Definition at line 1484 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 677 of file navgraph.cpp.
References edge(), and notify_of_change().
Referenced by connect_node_to_closest_edge().
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 696 of file navgraph.cpp.
References edge(), and notify_of_change().
void fawkes::NavGraph::remove_node | ( | const NavGraphNode & | node | ) |
Remove a node.
node | node to remove |
Definition at line 612 of file navgraph.cpp.
References edge(), node(), and notify_of_change().
Referenced by remove_orphan_nodes().
void fawkes::NavGraph::remove_node | ( | const std::string & | node_name | ) |
Remove a node.
node_name | name of node to remove |
Definition at line 629 of file navgraph.cpp.
References edge(), node(), and notify_of_change().
void fawkes::NavGraph::remove_orphan_nodes | ( | ) |
Remove orphan nodes.
Remove nodes which are neither marked unconnected nor participate on any edge.
Definition at line 652 of file navgraph.cpp.
References remove_node().
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 386 of file navgraph.cpp.
References nodes().
Referenced by closest_node(), and closest_node_to().
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 971 of file navgraph.cpp.
References search_path().
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 1070 of file navgraph.cpp.
References calc_reachability(), cost(), fawkes::NavGraphSearchState::node(), and fawkes::AStar::solve().
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 1000 of file navgraph.cpp.
References search_path().
Referenced by search_path().
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 1033 of file navgraph.cpp.
References node(), and search_path().
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 834 of file navgraph.cpp.
Referenced by fawkes::read_default_properties().
void fawkes::NavGraph::set_default_property | ( | const std::string & | property, |
bool | value | ||
) |
Set property.
property | property key |
value | property value |
Definition at line 864 of file navgraph.cpp.
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 824 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 844 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 854 of file navgraph.cpp.
References fawkes::StringConversions::to_string().
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 1498 of file navgraph.cpp.
Referenced by FawkesRemotePlexilAdapter::fam_event().
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 931 of file navgraph.cpp.
void fawkes::NavGraph::unset_search_funcs | ( | ) |
Reset actual and estimated cost function to defaults.
Definition at line 944 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 733 of file navgraph.cpp.
References edge(), 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 716 of file navgraph.cpp.
References fawkes::NavGraphNode::name(), and node().
Referenced by fawkes::load_yaml_navgraph().
|
inline |
Check if the default euclidean distance search is used.
Definition at line 193 of file navgraph.h.