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
24
25using namespace armarx;
26
27void
31
32void
36
37GeneratedGraspList
38GraspSelectionManager::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
50void
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
71GraspSelectionCriterionInterfaceList
76
77GraspingPlacementList
78GraspSelectionManager::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}
void onInitComponent() override
Pure virtual hook for the subclass.
GraspingPlacementList filterPlacements(const GraspingPlacementList &placements, const Ice::Current &=Ice::emptyCurrent) override
void onConnectComponent() override
Pure virtual hook for the subclass.
std::vector< GraspSelectionCriterionInterfacePrx > criteria
GraspSelectionCriterionInterfaceList getRegisteredGraspSelectionCriteria(const Ice::Current &) override
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.
GeneratedGraspList filterGrasps(const GeneratedGraspList &grasps, const Ice::Current &=Ice::emptyCurrent) override
Filters the grasps for each registered criterion.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
This file offers overloads of toIce() and fromIce() functions for STL container types.