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:
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 
93 
98  void setSize(int _size);
99 
104  int getSize();
105 
110  void setVersion(const std::string &_version);
111 
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 
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
iCub::skinDynLib::skinPartBase::size
int size
Definition: skinPart.h:55
iCub::skinDynLib::skinPart::print
void print(int verbosity=0)
Print Method.
Definition: skinPart.cpp:349
iCub
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
Definition: emotionInterface.h:17
iCub::skinDynLib::skinPart::setTaxelPosesFromFileOld
bool setTaxelPosesFromFileOld(const std::string &_filePath)
Populates the skinPart by reading from a file - old convention.
Definition: skinPart.cpp:234
iCub::skinDynLib::skinPart
Definition: skinPart.h:145
iCub::skinDynLib::skinPart::initRepresentativeTaxels
bool initRepresentativeTaxels()
Initializes the mapping between the taxels and their representatives (i.e.
Definition: skinPart.cpp:313
iCub::skinDynLib::skinPartBase::setTaxelPosesFromFile
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
iCub::skinDynLib::skinPart::~skinPart
~skinPart()
Destructor.
Definition: skinPart.cpp:395
iCub::skinDynLib::skinPartBase::setVersion
void setVersion(const std::string &_version)
Sets the version ("V1" / "V2" / "V2.1")
Definition: skinPart.cpp:50
iCub::skinDynLib::skinPartBase::operator=
virtual skinPartBase & operator=(const skinPartBase &_sp)
Copy Operator.
Definition: skinPart.cpp:16
iCub::skinDynLib::skinPart::repr2TaxelList
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
iCub::skinDynLib::skinPartBase::getVersion
std::string getVersion()
Gets the version.
Definition: skinPart.cpp:55
iCub::skinDynLib::skinPart::setTaxelPosesFromFile
bool setTaxelPosesFromFile(const std::string &_filePath, const std::string &_spatial_sampling="default")
Populates the skinPart by reading from a file.
Definition: skinPart.cpp:118
iCub::skinDynLib::skinPart::clearTaxels
void clearTaxels()
Clears the vector of taxels properly and gracefully.
Definition: skinPart.cpp:335
iCub::skinDynLib::skinPartBase::getName
std::string getName()
Gets the name of the class.
Definition: skinPart.cpp:35
Taxel.h
verbosity
int verbosity
Definition: main.cpp:22
iCub::skinDynLib::skinPart::taxel2Repr
std::vector< int > taxel2Repr
Indexing variable used in the case of reducing the resolution - e.g.
Definition: skinPart.h:164
iCub::skinDynLib::skinPart::skinPart
skinPart()
Constructor.
Definition: skinPart.cpp:79
iCub::skinDynLib::skinPartBase::skinPartBase
skinPartBase()
Constructor.
Definition: skinPart.cpp:9
iCub::skinDynLib::skinPartBase::toString
virtual std::string toString(int precision=0)
toString Method
Definition: skinPart.cpp:69
iCub::skinDynLib::skinPartBase::getSize
int getSize()
Gets the size of the class.
Definition: skinPart.cpp:45
iCub::skinDynLib::skinPart::taxels
std::vector< Taxel * > taxels
List of taxels that belong to the skinPart.
Definition: skinPart.h:151
iCub::skinDynLib::skinPartBase::setSize
void setSize(int _size)
Sets the size of the class.
Definition: skinPart.cpp:40
iCub::skinDynLib::skinPart::spatial_sampling
std::string spatial_sampling
Spatial_sampling used in building up the skinPart class.
Definition: skinPart.h:158
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
iCub::skinDynLib::skinPartBase::version
std::string version
Definition: skinPart.h:60
iCub::skinDynLib::skinPart::getTaxelsSize
int getTaxelsSize()
gets the size of the taxel vector (it differs from skinPartBase::getSize())
Definition: skinPart.cpp:330
iCub::skinDynLib::skinPartBase::name
std::string name
Definition: skinPart.h:54
iCub::skinDynLib::skinPart::operator=
skinPart & operator=(const skinPart &_sp)
Copy Operator.
Definition: skinPart.cpp:94
iCub::skinDynLib::skinPartBase::print
virtual void print(int verbosity=0)
Print Method.
Definition: skinPart.cpp:61
common.h
iCub::skinDynLib::skinPart::mapTaxelsOntoThemselves
bool mapTaxelsOntoThemselves()
Maps the taxels onto themselves, performing a 1:1 mapping.
Definition: skinPart.cpp:285
iCub::skinDynLib::skinPart::toString
std::string toString(int precision=0)
toString Method
Definition: skinPart.cpp:386
iCub::skinDynLib::skinPartBase
Definition: skinPart.h:51
iCub::skinDynLib::skinPartBase::recursive_mtx
std::recursive_mutex recursive_mtx
Definition: skinPart.h:63
iCub::skinDynLib::skinPartBase::setName
void setName(const std::string &_name)
Sets the name of the class.
Definition: skinPart.cpp:30