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 | Protected Member Functions | Protected Attributes | List of all members
ROSEE::ActionPrimitive Class Referenceabstract

Virtual class, Base of all the primitive actions. More...

#include <ActionPrimitive.h>

+ Inheritance diagram for ROSEE::ActionPrimitive:
+ Collaboration diagram for ROSEE::ActionPrimitive:

Public Types

enum  Type {
  PinchTight,
  PinchLoose,
  MultiplePinchTight,
  Trig,
  TipFlex,
  FingFlex,
  SingleJointMultipleTips,
  None
}
 Enum useful to discriminate each primitive 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< ActionPrimitivePtr
 
typedef std::shared_ptr< const ActionPrimitiveConstPtr
 
- 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

virtual ~ActionPrimitive ()
 
Type getPrimitiveType () const
 
unsigned int getMaxStoredActionStates () const
 
unsigned int getnFingersInvolved () const
 
virtual std::set< std::string > getKeyElements () const =0
 Depending on the primitive, we can use different "keys" to take info from yaml file when parsing for example, trig and pinches are selected through fingersInvolved, while ActionSingleJointMultipleTips uses the joint name. More...
 
void setJointsInvolvedCount (ROSEE::JointsInvolvedCount jointsInvolvedCount)
 
virtual void emitYaml (YAML::Emitter &) const override
 Function to fill the argument passed with info about the action. 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...
 
virtual JointPos getJointPos () const =0
 Get the position related to this action. More...
 
virtual std::vector< ROSEE::JointPosgetAllJointPos () const =0
 Return all the joint position stored. More...
 
virtual void print () const
 Overridable functions, if we want to make them more action-specific. More...
 
virtual bool fillFromYaml (YAML::const_iterator yamlIt)=0
 function to fill members of the Action with infos taken from yaml files More...
 

Protected Member Functions

 ActionPrimitive (std::string name, unsigned int maxStoredActionStates, Type type)
 
 ActionPrimitive (std::string name, unsigned int nFingersInvolved, unsigned int maxStoredActionStates, Type type)
 Protected costructor: object creable only by derived classes. More...
 
- Protected Member Functions inherited from ROSEE::Action
 Action ()
 
 Action (std::string actionName, Action::Type type)
 

Protected Attributes

unsigned int nFingersInvolved
 
const unsigned int maxStoredActionStates
 
const Type primitiveType
 
- Protected Attributes inherited from ROSEE::Action
std::string name
 
Action::Type type
 
std::set< std::string > fingersInvolved
 
JointsInvolvedCount jointsInvolvedCount
 

Detailed Description

Virtual class, Base of all the primitive actions.

It has some implemented functions that a derived class can use, if you don't want to override to make them more action-specific. All the primitives are defined by:

Definition at line 48 of file ActionPrimitive.h.

Member Typedef Documentation

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

Definition at line 54 of file ActionPrimitive.h.

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

Definition at line 53 of file ActionPrimitive.h.

Member Enumeration Documentation

Enum useful to discriminate each primitive action when, for example, we want to parse a file if you change this enum, change also the ROSEEControl.msg accordingly.

Enumerator
PinchTight 
PinchLoose 
MultiplePinchTight 
Trig 
TipFlex 
FingFlex 
SingleJointMultipleTips 
None 

Definition at line 60 of file ActionPrimitive.h.

Constructor & Destructor Documentation

virtual ROSEE::ActionPrimitive::~ActionPrimitive ( )
inlinevirtual

Definition at line 62 of file ActionPrimitive.h.

62 {};
ROSEE::ActionPrimitive::ActionPrimitive ( std::string  name,
unsigned int  maxStoredActionStates,
ActionPrimitive::Type  primitiveType 
)
protected

Definition at line 39 of file ActionPrimitive.cpp.

39  :
std::string name
Definition: Action.h:146
const unsigned int maxStoredActionStates
ROSEE::ActionPrimitive::ActionPrimitive ( std::string  name,
unsigned int  nFingersInvolved,
unsigned int  maxStoredActionStates,
ActionPrimitive::Type  primitiveType 
)
protected

Protected costructor: object creable only by derived classes.

There is no default costructor (without arguments) because we want to set always these members

Definition at line 42 of file ActionPrimitive.cpp.

44  :
unsigned int nFingersInvolved
std::string name
Definition: Action.h:146
const unsigned int maxStoredActionStates

Member Function Documentation

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

Function to fill the argument passed with info about the action.

Pure virtual because each derived class has different infos and stored differently. check YamlWorker to correctly emit and parse the file

Parameters
outthe yaml-cpp emitter which store infos about the action
Note
this function does not print in a file, but simply fill a YAML::Emitter.

Implements ROSEE::Action.

Reimplemented in ROSEE::ActionPinchLoose, ROSEE::ActionMultiplePinchTight, ROSEE::ActionSingleJointMultipleTips, and ROSEE::ActionPinchTight.

Definition at line 67 of file ActionPrimitive.cpp.

67  {
68 
69  // key: set of string (eg two tip names)
70  out << YAML::Key << YAML::Flow << fingersInvolved;
71 
72  unsigned int nCont = 1;
73  out << YAML::Value << YAML::BeginMap;
74  out << YAML::Key << "PrimitiveType" << YAML::Value << primitiveType;
75  out << YAML::Key << "ActionName" << YAML::Value << name;
76  out << YAML::Key << "JointsInvolvedCount" << YAML::Value << YAML::BeginMap;
77  for (const auto &jointCount : jointsInvolvedCount ) {
78  out << YAML::Key << jointCount.first;
79  out << YAML::Value << jointCount.second;
80  }
81  out << YAML::EndMap;
82 
83 
84  for (const auto & jointPos : getAllJointPos()) {
85 
86  std::string contSeq = "ActionState_" + std::to_string(nCont);
87  out << YAML::Key << contSeq;
88 
89  out << YAML::Value << YAML::BeginMap;
90  //actionState.first, the jointstates map
91  out << YAML::Key << "JointPos" << YAML::Value << YAML::BeginMap;
92  for (const auto &joint : jointPos) {
93  out << YAML::Key << joint.first;
94  out << YAML::Value << YAML::Flow << joint.second; //vector of double is emitted like Seq
95  }
96  out << YAML::EndMap;
97 
98  out << YAML::EndMap;
99  nCont++;
100  }
101  out << YAML::EndMap;
102 }
std::string name
Definition: Action.h:146
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
virtual std::vector< ROSEE::JointPos > getAllJointPos() const =0
Return all the joint position stored.
std::set< std::string > fingersInvolved
Definition: Action.h:148
virtual std::set< std::string> ROSEE::ActionPrimitive::getKeyElements ( ) const
pure virtual

Depending on the primitive, we can use different "keys" to take info from yaml file when parsing for example, trig and pinches are selected through fingersInvolved, while ActionSingleJointMultipleTips uses the joint name.

So each derived class must override this info, which for now is used only in YamlWorker::parseYamlPrimitive() and also by map handler to get the primitive, also on send action test

Implemented in ROSEE::ActionTrig, ROSEE::ActionSingleJointMultipleTips, and ROSEE::ActionPinchGeneric.

unsigned int ROSEE::ActionPrimitive::getMaxStoredActionStates ( ) const

Definition at line 53 of file ActionPrimitive.cpp.

53  {
54  return maxStoredActionStates;
55 }
const unsigned int maxStoredActionStates
unsigned int ROSEE::ActionPrimitive::getnFingersInvolved ( ) const

Definition at line 57 of file ActionPrimitive.cpp.

57  {
58  return nFingersInvolved;
59 }
unsigned int nFingersInvolved
ROSEE::ActionPrimitive::Type ROSEE::ActionPrimitive::getPrimitiveType ( ) const

Definition at line 49 of file ActionPrimitive.cpp.

49  {
50  return primitiveType;
51 }
void ROSEE::ActionPrimitive::setJointsInvolvedCount ( ROSEE::JointsInvolvedCount  jointsInvolvedCount)

Definition at line 61 of file ActionPrimitive.cpp.

61  {
63 }
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149

Member Data Documentation

const unsigned int ROSEE::ActionPrimitive::maxStoredActionStates
protected

Definition at line 95 of file ActionPrimitive.h.

unsigned int ROSEE::ActionPrimitive::nFingersInvolved
protected

Definition at line 92 of file ActionPrimitive.h.

const Type ROSEE::ActionPrimitive::primitiveType
protected

Definition at line 97 of file ActionPrimitive.h.


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