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::ActionTrig Class Reference

The action of moving some joints (see later) of a single finger in a full clousure position towards the palm. More...

#include <ActionTrig.h>

+ Inheritance diagram for ROSEE::ActionTrig:
+ Collaboration diagram for ROSEE::ActionTrig:

Public Types

typedef std::map< std::string, ActionTrigMap
 
- Public Types inherited from ROSEE::ActionPrimitive
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

 ActionTrig (std::string actionName, ActionPrimitive::Type)
 
 ActionTrig (std::string actionName, ActionPrimitive::Type, std::string tip, JointPos)
 
std::vector< JointPosgetAllJointPos () const override
 Overriden get from the pure virtual function of the base class ActionPrimitive The signature must be equal, even if here we have set and vector of only one element. More...
 
std::set< std::string > getKeyElements () const override
 Necessary method to know the key used by the maps which store all the Actions of one type. More...
 
JointPos getJointPos () const override
 Overriden get from the pure virtual function of the base class Action. More...
 
void setJointPos (JointPos)
 
std::string getFingerInvolved () const
 Specific method of trig to simply return a string instead of the full vector fingersInvolved that in this case contains only one element. More...
 
void setFingerInvolved (std::string)
 
bool fillFromYaml (YAML::const_iterator yamlIt) override
 function to fill members of the Action with infos taken from yaml files More...
 
- Public Member Functions inherited from ROSEE::ActionPrimitive
virtual ~ActionPrimitive ()
 
Type getPrimitiveType () const
 
unsigned int getMaxStoredActionStates () const
 
unsigned int getnFingersInvolved () const
 
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 void print () const
 Overridable functions, if we want to make them more action-specific. More...
 

Private Attributes

JointPos jointPos
 

Additional Inherited Members

- Protected Member Functions inherited from ROSEE::ActionPrimitive
 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 inherited from ROSEE::ActionPrimitive
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

The action of moving some joints (see later) of a single finger in a full clousure position towards the palm.

The action is unique (joints involved in a certain position: the bound) so maxStoredActionStates == 1 always Described by:

Actually, there are 3 types of action for this class

Todo:
instead of tip , use the finger name for the Trig (i.e. the defined srdf group).
Note
We have to understand the direction of joints to make the finger full close. Because full close position can be linked to both lower or upper bound of each joint involved. The method to solve this is to go in the max range of the joint, because usually a finger has more motion towards the palm respect the opposite (like humans). We consider the default joint pos to 0.
Warning
so, take care of joint limits: they must include the 0. Has it sense to have joint limits both positive or both negative (not including the 0) ?

Definition at line 64 of file ActionTrig.h.

Member Typedef Documentation

typedef std::map< std::string, ActionTrig > ROSEE::ActionTrig::Map

Definition at line 69 of file ActionTrig.h.

Constructor & Destructor Documentation

ROSEE::ActionTrig::ActionTrig ( std::string  actionName,
ActionPrimitive::Type  actionType 
)

Definition at line 21 of file ActionTrig.cpp.

21  :
22  ActionPrimitive ( actionName, 1, 1, actionType ) { }
ActionPrimitive(std::string name, unsigned int maxStoredActionStates, Type type)
ROSEE::ActionTrig::ActionTrig ( std::string  actionName,
ActionPrimitive::Type  actionType,
std::string  tip,
JointPos  jp 
)

Definition at line 24 of file ActionTrig.cpp.

24  :
25  ActionPrimitive ( actionName, 1, 1, actionType ) {
26 
27  fingersInvolved.insert(tip);
28  jointPos = jp;
29 }
JointPos jointPos
Definition: ActionTrig.h:107
ActionPrimitive(std::string name, unsigned int maxStoredActionStates, Type type)
std::set< std::string > fingersInvolved
Definition: Action.h:148

Member Function Documentation

bool ROSEE::ActionTrig::fillFromYaml ( YAML::const_iterator  yamlIt)
overridevirtual

function to fill members of the Action with infos taken from yaml files

Parameters
yamlIta YAML::const_iterator to the node that is loaded with YAML::LoadFile(dirPath + filename). check YamlWorker to correctly parse and emit the file

Implements ROSEE::Action.

Definition at line 59 of file ActionTrig.cpp.

59  {
60 
61 
62  std::vector <std::string> fingInvolvedVect = yamlIt->first.as <std::vector < std::string >> ();
63  for (const auto &it : fingInvolvedVect) {
64  fingersInvolved.insert(it);
65  }
66 
67  for ( YAML::const_iterator element = yamlIt->second.begin(); element != yamlIt->second.end(); ++element) {
68 
69  std::string key = element->first.as<std::string>();
70  if ( key.compare ("ActionName") == 0 ){
71  name = element->second.as < std::string > ();
72 
73  } else if (key.compare("JointsInvolvedCount") == 0) {
74  jointsInvolvedCount = element->second.as < JointsInvolvedCount > ();
75 
76  } else if (key.compare ("PrimitiveType") == 0) {
78  element->second.as <unsigned int>() );
79  if (parsedType != primitiveType ) {
80  std::cerr << "[ERROR ActionTrig::" << __func__ << " parsed a type " << parsedType <<
81  " but this object has primitive type " << primitiveType << std::endl;
82  return false;
83  }
84 
85  } else if (key.compare(0, 12, "ActionState_") == 0) { //compare 12 caracters from index 0 of key
86  for(YAML::const_iterator asEl = element->second.begin(); asEl != element->second.end(); ++asEl) {
87  //asEl can be the map JointStates or the map Optional
88 
89  if (asEl->first.as<std::string>().compare ("JointPos") == 0 ) {
90  jointPos = asEl->second.as < JointPos >() ;
91 
92  } else {
93  //ERRROr, only JointPos at this level (optional is not for trig)
94  std::cerr << "[ERROR ActionTrig::" << __func__ << " not know key "
95  << asEl->first.as<std::string>() <<
96  " found in the yaml file at this level" << std::endl;
97  return false;
98  }
99  }
100 
101  } else {
102  std::cerr << "[ERROR ActionTrig::" << __func__ << "not know key " << key <<
103  " found in the yaml file" << std::endl;
104  }
105  }
106  return true;
107 }
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
JointPos jointPos
Definition: ActionTrig.h:107
Type
Enum useful to discriminate each primitive action when, for example, we want to parse a file if you ...
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
std::set< std::string > fingersInvolved
Definition: Action.h:148
std::vector< ROSEE::JointPos > ROSEE::ActionTrig::getAllJointPos ( ) const
overridevirtual

Overriden get from the pure virtual function of the base class ActionPrimitive The signature must be equal, even if here we have set and vector of only one element.

For this class this function simply return a vector which contain a single element.

Implements ROSEE::Action.

Definition at line 47 of file ActionTrig.cpp.

47  {
48 
49  std::vector < JointPos > retVect {jointPos};
50  return retVect;
51 }
JointPos jointPos
Definition: ActionTrig.h:107
std::string ROSEE::ActionTrig::getFingerInvolved ( ) const

Specific method of trig to simply return a string instead of the full vector fingersInvolved that in this case contains only one element.

Definition at line 31 of file ActionTrig.cpp.

31  {
32  return *( fingersInvolved.begin() );
33 }
std::set< std::string > fingersInvolved
Definition: Action.h:148
ROSEE::JointPos ROSEE::ActionTrig::getJointPos ( ) const
overridevirtual

Overriden get from the pure virtual function of the base class Action.

Implements ROSEE::Action.

Definition at line 35 of file ActionTrig.cpp.

35  {
36  return jointPos;
37 }
JointPos jointPos
Definition: ActionTrig.h:107
std::set< std::string > ROSEE::ActionTrig::getKeyElements ( ) const
overridevirtual

Necessary method to know the key used by the maps which store all the Actions of one type.

Used by YamlWorker

Returns
for this class, it return the finger name, inserted in a single-element set because father signature say so

Implements ROSEE::ActionPrimitive.

Definition at line 39 of file ActionTrig.cpp.

39  {
40  return fingersInvolved;
41 }
std::set< std::string > fingersInvolved
Definition: Action.h:148
void ROSEE::ActionTrig::setFingerInvolved ( std::string  fingName)

Definition at line 54 of file ActionTrig.cpp.

54  {
55  fingersInvolved.clear();
56  fingersInvolved.insert(fingName);
57 }
std::set< std::string > fingersInvolved
Definition: Action.h:148
void ROSEE::ActionTrig::setJointPos ( ROSEE::JointPos  jointPos)

Definition at line 43 of file ActionTrig.cpp.

43  {
44  this->jointPos = jointPos;
45 }
JointPos jointPos
Definition: ActionTrig.h:107

Member Data Documentation

JointPos ROSEE::ActionTrig::jointPos
private

Definition at line 107 of file ActionTrig.h.


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