iCub-main
Fingertip.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4  * Copyright (C) 2009 RobotCub Consortium
5  * Author: Alessandro Scalzo alessandro.scalzo@iit.it
6  * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7  *
8  */
9 
10 #include "include/TouchSensor.h"
11 
12 #ifndef __ALE_FINGERTIP_H__
13 #define __ALE_FINGERTIP_H__
14 
15 class Fingertip : public TouchSensor
16 {
17 public:
18  Fingertip(double cx,double cy,double th,double gain=1.0,int layoutNum=0,int lrMirror=0)
19  {
20  dGain=gain;
21  ilrMirror=lrMirror;
22  ilayoutNum=layoutNum;
23  nVerts=7;
24  nTaxels=12;
25  /*
26  dX[11]= 41.0; dY[11]=10.0;
27  dX[10]= 65.0; dY[10]=10.0;
28  dX[ 9]= 65.0; dY[ 9]=35.0;
29  dX[ 8]= 41.0; dY[ 8]=35.0;
30  dX[ 7]= 30.0; dY[ 7]=62.0;
31  dX[ 6]= 45.0; dY[ 6]=78.0;
32  dX[ 5]= 0.0; dY[ 5]=82.0;
33  dX[ 4]=-45.0; dY[ 4]=78.0;
34  dX[ 3]=-30.0; dY[ 3]=62.0;
35  dX[ 2]=-41.0; dY[ 2]=35.0;
36  dX[ 1]=-65.0; dY[ 1]=35.0;
37  dX[ 0]=-65.0; dY[ 0]=10.0;
38  */
39 
40  dX[11]= 41.0; dY[11]=10.0;
41  dX[10]= 15.0; dY[10]=10.0;
42  dX[ 9]= 15.0; dY[ 9]=35.0;
43  dX[ 8]= 41.0; dY[ 8]=35.0;
44  dX[ 7]= 30.0; dY[ 7]=64.0;
45  dX[ 6]= 11.0; dY[ 6]=58.0;
46  dX[ 5]= 0.0; dY[ 5]=82.0;
47  dX[ 4]=-11.0; dY[ 4]=58.0;
48  dX[ 3]=-30.0; dY[ 3]=64.0;
49  dX[ 2]=-41.0; dY[ 2]=35.0;
50  dX[ 1]=-15.0; dY[ 1]=35.0;
51  dX[ 0]=-15.0; dY[ 0]=10.0;
52 
53  dXv[0]=53.0; dYv[0]= 0.0;
54  dXv[1]=53.0; dYv[1]=45.0;
55  dXv[2]=dX[7]+10.0; dYv[2]=dY[7]+10.0;
56  dXv[3]=0.0; dYv[3]=dY[5]+12.0;
57  dXv[4]=-dXv[2]; dYv[4]=dYv[2];
58  dXv[5]=-dXv[1]; dYv[5]=dYv[1];
59  dXv[6]=-dXv[0]; dYv[6]=dYv[0];
60 
61  const double scale=2.7/15.3;
62  for (int i=0; i<nTaxels; ++i)
63  {
64  dX[i]*=scale;
65  dY[i]*=scale;
66  }
67  for (int i=0; i<nVerts; ++i)
68  {
69  dXv[i]*=scale;
70  dYv[i]*=scale;
71  }
72 
73  m_RadiusOrig=1.8;
74 
75  const double DEG2RAD=M_PI/180.0;
76  const double CST=cos(DEG2RAD*th);
77  const double SNT=sin(DEG2RAD*th);
78 
79  for (int i=0; i<nTaxels; ++i)
80  {
81  double x=dX[i];
82  double y=dY[i];
83  if (lrMirror==1) x=-x;
84 
85  dX[i]=cx+CST*x-SNT*y;
86  dY[i]=cy+SNT*x+CST*y;
87  }
88 
89  for (int i=0; i<nVerts; ++i)
90  {
91  double x=dXv[i];
92  double y=dYv[i];
93  if (lrMirror==1) x=-x;
94 
95  dXv[i]=cx+CST*x-SNT*y;
96  dYv[i]=cy+SNT*x+CST*y;
97  }
98 
99  // in static definition
100  //dXmin=dYmin= HUGE;
101  //dXmax=dYmax=-HUGE;
102 
103  for (int i=0; i<nVerts; ++i)
104  {
105  if (dXv[i]<dXmin) dXmin=dXv[i];
106  if (dXv[i]>dXmax) dXmax=dXv[i];
107  if (dYv[i]<dYmin) dYmin=dYv[i];
108  if (dYv[i]>dYmax) dYmax=dYv[i];
109  }
110 
111  dXc=cx;
112  dYc=cy;
113  }
114 };
115 
116 #endif
#define M_PI
Definition: XSensMTx.cpp:24
constexpr double DEG2RAD
Fingertip(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition: Fingertip.h:18
double dX[MAX_TAXELS]
Definition: TouchSensor.h:382
double dYc
Definition: TouchSensor.h:385
int x[MAX_TAXELS]
Definition: TouchSensor.h:402
double m_RadiusOrig
Definition: TouchSensor.h:390
static double dXmin
Definition: TouchSensor.h:383
double dXc
Definition: TouchSensor.h:385
static double dYmax
Definition: TouchSensor.h:383
double dXv[8]
Definition: TouchSensor.h:384
double dY[MAX_TAXELS]
Definition: TouchSensor.h:382
static double dXmax
Definition: TouchSensor.h:383
double dYv[8]
Definition: TouchSensor.h:384
double dGain
Definition: TouchSensor.h:386
int y[MAX_TAXELS]
Definition: TouchSensor.h:402
static double dYmin
Definition: TouchSensor.h:383