Line data Source code
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 ACTIONSINGLEJOINTMULTIPLETIPS_H
18 : #define ACTIONSINGLEJOINTMULTIPLETIPS_H
19 :
20 : #include <ros_end_effector/GraspingActions/ActionPrimitive.h>
21 : #include <yaml-cpp/yaml.h>
22 : #include <iostream>
23 :
24 : namespace ROSEE {
25 :
26 : /**
27 : * @brief Primitive which indicate a motion of n fingers moving ONLY ONE joint.
28 : * For example, this primitive is necessary for the hands that have one joint that close all the fingers to do a grasp. But
29 : * it can also useful to detect other multiple finger motions (like a "spread finger")
30 : */
31 17 : class ActionSingleJointMultipleTips : public ActionPrimitive {
32 :
33 : public:
34 :
35 : typedef std::map < std::string, ActionSingleJointMultipleTips > Map;
36 :
37 : ActionSingleJointMultipleTips();
38 :
39 : /**
40 : * @brief NOT ANYOMORE ? used (for now) by yaml worker only. Before parsing we cant now the info that the other costructor need. So all these infos
41 : * are set in the \ref fillFromYaml
42 : * @param actionName name of the action
43 : * @param nFingers number of the fingers involved in the action (i.e. number of finger that the \ref jointInvolved moves)
44 : */
45 : ActionSingleJointMultipleTips(std::string actionName, unsigned int nFingers);
46 : /**
47 : * @brief "Standard" costructor, which fill all the necessary infos
48 : * @param actionName name of the action
49 : * @param fingers vector containing all the fingers involved
50 : * @param jointName the name of the joint involved in the action (one joint for definition)
51 : * @param jpFurther JointPosition of ALL joints of the hand, with only the \p jointName set, in a way that the position is to the bound
52 : * which is further from the default position (which is 0)
53 : * @param jpNearer JointPosition of ALL joints of the hand, with only the \p jointName set, in a way that the position is to the bound
54 : * which is nearer from the default position
55 : * @warning If 0 position is not included between the bounds (eg 0.4 | 5.1) , jpNearer is the one nearer
56 : * to 0 (0.4) and jpFurther the further (5.1). CHECK THIS FACT TO BE SURE
57 : */
58 : ActionSingleJointMultipleTips (std::string actionName, std::vector<std::string> fingers, std::string jointName, JointPos jpFurther, JointPos jpNearer);
59 :
60 : /**
61 : * @brief Overriden get from the pure virtual function of the base class \ref Action
62 : * The signature must be equal, even if here we have set and vector of only one element.
63 : * For this class this function return the vector which contain \ref jointPosFurther and \ref jointPosNearer
64 : */
65 : std::vector < JointPos > getAllJointPos() const override;
66 :
67 : /**
68 : * @brief Overriden get from the pure virtual function of the base class \ref Action
69 : * @return the jointPosFurther
70 : */
71 : JointPos getJointPos () const override;
72 :
73 : /**
74 : * @brief Necessary method to know the key used by the maps which store all the Actions of one type. Used by \ref YamlWorker
75 : * @return for this class, it return the jointName, inserted in a single-element set because father signature say so
76 : */
77 : std::set < std::string> getKeyElements () const override;
78 :
79 : JointPos getJointPosFurther () const;
80 : JointPos getJointPosNearer () const;
81 : std::string getJointName() const;
82 :
83 : void print () const override;
84 : void emitYaml ( YAML::Emitter& out ) const override;
85 : bool fillFromYaml( YAML::const_iterator yamlIt ) override;
86 :
87 : private:
88 :
89 : JointPos jointPosFurther;
90 : JointPos jointPosNearer;
91 : std::string jointInvolved;
92 : };
93 : }
94 :
95 : #endif // ACTIONSINGLEJOINTMULTIPLETIPS_H
|