20 #ifndef __COMPTHREAD_H__
21 #define __COMPTHREAD_H__
29 #include <yarp/sig/Vector.h>
30 #include <yarp/os/BufferedPort.h>
31 #include <yarp/os/PeriodicThread.h>
32 #include <yarp/os/ResourceFinder.h>
33 #include <yarp/dev/IAnalogSensor.h>
34 #include <yarp/dev/PolyDriver.h>
40 using namespace yarp::os;
41 using namespace yarp::sig;
47 namespace skinManager{
52 typedef enum {
calibration, compensation} CompensationThreadState;
56 CompensationThread(
string name, ResourceFinder* rf,
string robotName,
double _compensationGain,
double _contactCompensationGain,
57 int addThreshold,
float minBaseline,
bool zeroUpRawData,
int period,
bool binarization,
bool smoothFilter,
float smoothFactor);
63 void setBinarization(
bool value);
64 void setSmoothFilter(
bool value);
65 bool setSmoothFactor(
float value);
66 bool setAddThreshold(
unsigned int thr);
67 bool setCompensationGain(
double gain);
68 bool setContactCompensationGain(
double gain);
69 bool setMaxNeighborDistance(
double dist);
70 bool setTaxelPosition(
SkinPart sp,
unsigned int taxelId,
const Vector &position);
71 bool setTaxelPositions(
SkinPart sp,
const Vector &positions);
72 bool setTaxelOrientation(
SkinPart sp,
unsigned int taxelId,
const Vector &orientation);
73 bool setTaxelOrientations(
SkinPart sp,
const vector<Vector> &orientations);
74 bool setTaxelPose(
SkinPart sp,
unsigned int taxelId,
const Vector &pose);
75 bool setTaxelPoses(
SkinPart sp,
const vector<Vector> &poses);
76 bool setTaxelPoses(
SkinPart sp,
const Vector &poses);
78 Vector getTouchThreshold();
79 bool getBinarization();
80 bool getSmoothFilter();
81 float getSmoothFactor();
82 unsigned int getAddThreshold();
83 double getCompensationGain();
84 double getContactCompensationGain();
88 Vector getTaxelPosition(
SkinPart sp,
unsigned int taxelId);
90 Vector getTaxelOrientation(
SkinPart sp,
unsigned int taxelId);
92 Vector getTaxelPose(
SkinPart sp,
unsigned int taxelId);
94 double getPoseConfidence(
SkinPart sp,
unsigned int taxelId);
95 Vector getPoseConfidences(
SkinPart sp);
107 static const int CAL_TIME = 5;
112 unsigned int SKIN_DIM;
113 double compensationGain;
114 double contactCompensationGain;
116 bool initializationFinished;
119 int calibrationCounter;
120 int readErrorCounter;
133 unsigned int portNum;
135 vector<Compensator*> compensators;
136 vector<bool> compEnable;
137 vector<bool> compWorking;
138 unsigned int compensatorCounter;
144 BufferedPort<skinContactList> skinEventsPort;
145 BufferedPort<Vector> monitorPort;
146 BufferedPort<Bottle> infoPort;
148 CompensationThreadState
state;
153 bool doesBaselineExceed(
unsigned int &compInd,
unsigned int &taxInd,
double &baseline,
double &initialBaseline);
154 void sendMonitorData();
155 void sendDebugMsg(
string msg);
156 void sendErrorMsg(
string msg);
157 void sendSkinEvents();
double getMaxNeighborDistance()
std::vector< SkinPart > getSkinParts(BodyPart b)
Get the list of skin parts associated to the specified body part.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.