iCub-main
Loading...
Searching...
No Matches
PalmRight.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: Marco Maggiali marco.maggiali@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_PALMR_H__
13#define __ALE_PALMR_H__
14
15class PalmR : public TouchSensor
16{
17public:
18
19 PalmR(double cx,double cy,double th,double gain=1.0,int layoutNum=0,int lrMirror=0)
20 {
21 const double DEG2RAD=M_PI/180.0;
22
23 const double CST=cos(DEG2RAD*th);
24 const double SNT=sin(DEG2RAD*th);
25
26 const double H=sin(DEG2RAD*60.0);
27 const double L=2.0*H/9.0;
28
29 dGain=gain;
30 ilrMirror=lrMirror;
31 ilayoutNum=layoutNum;
32 nVerts=4;
33 nTaxels=48;
34 m_RadiusOrig=1.8;
35
36
37
38 for (int i=0; i<nTaxels; ++i)
39 {
40 dX[0]=15; //not used
41 dY[0]=15; //not used
42 }
43
44
45
46 dX[27]=1.5; dY[27]=6.5;
47 dX[26]=6.5; dY[26]=6;
48 dX[25]=11.5; dY[25]=6;
49 dX[24]=16.5; dY[24]=6;
50 dX[31]=21.5; dY[31]=6;
51 dX[29]=6.5; dY[29]=1;
52 dX[28]=11.5; dY[28]=1;
53 dX[32]=16.5; dY[32]=1;
54 dX[33]=21.5; dY[33]=1;
55 dX[35]=9.5; dY[35]=-2; //thermal_pad
56 dX[30]=14.5; dY[30]=-3.5;
57 dX[34]=21.5; dY[34]=-4;
58
59
60 dX[6]=27; dY[6]=6;
61 dX[3]=32; dY[3]=6;
62 dX[2]=37; dY[2]=6;
63 dX[1]=42; dY[1]=5.5;
64 dX[0]=47; dY[0]=4.5;
65 dX[11]=51.7; dY[11]=4; //thermal_pad
66 dX[7]=27; dY[7]=1;
67 dX[8]=32; dY[8]=1;
68 dX[4]=37; dY[4]=1;
69 dX[5]=42; dY[5]=0;
70 dX[9]=27; dY[9]=-3.5;
71 dX[10]=32; dY[10]=-3.5;
72
73
74 dX[16]=37.5; dY[16]=-4.5;
75 dX[15]=42; dY[15]=-5.5;
76 dX[14]=46.5; dY[14]=-8;
77 dX[20]=27; dY[20]=-9;
78 dX[21]=32; dY[21]=-9;
79 dX[17]=37; dY[17]=-9;
80 dX[19]=42; dY[19]=-10.5;
81 dX[22]=38; dY[22]=-14;
82 dX[18]=43; dY[18]=-16;
83 dX[13]=47; dY[13]=-13;
84 dX[12]=47.5; dY[12]=-18;
85 dX[23]=43.5; dY[23]=-20; //thermal_pad
86
87 dX[46]=33; dY[46]=-14.5;
88 dX[47]=28; dY[47]=-14.5;
89 dX[36]=28; dY[36]=-19.5;
90 dX[42]=33; dY[42]=-19.5;
91 dX[45]=38; dY[45]=-19.5;
92 dX[37]=28; dY[37]=-24.5;
93 dX[38]=33; dY[38]=-24.5;
94 dX[41]=38; dY[41]=-24.5;
95 dX[44]=43; dY[44]=-26;
96 dX[39]=35; dY[39]=-29;
97 dX[40]=40; dY[40]=-29.5;
98 dX[43]=37; dY[43]=-32.5; //thermal pad
99
100
101 for (int i=0; i<nTaxels; ++i)
102 {
103 double x=1.2*dX[i]-0.0;
104 double y=1.2*dY[i]-0.0;
105
106 if (lrMirror==1) x=-x;
107 dX[i]=cx+CST*x-SNT*y;
108 dY[i]=cy+SNT*x+CST*y;
109 }
110
111 dXv[0]=-25;
112 dYv[0]=-50;
113 dXv[1]=+50;
114 dYv[1]=-50;
115 dXv[2]=+50;
116 dYv[2]=+50;
117 dXv[3]=-25;
118 dYv[3]=+50;
119
120 for (int i=0; i<nVerts; ++i)
121 {
122 double x=dXv[i];
123 double y=dYv[i];
124 if (lrMirror==1) x=-x;
125 dXv[i]=cx+CST*x-SNT*y;
126 dYv[i]=cy+SNT*x+CST*y;
127 }
128
129 // in static definition
130 //dXmin=dYmin= HUGE;
131 //dXmax=dYmax=-HUGE;
132
133 for (int i=0; i<nVerts; ++i)
134 {
135 if (dXv[i]<dXmin) dXmin=dXv[i];
136 if (dXv[i]>dXmax) dXmax=dXv[i];
137 if (dYv[i]<dYmin) dYmin=dYv[i];
138 if (dYv[i]>dYmax) dYmax=dYv[i];
139 }
140
141 dXc=cx;
142 dYc=cy;
143 }
144 void draw(unsigned char *image)
145 {
146 for (int i=0; i<nVerts; ++i)
147 {
148 //drawLine(image,xv[i],yv[i],xv[(i+1)%nVerts],yv[(i+1)%nVerts]);
149 }
150
151 for (int i=0; i<nTaxels; ++i)
152 {
153 if ((i==43) || (i==23) || (i==11) || (i==35) )
154 {
155 drawCircle(image,x[i],y[i],m_Radius/2);
156 }
157 else
158 drawCircle(image,x[i],y[i],m_Radius);
159 }
160 }
161};
162
163#endif
#define M_PI
Definition XSensMTx.cpp:24
void draw(unsigned char *image)
Definition PalmRight.h:144
PalmR(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition PalmRight.h:19
double dX[MAX_TAXELS]
double m_Radius
int x[MAX_TAXELS]
double m_RadiusOrig
static double dXmin
static double dYmax
double dXv[8]
double dY[MAX_TAXELS]
static double dXmax
double dYv[8]
int y[MAX_TAXELS]
void drawCircle(unsigned char *image, int cx, int cy, double radius)
static double dYmin
#define DEG2RAD