22 #include <navgraph/constraints/static_list_edge_cost_constraint.h> 23 #include <core/exception.h> 59 edge_cost_list_buffer_.
lock();
60 edge_cost_list_ = edge_cost_list_buffer_;
61 edge_cost_list_buffer_.
unlock();
77 if (cost_factor < 1.00001) {
78 throw Exception(
"Invalid cost factor %f, must be >= 1.00001", cost_factor);
91 const std::vector<std::pair<fawkes::NavGraphEdge, float>> &edges)
93 for (
const std::pair<NavGraphEdge, float> &ec : edges) {
104 std::vector<std::pair<NavGraphEdge, float>>::iterator ec
105 = std::find_if(edge_cost_list_buffer_.begin(), edge_cost_list_buffer_.end(),
106 [&edge](
const std::pair<fawkes::NavGraphEdge, float> &p) {
107 return p.first == edge;
110 if (ec != edge_cost_list_buffer_.end()) {
123 return (std::find_if(edge_cost_list_buffer_.begin(), edge_cost_list_buffer_.end(),
124 [&edge](
const std::pair<fawkes::NavGraphEdge, float> &p) {
125 return p.first == edge;
127 != edge_cost_list_buffer_.end());
137 const std::vector<std::pair<fawkes::NavGraphEdge, float>> &
140 return edge_cost_list_;
148 if (! edge_cost_list_buffer_.empty()) {
150 edge_cost_list_buffer_.clear();
159 for (std::pair<NavGraphEdge, float> &ec : edge_cost_list_) {
160 if ((ec.first.from() == from.name() && ec.first.to() == to.name()) ||
161 (ec.first.from() == to.name() && ec.first.to() == from.name()) )
void add_edge(const fawkes::NavGraphEdge &edge, const float cost_factor)
Add a single edge to constraint list.
void erase_locked(typename std::vector< Type >::iterator pos)
Erase given element with lock protection.
Fawkes library namespace.
bool has_edge(const fawkes::NavGraphEdge &edge)
Check if constraint has a specific edge.
virtual bool compute(void)
Perform compuations before graph search and to indicate re-planning.
virtual void lock() const
Lock vector.
NavGraphStaticListEdgeCostConstraint(std::string name)
Constructor.
Constraint that can be queried for an edge cost factor.
void push_back_locked(const Type &x)
Push element to vector at back with lock protection.
virtual float cost_factor(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
Get cost factor for given edge.
virtual ~NavGraphStaticListEdgeCostConstraint()
Virtual empty destructor.
virtual void unlock() const
Unlock vector.
Base class for exceptions in Fawkes.
const std::vector< std::pair< fawkes::NavGraphEdge, float > > & edge_cost_list() const
Get list of blocked edges.
void add_edges(const std::vector< std::pair< fawkes::NavGraphEdge, float >> &edge_costs)
Add multiple edges to constraint list.
void clear_edges()
Remove all edges.
void remove_edge(const fawkes::NavGraphEdge &edge)
Remove a single edge from the constraint list.