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 
40 #include <fstream>
41 #include <vector>
42 #include <map>
43 #include <list>
44 #include <mutex>
45 
46 namespace iCub
47 {
48 namespace skinDynLib
49 {
50 
52 {
53  public:
54  std::string name;
55  int size; // theoretical maximum size of the skinPart
56  // it corresponds to the number of values on the respective port
57  // and number of rows in the taxel positions .txt files in
58  // icub-main/app/skinGui/conf/positions in the [calibration] group
59  // IMPORTANT: it may differ from taxels.size()
60  std::string version; // Version of the skin part - "V1", "V2", "V2.1" (or "unknown_version").
61  // Depending on the physical version of skin on the robot. For example,
62  // forearm V2 has one triangle more compared to V1 and also partly different taxel IDs.
63  std::recursive_mutex recursive_mtx;
64  public:
68  skinPartBase();
69 
74  skinPartBase(const skinPartBase &_spb);
75 
80  virtual skinPartBase &operator=(const skinPartBase &_sp);
81 
86  void setName(const std::string &_name);
87 
92  std::string getName();
93 
98  void setSize(int _size);
99 
104  int getSize();
105 
110  void setVersion(const std::string &_version);
111 
116  std::string getVersion();
117 
123  virtual bool setTaxelPosesFromFile(const std::string &_filePath, const std::string &_spatial_sampling="default") { return false; }
124 
129  virtual void print(int verbosity=0);
130 
135  virtual std::string toString(int precision=0);
136 };
137 
145 class skinPart : public skinPartBase
146 {
147  public:
151  std::vector<Taxel*> taxels;
152 
158  std::string spatial_sampling;
159 
164  std::vector<int> taxel2Repr;
165 
170  std::map<int, std::list<unsigned int> > repr2TaxelList;
171 
172  protected:
179  bool setTaxelPosesFromFileOld(const std::string &_filePath);
180 
188 
189  public:
193  skinPart();
194 
199  skinPart(const std::string &_filePath);
200 
205  skinPart(const skinPart &_sp);
206 
211  skinPart &operator=(const skinPart &_sp);
212 
221  bool setTaxelPosesFromFile(const std::string &_filePath,
222  const std::string &_spatial_sampling="default");
223 
230 
235  int getTaxelsSize();
236 
241  void clearTaxels();
242 
247  void print(int verbosity=0);
248 
253  std::string toString(int precision=0);
254 
258  ~skinPart();
259 };
260 
261 }
262 
263 }//end namespace
264 
265 #endif
266 
267 // empty line to make gcc happy
virtual void print(int verbosity=0)
Print Method.
Definition: skinPart.cpp:61
std::string getName()
Gets the name of the class.
Definition: skinPart.cpp:35
int getSize()
Gets the size of the class.
Definition: skinPart.cpp:45
void setSize(int _size)
Sets the size of the class.
Definition: skinPart.cpp:40
virtual std::string toString(int precision=0)
toString Method
Definition: skinPart.cpp:69
virtual bool setTaxelPosesFromFile(const std::string &_filePath, const std::string &_spatial_sampling="default")
Populates the skinPartBase by reading from a file.
Definition: skinPart.h:123
std::recursive_mutex recursive_mtx
Definition: skinPart.h:63
std::string getVersion()
Gets the version.
Definition: skinPart.cpp:55
void setName(const std::string &_name)
Sets the name of the class.
Definition: skinPart.cpp:30
virtual skinPartBase & operator=(const skinPartBase &_sp)
Copy Operator.
Definition: skinPart.cpp:16
void setVersion(const std::string &_version)
Sets the version ("V1" / "V2" / "V2.1")
Definition: skinPart.cpp:50
Class that encloses everything relate to a skinPart.
Definition: skinPart.h:146
std::vector< int > taxel2Repr
Indexing variable used in the case of reducing the resolution - e.g.
Definition: skinPart.h:164
bool mapTaxelsOntoThemselves()
Maps the taxels onto themselves, performing a 1:1 mapping.
Definition: skinPart.cpp:285
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:170
std::vector< Taxel * > taxels
List of taxels that belong to the skinPart.
Definition: skinPart.h:151
skinPart & operator=(const skinPart &_sp)
Copy Operator.
Definition: skinPart.cpp:94
std::string spatial_sampling
Spatial_sampling used in building up the skinPart class.
Definition: skinPart.h:158
bool setTaxelPosesFromFileOld(const std::string &_filePath)
Populates the skinPart by reading from a file - old convention.
Definition: skinPart.cpp:234
int getTaxelsSize()
gets the size of the taxel vector (it differs from skinPartBase::getSize())
Definition: skinPart.cpp:330
void clearTaxels()
Clears the vector of taxels properly and gracefully.
Definition: skinPart.cpp:335
std::string toString(int precision=0)
toString Method
Definition: skinPart.cpp:386
bool initRepresentativeTaxels()
Initializes the mapping between the taxels and their representatives (i.e.
Definition: skinPart.cpp:313
bool setTaxelPosesFromFile(const std::string &_filePath, const std::string &_spatial_sampling="default")
Populates the skinPart by reading from a file.
Definition: skinPart.cpp:118
void print(int verbosity=0)
Print Method.
Definition: skinPart.cpp:349
skinPart()
Constructor.
Definition: skinPart.cpp:79
int verbosity
Definition: main.cpp:17
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.