ROSEndEffector
ROS End-Effector package: provides a ROS-based set of standard interfaces to command robotics end-effectors in an agnostic fashion.
Public Types | Public Member Functions | Private Attributes | List of all members
ROSEE::ActionTimed Class Reference

An action composed by other ones that must be executed one after other with some wait time (also 0) in between. More...

#include <ActionTimed.h>

+ Inheritance diagram for ROSEE::ActionTimed:
+ Collaboration diagram for ROSEE::ActionTimed:

Public Types

typedef std::shared_ptr< ActionTimedPtr
 
typedef std::shared_ptr< const ActionTimedConstPtr
 
- Public Types inherited from ROSEE::Action
enum  Type {
  Primitive,
  Generic,
  Composed,
  Timed,
  None
}
 Enum useful to discriminate each action when, for example, we want to parse a file if you change this enum, change also the ROSEEControl.msg accordingly. More...
 
typedef std::shared_ptr< ActionPtr
 
typedef std::shared_ptr< const ActionConstPtr
 

Public Member Functions

 ActionTimed ()
 Default constructor, used when parsing action from yaml file. More...
 
 ActionTimed (std::string actionName)
 Costructor. More...
 
 ~ActionTimed ()
 Destructor. More...
 
JointPos getJointPos () const override
 Override this function is necessary because it is pure virtual in father class Action. More...
 
std::vector< ROSEE::JointPosgetAllJointPos () const override
 Override function from father Action. More...
 
std::vector< ROSEE::JointsInvolvedCountgetAllJointCountAction () const
 Get the JointsInvolvedCount maps of all the inner actions, in order. More...
 
std::vector< std::pair< double, double > > getAllActionMargins () const
 get all the time margins of all inner action More...
 
ROSEE::JointPos getJointPosAction (std::string actionName) const
 get for joint positions More...
 
std::pair< double, double > getActionMargins (std::string actionName) const
 get for time margins More...
 
ROSEE::JointsInvolvedCount getJointCountAction (std::string actionName) const
 get for JointsInvolvedCount of the inner actions More...
 
std::vector< std::string > getInnerActionsNames () const
 getter for action that composed this one More...
 
void print () const override
 Print info about this action. More...
 
void emitYaml (YAML::Emitter &out) const override
 Emit info in a file with yaml format. More...
 
bool fillFromYaml (YAML::const_iterator yamlIt) override
 Fill the internal data with infos taken from yaml file. More...
 
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. More...
 
- Public Member Functions inherited from ROSEE::Action
virtual ~Action ()
 
std::string getName () const
 Get the name of the action. More...
 
Type getType () const
 
std::set< std::string > getFingersInvolved () const
 Get for fingersInvolved. More...
 
JointsInvolvedCount getJointsInvolvedCount () const
 Get for jointsInvolvedCount. More...
 

Private Attributes

std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
 
std::map< std::string, ROSEE::JointPosactionsJointPosMap
 
std::map< std::string, ROSEE::JointsInvolvedCountactionsJointCountMap
 
ROSEE::JointPos jointPosFinal
 Here is contained the wanted final position of the timed action. More...
 
std::vector< std::string > actionsNamesOrdered
 This vector is used to take count of the order of the actions inserted. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ROSEE::Action
 Action ()
 
 Action (std::string actionName, Action::Type type)
 
- Protected Attributes inherited from ROSEE::Action
std::string name
 
Action::Type type
 
std::set< std::string > fingersInvolved
 
JointsInvolvedCount jointsInvolvedCount
 

Detailed Description

An action composed by other ones that must be executed one after other with some wait time (also 0) in between.

E.G. 0.000000second --—> Grasp --—> 0.1 + 0.1 second --—> OpenLid --—> 0.5second -— and so on This class contains all the joint position of each action (actionsJointPosMap ) and some time margins which indicates wait time before and after the action (actionsTimeMarginsMap). Each action inside is identified by its name, so no two action with same name can exist (see insertAction ) After create the ActionTimed object, we can add actions with insertAction(). As all other Action classes, it implements also functions to emit and parse in a yaml file

Todo:
identify inner actions with integer instead of given name?

Definition at line 39 of file ActionTimed.h.

Member Typedef Documentation

typedef std::shared_ptr<const ActionTimed> ROSEE::ActionTimed::ConstPtr

Definition at line 43 of file ActionTimed.h.

typedef std::shared_ptr<ActionTimed> ROSEE::ActionTimed::Ptr

Definition at line 42 of file ActionTimed.h.

Constructor & Destructor Documentation

ROSEE::ActionTimed::ActionTimed ( )

Default constructor, used when parsing action from yaml file.

Definition at line 19 of file ActionTimed.cpp.

19  {
20  type = Action::Type::Timed;
21 }
Action::Type type
Definition: Action.h:147
ROSEE::ActionTimed::ActionTimed ( std::string  actionName)

Costructor.

Parameters
actionNamename of the action that will be created

Definition at line 23 of file ActionTimed.cpp.

23  : Action(name, Action::Type::Timed) {
24 
25 }
std::string name
Definition: Action.h:146
ROSEE::ActionTimed::~ActionTimed ( )
inline

Destructor.

Definition at line 58 of file ActionTimed.h.

58 {};

Member Function Documentation

void ROSEE::ActionTimed::emitYaml ( YAML::Emitter &  out) const
overridevirtual

Emit info in a file with yaml format.

Parameters
outa YAML::Emitter& object to emit the infos

Implements ROSEE::Action.

Definition at line 142 of file ActionTimed.cpp.

142  {
143 
144  out << YAML::BeginMap << YAML::Key << name << YAML::Value << YAML::BeginMap ;
145  std::string timeline;
146  for ( auto it : actionsNamesOrdered ) {
147  timeline += (std::to_string(actionsTimeMarginsMap.at(it).first) + " -----> " +
148  it + " -----> " + std::to_string(actionsTimeMarginsMap.at(it).second) + " + ");
149  }
150  if (! timeline.empty() ) {
151  timeline.pop_back(); timeline.pop_back(); timeline.pop_back(); //to delete last " + "
152  }
153 
154  out << YAML::Comment(timeline);
155  out << YAML::Key << "Type" << YAML::Value << type;
156  out << YAML::Key << "FingersInvolved" << YAML::Value << YAML::Flow << fingersInvolved;
157 
158  out << YAML::Key << "JointsInvolvedCount" << YAML::Value << YAML::BeginMap;
159  for (const auto &jointCount : jointsInvolvedCount ) {
160  out << YAML::Key << jointCount.first;
161  out << YAML::Value << jointCount.second;
162  }
163  out << YAML::EndMap;
164 
165  out << YAML::Key << "ActionsJointPosFinal" << YAML::Value << YAML::BeginMap;
166  for ( const auto joint : jointPosFinal ) {
167  out << YAML::Key << joint.first;
168  out << YAML::Value << YAML::Flow << joint.second; //vector of double is emitted like Seq
169  }
170  out << YAML::EndMap;
171 
172  out << YAML::Key << "ActionsNamesOrdered" << YAML::Value << YAML::Flow << actionsNamesOrdered;
173 
174  out << YAML::Key << "ActionsTimeMargins" << YAML::Value << YAML::BeginMap;
175  for (const std::string action : actionsNamesOrdered ){
176 
177  out << YAML::Key << action << YAML::Value << YAML::BeginMap;
178 
179  out << YAML::Key << "marginBefore" <<
180  YAML::Value << actionsTimeMarginsMap.at(action).first;
181 
182  out << YAML::Key << "marginAfter" <<
183  YAML::Value << actionsTimeMarginsMap.at(action).second;
184  out << YAML::EndMap;
185  }
186  out << YAML::EndMap;
187 
188  out << YAML::Key << "ActionsJointPos" << YAML::Value << YAML::BeginMap;
189  for (const std::string action : actionsNamesOrdered ){
190 
191  out << YAML::Key << action << YAML::Value << YAML::BeginMap;
192 
193  for ( const auto joint : actionsJointPosMap.at(action) ) {
194  out << YAML::Key << joint.first;
195  out << YAML::Value << YAML::Flow << joint.second; //vector of double is emitted like Seq
196  }
197  out << YAML::EndMap;
198  }
199  out << YAML::EndMap;
200 
201 
202  out << YAML::Key << "ActionsJointCount" << YAML::Value << YAML::BeginMap;
203  for (const std::string action : actionsNamesOrdered ){
204 
205  out << YAML::Key << action << YAML::Value << YAML::BeginMap;
206 
207  for ( const auto joint : actionsJointCountMap.at(action) ) {
208  out << YAML::Key << joint.first;
209  out << YAML::Value << YAML::Flow << joint.second; //vector of double is emitted like Seq
210  }
211  out << YAML::EndMap;
212  }
213  out << YAML::EndMap;
214 
215 
216 
217 
218  out << YAML::EndMap; // map began at the beginning of the function
219  out << YAML::EndMap;// map began at the beginning of the function
220 }
std::string name
Definition: Action.h:146
ROSEE::JointPos jointPosFinal
Here is contained the wanted final position of the timed action.
Definition: ActionTimed.h:162
std::map< std::string, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
Action::Type type
Definition: Action.h:147
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::map< std::string, ROSEE::JointsInvolvedCount > actionsJointCountMap
Definition: ActionTimed.h:156
std::set< std::string > fingersInvolved
Definition: Action.h:148
bool ROSEE::ActionTimed::fillFromYaml ( YAML::const_iterator  yamlIt)
overridevirtual

Fill the internal data with infos taken from yaml file.

Parameters
yamlIta yamlt iterator to a node which has loaded the file
Returns
false if some error happened

Implements ROSEE::Action.

Definition at line 222 of file ActionTimed.cpp.

222  {
223 
224  name = yamlIt->first.as<std::string>();
225  type = Action::Type::Timed;
226 
227  for (auto keyValue = yamlIt->second.begin(); keyValue != yamlIt->second.end(); ++keyValue ) {
228 
229  std::string key = keyValue->first.as<std::string>();
230 
231  if ( key.compare ("FingersInvolved") == 0 ) {
232  auto tempVect = keyValue->second.as <std::vector <std::string> > ();
233  fingersInvolved.insert ( tempVect.begin(), tempVect.end() );
234 
235  } else if ( key.compare ("Type") == 0 ) {
236  if (ROSEE::Action::Type::Timed != static_cast<ROSEE::Action::Type> ( keyValue->second.as <unsigned int>() )) {
237  std::cout << "[Timed ACTION::" << __func__ << "] Error, found type " << keyValue->second.as <unsigned int>()
238  << "instead of Timed type (" << ROSEE::Action::Type::Timed << ")" << std::endl;
239  return false;
240  }
241  type = ROSEE::Action::Type::Timed;
242 
243  } else if ( key.compare ("ActionsNamesOrdered") == 0 ) {
244  actionsNamesOrdered = keyValue->second.as < std::vector <std::string> > ();
245 
246  } else if ( key.compare ("JointsInvolvedCount") == 0 ) {
247  jointsInvolvedCount = keyValue->second.as < JointsInvolvedCount >();
248 
249  } else if ( key.compare("ActionsTimeMargins") == 0 ) {
250 
251  for (auto tMargins = keyValue->second.begin(); tMargins != keyValue->second.end(); ++tMargins ) {
252 
253  std::string actNAme = tMargins->first.as<std::string>();
254  double before = tMargins->second["marginBefore"].as<double>();
255  double after = tMargins->second["marginAfter"].as<double>();
256  actionsTimeMarginsMap.insert (std::make_pair (actNAme, std::make_pair(before, after) ) ) ;
257  }
258 
259  } else if ( key.compare("ActionsJointPos") == 0) {
260 
261  for (auto jPos = keyValue->second.begin(); jPos != keyValue->second.end(); ++jPos ) {
262 
263  std::string actName = jPos->first.as<std::string>();
264  JointPos jp = jPos->second.as<ROSEE::JointPos>();
265  actionsJointPosMap.insert (std::make_pair (actName, jp) );
266  }
267 
268  } else if ( key.compare("ActionsJointCount") == 0) {
269 
270  for (auto jCount = keyValue->second.begin(); jCount != keyValue->second.end(); ++jCount ) {
271 
272  std::string actName = jCount->first.as<std::string>();
273  JointsInvolvedCount jc = jCount->second.as<ROSEE::JointsInvolvedCount>();
274  actionsJointCountMap.insert (std::make_pair (actName, jc) );
275  }
276 
277 
278  } else if ( key.compare("ActionsJointPosFinal") == 0) {
279 
280  jointPosFinal = keyValue->second.as < JointPos >();
281 
282  } else {
283  std::cerr << "[TIMEDACTION::" << __func__ << "] Error, not known key " << key << std::endl;
284  return false;
285  }
286  }
287 
288  return true;
289 }
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
ROSEE::JointPos jointPosFinal
Here is contained the wanted final position of the timed action.
Definition: ActionTimed.h:162
std::map< std::string, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
Action::Type type
Definition: Action.h:147
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::map< std::string, ROSEE::JointsInvolvedCount > actionsJointCountMap
Definition: ActionTimed.h:156
std::set< std::string > fingersInvolved
Definition: Action.h:148
std::pair< double, double > ROSEE::ActionTimed::getActionMargins ( std::string  actionName) const

get for time margins

Parameters
actionNamethe name of the inner action of which we want to know the time margins
Returns
a pair of positive double. The first is the time needed BEFORE the action, the secont the time AFTER return -1 -1 if the actionName was not present in this ActionTimed.

Definition at line 88 of file ActionTimed.cpp.

88  {
89 
90  auto it = actionsTimeMarginsMap.find(actionName);
91 
92  if ( it != actionsTimeMarginsMap.end() ) {
93  return ( it->second );
94 
95  } else {
96  std::cerr << "[ACTIONTIMED:: " << __func__ << "] ERROR: action " << actionName << " not present in this composed timed action" << std::endl;
97  return std::make_pair(-1, -1);
98  }
99 }
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
std::vector< std::pair< double, double > > ROSEE::ActionTimed::getAllActionMargins ( ) const

get all the time margins of all inner action

Returns
vector of pair : the first element of pair is the time to wait before executing the action, the second element the time to wait after.

Definition at line 51 of file ActionTimed.cpp.

51  {
52 
53  std::vector <std::pair <double,double> > timeVect;
54  timeVect.reserve (actionsNamesOrdered.size());
55  for (auto actName : actionsNamesOrdered) {
56  timeVect.push_back( actionsTimeMarginsMap.at (actName) );
57  }
58  return timeVect;
59 }
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::vector< ROSEE::JointsInvolvedCount > ROSEE::ActionTimed::getAllJointCountAction ( ) const

Get the JointsInvolvedCount maps of all the inner actions, in order.

Returns
vector of JointsInvolvedCount map of inner actions

Definition at line 41 of file ActionTimed.cpp.

41  {
42 
43  std::vector<ROSEE::JointsInvolvedCount> jcVect;
44  jcVect.reserve (actionsNamesOrdered.size());
45  for (auto actName : actionsNamesOrdered) {
46  jcVect.push_back( actionsJointCountMap.at (actName) );
47  }
48  return jcVect;
49 }
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::map< std::string, ROSEE::JointsInvolvedCount > actionsJointCountMap
Definition: ActionTimed.h:156
std::vector< ROSEE::JointPos > ROSEE::ActionTimed::getAllJointPos ( ) const
overridevirtual

Override function from father Action.

For this class, it returns the jointPos of all the inner actions that are inside this ActionTimed.

Returns
vector of JointPos of all the inner actions, in order of execution

Implements ROSEE::Action.

Definition at line 31 of file ActionTimed.cpp.

31  {
32 
33  std::vector<ROSEE::JointPos> jpVect;
34  jpVect.reserve (actionsNamesOrdered.size());
35  for (auto actName : actionsNamesOrdered) {
36  jpVect.push_back( actionsJointPosMap.at (actName) );
37  }
38  return jpVect;
39 }
std::map< std::string, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::vector< std::string > ROSEE::ActionTimed::getInnerActionsNames ( ) const

getter for action that composed this one

Returns
vector of string of inner actions, ordered by time execution

Definition at line 101 of file ActionTimed.cpp.

101  {
102  return actionsNamesOrdered;
103 }
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
ROSEE::JointsInvolvedCount ROSEE::ActionTimed::getJointCountAction ( std::string  actionName) const

get for JointsInvolvedCount of the inner actions

Parameters
actionNamethe name of the inner action of which we want to know the JointCount
Returns
JointsInvolvedCount of joints of actionName Return empty JointsInvolvedCount if actionName is not present in this ActionTimed

Definition at line 74 of file ActionTimed.cpp.

74  {
75 
76  auto it = actionsJointCountMap.find(actionName);
77 
78  if ( it != actionsJointCountMap.end() ) {
79  return (it->second);
80 
81  } else {
82  std::cerr << "[ACTIONTIMED:: " << __func__ << "] ERROR: action " << actionName << " not present in this composed timed action" << std::endl;
84  }
85 }
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::map< std::string, ROSEE::JointsInvolvedCount > actionsJointCountMap
Definition: ActionTimed.h:156
ROSEE::JointPos ROSEE::ActionTimed::getJointPos ( ) const
overridevirtual

Override this function is necessary because it is pure virtual in father class Action.

Returns
JointPos the joints positions of the last inserted action (the last one in the time line)

Implements ROSEE::Action.

Definition at line 27 of file ActionTimed.cpp.

27  {
28  return jointPosFinal;
29 }
ROSEE::JointPos jointPosFinal
Here is contained the wanted final position of the timed action.
Definition: ActionTimed.h:162
ROSEE::JointPos ROSEE::ActionTimed::getJointPosAction ( std::string  actionName) const

get for joint positions

Parameters
actionNamethe name of the inner action of which we want to know the JointPos
Returns
JointPos position of joints of actionName Return empty JointPos if actionName is not present in this ActionTimed

Definition at line 61 of file ActionTimed.cpp.

61  {
62 
63  auto it = actionsJointPosMap.find(actionName);
64 
65  if ( it != actionsJointPosMap.end() ) {
66  return (it->second);
67 
68  } else {
69  std::cerr << "[ACTIONTIMED:: " << __func__ << "] ERROR: action " << actionName << " not present in this composed timed action" << std::endl;
70  return ROSEE::JointPos();
71  }
72 }
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, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
bool ROSEE::ActionTimed::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.

Parameters
actionpointer to the action to be inserted
marginBeforethe time margin to wait before executing the action
marginAfterthe time margin to wait after executing the action
jointPosIndex(default == 0) the wanted jointPos of action to insert. Error the index is greater than the number of joint pos in the action. First element has index 0.
percentJointPos(default == 1) OPTIONAL argument to scale all the joint position of the action that is being inserted
newActionName(default == "") OPTIONAL argument if we want to store the action with a different name
Returns
False if some error happened
Warning
We can't have inned actions with same name. So, if action name (or newActionName) is already present, the action is not inserted and the function returns false. Being Action names not changeable, to solve this we can pass the newActionName argument to this function. If it will be inserted, it will be referenced with this new name
Note
We take only necessary infos from action and store them in the members of ActionTimed. There is not way to go back to the original inserted action from an ActionTimed

Definition at line 291 of file ActionTimed.cpp.

292  {
293 
294  std::string usedName = (newActionName.empty()) ? action->getName() : newActionName;
295 
296  unsigned int count = actionsJointPosMap.count( usedName );
297 
298  if (count > 0) {
299  std::cerr << "[ACTIONTIMED:: " << __func__ << "] ERROR: " << usedName << " already present. Failed Insertion" << std::endl;
300  return false;
301  }
302 
303  if (marginAfter < 0 || marginBefore < 0) {
304  std::cerr << "[ACTIONTIMED:: " << __func__ << "] ERROR: Please pass positive time margins" << std::endl;
305  return false;
306  }
307 
308  if ( jointPosIndex > action->getAllJointPos().size()-1 ) {
309  std::cerr << "[ACTIONTIMED:: " << __func__ << "] ERROR: you pass index "<< jointPosIndex <<
310  " but there are only " << action->getAllJointPos().size() << " JointPos in the action passed as argument" << std::endl;
311  return false;
312  }
313 
314  if (percentJointPos < 0 || percentJointPos > 1) {
315  std::cerr << "[ACTIONTIMED:: " << __func__ << "] Please insert percentage for jointpos between 0 and 1. Passed: "
316  << percentJointPos << std::endl;
317  return false;
318  }
319 
320  if ( actionsNamesOrdered.size() > 0 &&
321  (! ROSEE::Utils::keys_equal(action->getAllJointPos().at(jointPosIndex), actionsJointPosMap.begin()->second)) ) {
322  //we need only to compare the first jointPos (.begin())
323  std::cerr << "[ACTIONTIMED:: " << __func__ << "] The action passed as argument has different keys in jointPosmap"
324  << " respect to the others inserted in this timed action " << std::endl;
325  return false;
326  }
327 
328  ROSEE::JointPos insertingJP = (percentJointPos)*(action->getAllJointPos().at( jointPosIndex )) ;
329  actionsJointPosMap.insert (std::make_pair ( usedName, insertingJP) );
330  actionsTimeMarginsMap.insert ( std::make_pair( usedName, std::make_pair(marginBefore, marginAfter)));
331  actionsNamesOrdered.push_back ( usedName );
332  actionsJointCountMap.insert (std::make_pair (usedName, action->getJointsInvolvedCount()));
333 
334  //father member
335  for ( auto it: action->getFingersInvolved() ) {
336  fingersInvolved.insert ( it );
337  }
338 
339  if (actionsNamesOrdered.size() == 1 ) { //We are inserting first action, we have to init the JointsInvolvedCount map
340 
341  jointsInvolvedCount = action->getJointsInvolvedCount();
342  jointPosFinal = insertingJP;
343 
344  } else {
345  // add the action.jointInvolvedCount to the timed jointCount
346  // and update jointPosFinal
347  for (auto jic : action->getJointsInvolvedCount() ) {
348  jointsInvolvedCount.at(jic.first) += jic.second;
349 
350  if (jic.second > 0) {
351  //if so, we must overwrite the pos of this joint in jointPosFina
352  jointPosFinal.at(jic.first) = insertingJP.at(jic.first);
353  }
354  }
355  }
356 
357  return true;
358 }
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
Definition: Action.h:40
ROSEE::JointPos jointPosFinal
Here is contained the wanted final position of the timed action.
Definition: ActionTimed.h:162
bool keys_equal(std::map< keyType, valueType1 > const &lhs, std::map< keyType, valueType2 > const &rhs)
Return false if two maps have different keys.
Definition: Utils.h:182
std::map< std::string, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::map< std::string, ROSEE::JointsInvolvedCount > actionsJointCountMap
Definition: ActionTimed.h:156
std::set< std::string > fingersInvolved
Definition: Action.h:148
void ROSEE::ActionTimed::print ( ) const
overridevirtual

Print info about this action.

Reimplemented from ROSEE::Action.

Definition at line 106 of file ActionTimed.cpp.

106  {
107 
108  std::stringstream output;
109 
110  output << "Timed Action '" << name << "'" << std::endl;
111 
112  output << "\tNice TimeLine:" << std::endl << "\t\t";
113  for ( auto it : actionsNamesOrdered ) {
114  output << actionsTimeMarginsMap.at(it).first << " -----> " << it << " -----> " << actionsTimeMarginsMap.at(it).second << " + ";
115  }
116  output.seekp (-3, output.cur); //to remove the last --+--
117  output << std::endl;
118 
119  output << "\tJointPos of each actions, in order of execution:\n";
120  for ( auto actionName : actionsNamesOrdered ) {
121  output << "\t" << actionName << std::endl;
122  output << actionsJointPosMap.at(actionName) << std::endl;
123  }
124 
125  output << "\tJointPos final, the sum of all joint pos of each inner action:\n";
126  output << jointPosFinal << std::endl;
127 
128  output << "\tFingers involved: [" ;
129  for (auto it : fingersInvolved) {
130  output << it << ", ";
131  }
132  output.seekp (-2, output.cur); //to remove the last comma (and space)
133  output << "]" << std::endl;
134 
135  output << "\tEach joint influenced by x inner action:" << std::endl;
136  output << jointsInvolvedCount << std::endl;
137 
138  std::cout << output.str();
139 
140 }
std::string name
Definition: Action.h:146
ROSEE::JointPos jointPosFinal
Here is contained the wanted final position of the timed action.
Definition: ActionTimed.h:162
std::map< std::string, ROSEE::JointPos > actionsJointPosMap
Definition: ActionTimed.h:155
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
Definition: ActionTimed.h:154
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
std::vector< std::string > actionsNamesOrdered
This vector is used to take count of the order of the actions inserted.
Definition: ActionTimed.h:167
std::set< std::string > fingersInvolved
Definition: Action.h:148

Member Data Documentation

std::map<std::string, ROSEE::JointsInvolvedCount> ROSEE::ActionTimed::actionsJointCountMap
private

Definition at line 156 of file ActionTimed.h.

std::map<std::string, ROSEE::JointPos> ROSEE::ActionTimed::actionsJointPosMap
private

Definition at line 155 of file ActionTimed.h.

std::vector< std::string > ROSEE::ActionTimed::actionsNamesOrdered
private

This vector is used to take count of the order of the actions inserted.

Definition at line 167 of file ActionTimed.h.

std::map<std::string, std::pair<double, double> > ROSEE::ActionTimed::actionsTimeMarginsMap
private

Definition at line 154 of file ActionTimed.h.

ROSEE::JointPos ROSEE::ActionTimed::jointPosFinal
private

Here is contained the wanted final position of the timed action.

So, it is the sum of all the wanted joint position of all the inner actions

Definition at line 162 of file ActionTimed.h.


The documentation for this class was generated from the following files: