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

Primitive which indicate a motion of n fingers moving ONLY ONE joint. More...

#include <ActionSingleJointMultipleTips.h>

+ Inheritance diagram for ROSEE::ActionSingleJointMultipleTips:
+ Collaboration diagram for ROSEE::ActionSingleJointMultipleTips:

Public Types

typedef std::map< std::string, ActionSingleJointMultipleTipsMap
 
- 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

 ActionSingleJointMultipleTips ()
 
 ActionSingleJointMultipleTips (std::string actionName, unsigned int nFingers)
 NOT ANYOMORE ? used (for now) by yaml worker only. More...
 
 ActionSingleJointMultipleTips (std::string actionName, std::vector< std::string > fingers, std::string jointName, JointPos jpFurther, JointPos jpNearer)
 "Standard" costructor, which fill all the necessary infos More...
 
std::vector< JointPosgetAllJointPos () const override
 Overriden get from the pure virtual function of the base class Action The signature must be equal, even if here we have set and vector of only one element. More...
 
JointPos getJointPos () const override
 Overriden get from the pure virtual function of the base class Action. 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 getJointPosFurther () const
 
JointPos getJointPosNearer () const
 
std::string getJointName () const
 
void print () const override
 Overridable functions, if we want to make them more action-specific. More...
 
void emitYaml (YAML::Emitter &out) const override
 Function to fill the argument passed with info about the action. More...
 
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)
 
- 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

JointPos jointPosFurther
 
JointPos jointPosNearer
 
std::string jointInvolved
 

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

Primitive which indicate a motion of n fingers moving ONLY ONE joint.

For example, this primitive is necessary for the hands that have one joint that close all the fingers to do a grasp. But it can also useful to detect other multiple finger motions (like a "spread finger")

Definition at line 31 of file ActionSingleJointMultipleTips.h.

Member Typedef Documentation

Definition at line 35 of file ActionSingleJointMultipleTips.h.

Constructor & Destructor Documentation

ROSEE::ActionSingleJointMultipleTips::ActionSingleJointMultipleTips ( )

Definition at line 19 of file ActionSingleJointMultipleTips.cpp.

19  :
20  ActionPrimitive ( "singleJointMultipleTips", 1, ROSEE::ActionPrimitive::Type::SingleJointMultipleTips ) {}
ActionPrimitive(std::string name, unsigned int maxStoredActionStates, Type type)
ROSEE::ActionSingleJointMultipleTips::ActionSingleJointMultipleTips ( std::string  actionName,
unsigned int  nFingers 
)

NOT ANYOMORE ? used (for now) by yaml worker only.

Before parsing we cant now the info that the other costructor need. So all these infos are set in the fillFromYaml

Parameters
actionNamename of the action
nFingersnumber of the fingers involved in the action (i.e. number of finger that the jointInvolved moves)

Definition at line 22 of file ActionSingleJointMultipleTips.cpp.

22  :
23  ActionPrimitive ( actionName, nFingers, 1, ROSEE::ActionPrimitive::Type::SingleJointMultipleTips ) {}
ActionPrimitive(std::string name, unsigned int maxStoredActionStates, Type type)
ROSEE::ActionSingleJointMultipleTips::ActionSingleJointMultipleTips ( std::string  actionName,
std::vector< std::string >  fingers,
std::string  jointName,
JointPos  jpFurther,
JointPos  jpNearer 
)

"Standard" costructor, which fill all the necessary infos

Parameters
actionNamename of the action
fingersvector containing all the fingers involved
jointNamethe name of the joint involved in the action (one joint for definition)
jpFurtherJointPosition of ALL joints of the hand, with only the jointName set, in a way that the position is to the bound which is further from the default position (which is 0)
jpNearerJointPosition of ALL joints of the hand, with only the jointName set, in a way that the position is to the bound which is nearer from the default position
Warning
If 0 position is not included between the bounds (eg 0.4 | 5.1) , jpNearer is the one nearer to 0 (0.4) and jpFurther the further (5.1). CHECK THIS FACT TO BE SURE

Definition at line 25 of file ActionSingleJointMultipleTips.cpp.

26  :
27  ActionPrimitive ( actionName, fingers.size(), 1, ROSEE::ActionPrimitive::Type::SingleJointMultipleTips ) {
28 
29  this->jointInvolved = jointName;
30  fingersInvolved.insert (fingers.begin(), fingers.end());
31 
32  this->jointPosFurther = jpFurther;
33  this->jointPosNearer = jpNearer;
34 
35  // still need to do this, that can be done in costructor because we know that only one joint will be used, per definition of this action
36  for (auto it : jpFurther ) {
37  jointsInvolvedCount.insert (std::make_pair (it.first, 0) );
38  }
39  jointsInvolvedCount.at (jointName) = 1;
40 
41 }
ActionPrimitive(std::string name, unsigned int maxStoredActionStates, Type type)
JointsInvolvedCount jointsInvolvedCount
Definition: Action.h:149
std::set< std::string > fingersInvolved
Definition: Action.h:148

Member Function Documentation

void ROSEE::ActionSingleJointMultipleTips::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.

Reimplemented from ROSEE::ActionPrimitive.

Definition at line 99 of file ActionSingleJointMultipleTips.cpp.

99  {
100 
101  out << YAML::Key << jointInvolved;
102  out << YAML::Value << YAML::BeginMap;
103 
104  out << YAML::Key << "PrimitiveType" << YAML::Value << primitiveType;
105  out << YAML::Key << "ActionName" << YAML::Value << name;
106  out << YAML::Key << "FingersInvolved" << YAML::Value << YAML::Flow << fingersInvolved;
107 
108  out << YAML::Key << "JointPosFurther" << YAML::Value << YAML::BeginMap;
109  for (const auto &joint : jointPosFurther) {
110  out << YAML::Key << joint.first;
111  out << YAML::Value << YAML::Flow << joint.second; //vector of double is emitted like Seq
112  }
113  out << YAML::EndMap;
114 
115  out << YAML::Key << "JointPosNearer" << YAML::Value << YAML::BeginMap;
116  for (const auto &joint : jointPosNearer) {
117  out << YAML::Key << joint.first;
118  out << YAML::Value << YAML::Flow << joint.second; //vector of double is emitted like Seq
119  }
120  out << YAML::EndMap;
121 
122  out << YAML::EndMap;
123 
124 }
std::string name
Definition: Action.h:146
std::set< std::string > fingersInvolved
Definition: Action.h:148
bool ROSEE::ActionSingleJointMultipleTips::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 128 of file ActionSingleJointMultipleTips.cpp.

128  {
129 
130  jointInvolved = yamlIt->first.as < std::string > ();
131 
132  for ( YAML::const_iterator keyValue = yamlIt->second.begin(); keyValue != yamlIt->second.end(); ++keyValue) {
133  std::string key = keyValue->first.as<std::string>();
134 
135  if ( key.compare ("ActionName") == 0 ){
136  name = keyValue->second.as < std::string > ();
137 
138  } else if (key.compare("FingersInvolved") == 0) {
139  std::vector <std::string> fingInvolvedVect = keyValue->second.as <std::vector < std::string >> ();
140  for (const auto &it : fingInvolvedVect) {
141  fingersInvolved.insert(it);
142  }
143 
144  } else if (key.compare ("JointPosNearer") == 0) {
145  jointPosNearer = keyValue->second.as <JointPos>();
146 
147  } else if (key.compare ("JointPosFurther") == 0) {
148  jointPosFurther = keyValue->second.as <JointPos>();
149 
150  } else if (key.compare ("PrimitiveType") == 0) {
152  keyValue->second.as <unsigned int>() );
153  if (parsedType != primitiveType ) {
154  std::cerr << "[ERROR ActionSingleJointMultipleTips::" << __func__ << " parsed a type " << parsedType <<
155  " but this object has primitive type " << primitiveType << std::endl;
156  return false;
157  }
158 
159  } else {
160  std::cerr << "[ERROR ActionSingleJointMultipleTips::" << __func__ << "not know key " << key <<
161  " found in the yaml file" << std::endl;
162  return false;
163  }
164  }
165 
166  // we have also to fill this structure, that is not present on yaml file because redundant
167  for (auto it : jointPosFurther ) {
168  jointsInvolvedCount.insert (std::make_pair (it.first, 0) );
169  }
171 
173 
174  return true;
175 
176 }
unsigned int nFingersInvolved
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
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::ActionSingleJointMultipleTips::getAllJointPos ( ) const
overridevirtual

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

For this class this function return the vector which contain jointPosFurther and jointPosNearer

Implements ROSEE::Action.

Definition at line 43 of file ActionSingleJointMultipleTips.cpp.

43  {
44 
45  std::vector<JointPos> vect;
46  vect.push_back (jointPosFurther);
47  vect.push_back (jointPosNearer);
48  return vect;
49 }
std::string ROSEE::ActionSingleJointMultipleTips::getJointName ( ) const

Definition at line 63 of file ActionSingleJointMultipleTips.cpp.

ROSEE::JointPos ROSEE::ActionSingleJointMultipleTips::getJointPos ( ) const
overridevirtual

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

Returns
the jointPosFurther

Implements ROSEE::Action.

Definition at line 51 of file ActionSingleJointMultipleTips.cpp.

ROSEE::JointPos ROSEE::ActionSingleJointMultipleTips::getJointPosFurther ( ) const

Definition at line 55 of file ActionSingleJointMultipleTips.cpp.

ROSEE::JointPos ROSEE::ActionSingleJointMultipleTips::getJointPosNearer ( ) const

Definition at line 59 of file ActionSingleJointMultipleTips.cpp.

std::set< std::string > ROSEE::ActionSingleJointMultipleTips::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 jointName, inserted in a single-element set because father signature say so

Implements ROSEE::ActionPrimitive.

Definition at line 67 of file ActionSingleJointMultipleTips.cpp.

67  {
68  std::set <std::string> set;
69  set.insert(jointInvolved);
70  return set;
71 }
void ROSEE::ActionSingleJointMultipleTips::print ( ) const
overridevirtual

Overridable functions, if we want to make them more action-specific.

Reimplemented from ROSEE::Action.

Definition at line 73 of file ActionSingleJointMultipleTips.cpp.

73  {
74 
75  std::stringstream output;
76  output << "ActionName: " << name << std::endl;
77 
78  output << "FingersInvolved: [";
79  for (auto fingName : fingersInvolved){
80  output << fingName << ", " ;
81  }
82  output.seekp (-2, output.cur); //to remove the last comma (and space)
83  output << "]" << std::endl;
84 
85  output << "Joint which moves the tips: " << jointInvolved << std::endl;
86 
87  output << "JointPos Further from 0:" << std::endl;
88  output << jointPosFurther;
89 
90  output << "JointPos Nearer to 0:" << std::endl;
91  output << jointPosNearer;
92 
93  output << std::endl;
94 
95  std::cout << output.str();
96 
97 }
std::string name
Definition: Action.h:146
std::set< std::string > fingersInvolved
Definition: Action.h:148

Member Data Documentation

std::string ROSEE::ActionSingleJointMultipleTips::jointInvolved
private

Definition at line 91 of file ActionSingleJointMultipleTips.h.

JointPos ROSEE::ActionSingleJointMultipleTips::jointPosFurther
private

Definition at line 89 of file ActionSingleJointMultipleTips.h.

JointPos ROSEE::ActionSingleJointMultipleTips::jointPosNearer
private

Definition at line 90 of file ActionSingleJointMultipleTips.h.


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