ROSEndEffector
ROS End-Effector package: provides a ROS-based set of standard interfaces to command robotics end-effectors in an agnostic fashion.
ActionTimed.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 ROSEE_ACTIONTIMED_H
18 #define ROSEE_ACTIONTIMED_H
19 
20 #include <vector>
21 #include <string>
22 #include <map>
24 #include <end_effector/Utils.h>
25 #include <yaml-cpp/yaml.h>
26 
27 namespace ROSEE {
28 
39 class ActionTimed : public Action
40 {
41 public:
42  typedef std::shared_ptr<ActionTimed> Ptr;
43  typedef std::shared_ptr<const ActionTimed> ConstPtr;
47  ActionTimed();
48 
53  ActionTimed(std::string actionName);
54 
59 
64  JointPos getJointPos () const override;
65 
71  std::vector < ROSEE::JointPos > getAllJointPos () const override;
72 
77  std::vector < ROSEE::JointsInvolvedCount > getAllJointCountAction() const;
78 
84  std::vector < std::pair <double, double> > getAllActionMargins() const;
85 
92  ROSEE::JointPos getJointPosAction ( std::string actionName ) const ;
93 
100  std::pair <double, double> getActionMargins ( std::string actionName ) const ;
101 
109  ROSEE::JointsInvolvedCount getJointCountAction ( std::string actionName ) const;
110 
115  std::vector <std::string> getInnerActionsNames() const ;
119  void print () const override;
120 
125  void emitYaml ( YAML::Emitter& out) const override;
126 
132  bool fillFromYaml( YAML::const_iterator yamlIt ) override;
133 
150  bool insertAction ( ROSEE::Action::Ptr action, double marginBefore = 0.0, double marginAfter = 0.0,
151  unsigned int jointPosIndex = 0, double percentJointPos = 1, std::string newActionName = "");
152 
153 private:
154  std::map <std::string, std::pair<double, double> > actionsTimeMarginsMap;
155  std::map <std::string, ROSEE::JointPos> actionsJointPosMap;
156  std::map <std::string, ROSEE::JointsInvolvedCount> actionsJointCountMap;
157 
163 
167  std::vector < std::string > actionsNamesOrdered;
168 
169 };
170 
171 }
172 
173 #endif // ROSEE_ACTIONTIMED_H
ActionTimed()
Default constructor, used when parsing action from yaml file.
Definition: ActionTimed.cpp:19
bool insertAction(ROSEE::Action::Ptr action, double marginBefore=0.0, double marginAfter=0.0, unsigned int jointPosIndex=0, double percentJointPos=1, std::string newActionName="")
Insert an action as last one in the time line.
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
Definition: Action.h:40
std::vector< ROSEE::JointPos > getAllJointPos() const override
Override function from father Action.
Definition: ActionTimed.cpp:31
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
std::pair< double, double > getActionMargins(std::string actionName) const
get for time margins
Definition: ActionTimed.cpp:88
The pure virtual class representing an Action.
Definition: Action.h:71
ROSEE::JointPos jointPosFinal
Here is contained the wanted final position of the timed action.
Definition: ActionTimed.h:162
void emitYaml(YAML::Emitter &out) const override
Emit info in a file with yaml format.
std::map< std::string, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
bool fillFromYaml(YAML::const_iterator yamlIt) override
Fill the internal data with infos taken from yaml file.
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
~ActionTimed()
Destructor.
Definition: ActionTimed.h:58
ROSEE::JointPos getJointPosAction(std::string actionName) const
get for joint positions
Definition: ActionTimed.cpp:61
std::vector< std::string > getInnerActionsNames() const
getter for action that composed this one
std::vector< ROSEE::JointsInvolvedCount > getAllJointCountAction() const
Get the JointsInvolvedCount maps of all the inner actions, in order.
Definition: ActionTimed.cpp:41
std::shared_ptr< ActionTimed > Ptr
Definition: ActionTimed.h:42
std::shared_ptr< Action > Ptr
Definition: Action.h:75
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
An action composed by other ones that must be executed one after other with some wait time (also 0) i...
Definition: ActionTimed.h:39
std::shared_ptr< const ActionTimed > ConstPtr
Definition: ActionTimed.h:43
void print() const override
Print info about this action.
std::map< std::string, ROSEE::JointsInvolvedCount > actionsJointCountMap
Definition: ActionTimed.h:156
ROSEE::JointsInvolvedCount getJointCountAction(std::string actionName) const
get for JointsInvolvedCount of the inner actions
Definition: ActionTimed.cpp:74
JointPos getJointPos() const override
Override this function is necessary because it is pure virtual in father class Action.
Definition: ActionTimed.cpp:27
std::vector< std::pair< double, double > > getAllActionMargins() const
get all the time margins of all inner action
Definition: ActionTimed.cpp:51