Fawkes API  Fawkes Development Version
fawkes::NavGraphNode Class Reference

Topological graph node. More...

#include <>>

Public Member Functions

 NavGraphNode ()
 Constructor for invalid node. More...
 
 NavGraphNode (const std::string &name, float x, float y, std::map< std::string, std::string > properties)
 Constructor. More...
 
 NavGraphNode (const std::string &name, float x, float y)
 Constructor. More...
 
const std::string & name () const
 Get name of node. More...
 
float x () const
 Get X coordinate in global frame. More...
 
float y () const
 Get Y coordinate in global frame. More...
 
bool unconnected () const
 Check if this node shall be unconnected. More...
 
void set_x (float x)
 Set X position. More...
 
void set_y (float y)
 Set Y position. More...
 
void set_name (const std::string &name)
 Set name of node. More...
 
void set_unconnected (bool unconnected)
 Set unconnected state of the node. More...
 
float distance (const NavGraphNode &n)
 Get euclidean distance from this node to another. More...
 
float distance (float x, float y)
 Get euclidean distance from this node to a point. More...
 
const std::map< std::string, std::string > & properties () const
 Get all properties. More...
 
bool has_property (const std::string &property) const
 Check if node has specified property. More...
 
bool is_valid () const
 Check if node is valid, i.e. More...
 
void set_properties (const std::map< std::string, std::string > &properties)
 Overwrite properties with given ones. More...
 
void set_property (const std::string &property, const std::string &value)
 Set property. More...
 
void set_property (const std::string &property, float value)
 Set property. More...
 
void set_property (const std::string &property, int value)
 Set property. More...
 
void set_property (const std::string &property, bool value)
 Set property. More...
 
std::string property (const std::string &prop) const
 Get specified property as string. More...
 
float property_as_float (const std::string &prop) const
 Get property converted to float. More...
 
int property_as_int (const std::string &prop) const
 Get property converted to int. More...
 
bool property_as_bool (const std::string &prop) const
 Get property converted to bol. More...
 
bool operator== (const NavGraphNode &n) const
 Check nodes for equality. More...
 
bool operator!= (const NavGraphNode &n) const
 Check nodes for inequality. More...
 
 operator bool () const
 Check if node is valid. More...
 
void set_reachable_nodes (std::vector< std::string > reachable_nodes)
 Set directly reachable nodes of node. More...
 
const std::vector< std::string > & reachable_nodes () const
 Get reachable nodes. More...
 

Detailed Description

Topological graph node.

Author
Tim Niemueller

Definition at line 38 of file navgraph_node.h.

Constructor & Destructor Documentation

◆ NavGraphNode() [1/3]

fawkes::NavGraphNode::NavGraphNode ( )

Constructor for invalid node.

Definition at line 36 of file navgraph_node.cpp.

◆ NavGraphNode() [2/3]

fawkes::NavGraphNode::NavGraphNode ( const std::string &  name,
float  x,
float  y,
std::map< std::string, std::string >  properties 
)

Constructor.

Parameters
namename of the node
xx coordinate in global frame of node
yy coordinate in global frame of node
propertiesproperties for the new node

Definition at line 48 of file navgraph_node.cpp.

References name(), properties(), x(), and y().

◆ NavGraphNode() [3/3]

fawkes::NavGraphNode::NavGraphNode ( const std::string &  name,
float  x,
float  y 
)

Constructor.

Parameters
namename of the node
xx coordinate in global frame of node
yy coordinate in global frame of node

Definition at line 64 of file navgraph_node.cpp.

References name(), x(), and y().

Member Function Documentation

◆ distance() [1/2]

float fawkes::NavGraphNode::distance ( const NavGraphNode n)
inline

Get euclidean distance from this node to another.

Parameters
nnode to get distance to
Returns
distance

Definition at line 75 of file navgraph_node.h.

Referenced by fawkes::NavGraph::connect_node_to_closest_edge().

◆ distance() [2/2]

float fawkes::NavGraphNode::distance ( float  x,
float  y 
)
inline

Get euclidean distance from this node to a point.

Parameters
xpoint X coordinate
ypoint Y coordinate
Returns
distance

Definition at line 82 of file navgraph_node.h.

◆ has_property()

bool fawkes::NavGraphNode::has_property ( const std::string &  property) const
inline

Check if node has specified property.

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

Definition at line 95 of file navgraph_node.h.

Referenced by fawkes::NavGraph::apply_default_properties(), NavGraphVisualizationThread::loop(), NavGraphThread::loop(), NavGraphInteractiveThread::loop(), and fawkes::EclExternalRCSoftMapGraph::map_graph().

◆ is_valid()

bool fawkes::NavGraphNode::is_valid ( ) const
inline

Check if node is valid, i.e.

it has a name.

Returns
true if node is valid, false otherwise

Definition at line 101 of file navgraph_node.h.

References property(), set_properties(), and set_property().

Referenced by NavGraphThread::loop(), and fawkes::NavGraph::reachable_nodes().

◆ name()

◆ operator bool()

fawkes::NavGraphNode::operator bool ( ) const
inline

Check if node is valid.

A node is valid if it has a name set.

Returns
true if the node is valid, false otherwise

Definition at line 153 of file navgraph_node.h.

References reachable_nodes(), and set_reachable_nodes().

◆ operator!=()

bool fawkes::NavGraphNode::operator!= ( const NavGraphNode n) const
inline

Check nodes for inequality.

Nodes are inequal if they have different names.

Parameters
nnode to compare with
Returns
true if the node is different from this one, false otherwise

Definition at line 146 of file navgraph_node.h.

◆ operator==()

bool fawkes::NavGraphNode::operator== ( const NavGraphNode n) const
inline

Check nodes for equality.

Nodes are equal if they have the same name.

Parameters
nnode to compare with
Returns
true if the node is the same as this one, false otherwise

Definition at line 138 of file navgraph_node.h.

◆ properties()

const std::map<std::string, std::string>& fawkes::NavGraphNode::properties ( ) const
inline

Get all properties.

Returns
property map

Definition at line 88 of file navgraph_node.h.

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

◆ property()

std::string fawkes::NavGraphNode::property ( const std::string &  prop) const

Get specified property as string.

Parameters
propproperty key
Returns
property value as string

Definition at line 122 of file navgraph_node.cpp.

Referenced by is_valid(), property_as_bool(), property_as_float(), property_as_int(), and set_property().

◆ property_as_bool()

bool fawkes::NavGraphNode::property_as_bool ( const std::string &  prop) const
inline

Get property converted to bol.

Parameters
propproperty key
Returns
property value

Definition at line 130 of file navgraph_node.h.

References property(), and fawkes::StringConversions::to_bool().

◆ property_as_float()

float fawkes::NavGraphNode::property_as_float ( const std::string &  prop) const
inline

Get property converted to float.

Parameters
propproperty key
Returns
property value

Definition at line 116 of file navgraph_node.h.

References property(), and fawkes::StringConversions::to_float().

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

◆ property_as_int()

int fawkes::NavGraphNode::property_as_int ( const std::string &  prop) const
inline

Get property converted to int.

Parameters
propproperty key
Returns
property value

Definition at line 123 of file navgraph_node.h.

References property(), and fawkes::StringConversions::to_int().

◆ reachable_nodes()

const std::vector<std::string>& fawkes::NavGraphNode::reachable_nodes ( ) const
inline

◆ set_name()

void fawkes::NavGraphNode::set_name ( const std::string &  name)

Set name of node.

Parameters
namenew name for node

Definition at line 96 of file navgraph_node.cpp.

References name().

Referenced by fawkes::operator>>(), and unconnected().

◆ set_properties()

void fawkes::NavGraphNode::set_properties ( const std::map< std::string, std::string > &  properties)

Overwrite properties with given ones.

Parameters
propertiesmap of properties to set

Definition at line 137 of file navgraph_node.cpp.

References properties().

Referenced by is_valid().

◆ set_property() [1/4]

void fawkes::NavGraphNode::set_property ( const std::string &  property,
const std::string &  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 148 of file navgraph_node.cpp.

References property().

Referenced by fawkes::NavGraph::apply_default_properties(), is_valid(), NavGraphThread::loop(), fawkes::operator>>(), and NavGraphInteractiveThread::~NavGraphInteractiveThread().

◆ set_property() [2/4]

void fawkes::NavGraphNode::set_property ( const std::string &  property,
float  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 159 of file navgraph_node.cpp.

References property(), and fawkes::StringConversions::to_string().

◆ set_property() [3/4]

void fawkes::NavGraphNode::set_property ( const std::string &  property,
int  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 169 of file navgraph_node.cpp.

References property(), and fawkes::StringConversions::to_string().

◆ set_property() [4/4]

void fawkes::NavGraphNode::set_property ( const std::string &  property,
bool  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 179 of file navgraph_node.cpp.

References property().

◆ set_reachable_nodes()

void fawkes::NavGraphNode::set_reachable_nodes ( std::vector< std::string >  reachable_nodes)

Set directly reachable nodes of node.

Parameters
reachable_nodesvector of directly reachable nodes

Definition at line 189 of file navgraph_node.cpp.

References reachable_nodes().

Referenced by operator bool().

◆ set_unconnected()

void fawkes::NavGraphNode::set_unconnected ( bool  unconnected)

Set unconnected state of the node.

A node must be marked as unconnected explicitly or otherwise it is an error that the graph will report as an error. On other hand, unconnected nodes may not have any connection. By default nodes are expected to have at least one connection (behaving as though this function had been called with "false").

Parameters
unconnectedtrue to make this node a unconnected node, false otherwise

Definition at line 111 of file navgraph_node.cpp.

References unconnected().

Referenced by fawkes::load_yaml_navgraph(), NavGraphGeneratorThread::loop(), fawkes::operator>>(), and unconnected().

◆ set_x()

void fawkes::NavGraphNode::set_x ( float  x)

Set X position.

Parameters
xX coordinate in global frame for node.

Definition at line 77 of file navgraph_node.cpp.

References x().

Referenced by fawkes::operator>>(), unconnected(), and NavGraphInteractiveThread::~NavGraphInteractiveThread().

◆ set_y()

void fawkes::NavGraphNode::set_y ( float  y)

Set Y position.

Parameters
yY coordinate in global frame for node.

Definition at line 86 of file navgraph_node.cpp.

References y().

Referenced by fawkes::operator>>(), unconnected(), and NavGraphInteractiveThread::~NavGraphInteractiveThread().

◆ unconnected()

bool fawkes::NavGraphNode::unconnected ( ) const
inline

Check if this node shall be unconnected.

Returns
true if the node is unconnected, false otherwise

Definition at line 64 of file navgraph_node.h.

References set_name(), set_unconnected(), set_x(), and set_y().

Referenced by fawkes::NavGraph::cost(), and set_unconnected().

◆ x()

◆ y()


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