Fawkes API  Fawkes Development Version
clusters_block_constraint.cpp
1 /***************************************************************************
2  * clusters_block_constraint.h - block edges close to clusters
3  *
4  * Created: Fri Jul 18 21:55:25 2014
5  * Copyright 2014 Tim Niemueller
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #include "clusters_block_constraint.h"
22 
23 #include "navgraph_clusters_thread.h"
24 
25 /** @class NavGraphClustersBlockConstraint "clusters_block_constraint.h"
26  * Constraint to block edges close to clusters.
27  * @author Tim Niemueller
28  */
29 
30 /** Constructor.
31  * @param name constraint name
32  * @param parent parent to call for blocked edges
33  */
35  NavGraphClustersThread *parent)
36 : NavGraphEdgeConstraint(name)
37 {
38  parent_ = parent;
39 }
40 
41 /** Virtual empty destructor. */
43 {
44 }
45 
46 bool
48 {
49  blocked_ = parent_->blocked_edges();
50  return true;
51 }
52 
53 bool
55  const fawkes::NavGraphNode &to) noexcept
56 {
57  std::string to_n = to.name();
58  std::string from_n = from.name();
59  return ((find(blocked_.begin(), blocked_.end(), make_pair(from_n, to_n)) != blocked_.end())
60  || (find(blocked_.begin(), blocked_.end(), make_pair(to_n, from_n)) != blocked_.end()));
61 }
NavGraphClustersBlockConstraint(const char *name, NavGraphClustersThread *parent)
Constructor.
virtual bool blocks(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to) noexcept
Check if constraint blocks an edge.
virtual bool compute(void) noexcept
Perform compuations before graph search and to indicate re-planning.
virtual ~NavGraphClustersBlockConstraint()
Virtual empty destructor.
Block navgraph paths based on laser clusters.
Topological graph node.
Definition: navgraph_node.h:36