ROSEndEffector
ROS End-Effector package: provides a ROS-based set of standard interfaces to command robotics end-effectors in an agnostic fashion.
MapActionHandler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 <copyright holder> <email>
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MAPACTIONHANDLER_H
18 #define MAPACTIONHANDLER_H
19 
20 #include <string>
21 #include <map>
22 #include <set>
23 #include <memory>
24 
26 #include <end_effector/Utils.h>
27 
32 
33 
34 
35 namespace ROSEE {
40 
41 public:
42 
43  typedef std::shared_ptr<MapActionHandler> Ptr;
44 
46 
47  typedef std::map < std::set < std::string >, ROSEE::ActionPrimitive::Ptr > ActionPrimitiveMap;
48 
52  bool parseAllPrimitives(std::string pathFolder);
53  bool parseAllGenerics(std::string pathFolder);
54  bool parseAllTimeds(std::string pathFolder);
55  bool parseAllActions(std::string pathFolder);
56 
57  /************************************* Generic Functions to get actions *************************/
68  std::vector<ActionPrimitiveMap> getPrimitiveMap( ROSEE::ActionPrimitive::Type type ) const;
69 
70  ActionPrimitiveMap getPrimitiveMap( std::string primitiveName ) const;
71  std::map <std::string, ActionPrimitiveMap> getAllPrimitiveMaps () const;
72 
88  ROSEE::ActionPrimitive::Ptr getPrimitive (std::string primitiveName, std::set<std::string> key) const;
89  std::vector<ROSEE::ActionPrimitive::Ptr> getPrimitive (ROSEE::ActionPrimitive::Type, std::set<std::string> key) const;
90  ROSEE::ActionPrimitive::Ptr getPrimitive (std::string primitiveName, std::vector<std::string> key) const;
91  std::vector<ROSEE::ActionPrimitive::Ptr> getPrimitive (ROSEE::ActionPrimitive::Type, std::vector<std::string> key) const;
92  ROSEE::ActionPrimitive::Ptr getPrimitive (std::string primitiveName, std::pair<std::string, std::string> key) const;
93  std::vector<ROSEE::ActionPrimitive::Ptr> getPrimitive (ROSEE::ActionPrimitive::Type, std::pair<std::string, std::string> key) const;
94  ROSEE::ActionPrimitive::Ptr getPrimitive (std::string primitiveName, std::string key) const;
95  std::vector<ROSEE::ActionPrimitive::Ptr> getPrimitive (ROSEE::ActionPrimitive::Type, std::string key) const;
96 
100  std::shared_ptr<ROSEE::ActionGeneric> getGeneric (std::string name, bool verbose = true) const;
101  std::map <std::string, std::shared_ptr<ROSEE::ActionGeneric>> getAllGenerics () const;
102 
103  std::shared_ptr<ROSEE::ActionTimed> getTimed (std::string name) const;
104  std::map <std::string, std::shared_ptr<ROSEE::ActionTimed>> getAllTimeds () const;
105 
106  /************************************* Specific functions for specific actions *************************/
107 
108 
122  std::map <std::string, ROSEE::ActionPrimitive::Ptr> getPrimitiveSingleJointMultipleTipsMap ( unsigned int nFingers ) const;
123 
145  ROSEE::Action::Ptr getGrasp ( unsigned int nFingers, std::string graspName = "grasp" ) ;
146 
147  /************************************* Other functions not returning actions themselves *************************/
148  std::set<std::string> getFingertipsForPinch ( std::string finger, ROSEE::ActionPrimitive::Type pinchType) const;
149  std::map <std::string, std::set<std::string> > getPinchTightPairsMap ( ) const;
150  std::map <std::string, std::set<std::string> > getPinchLoosePairsMap ( ) const;
151 
152  /***************************** Other *******************************************/
153 
159 
160 private:
161 
162  void findPinchPairsMap();
163 
164  std::string handName;
165 
166  std::map <std::string, ActionPrimitiveMap> primitives;
167  std::map <std::string, std::shared_ptr<ROSEE::ActionGeneric>> generics;
168  std::map <std::string, std::shared_ptr<ROSEE::ActionTimed>> timeds;
169 
170  std::map <std::string, std::set<std::string> > pinchTightPairsMap;
171  std::map <std::string, std::set<std::string> > pinchLoosePairsMap;
172 
173 
174 };
175 
176 } //namespace rosee
177 
178 #endif // MAPACTIONHANDLER_H
std::map< std::string, std::set< std::string > > getPinchTightPairsMap() const
std::set< std::string > getFingertipsForPinch(std::string finger, ROSEE::ActionPrimitive::Type pinchType) const
std::map< std::string, std::set< std::string > > getPinchLoosePairsMap() const
std::map< std::string, std::set< std::string > > pinchLoosePairsMap
std::map< std::string, std::shared_ptr< ROSEE::ActionGeneric > > getAllGenerics() const
std::shared_ptr< ActionGeneric > Ptr
Definition: ActionGeneric.h:35
std::shared_ptr< ActionPrimitive > Ptr
bool parseAllPrimitives(std::string pathFolder)
std::vector< ActionPrimitiveMap > getPrimitiveMap(ROSEE::ActionPrimitive::Type type) const
getter to take all the primitives maps of one type (
bool parseAllGenerics(std::string pathFolder)
std::map< std::string, std::shared_ptr< ROSEE::ActionTimed > > timeds
std::shared_ptr< ROSEE::ActionGeneric > getGeneric(std::string name, bool verbose=true) const
Type
Enum useful to discriminate each primitive action when, for example, we want to parse a file if you ...
std::map< std::string, ActionPrimitiveMap > primitives
std::shared_ptr< MapActionHandler > Ptr
std::map< std::string, ROSEE::ActionPrimitive::Ptr > getPrimitiveSingleJointMultipleTipsMap(unsigned int nFingers) const
function to return the map that contains all the singleJointMultipleTips primitive with that moves th...
ROSEE::ActionPrimitive::Ptr getPrimitive(std::string primitiveName, std::set< std::string > key) const
std::shared_ptr< ROSEE::ActionTimed > getTimed(std::string name) const
bool insertSingleGeneric(ROSEE::ActionGeneric::Ptr generic)
This is needed by rosservicehandler which has to include a new doable action, if received the service...
std::shared_ptr< Action > Ptr
Definition: Action.h:75
ROSEE::Action::Ptr getGrasp(unsigned int nFingers, std::string graspName="grasp")
This function try to get an action that should be a grasp.
bool parseAllActions(std::string pathFolder)
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > ActionPrimitiveMap
std::map< std::string, std::shared_ptr< ROSEE::ActionTimed > > getAllTimeds() const
bool parseAllTimeds(std::string pathFolder)
std::map< std::string, std::shared_ptr< ROSEE::ActionGeneric > > generics
std::map< std::string, std::set< std::string > > pinchTightPairsMap
std::map< std::string, ActionPrimitiveMap > getAllPrimitiveMaps() const