iCub-main
skinPart.h
Go to the documentation of this file.
1 
32 #ifndef __SKINPART_H__
33 #define __SKINPART_H__
34 
35 #include "iCub/skinDynLib/Taxel.h"
36 #include "iCub/skinDynLib/common.h"
37 
38 #include <yarp/os/RFModule.h>
39 #include <yarp/os/RecursiveMutex.h>
40 
41 #include <fstream>
42 #include <vector>
43 #include <map>
44 #include <list>
45 #include <mutex>
46 
47 namespace iCub
48 {
49 namespace skinDynLib
50 {
51 
53 {
54  public:
55  std::string name;
56  int size; // theoretical maximum size of the skinPart
57  // it corresponds to the number of values on the respective port
58  // and number of rows in the taxel positions .txt files in
59  // icub-main/app/skinGui/conf/positions in the [calibration] group
60  // IMPORTANT: it may differ from taxels.size()
61  std::string version; // Version of the skin part - "V1", "V2", "V2.1" (or "unknown_version").
62  // Depending on the physical version of skin on the robot. For example,
63  // forearm V2 has one triangle more compared to V1 and also partly different taxel IDs.
64  std::recursive_mutex recursive_mtx;
65  public:
69  skinPartBase();
70 
75  skinPartBase(const skinPartBase &_spb);
76 
81  virtual skinPartBase &operator=(const skinPartBase &_sp);
82 
87  void setName(const std::string &_name);
88 
93  std::string getName();
94 
99  void setSize(int _size);
100 
105  int getSize();
106 
111  void setVersion(const std::string &_version);
112 
117  std::string getVersion();
118 
124  virtual bool setTaxelPosesFromFile(const std::string &_filePath, const std::string &_spatial_sampling="default") { return false; }
125 
130  virtual void print(int verbosity=0);
131 
136  virtual std::string toString(int precision=0);
137 };
138 
146 class skinPart : public skinPartBase
147 {
148  public:
152  std::vector<Taxel*> taxels;
153 
159  std::string spatial_sampling;
160 
165  std::vector<int> taxel2Repr;
166 
171  std::map<int, std::list<unsigned int> > repr2TaxelList;
172 
173  protected:
180  bool setTaxelPosesFromFileOld(const std::string &_filePath);
181 
188  bool mapTaxelsOntoThemselves();
189 
190  public:
194  skinPart();
195 
200  skinPart(const std::string &_filePath);
201 
206  skinPart(const skinPart &_sp);
207 
212  skinPart &operator=(const skinPart &_sp);
213 
222  bool setTaxelPosesFromFile(const std::string &_filePath,
223  const std::string &_spatial_sampling="default");
224 
230  bool initRepresentativeTaxels();
231 
236  int getTaxelsSize();
237 
242  void clearTaxels();
243 
248  void print(int verbosity=0);
249 
254  std::string toString(int precision=0);
255 
259  ~skinPart();
260 };
261 
262 }
263 
264 }//end namespace
265 
266 #endif
267 
268 // empty line to make gcc happy
int verbosity
Definition: main.cpp:20
std::vector< int > taxel2Repr
Indexing variable used in the case of reducing the resolution - e.g.
Definition: skinPart.h:165
virtual skinPartBase & operator=(const skinPartBase &_sp)
Copy Operator.
Definition: skinPart.cpp:16
void setName(const std::string &_name)
Sets the name of the class.
Definition: skinPart.cpp:30
skinPartBase()
Constructor.
Definition: skinPart.cpp:9
int getSize()
Gets the size of the class.
Definition: skinPart.cpp:45
std::string getVersion()
Gets the version.
Definition: skinPart.cpp:55
std::string getName()
Gets the name of the class.
Definition: skinPart.cpp:35
std::vector< Taxel * > taxels
List of taxels that belong to the skinPart.
Definition: skinPart.h:152
void setSize(int _size)
Sets the size of the class.
Definition: skinPart.cpp:40
std::recursive_mutex recursive_mtx
Definition: skinPart.h:64
std::string spatial_sampling
Spatial_sampling used in building up the skinPart class.
Definition: skinPart.h:159
void setVersion(const std::string &_version)
Sets the version ("V1" / "V2" / "V2.1")
Definition: skinPart.cpp:50
virtual std::string toString(int precision=0)
toString Method
Definition: skinPart.cpp:69
This file contains the definition of unique IDs for the body parts and the skin parts of the robot...
Class that encloses everything relate to a skinPart.
Definition: skinPart.h:146
virtual bool setTaxelPosesFromFile(const std::string &_filePath, const std::string &_spatial_sampling="default")
Populates the skinPartBase by reading from a file.
Definition: skinPart.h:124
virtual void print(int verbosity=0)
Print Method.
Definition: skinPart.cpp:61
std::map< int, std::list< unsigned int > > repr2TaxelList
Mapping in the opposite direction Indexed by representative taxel IDs, it stores lists of the taxels ...
Definition: skinPart.h:171