GraspSelectionManager.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotComponents::GraspSelectionManager
17 * @author Valerij Wittenbeck ( valerij.wittenbeck at student dot kit dot edu)
18 * @date 2016
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "GraspSelectionManager.h"
24 
25 using namespace armarx;
26 
27 void
29 {
30 }
31 
32 void
34 {
35 }
36 
37 GeneratedGraspList
38 GraspSelectionManager::filterGrasps(const GeneratedGraspList& grasps, const Ice::Current&)
39 {
40  GeneratedGraspList result = grasps;
41 
42  for (const GraspSelectionCriterionInterfacePrx& criterion : criteria)
43  {
44  result = criterion->filterGrasps(result);
45  }
46 
47  return result;
48 }
49 
50 void
52  const GraspSelectionCriterionInterfacePrx& criterion,
53  const Ice::Current&)
54 {
55  bool alreadyAdded = std::find_if(criteria.cbegin(),
56  criteria.cend(),
57  [&](const GraspSelectionCriterionInterfacePrx& gsc) {
58  return gsc->getHash() == criterion->getHash();
59  }) != criteria.cend();
60 
61  if (alreadyAdded)
62  {
63  ARMARX_ERROR << "criterion '" << criterion->ice_id() << "' already added";
64  }
65  else
66  {
67  criteria.push_back(criterion);
68  }
69 }
70 
71 GraspSelectionCriterionInterfaceList
73 {
74  return criteria;
75 }
76 
77 GraspingPlacementList
78 GraspSelectionManager::filterPlacements(const GraspingPlacementList& placements,
79  const Ice::Current&)
80 {
81  ARMARX_INFO << "length of criteria vector: " << criteria.size();
82  GraspingPlacementList result = placements;
83  for (const GraspSelectionCriterionInterfacePrx& criterion : criteria)
84  {
85  result = criterion->filterPlacements(result);
86  }
87  return result;
88 }
armarx::GraspSelectionManager::filterPlacements
GraspingPlacementList filterPlacements(const GraspingPlacementList &placements, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraspSelectionManager.cpp:78
armarx::GraspSelectionManager::criteria
std::vector< GraspSelectionCriterionInterfacePrx > criteria
Definition: GraspSelectionManager.h:94
armarx::GraspSelectionManager::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: GraspSelectionManager.cpp:28
GraspSelectionManager.h
armarx::GraspSelectionManager::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: GraspSelectionManager.cpp:33
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:196
armarx::GraspSelectionManager::filterGrasps
GeneratedGraspList filterGrasps(const GeneratedGraspList &grasps, const Ice::Current &=Ice::emptyCurrent) override
Filters the grasps for each registered criterion.
Definition: GraspSelectionManager.cpp:38
armarx::GraspSelectionManager::registerAsGraspSelectionCriterion
void registerAsGraspSelectionCriterion(const GraspSelectionCriterionInterfacePrx &criterion, const Ice::Current &=Ice::emptyCurrent) override
Checks if a criterion is already registered; if not, register it with the GraspSelectionManager.
Definition: GraspSelectionManager.cpp:51
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::GraspSelectionManager::getRegisteredGraspSelectionCriteria
GraspSelectionCriterionInterfaceList getRegisteredGraspSelectionCriteria(const Ice::Current &) override
Definition: GraspSelectionManager.cpp:72