Fawkes API  Fawkes Development Version
fawkes::NavGraph Class Reference

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< NavGraphConstraintRepoconstraint_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< NavGraphNodesearch_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...
 
NavGraphoperator= (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...
 

Detailed Description

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.

Author
Tim Niemueller

Definition at line 57 of file navgraph.h.

Member Enumeration Documentation

◆ ConnectionMode

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.

◆ EdgeMode

Mode to use to add edges.

Enumerator
EDGE_FORCE 

add nodes no matter what (be careful)

EDGE_NO_INTERSECTION 

Only add edge if it does not intersect with any existing edge.

EDGE_SPLIT_INTERSECTION 

Add the edge, but if it intersects with an existing edges add new points at the intersection points for both, the conflicting edges and the new edge.

Definition at line 69 of file navgraph.h.

Constructor & Destructor Documentation

◆ NavGraph()

fawkes::NavGraph::NavGraph ( const std::string &  graph_name)

Constructor.

Parameters
graph_nameName 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().

◆ ~NavGraph()

fawkes::NavGraph::~NavGraph ( )
virtual

Virtual empty destructor.

Definition at line 83 of file navgraph.cpp.

Member Function Documentation

◆ add_change_listener()

void fawkes::NavGraph::add_change_listener ( ChangeListener listener)

Add a change listener.

Parameters
listenerlistener to add

Definition at line 1452 of file navgraph.cpp.

Referenced by NavGraphThread::init().

◆ add_edge()

void fawkes::NavGraph::add_edge ( const NavGraphEdge edge,
NavGraph::EdgeMode  mode = EDGE_NO_INTERSECTION,
bool  allow_existing = false 
)

Add an edge.

Parameters
edgeedge to add
modeedge add mode
allow_existingif 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.
Exceptions
Exceptionthrown 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().

◆ add_node()

void fawkes::NavGraph::add_node ( const NavGraphNode node)

Add a node.

Parameters
nodenode to add
Exceptions
Exceptionthrown 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().

◆ add_node_and_connect()

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.

Parameters
nodenode to add
conn_modeconnection mode to use

Definition at line 500 of file navgraph.cpp.

◆ apply_default_properties()

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.

Parameters
nodenode 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().

◆ calc_reachability()

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.

Parameters
allow_multi_graphif true, allows multiple disconnected graph segments.

Definition at line 1387 of file navgraph.cpp.

Referenced by fawkes::NavGraphGeneratorVoronoi::compute(), and fawkes::load_yaml_navgraph().

◆ clear()

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.

◆ closest_edge()

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.

Parameters
pos_xX coordinate in global (map) frame of point
pos_yX coordinate in global (map) frame of point
Returns
edge closest to the given point, or invalid edge if such an edge does not exist.

Definition at line 349 of file navgraph.cpp.

References fawkes::distance().

◆ closest_node() [1/2]

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.

Parameters
pos_xX coordinate in global (map) frame
pos_yX coordinate in global (map) frame
propertyproperty the node must have to be considered, empty string to not check for any property
Returns
node closest to the given point in the global frame, or an invalid node if such a node cannot be found

Definition at line 181 of file navgraph.cpp.

Referenced by NavGraphThread::loop(), and fawkes::EclExternalRCSoftMapGraph::map_graph().

◆ closest_node() [2/2]

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.

Parameters
pos_xX coordinate in global (map) frame
pos_yX coordinate in global (map) frame
consider_unconnectedconsider unconnected node for the search of the closest node
propertyproperty the node must have to be considered, empty string to not check for any property
Returns
node closest to the given point in the global frame, or an invalid node if such a node cannot be found

Definition at line 246 of file navgraph.cpp.

◆ closest_node_to() [1/2]

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.

Parameters
node_namethe name of the node from which to start
propertyproperty the node must have to be considered, empty string to not check for any property
Returns
node closest to the given point in the global frame, or an invalid node if such a node cannot be found. The node will obviously not be the node with the name node_name.

Definition at line 213 of file navgraph.cpp.

◆ closest_node_to() [2/2]

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.

Parameters
node_namethe name of the node from which to start
consider_unconnectedconsider unconnected node for the search of the closest node
propertyproperty the node must have to be considered, empty string to not check for any property
Returns
node closest to the given point in the global frame, or an invalid node if such a node cannot be found. The node will obviously not be the node with the name node_name.

Definition at line 285 of file navgraph.cpp.

References fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().

◆ closest_node_to_with_unconnected()

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.

Parameters
node_namethe name of the node from which to start
propertyproperty the node must have to be considered, empty string to not check for any property
Returns
node closest to the given point in the global frame, or an invalid node if such a node cannot be found. The node will obviously not be the node with the name node_name.

Definition at line 229 of file navgraph.cpp.

◆ closest_node_with_unconnected()

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.

Parameters
pos_xX coordinate in global (map) frame
pos_yX coordinate in global (map) frame
propertyproperty the node must have to be considered, empty string to not check for any property
Returns
node closest to the given point in the global frame, or an invalid node if such a node cannot be found

Definition at line 197 of file navgraph.cpp.

◆ connect_node_to_closest_edge()

◆ connect_node_to_closest_node()

void fawkes::NavGraph::connect_node_to_closest_node ( const NavGraphNode n)

Connect node to closest node.

Parameters
nnode 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().

◆ constraint_repo()

fawkes::LockPtr< NavGraphConstraintRepo > fawkes::NavGraph::constraint_repo ( ) const

Get locked pointer to constraint repository.

Returns
locked pointer to navgraph constraint repo. Note that you must lock it when invoking operations on the repo.

Definition at line 145 of file navgraph.cpp.

Referenced by NavGraphThread::init().

◆ cost()

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.

Parameters
fromfirst node
tosecond node
Returns
cost from 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().

◆ default_properties()

const std::map< std::string, std::string > & fawkes::NavGraph::default_properties ( ) const

Get all default properties.

Returns
property map

Definition at line 743 of file navgraph.cpp.

Referenced by NavGraphVisualizationThread::loop(), and fawkes::save_yaml_navgraph().

◆ default_property()

std::string fawkes::NavGraph::default_property ( const std::string &  prop) const

Get specified default property as string.

Parameters
propproperty key
Returns
default property value as string

Definition at line 763 of file navgraph.cpp.

◆ default_property_as_bool()

bool fawkes::NavGraph::default_property_as_bool ( const std::string &  prop) const

Get property converted to bol.

Parameters
propproperty key
Returns
property value

Definition at line 798 of file navgraph.cpp.

References fawkes::StringConversions::to_bool().

◆ default_property_as_float()

float fawkes::NavGraph::default_property_as_float ( const std::string &  prop) const

Get property converted to float.

Parameters
propproperty key
Returns
property value

Definition at line 778 of file navgraph.cpp.

References fawkes::StringConversions::to_float().

Referenced by NavGraphThread::init().

◆ default_property_as_int()

int fawkes::NavGraph::default_property_as_int ( const std::string &  prop) const

Get property converted to int.

Parameters
propproperty key
Returns
property value

Definition at line 788 of file navgraph.cpp.

References fawkes::StringConversions::to_int().

◆ edge()

NavGraphEdge fawkes::NavGraph::edge ( const std::string &  from,
const std::string &  to 
) const

Get a specified edge.

Parameters
fromoriginating node name
totarget node name
Returns
the edge representation for the edge with the given originating and target nodes or an invalid edge if the edge cannot be found

Definition at line 323 of file navgraph.cpp.

◆ edge_exists() [1/2]

bool fawkes::NavGraph::edge_exists ( const NavGraphEdge edge) const

Check if a certain edge exists.

Parameters
edgeedge to look for (will check for a node with the same originating and target node)
Returns
true if an edge with the same originating and target node exists, false otherwise

Definition at line 432 of file navgraph.cpp.

◆ edge_exists() [2/2]

bool fawkes::NavGraph::edge_exists ( const std::string &  from,
const std::string &  to 
) const

Check if a certain edge exists.

Parameters
fromoriginating node name
totarget node name
Returns
true if an edge with the same originating and target node exists, false otherwise

Definition at line 445 of file navgraph.cpp.

◆ edges()

const std::vector< NavGraphEdge > & fawkes::NavGraph::edges ( ) const

Get edges of the graph.

Returns
const reference to vector of edges of this graph

Definition at line 134 of file navgraph.cpp.

Referenced by NavGraphThread::fam_event(), NavGraphVisualizationThread::loop(), NavGraphInteractiveThread::loop(), and fawkes::save_yaml_navgraph().

◆ format_name()

std::string fawkes::NavGraph::format_name ( const char *  format,
  ... 
)
static

Create node name from a format string.

Parameters
formatformat for the name according to sprintf arguments
...parameters according to format
Returns
generated name

Definition at line 1434 of file navgraph.cpp.

Referenced by connect_node_to_closest_edge().

◆ 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.

Parameters
prefixthe node name prefix
Returns
unique node name

Definition at line 1416 of file navgraph.cpp.

◆ has_default_property()

bool fawkes::NavGraph::has_default_property ( const std::string &  property) const

Check if graph has specified default property.

Parameters
propertyproperty key
Returns
true if node has specified property, false otherwise

Definition at line 753 of file navgraph.cpp.

Referenced by NavGraphThread::init().

◆ name()

std::string fawkes::NavGraph::name ( ) const

Get graph name.

Returns
graph name

Definition at line 114 of file navgraph.cpp.

Referenced by NavGraphInteractiveThread::loop(), fawkes::read_default_properties(), and fawkes::save_yaml_navgraph().

◆ node()

NavGraphNode fawkes::NavGraph::node ( const std::string &  name) const

Get a specified node.

Parameters
namename of the node to get
Returns
the node representation of the searched node, if not found returns an invalid node.

Definition at line 156 of file navgraph.cpp.

Referenced by fawkes::NavGraphSearchState::is_goal(), NavGraphThread::loop(), and fawkes::EclExternalRCSoftMapGraph::map_graph().

◆ node_exists() [1/2]

bool fawkes::NavGraph::node_exists ( const NavGraphNode node) const

Check if a certain node exists.

Parameters
nodenode to look for (will check for a node with the same name)
Returns
true if a node with the same name as the given node exists, false otherwise

Definition at line 404 of file navgraph.cpp.

◆ node_exists() [2/2]

bool fawkes::NavGraph::node_exists ( const std::string &  name) const

Check if a certain node exists.

Parameters
namename of the node to look for
Returns
true if a node with the given name exists, false otherwise

Definition at line 417 of file navgraph.cpp.

◆ nodes()

const std::vector< NavGraphNode > & fawkes::NavGraph::nodes ( ) const

◆ notify_of_change()

void fawkes::NavGraph::notify_of_change ( )
throw (
)

Notify all listeners of a change.

Definition at line 1483 of file navgraph.cpp.

◆ operator=()

NavGraph & fawkes::NavGraph::operator= ( const NavGraph g)

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.

Parameters
ggraph from which to copy the data
Returns
reference to this instance

Definition at line 97 of file navgraph.cpp.

◆ reachable_nodes()

std::vector< std::string > fawkes::NavGraph::reachable_nodes ( const std::string &  node_name) const

Get nodes reachable from specified nodes.

Parameters
node_namename of the node to get reachable nodes for
Returns
vector of names of nodes reachable from the specified node

Definition at line 876 of file navgraph.cpp.

References fawkes::NavGraphNode::is_valid().

◆ remove_change_listener()

void fawkes::NavGraph::remove_change_listener ( ChangeListener listener)

Remove a change listener.

Parameters
listenerlistener to remove

Definition at line 1461 of file navgraph.cpp.

Referenced by NavGraphThread::finalize().

◆ remove_edge() [1/2]

void fawkes::NavGraph::remove_edge ( const NavGraphEdge edge)

Remove an edge.

Parameters
edgeedge to remove

Definition at line 660 of file navgraph.cpp.

References fawkes::NavGraphEdge::from(), and fawkes::NavGraphEdge::to().

◆ remove_edge() [2/2]

void fawkes::NavGraph::remove_edge ( const std::string &  from,
const std::string &  to 
)

Remove an edge.

Parameters
fromoriginating node name
totarget node name

Definition at line 677 of file navgraph.cpp.

◆ remove_node() [1/2]

void fawkes::NavGraph::remove_node ( const NavGraphNode node)

Remove a node.

Parameters
nodenode to remove

Definition at line 624 of file navgraph.cpp.

References fawkes::NavGraphNode::name().

◆ remove_node() [2/2]

void fawkes::NavGraph::remove_node ( const std::string &  node_name)

Remove a node.

Parameters
node_namename of node to remove

Definition at line 640 of file navgraph.cpp.

◆ search_nodes()

std::vector< NavGraphNode > fawkes::NavGraph::search_nodes ( const std::string &  property) const

Search nodes for given property.

Parameters
propertyproperty name to look for
Returns
vector of nodes having the specified property

Definition at line 382 of file navgraph.cpp.

Referenced by fawkes::EclExternalRCSoftMapGraph::map_graph().

◆ search_path() [1/4]

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).

Parameters
fromname of node to search from
toname of the goal node
use_constraintstrue to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever.
compute_constraintsif true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes.
Returns
ordered vector of nodes which denote a path from 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().

◆ search_path() [2/4]

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.

Parameters
fromname of node to search from
toname of the goal node
estimate_funcfunction 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_funcfunction 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_constraintstrue to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever.
compute_constraintsif true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes.
Returns
ordered vector of nodes which denote a path from 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.

◆ search_path() [3/4]

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).

Parameters
fromnode to search from
togoal node
use_constraintstrue to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever.
compute_constraintsif true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes.
Returns
ordered vector of nodes which denote a path from 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.

◆ search_path() [4/4]

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.

Parameters
fromnode to search from
togoal node
estimate_funcfunction 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_funcfunction 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_constraintstrue to respect constraints imposed by the constraint repository, false to ignore the repository searching as if there were no constraints whatsoever.
compute_constraintsif true re-compute constraints, otherwise use constraints as-is, for example if they have been computed before to check for changes.
Returns
ordered vector of nodes which denote a path from 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().

◆ set_default_properties()

void fawkes::NavGraph::set_default_properties ( const std::map< std::string, std::string > &  properties)

Set default properties.

This overwrites all existing properties.

Parameters
propertiesmap of property name to value as string

Definition at line 818 of file navgraph.cpp.

Referenced by fawkes::read_default_properties().

◆ set_default_property() [1/4]

void fawkes::NavGraph::set_default_property ( const std::string &  property,
const std::string &  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 808 of file navgraph.cpp.

◆ set_default_property() [2/4]

void fawkes::NavGraph::set_default_property ( const std::string &  property,
float  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 829 of file navgraph.cpp.

References fawkes::StringConversions::to_string().

◆ set_default_property() [3/4]

void fawkes::NavGraph::set_default_property ( const std::string &  property,
int  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 839 of file navgraph.cpp.

References fawkes::StringConversions::to_string().

◆ set_default_property() [4/4]

void fawkes::NavGraph::set_default_property ( const std::string &  property,
bool  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 849 of file navgraph.cpp.

◆ set_notifications_enabled()

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().

Parameters
enabledtrue to enable notifications, false to disable

Definition at line 1476 of file navgraph.cpp.

◆ set_search_funcs()

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.

Parameters
estimate_funccost estimation function
cost_funcactual cost function
See also
NavGraph::search_path
Exceptions
Exceptionif search functions have already been set.

Definition at line 918 of file navgraph.cpp.

◆ unset_search_funcs()

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().

◆ update_edge()

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.

Parameters
edgeedge to update

Definition at line 714 of file navgraph.cpp.

References fawkes::NavGraphEdge::from(), and fawkes::NavGraphEdge::to().

◆ update_node()

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.

Parameters
nodenode to update

Definition at line 696 of file navgraph.cpp.

References fawkes::NavGraphNode::name().

Referenced by fawkes::load_yaml_navgraph().

◆ uses_default_search()

bool fawkes::NavGraph::uses_default_search ( ) const
inline

Check if the default euclidean distance search is used.

Returns
true if the default cost and cost estimation functions are used, false of custom ones have been set.

Definition at line 189 of file navgraph.h.


The documentation for this class was generated from the following files: