ROSEndEffector
ROS End-Effector package: provides a ROS-based set of standard interfaces to command robotics end-effectors in an agnostic fashion.
Action.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 IIT-HHCM
3  * Author: Davide Torielli
4  * email: davide.torielli@iit.it
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef __ROSEE_ACTION_H
20 #define __ROSEE_ACTION_H
21 
22 #include <vector>
23 #include <string>
24 #include <map>
25 #include <yaml-cpp/yaml.h>
26 #include <memory>
27 #include <iostream>
28 
29 #include <end_effector/Utils.h>
30 
34 namespace ROSEE {
35 
40 typedef std::map <std::string, std::vector <double> > JointPos;
41 
43 std::ostream& operator << (std::ostream& output, const JointPos jp) ;
44 
45 JointPos operator * ( double multiplier, JointPos jp) ;
46 
47 JointPos operator * ( JointPos jp, double multiplier ) ;
48 
49 JointPos& operator *= ( JointPos& jp, double multiplier ) ;
50 
51 JointPos operator + ( JointPos jp1, JointPos jp2) ;
52 
53 JointPos& operator += ( JointPos& jp1, ROSEE::JointPos jp2);
54 
55 
63 typedef std::map <std::string, unsigned int> JointsInvolvedCount;
64 
65 std::ostream& operator << (std::ostream& output, const JointsInvolvedCount jic);
66 
67 
71 class Action
72 {
73 
74 public:
75  typedef std::shared_ptr<Action> Ptr;
76  typedef std::shared_ptr<const Action> ConstPtr;
77 
83 
84  /* destructor of base must be virtual */
85  virtual ~Action() {};
86 
91  std::string getName () const ;
92 
93  Type getType() const;
94 
99  std::set <std::string> getFingersInvolved () const ;
100 
105  JointsInvolvedCount getJointsInvolvedCount () const ;
106 
112  //TODO rename getJointsPos
113  virtual JointPos getJointPos () const = 0;
114 
120  //TODO rename getAllJointsPos
121  virtual std::vector < ROSEE::JointPos > getAllJointPos () const = 0;
122 
124  virtual void print () const ;
125 
133  virtual void emitYaml ( YAML::Emitter& out ) const = 0;
139  virtual bool fillFromYaml ( YAML::const_iterator yamlIt ) = 0;
140 
141 protected:
142  // Only derived class can create this class
143  Action();
144  Action(std::string actionName, Action::Type type);
145 
146  std::string name;
148  std::set <std::string> fingersInvolved;
149  JointsInvolvedCount jointsInvolvedCount;
150 
151 };
152 
157 std::ostream& operator <<(std::ostream& out, const ROSEE::Action::Type type);
158 
159 }
160 
161 #endif // __ROSEE_ACTION_H
std::string getName() const
Get the name of the action.
Definition: Action.cpp:116
Type
Enum useful to discriminate each action when, for example, we want to parse a file if you change thi...
Definition: Action.h:82
std::shared_ptr< const Action > ConstPtr
Definition: Action.h:76
std::string name
Definition: Action.h:146
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
Definition: Action.h:40
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action.
Definition: Action.h:63
The pure virtual class representing an Action.
Definition: Action.h:71
virtual void print() const
Overridable functions, if we want to make them more action-specific.
Definition: Action.cpp:135
JointPos operator+(JointPos jp1, JointPos jp2)
Definition: Action.cpp:57
JointsInvolvedCount getJointsInvolvedCount() const
Get for jointsInvolvedCount.
Definition: Action.cpp:130
virtual bool fillFromYaml(YAML::const_iterator yamlIt)=0
function to fill members of the Action with infos taken from yaml files
std::ostream & operator<<(std::ostream &output, const JointPos jp)
operator overload for JointPos so it is easier to print
Definition: Action.cpp:24
virtual void emitYaml(YAML::Emitter &out) const =0
Function to fill the argument passed with info about the action.
virtual ~Action()
Definition: Action.h:85
Action::Type type
Definition: Action.h:147
std::set< std::string > getFingersInvolved() const
Get for fingersInvolved.
Definition: Action.cpp:125
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
JointPos & operator*=(JointPos &jp, double multiplier)
Definition: Action.cpp:46
virtual JointPos getJointPos() const =0
Get the position related to this action.
std::shared_ptr< Action > Ptr
Definition: Action.h:75
JointPos & operator+=(JointPos &jp1, ROSEE::JointPos jp2)
Definition: Action.cpp:62
virtual std::vector< ROSEE::JointPos > getAllJointPos() const =0
Return all the joint position stored.
std::set< std::string > fingersInvolved
Definition: Action.h:148
JointPos operator*(double multiplier, JointPos jp)
Definition: Action.cpp:36
Type getType() const
Definition: Action.cpp:120