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. 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. More...

#include <ActionTimed.h>

Inheritance diagram for ROSEE::ActionTimed:
Inheritance graph
[legend]

Public Types

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

Public Member Functions

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

Private Attributes

std::map< std::string, ROSEE::JointsInvolvedCountactionsJointCountMap
 
std::map< std::string, ROSEE::JointPosactionsJointPosMap
 
std::vector< std::string > actionsNamesOrdered
 
std::map< std::string, std::pair< double, double > > actionsTimeMarginsMap
 
ROSEE::JointPos jointPosFinal
 

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::set< std::string > fingersInvolved
 
JointsInvolvedCount jointsInvolvedCount
 
std::string name
 
Action::Type type
 

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

◆ ConstPtr

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

Definition at line 43 of file ActionTimed.h.

◆ Ptr

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

Definition at line 42 of file ActionTimed.h.

Constructor & Destructor Documentation

◆ ActionTimed() [1/2]

ROSEE::ActionTimed::ActionTimed ( )

Default constructor, used when parsing action from yaml file.

Definition at line 19 of file ActionTimed.cpp.

◆ ActionTimed() [2/2]

ROSEE::ActionTimed::ActionTimed ( std::string  actionName)

Costructor.

Parameters
actionNamename of the action that will be created

Definition at line 23 of file ActionTimed.cpp.

◆ ~ActionTimed()

ROSEE::ActionTimed::~ActionTimed ( )
inline

Destructor.

Definition at line 58 of file ActionTimed.h.

Member Function Documentation

◆ emitYaml()

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.

◆ fillFromYaml()

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.

◆ getActionMargins()

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.

◆ getAllActionMargins()

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.

◆ getAllJointCountAction()

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.

◆ getAllJointPos()

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.

◆ getInnerActionsNames()

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.

◆ getJointCountAction()

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.

◆ getJointPos()

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.

◆ getJointPosAction()

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.

◆ insertAction()

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.

◆ print()

void ROSEE::ActionTimed::print ( ) const
overridevirtual

Print info about this action.

Reimplemented from ROSEE::Action.

Definition at line 106 of file ActionTimed.cpp.

Member Data Documentation

◆ actionsJointCountMap

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

Definition at line 156 of file ActionTimed.h.

◆ actionsJointPosMap

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

Definition at line 155 of file ActionTimed.h.

◆ actionsNamesOrdered

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.

◆ actionsTimeMarginsMap

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

Definition at line 154 of file ActionTimed.h.

◆ jointPosFinal

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:


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