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 
52 
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 
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;
150 
151 };
152 
157 std::ostream& operator <<(std::ostream& out, const ROSEE::Action::Type type);
158 
159 }
160 
161 #endif // __ROSEE_ACTION_H
ROSEE::Action::jointsInvolvedCount
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
ROSEE::Action::getJointPos
virtual JointPos getJointPos() const =0
Get the position related to this action. Pure Virtual function: the derived class store this info dif...
ROSEE::operator+
JointPos operator+(JointPos jp1, JointPos jp2)
Definition: Action.cpp:57
ROSEE::Action::Generic
@ Generic
Definition: Action.h:82
ROSEE::Action::None
@ None
Definition: Action.h:82
ROSEE
Definition: EEInterface.h:30
ROSEE::Action::Composed
@ Composed
Definition: Action.h:82
ROSEE::JointsInvolvedCount
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action. An ActionPrimitive and an ActionCom...
Definition: Action.h:63
ROSEE::Action
The pure virtual class representing an Action. It has members that are in common to all derived class...
Definition: Action.h:71
ROSEE::operator+=
JointPos & operator+=(JointPos &jp1, ROSEE::JointPos jp2)
Definition: Action.cpp:62
ROSEE::Action::emitYaml
virtual void emitYaml(YAML::Emitter &out) const =0
Function to fill the argument passed with info about the action. Pure virtual because each derived cl...
ROSEE::Action::~Action
virtual ~Action()
Definition: Action.h:85
Utils.h
ROSEE::operator*
JointPos operator*(double multiplier, JointPos jp)
Definition: Action.cpp:36
ROSEE::Action::Primitive
@ Primitive
Definition: Action.h:82
ROSEE::Action::Action
Action()
Definition: Action.cpp:106
ROSEE::operator*=
JointPos & operator*=(JointPos &jp, double multiplier)
Definition: Action.cpp:46
ROSEE::Action::getFingersInvolved
std::set< std::string > getFingersInvolved() const
Get for fingersInvolved.
Definition: Action.cpp:125
Type
Type
ROSEE::Action::getAllJointPos
virtual std::vector< ROSEE::JointPos > getAllJointPos() const =0
Return all the joint position stored. If the concrete (derived from Action) has only one joint positi...
ROSEE::Action::Ptr
std::shared_ptr< Action > Ptr
Definition: Action.h:75
ROSEE::Action::Type
Type
Enum useful to discriminate each action when, for example, we want to parse a file @remind if you cha...
Definition: Action.h:82
ROSEE::Action::Timed
@ Timed
Definition: Action.h:82
ROSEE::Action::getJointsInvolvedCount
JointsInvolvedCount getJointsInvolvedCount() const
Get for jointsInvolvedCount.
Definition: Action.cpp:130
ROSEE::operator<<
std::ostream & operator<<(std::ostream &output, const JointPos jp)
Definition: Action.cpp:24
ROSEE::JointPos
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints. The key is the name of the string,...
Definition: Action.h:40
ROSEE::Action::fillFromYaml
virtual bool fillFromYaml(YAML::const_iterator yamlIt)=0
function to fill members of the Action with infos taken from yaml files
ROSEE::Action::getName
std::string getName() const
Get the name of the action.
Definition: Action.cpp:116
ROSEE::Action::fingersInvolved
std::set< std::string > fingersInvolved
Definition: Action.h:148
ROSEE::Action::name
std::string name
Definition: Action.h:146
ROSEE::Action::type
Action::Type type
Definition: Action.h:147
ROSEE::Action::getType
Type getType() const
Definition: Action.cpp:120
ROSEE::Action::ConstPtr
std::shared_ptr< const Action > ConstPtr
Definition: Action.h:76
ROSEE::Action::print
virtual void print() const
Overridable functions, if we want to make them more action-specific.
Definition: Action.cpp:135


end-effector
Author(s): Luca Muratore , Davide Torielli , Liana Bertoni
autogenerated on Sat Dec 14 2024 03:49:26