iCub-main
skinContact.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2011 RobotCub Consortium
3  * Author: Andrea Del Prete
4  * CopyPolicy: Released under the terms of the GNU GPL v2.0.
5  *
6  */
7 
29 #ifndef __SKINCONT_H__
30 #define __SKINCONT_H__
31 
32 #include <iostream>
33 #include <iomanip>
34 #include <vector>
35 #include <yarp/sig/Vector.h>
37 
38 namespace iCub
39 {
40 
41 namespace skinDynLib
42 {
43 
49 class skinContact : public dynContact
50 {
51 protected:
52  // id of the skin patch where the contact is applied
54  // average pressure applied on the contact area
55  // (if the skin is not calibrated in pressure this is just the average taxel output)
56  double pressure;
57  // geometric center of the contact area expressed w.r.t. the reference frame of the link where the contact is applied
58  yarp::sig::Vector geoCenter;
59  // contact area normal direction (link reference frame)
60  yarp::sig::Vector normalDir;
61  // number of taxels activated by the contact
62  unsigned int activeTaxels;
63  // list of active taxel ids
64  std::vector<unsigned int> taxelList;
65 
66 public:
67  //~~~~~~~~~~~~~~~~~~~~~~
68  // CONSTRUCTORS
69  //~~~~~~~~~~~~~~~~~~~~~~
73  skinContact();
74 
78  skinContact(const dynContact &c);
79 
90  skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP,
91  const yarp::sig::Vector &_geoCenter, unsigned int _activeTaxels, double _pressure);
92 
103  skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP,
104  const yarp::sig::Vector &_geoCenter, std::vector<unsigned int> _taxelList, double _pressure);
105 
117  skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP,
118  const yarp::sig::Vector &_geoCenter, unsigned int _activeTaxels, double _pressure, const yarp::sig::Vector &_normalDir);
119 
131  skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP,
132  const yarp::sig::Vector &_geoCenter, std::vector<unsigned int> _taxelList, double _pressure, const yarp::sig::Vector &_normalDir);
133 
147  skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP,
148  const yarp::sig::Vector &_geoCenter, std::vector<unsigned int> _taxelList, double _pressure, const yarp::sig::Vector &_normalDir,
149  const yarp::sig::Vector &_F, const yarp::sig::Vector &_Mu);
150 
151 
152  //~~~~~~~~~~~~~~~~~~~~~~
153  // GET methods
154  //~~~~~~~~~~~~~~~~~~~~~~
159  const yarp::sig::Vector& getGeoCenter() const{ return geoCenter; }
164  const yarp::sig::Vector& getNormalDir() const{ return normalDir; }
169  double getPressure() const{ return pressure; }
174  unsigned int getActiveTaxels() const{ return activeTaxels; }
179  SkinPart getSkinPart() const{ return skinPart; }
184  std::string getSkinPartName() const{ return SkinPart_s[skinPart]; }
189  std::vector<unsigned int> getTaxelList() const{ return taxelList; }
190 
191 
192  //~~~~~~~~~~~~~~~~~~~~~~
193  // SET methods
194  //~~~~~~~~~~~~~~~~~~~~~~
200  bool setGeoCenter(const yarp::sig::Vector &_geoCenter);
206  bool setNormalDir(const yarp::sig::Vector &_normalDir);
212  bool setPressure(double _pressure);
218  void setActiveTaxels(unsigned int _activeTaxels);
224  void setSkinPart(SkinPart _skinPart);
230  void setTaxelList(const std::vector<unsigned int> &list);
231 
232  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233  // SERIALIZATION methods
234  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235  /*
236  * Read skinContact from a connection.
237  * @param connection connection to read from
238  * @return true iff a skinContact was read correctly
239  */
240  virtual bool read(yarp::os::ConnectionReader& connection) override;
241 
256  virtual bool write(yarp::os::ConnectionWriter& connection) const override;
257 
275  virtual yarp::sig::Vector toVector() const;
276 
295  virtual bool fromVector(const yarp::sig::Vector &v);
296 
302  virtual std::string toString(int precision=-1) const override;
303 
304 };
305 
306 
307 }
308 
309 }//end namespace
310 
311 #endif
312 
313 
Class representing an external contact acting on a link of the robot body.
Definition: dynContact.h:52
Class representing an external contact acting on the iCub' skin.
Definition: skinContact.h:50
void setSkinPart(SkinPart _skinPart)
Set the skin part on which this contact is applied.
Definition: skinContact.cpp:88
unsigned int getActiveTaxels() const
Get the number of active taxels.
Definition: skinContact.h:174
skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP, const yarp::sig::Vector &_geoCenter, unsigned int _activeTaxels, double _pressure, const yarp::sig::Vector &_normalDir)
Constructor with contact surface normal.
std::string getSkinPartName() const
Get the name of the skin part on which this contact is applied.
Definition: skinContact.h:184
bool setNormalDir(const yarp::sig::Vector &_normalDir)
Set the normal direction of the contact area, expressed in link reference frame.
Definition: skinContact.cpp:69
virtual std::string toString(int precision=-1) const override
Convert this skinContact into a string.
void setTaxelList(const std::vector< unsigned int > &list)
Set the list of taxels that are activated by this contact.
Definition: skinContact.cpp:92
std::vector< unsigned int > taxelList
Definition: skinContact.h:64
const yarp::sig::Vector & getNormalDir() const
Get the direction normal to the contact area, expressed in the link reference frame.
Definition: skinContact.h:164
bool setGeoCenter(const yarp::sig::Vector &_geoCenter)
Set the geometric center of the contact area (link reference frame).
Definition: skinContact.cpp:62
virtual bool fromVector(const yarp::sig::Vector &v)
Convert the specified vector into a skinContact.
void setActiveTaxels(unsigned int _activeTaxels)
Set the number of active taxels.
Definition: skinContact.cpp:83
yarp::sig::Vector normalDir
Definition: skinContact.h:60
virtual yarp::sig::Vector toVector() const
Convert this skinContact to a vector.
double getPressure() const
Get the average pressure measured at this contact.
Definition: skinContact.h:169
bool setPressure(double _pressure)
Set the average contact pressure.
Definition: skinContact.cpp:76
SkinPart getSkinPart() const
Get the skin part on which this contact is applied.
Definition: skinContact.h:179
skinContact(const BodyPart &_bodyPart, const SkinPart &_skinPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP, const yarp::sig::Vector &_geoCenter, std::vector< unsigned int > _taxelList, double _pressure, const yarp::sig::Vector &_normalDir)
Constructor with contact surface normal and list of active taxels.
std::vector< unsigned int > getTaxelList() const
Get the list of id's of the taxels activated by this contact.
Definition: skinContact.h:189
skinContact()
Empty contructor.
Definition: skinContact.cpp:57
const yarp::sig::Vector & getGeoCenter() const
Get the contact geometric center, expressed in the link reference frame.
Definition: skinContact.h:159
yarp::sig::Vector geoCenter
Definition: skinContact.h:58
virtual bool read(yarp::os::ConnectionReader &connection) override
virtual bool write(yarp::os::ConnectionWriter &connection) const override
Write this skinContact to a connection.
Definition: skinContact.cpp:99
const std::string SkinPart_s[]
Definition: common.h:64
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.