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 
28 {
29 }
30 
32 {
33 }
34 
35 GeneratedGraspList GraspSelectionManager::filterGrasps(const GeneratedGraspList& grasps, const Ice::Current&)
36 {
37  GeneratedGraspList result = grasps;
38 
39  for (const GraspSelectionCriterionInterfacePrx& criterion : criteria)
40  {
41  result = criterion->filterGrasps(result);
42  }
43 
44  return result;
45 }
46 
47 void GraspSelectionManager::registerAsGraspSelectionCriterion(const GraspSelectionCriterionInterfacePrx& criterion, const Ice::Current&)
48 {
49  bool alreadyAdded = std::find_if(criteria.cbegin(), criteria.cend(), [&](const GraspSelectionCriterionInterfacePrx & gsc)
50  {
51  return gsc->getHash() == criterion->getHash();
52  }) != criteria.cend();
53 
54  if (alreadyAdded)
55  {
56  ARMARX_ERROR << "criterion '" << criterion->ice_id() << "' already added";
57  }
58  else
59  {
60  criteria.push_back(criterion);
61  }
62 }
63 
64 GraspSelectionCriterionInterfaceList GraspSelectionManager::getRegisteredGraspSelectionCriteria(const Ice::Current&)
65 {
66  return criteria;
67 }
68 
69 GraspingPlacementList
70 GraspSelectionManager::filterPlacements(const GraspingPlacementList& placements, const Ice::Current&)
71 {
72  ARMARX_INFO << "length of criteria vector: " << criteria.size();
73  GraspingPlacementList result = placements;
74  for (const GraspSelectionCriterionInterfacePrx& criterion : criteria)
75  {
76  result = criterion->filterPlacements(result);
77  }
78  return result;
79 }
armarx::GraspSelectionManager::filterPlacements
GraspingPlacementList filterPlacements(const GraspingPlacementList &placements, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraspSelectionManager.cpp:70
armarx::GraspSelectionManager::criteria
std::vector< GraspSelectionCriterionInterfacePrx > criteria
Definition: GraspSelectionManager.h:90
armarx::GraspSelectionManager::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: GraspSelectionManager.cpp:27
GraspSelectionManager.h
armarx::GraspSelectionManager::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: GraspSelectionManager.cpp:31
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::GraspSelectionManager::filterGrasps
GeneratedGraspList filterGrasps(const GeneratedGraspList &grasps, const Ice::Current &=Ice::emptyCurrent) override
Filters the grasps for each registered criterion.
Definition: GraspSelectionManager.cpp:35
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:47
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::GraspSelectionManager::getRegisteredGraspSelectionCriteria
GraspSelectionCriterionInterfaceList getRegisteredGraspSelectionCriteria(const Ice::Current &) override
Definition: GraspSelectionManager.cpp:64