Fawkes API  Fawkes Development Version
fawkes::NavGraphConstraintRepo Class Reference

Constraint repository to maintain blocks on nodes. More...

#include <>>

Public Types

typedef std::vector< fawkes::NavGraphNodeConstraint * > NodeConstraintList
 List of navgraph node constraints. More...
 
typedef std::vector< fawkes::NavGraphEdgeConstraint * > EdgeConstraintList
 List of navgraph edge constraints. More...
 
typedef std::vector< fawkes::NavGraphEdgeCostConstraint * > EdgeCostConstraintList
 List of navgraph edge cost constraints. More...
 

Public Member Functions

 NavGraphConstraintRepo ()
 Constructor. More...
 
 ~NavGraphConstraintRepo ()
 Destructor. More...
 
void register_constraint (NavGraphNodeConstraint *constraint)
 Register a constraint. More...
 
void register_constraint (NavGraphEdgeConstraint *constraint)
 Register a constraint. More...
 
void register_constraint (NavGraphEdgeCostConstraint *constraint)
 Register an edge cost constraint. More...
 
void unregister_constraint (std::string name)
 Unregister a constraint by name. More...
 
bool has_constraint (std::string &name)
 Check by name if a constraint has been registered. More...
 
fawkes::NavGraphNodeConstraintget_node_constraint (std::string &name)
 Get a node constraint by name. More...
 
fawkes::NavGraphEdgeConstraintget_edge_constraint (std::string &name)
 Get an edge constraint by name. More...
 
fawkes::NavGraphEdgeCostConstraintget_edge_cost_constraint (std::string &name)
 Get an edge cost constraint by name. More...
 
const NodeConstraintListnode_constraints () const
 Get a list of registered node constraints. More...
 
const EdgeConstraintListedge_constraints () const
 Get a list of registered edge constraints. More...
 
const EdgeCostConstraintListedge_cost_constraints () const
 Get a list of registered edge cost constraints. More...
 
bool has_constraints () const
 Check if there are any constraints at all. More...
 
bool compute ()
 Call compute method on all registered constraints. More...
 
NavGraphNodeConstraintblocks (const fawkes::NavGraphNode &node)
 Check if any constraint in the repo blocks the node. More...
 
NavGraphEdgeConstraintblocks (const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
 Check if any constraint in the repo blocks the edge. More...
 
NavGraphEdgeCostConstraintincreases_cost (const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
 Check if any constraint in the repo increases the cost of the edge. More...
 
NavGraphEdgeCostConstraintincreases_cost (const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to, float &cost_factor)
 Check if any constraint in the repo increases the cost of the edge. More...
 
float cost_factor (const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
 Get the highest increasing cost factor for an edge. More...
 
std::map< std::string, std::string > blocks (const std::vector< fawkes::NavGraphNode > &nodes)
 Check if any constraint in the repo blocks (some) nodes. More...
 
std::map< std::pair< std::string, std::string >, std::string > blocks (const std::vector< fawkes::NavGraphEdge > &edges)
 Check if any constraint in the repo blocks (some) edges. More...
 
std::list< std::tuple< std::string, std::string, std::string, float > > cost_factor (const std::vector< fawkes::NavGraphEdge > &edges)
 Get the highest increasing cost factor for an edge. More...
 
bool modified (bool reset_modified=false)
 Check if the constraint repo has been modified. More...
 

Detailed Description

Constraint repository to maintain blocks on nodes.

Author
Sebastian Reuter
Tim Niemueller

Definition at line 41 of file constraint_repo.h.

Member Typedef Documentation

◆ EdgeConstraintList

List of navgraph edge constraints.

Definition at line 47 of file constraint_repo.h.

◆ EdgeCostConstraintList

List of navgraph edge cost constraints.

Definition at line 49 of file constraint_repo.h.

◆ NodeConstraintList

List of navgraph node constraints.

Definition at line 45 of file constraint_repo.h.

Constructor & Destructor Documentation

◆ NavGraphConstraintRepo()

fawkes::NavGraphConstraintRepo::NavGraphConstraintRepo ( )

Constructor.

Definition at line 40 of file constraint_repo.cpp.

◆ ~NavGraphConstraintRepo()

fawkes::NavGraphConstraintRepo::~NavGraphConstraintRepo ( )

Destructor.

Definition at line 46 of file constraint_repo.cpp.

Member Function Documentation

◆ blocks() [1/4]

fawkes::NavGraphNodeConstraint * fawkes::NavGraphConstraintRepo::blocks ( const fawkes::NavGraphNode node)

Check if any constraint in the repo blocks the node.

Parameters
nodeNode to check for a block
Returns
the (first) node constraint that blocked the node, NULL if the node is not blocked

Definition at line 279 of file constraint_repo.cpp.

Referenced by fawkes::NavGraphSearchState::is_goal(), and NavGraphVisualizationThread::loop().

◆ blocks() [2/4]

fawkes::NavGraphEdgeConstraint * fawkes::NavGraphConstraintRepo::blocks ( const fawkes::NavGraphNode from,
const fawkes::NavGraphNode to 
)

Check if any constraint in the repo blocks the edge.

Parameters
fromnode from which the edge originates
tonode to which the edge leads
Returns
the (first) edge constraint that blocked the node, NULL if the node is not blocked

Definition at line 320 of file constraint_repo.cpp.

◆ blocks() [3/4]

std::map< std::string, std::string > fawkes::NavGraphConstraintRepo::blocks ( const std::vector< fawkes::NavGraphNode > &  nodes)

Check if any constraint in the repo blocks (some) nodes.

Parameters
nodesvector of nodes to check for a block
Returns
map of blocked nodes, first element is the node name, second element is the name of the constraint that blocks the node. Nodes from nodes that are not blocked will not appear in the map.

Definition at line 298 of file constraint_repo.cpp.

◆ blocks() [4/4]

std::map< std::pair< std::string, std::string >, std::string > fawkes::NavGraphConstraintRepo::blocks ( const std::vector< fawkes::NavGraphEdge > &  edges)

Check if any constraint in the repo blocks (some) edges.

Parameters
edgesvector of edges to check for a block
Returns
map of blocked edges, first element is a pair of the node names, second element is the name of the constraint that blocks the edge. Edges from edges that are not blocked will not appear in the map.

Definition at line 390 of file constraint_repo.cpp.

◆ compute()

bool fawkes::NavGraphConstraintRepo::compute ( )

Call compute method on all registered constraints.

Returns
true if any constraint reported a change, false otherwise

Definition at line 256 of file constraint_repo.cpp.

Referenced by NavGraphThread::loop().

◆ cost_factor() [1/2]

float fawkes::NavGraphConstraintRepo::cost_factor ( const fawkes::NavGraphNode from,
const fawkes::NavGraphNode to 
)

Get the highest increasing cost factor for an edge.

This methods goes through all of the given edges and queries all edge cost constraints. If any constraint increases the cost of an edge (cost >= 1.00001), it adds a tuple of the start node name, end node name, constraint name, and cost factor of the constraint that returned the highest cost factor to the list.

Parameters
fromstart node of the edge
todestination node of edge
Returns
highest cost factor denoted by any edge or 1.0 if no constraint has been specified.

Definition at line 456 of file constraint_repo.cpp.

Referenced by NavGraphVisualizationThread::loop().

◆ cost_factor() [2/2]

std::list< std::tuple< std::string, std::string, std::string, float > > fawkes::NavGraphConstraintRepo::cost_factor ( const std::vector< fawkes::NavGraphEdge > &  edges)

Get the highest increasing cost factor for an edge.

This methods goes through all of the given edges and queries all edge cost constraints. If any constraint increases the cost of an edge (cost >= 1.00001), it adds a tuple of the start node name, end node name, constraint name, and cost factor of the constraint that returned the highest cost factor to the list.

Parameters
edgesvector of edges to check for a block
Returns
tuple of edges with increased costs consisting of start node name, target node name, name and cost factor of constraint returning the highest cost increase factor. Edges for which no increase has been indicated will not be returned in the list of tuples.

Definition at line 421 of file constraint_repo.cpp.

References fawkes::NavGraphEdgeCostConstraint::cost_factor(), and fawkes::NavGraphEdgeCostConstraint::name().

◆ edge_constraints()

const NavGraphConstraintRepo::EdgeConstraintList & fawkes::NavGraphConstraintRepo::edge_constraints ( ) const

Get a list of registered edge constraints.

Returns
list of edge constraints

Definition at line 225 of file constraint_repo.cpp.

Referenced by NavGraphVisualizationThread::loop().

◆ edge_cost_constraints()

const NavGraphConstraintRepo::EdgeCostConstraintList & fawkes::NavGraphConstraintRepo::edge_cost_constraints ( ) const

Get a list of registered edge cost constraints.

Returns
list of edge cost constraints

Definition at line 234 of file constraint_repo.cpp.

◆ get_edge_constraint()

fawkes::NavGraphEdgeConstraint * fawkes::NavGraphConstraintRepo::get_edge_constraint ( std::string &  name)

Get an edge constraint by name.

Parameters
namename of constraint to retrieve
Returns
if found returns a pointer to the edge constraint, NULL if not found

Definition at line 176 of file constraint_repo.cpp.

◆ get_edge_cost_constraint()

fawkes::NavGraphEdgeCostConstraint * fawkes::NavGraphConstraintRepo::get_edge_cost_constraint ( std::string &  name)

Get an edge cost constraint by name.

Parameters
namename of constraint to retrieve
Returns
if found returns a pointer to the edge cost constraint, NULL if not found

Definition at line 196 of file constraint_repo.cpp.

◆ get_node_constraint()

fawkes::NavGraphNodeConstraint * fawkes::NavGraphConstraintRepo::get_node_constraint ( std::string &  name)

Get a node constraint by name.

Parameters
namename of constraint to retrieve
Returns
if found returns a pointer to the node constraint, NULL if not found

Definition at line 157 of file constraint_repo.cpp.

◆ has_constraint()

bool fawkes::NavGraphConstraintRepo::has_constraint ( std::string &  name)

Check by name if a constraint has been registered.

Parameters
namename of constraint to look for
Returns
true if a constraint with the given name has been registered, false otherwise

Definition at line 125 of file constraint_repo.cpp.

◆ has_constraints()

bool fawkes::NavGraphConstraintRepo::has_constraints ( ) const

Check if there are any constraints at all.

Returns
true if constraints have been registered, false otherwise

Definition at line 244 of file constraint_repo.cpp.

◆ increases_cost() [1/2]

fawkes::NavGraphEdgeCostConstraint * fawkes::NavGraphConstraintRepo::increases_cost ( const fawkes::NavGraphNode from,
const fawkes::NavGraphNode to 
)

Check if any constraint in the repo increases the cost of the edge.

Parameters
fromnode from which the edge originates
tonode to which the edge leads
Returns
the (first) edge cost constraint that increases the cost of the node, i.e. that returns a cost factor >= 1.00001.

Definition at line 339 of file constraint_repo.cpp.

Referenced by fawkes::NavGraphSearchState::is_goal().

◆ increases_cost() [2/2]

fawkes::NavGraphEdgeCostConstraint * fawkes::NavGraphConstraintRepo::increases_cost ( const fawkes::NavGraphNode from,
const fawkes::NavGraphNode to,
float &  cost_factor 
)

Check if any constraint in the repo increases the cost of the edge.

Parameters
fromnode from which the edge originates
tonode to which the edge leads
cost_factorupon return with a non-NULL edge cost constraints contains the cost increase.
Returns
the edge cost constraint that returns the highest increase in cost of the node (and by a cost factor of at least >= 1.00001).

Definition at line 361 of file constraint_repo.cpp.

References fawkes::NavGraphEdgeCostConstraint::cost_factor().

◆ modified()

bool fawkes::NavGraphConstraintRepo::modified ( bool  reset_modified = false)

Check if the constraint repo has been modified.

Parameters
reset_modifiedtrue to reset the modified flag, false to leave it
Returns
true if the constraint repo has been modified, false otherwise

Definition at line 476 of file constraint_repo.cpp.

Referenced by NavGraphThread::loop().

◆ node_constraints()

const NavGraphConstraintRepo::NodeConstraintList & fawkes::NavGraphConstraintRepo::node_constraints ( ) const

Get a list of registered node constraints.

Returns
list of node constraints

Definition at line 215 of file constraint_repo.cpp.

Referenced by NavGraphVisualizationThread::loop().

◆ register_constraint() [1/3]

void fawkes::NavGraphConstraintRepo::register_constraint ( NavGraphNodeConstraint constraint)

Register a constraint.

Parameters
constraintnode constraint to register

Definition at line 55 of file constraint_repo.cpp.

◆ register_constraint() [2/3]

void fawkes::NavGraphConstraintRepo::register_constraint ( NavGraphEdgeConstraint constraint)

Register a constraint.

Parameters
constraintedge constraint to register

Definition at line 65 of file constraint_repo.cpp.

◆ register_constraint() [3/3]

void fawkes::NavGraphConstraintRepo::register_constraint ( NavGraphEdgeCostConstraint constraint)

Register an edge cost constraint.

Parameters
constraintedge cost constraint to register

Definition at line 75 of file constraint_repo.cpp.

◆ unregister_constraint()

void fawkes::NavGraphConstraintRepo::unregister_constraint ( std::string  name)

Unregister a constraint by name.

Parameters
namename of constraint to remove.

Definition at line 86 of file constraint_repo.cpp.


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