iCub-main
CER_SH_PDL.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 __CER_SH_PDL_H__
13 #define __CER_SH_PDL_H__
14 
15 class CER_SH_PDL : public TouchSensor
16 {
17 public:
18 
19  CER_SH_PDL(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  dGain=gain;
27  ilrMirror=lrMirror;
28  ilayoutNum=layoutNum;
29  nVerts=7;
30  nTaxels=36;
31  m_RadiusOrig=1.8;
32 
33  for (int i = 0; i<nTaxels; ++i) dX[0] = dY[0] = 0.0;
34 
35  int n = 0;
36 
37  dX[n]=37.2; dY[n++]=16.7; // 0
38  dX[n]=31.2; dY[n++]=22.7; // 1
39  dX[n]=31.2; dY[n++]=16.7; // 2
40  dX[n]=43.2; dY[n++]=10.7; // 3
41  dX[n]=25.2; dY[n++]=22.7; // 4
42  dX[n]=37.2; dY[n++]=10.7; // 5
43  dX[n]=43.2; dY[n++]= 4.7; // 6
44  dX[n]=31.2; dY[n++]= 4.7; // 7
45  dX[n]=37.2; dY[n++]= 4.7; // 8
46  dX[n]=25.2; dY[n++]= 4.7; // 9
47  dX[n]=31.2; dY[n++]=10.7; // 10
48  connected[n++] = false; // 11
49  dX[n]=25.2; dY[n++]=10.7; // 12
50  dX[n]=13.2; dY[n++]= 4.7; // 13
51  dX[n]= 7.2; dY[n++]= 4.7; // 14
52  dX[n]=19.2; dY[n++]= 4.7; // 15
53  dX[n]= 7.2; dY[n++]=10.7; // 16
54  dX[n]=13.2; dY[n++]=10.7; // 17
55  dX[n]= 7.2; dY[n++]=16.7; // 18
56  dX[n]=13.2; dY[n++]=16.7; // 19
57  dX[n]=19.2; dY[n++]=10.7; // 20
58  dX[n]=19.2; dY[n++]=16.7; // 21
59  dX[n]=25.2; dY[n++]=16.7; // 22
60  connected[n++] = false; // 23
61  dX[n]= 7.2; dY[n++]=22.7; // 24
62  dX[n]=10.2; dY[n++]=27.7; // 25
63  dX[n]=13.2; dY[n++]=22.7; // 26
64  dX[n]=16.2; dY[n++]=27.7; // 27
65  dX[n]=19.2; dY[n++]=22.7; // 28
66  connected[n++] = false; // 29
67  connected[n++] = false; // 30
68  connected[n++] = false; // 31
69  connected[n++] = false; // 32
70  connected[n++] = false; // 33
71  connected[n++] = false; // 34
72  connected[n++] = false; // 35
73 
74  for (int i=0; i<nTaxels; ++i)
75  {
76  double x=dX[i]-0.0;
77  double y=dY[i]-0.0;
78 
79  if (lrMirror) x=-x;
80 
81  dX[i]=cx+CST*x-SNT*y;
82  dY[i]=cy+SNT*x+CST*y;
83  }
84 
85  dXv[0]=2; dYv[0]=0;
86  dXv[1]=2; dYv[1]=28;
87  dXv[2]=7; dYv[2]=33;
88  dXv[3]=22; dYv[3]=33;
89  dXv[4]=38; dYv[4]=24;
90  dXv[5]=49; dYv[5]=12;
91  dXv[6]=49; dYv[6]=0;
92 
93  for (int i=0; i<nVerts; ++i)
94  {
95  double x=dXv[i];
96  double y=dYv[i];
97  if (lrMirror) x=-x;
98  dXv[i]=cx+CST*x-SNT*y;
99  dYv[i]=cy+SNT*x+CST*y;
100  }
101 
102  // in static definition
103  //dXmin=dYmin= HUGE;
104  //dXmax=dYmax=-HUGE;
105 
106  for (int i=0; i<nVerts; ++i)
107  {
108  if (dXv[i]<dXmin) dXmin=dXv[i];
109  if (dXv[i]>dXmax) dXmax=dXv[i];
110  if (dYv[i]<dYmin) dYmin=dYv[i];
111  if (dYv[i]>dYmax) dYmax=dYv[i];
112  }
113 
114  dXc=cx;
115  dYc=cy;
116  }
117  void draw(unsigned char *image)
118  {
119  for (int i = 0; i<nVerts; ++i)
120  {
121  drawLine(image, xv[i], yv[i], xv[(i + 1) % nVerts], yv[(i + 1) % nVerts]);
122  }
123 
124  for (int i = 0; i <= 28; ++i) if (connected[i])
125  {
126  drawCircle(image, x[i], y[i], m_Radius);
127  }
128  }
129 };
130 
131 class CER_SH_PDR : public TouchSensor
132 {
133 public:
134 
135  CER_SH_PDR(double cx, double cy, double th, double gain = 1.0, int layoutNum = 0, int lrMirror = 0)
136  {
137  const double DEG2RAD = M_PI / 180.0;
138 
139  const double CST = cos(DEG2RAD*th);
140  const double SNT = sin(DEG2RAD*th);
141 
142  dGain = gain;
143  ilrMirror = lrMirror;
144  ilayoutNum = layoutNum;
145  nVerts = 7;
146  nTaxels = 36;
147  m_RadiusOrig = 1.8;
148 
149  for (int i = 0; i<nTaxels; ++i) dX[0] = dY[0] = 0.0;
150 
151  int n = 0;
152 
153  dX[n]=11.2; dY[n++]=16.7; // 0
154  dX[n]=17.2; dY[n++]=22.7; // 1
155  dX[n]=17.2; dY[n++]=16.7; // 2
156  dX[n]= 5.2; dY[n++]=10.7; // 3
157  dX[n]=23.2; dY[n++]=22.7; // 4
158  dX[n]=11.2; dY[n++]=10.7; // 5
159  dX[n]= 5.2; dY[n++]= 4.7; // 6
160  dX[n]=17.2; dY[n++]= 4.7; // 7
161  dX[n]=11.2; dY[n++]= 4.7; // 8
162  dX[n]=23.2; dY[n++]= 4.7; // 9
163  dX[n]=17.2; dY[n++]=10.7; // 10
164  connected[n++] = false; // 11
165  dX[n]=23.2; dY[n++]=10.7; // 12
166  dX[n]=35.2; dY[n++]= 4.7; // 13
167  dX[n]=41.2; dY[n++]= 4.7; // 14
168  dX[n]=29.2; dY[n++]= 4.7; // 15
169  dX[n]=41.2; dY[n++]=10.7; // 16
170  dX[n]=35.2; dY[n++]=10.7; // 17
171  dX[n]=41.2; dY[n++]=16.7; // 18
172  dX[n]=35.2; dY[n++]=16.7; // 19
173  dX[n]=29.2; dY[n++]=10.7; // 20
174  dX[n]=29.2; dY[n++]=16.7; // 21
175  dX[n]=23.2; dY[n++]=16.7; // 22
176  connected[n++] = false; // 23
177  dX[n]=41.2; dY[n++]=22.7; // 24
178  dX[n]=38.2; dY[n++]=27.7; // 25
179  dX[n]=35.2; dY[n++]=22.7; // 26
180  dX[n]=32.2; dY[n++]=27.7; // 27
181  dX[n]=29.2; dY[n++]=22.7; // 28
182  connected[n++] = false; // 29
183  connected[n++] = false; // 30
184  connected[n++] = false; // 31
185  connected[n++] = false; // 32
186  connected[n++] = false; // 33
187  connected[n++] = false; // 34
188  connected[n++] = false; // 35
189 
190  for (int i = 0; i<nTaxels; ++i)
191  {
192  double x = dX[i];
193  double y = dY[i];
194 
195  if (lrMirror) x = -x;
196 
197  dX[i] = cx + CST*x - SNT*y;
198  dY[i] = cy + SNT*x + CST*y;
199  }
200 
201  dXv[0] = 49-2; dYv[0] = 0;
202  dXv[1] = 49-2; dYv[1] = 28;
203  dXv[2] = 49-7; dYv[2] = 33;
204  dXv[3] = 49-22; dYv[3] = 33;
205  dXv[4] = 49-38; dYv[4] = 24;
206  dXv[5] = 49-49; dYv[5] = 12;
207  dXv[6] = 49-49; dYv[6] = 0;
208 
209  for (int i = 0; i<nVerts; ++i)
210  {
211  double x = dXv[i];
212  double y = dYv[i];
213  if (lrMirror) x = -x;
214  dXv[i] = cx + CST*x - SNT*y;
215  dYv[i] = cy + SNT*x + CST*y;
216  }
217 
218  // in static definition
219  //dXmin=dYmin= HUGE;
220  //dXmax=dYmax=-HUGE;
221 
222  for (int i = 0; i<nVerts; ++i)
223  {
224  if (dXv[i]<dXmin) dXmin = dXv[i];
225  if (dXv[i]>dXmax) dXmax = dXv[i];
226  if (dYv[i]<dYmin) dYmin = dYv[i];
227  if (dYv[i]>dYmax) dYmax = dYv[i];
228  }
229 
230  dXc = cx;
231  dYc = cy;
232  }
233  void draw(unsigned char *image)
234  {
235  for (int i = 0; i<nVerts; ++i)
236  {
237  drawLine(image, xv[i], yv[i], xv[(i + 1) % nVerts], yv[(i + 1) % nVerts]);
238  }
239 
240  for (int i = 0; i<=28; ++i) if (connected[i])
241  {
242  drawCircle(image, x[i], y[i], m_Radius);
243  }
244  }
245 };
246 
247 class CER_SH_PP : public TouchSensor
248 {
249 public:
250 
251  CER_SH_PP(double cx, double cy, double th, double gain = 1.0, int layoutNum = 0, int lrMirror = 0)
252  {
253  const double DEG2RAD = M_PI / 180.0;
254 
255  const double CST = cos(DEG2RAD*th);
256  const double SNT = sin(DEG2RAD*th);
257 
258  dGain = gain;
259  ilrMirror = lrMirror;
260  ilayoutNum = layoutNum;
261  nVerts = 4;
262  nTaxels = 24;
263  m_RadiusOrig = 1.8;
264 
265  for (int i = 0; i<nTaxels; ++i) dX[0] = dY[0] = 0.0;
266 
267  int n = 0;
268 
269  dX[n] = 10; dY[n++] = 3.5; // 48
270  dX[n] = 16; dY[n++] = 3.5; // 49
271  dX[n] = 4; dY[n++] = 3.5; // 50
272  dX[n] = 4; dY[n++] = 9.5; // 51
273  dX[n] = 4; dY[n++] = 21.5; // 52
274  dX[n] = 4; dY[n++] = 15.5; // 53
275  dX[n] = 10; dY[n++] = 9.5; // 54
276  dX[n] = 10; dY[n++] = 15.5; // 55
277  dX[n] = 10; dY[n++] = 21.5; // 56
278  dX[n] = 16; dY[n++] = 15.5; // 57
279  dX[n] = 16; dY[n++] = 9.5; // 58
280  connected[n++] = false; // 59
281  dX[n] = 16; dY[n++] = 33.5; // 60
282  dX[n] = 16; dY[n++] = 39.5; // 61
283  dX[n] = 10; dY[n++] = 33.5; // 62
284  dX[n] = 16; dY[n++] = 27.5; // 63
285  dX[n] = 10; dY[n++] = 39.5; // 64
286  dX[n] = 16; dY[n++] = 21.5; // 65
287  dX[n] = 10; dY[n++] = 27.5; // 66
288  dX[n] = 4; dY[n++] = 27.5; // 67
289  dX[n] = 4; dY[n++] = 33.5; // 68
290  dX[n] = 4; dY[n++] = 39.5; // 69
291  connected[n++] = false; // 70
292  connected[n++] = false; // 71
293 
294  for (int i = 0; i<nTaxels; ++i)
295  {
296  double x = dX[i];
297  double y = dY[i];
298 
299  if (lrMirror) x = -x;
300 
301  dX[i] = cx + CST*x - SNT*y;
302  dY[i] = cy + SNT*x + CST*y;
303  }
304 
305  dXv[0] = -1; dYv[0] = -2;
306  dXv[1] = -1; dYv[1] = 45;
307  dXv[2] = 21; dYv[2] = 45;
308  dXv[3] = 21; dYv[3] = -2;
309 
310  for (int i = 0; i<nVerts; ++i)
311  {
312  double x = dXv[i];
313  double y = dYv[i];
314  if (lrMirror) x = -x;
315  dXv[i] = cx + CST*x - SNT*y;
316  dYv[i] = cy + SNT*x + CST*y;
317  }
318 
319  // in static definition
320  //dXmin=dYmin= HUGE;
321  //dXmax=dYmax=-HUGE;
322 
323  for (int i = 0; i<nVerts; ++i)
324  {
325  if (dXv[i]<dXmin) dXmin = dXv[i];
326  if (dXv[i]>dXmax) dXmax = dXv[i];
327  if (dYv[i]<dYmin) dYmin = dYv[i];
328  if (dYv[i]>dYmax) dYmax = dYv[i];
329  }
330 
331  dXc = cx;
332  dYc = cy;
333  }
334  void draw(unsigned char *image)
335  {
336  for (int i = 0; i<nVerts; ++i)
337  {
338  drawLine(image, xv[i], yv[i], xv[(i + 1) % nVerts], yv[(i + 1) % nVerts]);
339  }
340 
341  for (int i = 0; i <= 21; ++i) if (connected[i])
342  {
343  drawCircle(image, x[i], y[i], m_Radius);
344  }
345  }
346 };
347 
348 class CER_SH_TD : public TouchSensor
349 {
350 public:
351 
352  CER_SH_TD(double cx, double cy, double th, double gain = 1.0, int layoutNum = 0, int lrMirror = 0)
353  {
354  const double DEG2RAD = M_PI / 180.0;
355 
356  const double CST = cos(DEG2RAD*th);
357  const double SNT = sin(DEG2RAD*th);
358 
359  dGain = gain;
360  ilrMirror = lrMirror;
361  ilayoutNum = layoutNum;
362  nVerts = 6;
363  nTaxels = 24;
364  m_RadiusOrig = 1.8;
365 
366  for (int i = 0; i < nTaxels; ++i) dX[0] = dY[0] = 0.0;
367 
368  int n = 0;
369 
370  dX[n] = 30.0; dY[n++] = 10.5; // 96
371  dX[n] = 30.0; dY[n++] = 4.5; // 97
372  dX[n] = 18.0; dY[n++] = 4.5; // 98
373  dX[n] = 6.1; dY[n++] = 4.5; // 99
374  dX[n] = 12.0; dY[n++] = 4.5; // 100
375  dX[n] = 24.0; dY[n++] = 4.5; // 101
376  dX[n] = 12.0; dY[n++] = 16.4; // 102
377  dX[n] = 18.0; dY[n++] = 10.5; // 103
378  dX[n] = 18.0; dY[n++] = 16.5; // 104
379  dX[n] = 24.0; dY[n++] = 16.5; // 105
380  dX[n] = 24.0; dY[n++] = 10.5; // 106
381  connected[n++] = false; // 107
382  dX[n] = 12.0; dY[n++] = 10.5; // 108
383  dX[n] = 6.0; dY[n++] = 10.5; // 109
384  connected[n++] = false; // 110
385  connected[n++] = false; // 111
386  connected[n++] = false; // 112
387  connected[n++] = false; // 113
388  connected[n++] = false; // 114
389  connected[n++] = false; // 115
390  connected[n++] = false; // 116
391  connected[n++] = false; // 117
392  connected[n++] = false; // 118
393  connected[n++] = false; // 119
394 
395  for (int i = 0; i < nTaxels; ++i)
396  {
397  double x = dX[i];
398  double y = dY[i];
399 
400  if (lrMirror) x = -x;
401 
402  dX[i] = cx + CST*x - SNT*y;
403  dY[i] = cy + SNT*x + CST*y;
404  }
405 
406  dXv[0] = 1; dYv[0] = 0;
407  dXv[1] = 1; dYv[1] = 16;
408  dXv[2] = 7; dYv[2] = 22;
409  dXv[3] = 29; dYv[3] = 22;
410  dXv[4] = 35; dYv[4] = 16;
411  dXv[5] = 35; dYv[5] = 0;
412 
413  for (int i = 0; i < nVerts; ++i)
414  {
415  double x = dXv[i];
416  double y = dYv[i];
417  if (lrMirror) x = -x;
418  dXv[i] = cx + CST*x - SNT*y;
419  dYv[i] = cy + SNT*x + CST*y;
420  }
421 
422  // in static definition
423  //dXmin=dYmin= HUGE;
424  //dXmax=dYmax=-HUGE;
425 
426  for (int i = 0; i < nVerts; ++i)
427  {
428  if (dXv[i] < dXmin) dXmin = dXv[i];
429  if (dXv[i] > dXmax) dXmax = dXv[i];
430  if (dYv[i] < dYmin) dYmin = dYv[i];
431  if (dYv[i] > dYmax) dYmax = dYv[i];
432  }
433 
434  dXc = cx;
435  dYc = cy;
436  }
437  void draw(unsigned char *image)
438  {
439  for (int i = 0; i < nVerts; ++i)
440  {
441  drawLine(image, xv[i], yv[i], xv[(i + 1) % nVerts], yv[(i + 1) % nVerts]);
442  }
443 
444  for (int i = 0; i <= 13; ++i) if (connected[i])
445  {
446  drawCircle(image, x[i], y[i], m_Radius);
447  }
448  }
449 };
450 
451 class CER_SH_TP : public TouchSensor
452 {
453 public:
454 
455  CER_SH_TP(double cx, double cy, double th, double gain = 1.0, int layoutNum = 0, int lrMirror = 0)
456  {
457  const double DEG2RAD = M_PI / 180.0;
458 
459  const double CST = cos(DEG2RAD*th);
460  const double SNT = sin(DEG2RAD*th);
461 
462  dGain = gain;
463  ilrMirror = lrMirror;
464  ilayoutNum = layoutNum;
465  nVerts = 4;
466  nTaxels = 12;
467  m_RadiusOrig = 1.8;
468 
469  for (int i = 0; i < nTaxels; ++i) dX[0] = dY[0] = 0.0;
470 
471  int n = 0;
472 
473  dX[n] = 3.0; dY[n++] = 17; // 144
474  dX[n] = 3.0; dY[n++] = 5; // 145
475  dX[n] = 3.0; dY[n++] = 11; // 146
476  dX[n] = 10.0; dY[n++] = 5; // 147
477  dX[n] = 10.0; dY[n++] = 29; // 148
478  dX[n] = 3.0; dY[n++] = 23; // 149
479  dX[n] = 3.0; dY[n++] = 29; // 150
480  dX[n] = 10.0; dY[n++] = 23; // 151
481  dX[n] = 10.0; dY[n++] = 17; // 152
482  dX[n] = 10.0; dY[n++] = 11; // 153
483  connected[n++] = false; // 154
484  connected[n++] = false; // 155
485 
486 
487  for (int i = 0; i < nTaxels; ++i)
488  {
489  double x = dX[i];
490  double y = dY[i];
491 
492  if (lrMirror) x = -x;
493 
494  dX[i] = cx + CST*x - SNT*y;
495  dY[i] = cy + SNT*x + CST*y;
496  }
497 
498  dXv[0] = -2; dYv[0] = 0;
499  dXv[1] = -2; dYv[1] = 34;
500  dXv[2] = 15; dYv[2] = 34;
501  dXv[3] = 15; dYv[3] = 0;
502 
503  for (int i = 0; i < nVerts; ++i)
504  {
505  double x = dXv[i];
506  double y = dYv[i];
507  if (lrMirror) x = -x;
508  dXv[i] = cx + CST*x - SNT*y;
509  dYv[i] = cy + SNT*x + CST*y;
510  }
511 
512  // in static definition
513  //dXmin=dYmin= HUGE;
514  //dXmax=dYmax=-HUGE;
515 
516  for (int i = 0; i < nVerts; ++i)
517  {
518  if (dXv[i] < dXmin) dXmin = dXv[i];
519  if (dXv[i] > dXmax) dXmax = dXv[i];
520  if (dYv[i] < dYmin) dYmin = dYv[i];
521  if (dYv[i] > dYmax) dYmax = dYv[i];
522  }
523 
524  dXc = cx;
525  dYc = cy;
526  }
527  void draw(unsigned char *image)
528  {
529  for (int i = 0; i < nVerts; ++i)
530  {
531  drawLine(image, xv[i], yv[i], xv[(i + 1) % nVerts], yv[(i + 1) % nVerts]);
532  }
533 
534  for (int i = 0; i <= 9; ++i) if (connected[i])
535  {
536  drawCircle(image, x[i], y[i], m_Radius);
537  }
538  }
539 };
540 
541 
542 #endif
#define M_PI
Definition: XSensMTx.cpp:24
constexpr double DEG2RAD
CER_SH_PDL(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition: CER_SH_PDL.h:19
void draw(unsigned char *image)
Definition: CER_SH_PDL.h:117
void draw(unsigned char *image)
Definition: CER_SH_PDL.h:233
CER_SH_PDR(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition: CER_SH_PDL.h:135
void draw(unsigned char *image)
Definition: CER_SH_PDL.h:334
CER_SH_PP(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition: CER_SH_PDL.h:251
CER_SH_TD(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition: CER_SH_PDL.h:352
void draw(unsigned char *image)
Definition: CER_SH_PDL.h:437
void draw(unsigned char *image)
Definition: CER_SH_PDL.h:527
CER_SH_TP(double cx, double cy, double th, double gain=1.0, int layoutNum=0, int lrMirror=0)
Definition: CER_SH_PDL.h:455
double dX[MAX_TAXELS]
Definition: TouchSensor.h:382
double dYc
Definition: TouchSensor.h:385
bool connected[MAX_TAXELS]
Definition: TouchSensor.h:393
double m_Radius
Definition: TouchSensor.h:390
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
void drawLine(unsigned char *image, int x0, int y0, int x1, int y1)
Definition: TouchSensor.h:340
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
void drawCircle(unsigned char *image, int cx, int cy, double radius)
Definition: TouchSensor.h:353
static double dYmin
Definition: TouchSensor.h:383
int n