ViSP  2.6.2
vpPtu46.cpp
1 /****************************************************************************
2  *
3  * $Id: vpPtu46.cpp 3700 2012-05-03 15:23:38Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Interface for the ptu-46 robot.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
42 
43 
44 /* ----------------------------------------------------------------------- */
45 /* --- INCLUDE ----------------------------------------------------------- */
46 /* ----------------------------------------------------------------------- */
47 
48 
49 #include <visp/vpPtu46.h>
50 #include <visp/vpDebug.h>
51 #include <visp/vpRobotException.h>
52 
53 
54 /* Inclusion des fichiers standards. */
55 #include <math.h>
56 #include <visp/vpMath.h>
57 
58 
59 
60 
61 
62 /* ------------------------------------------------------------------------ */
63 /* --- COMPUTE ------------------------------------------------------------ */
64 /* ------------------------------------------------------------------------ */
65 const unsigned int vpPtu46::ndof = 2; /*<! Pan and tilt are considered. */
66 const float vpPtu46::L = 0.0765f;
68 const float vpPtu46::h = 0.068f; /*<! Vertical offset from last joint to
69  camera frame. */
70 
71 
82 void
84 {
85  if (q.getRows() != 2) {
86  vpERROR_TRACE("Bad dimension for ptu-46 articular vector");
87  throw(vpException(vpException::dimensionError, "Bad dimension for ptu-46 articular vector"));
88  }
89 
90  double q1 = q[0]; // pan
91  double q2 = q[1]; // tilt
92 
93  double c1 = cos(q1);
94  double s1 = sin(q1);
95  double c2 = cos(q2);
96  double s2 = sin(q2);
97 
98  fMc[0][0] = s1;
99  fMc[0][1] = c1*s2;
100  fMc[0][2] = c1*c2;
101  fMc[0][3] = -h*c1*s2 - L*s1;
102 
103  fMc[1][0] = -c1;
104  fMc[1][1] = s1*s2;
105  fMc[1][2] = s1*c2;
106  fMc[1][3] = -h*s1*s2 + L*c1;
107 
108  fMc[2][0] = 0;
109  fMc[2][1] = -c2;
110  fMc[2][2] = s2;
111  fMc[2][3] = h*c2;
112 
113  fMc[3][0] = 0;
114  fMc[3][1] = 0;
115  fMc[3][2] = 0;
116  fMc[3][3] = 1;
117 
118  vpCDEBUG (6) << "Position de la camera: " << std::endl << fMc;
119 
120  return ;
121 }
122 
135 {
137 
138  computeMGD (q, fMc);
139 
140  return fMc;
141 }
142 
152 void
154 {
156 
157  computeMGD (q, fMc);
158  r.buildFrom(fMc.inverse());
159 
160  return ;
161 }
162 
163 
164 
165 /* ---------------------------------------------------------------------- */
166 /* --- CONSTRUCTOR ------------------------------------------------------ */
167 /* ---------------------------------------------------------------------- */
168 
175 {
176  init();
177 }
178 /* ---------------------------------------------------------------------- */
179 /* --- PRIVATE ---------------------------------------------------------- */
180 /* ---------------------------------------------------------------------- */
181 
182 
187 void
189 {
190  return ;
191 }
192 
193 
194 /* ----------------------------------------------------------------------- */
195 /* --- DISPLAY ----------------------------------------------------------- */
196 /* ----------------------------------------------------------------------- */
197 
198 std::ostream & operator << (std::ostream & os,
199  const vpPtu46 & /* constant */)
200 {
201 
202  os
203  << "Geometric parameters: " << std::endl
204  << "L: "
205  << "\t" << vpPtu46::L << std::endl
206  << "h: "
207  << "\t" << vpPtu46::h << std::endl;
208 
209  return os;
210 }
211 
212 
223 void
225 {
226  vpHomogeneousMatrix cMe ;
227  get_cMe(cMe) ;
228 
229  cVe.buildFrom(cMe) ;
230 }
231 
241 void
243 {
244  vpHomogeneousMatrix eMc ;
245 
246  eMc[0][0] = 0;
247  eMc[0][1] = -1;
248  eMc[0][2] = 0;
249  eMc[0][3] = h;
250 
251  eMc[1][0] = 1;
252  eMc[1][1] = 0;
253  eMc[1][2] = 0;
254  eMc[1][3] = -L;
255 
256  eMc[2][0] = 0;
257  eMc[2][1] = 0;
258  eMc[2][2] = 1;
259  eMc[2][3] = 0;
260 
261  eMc[3][0] = 0;
262  eMc[3][1] = 0;
263  eMc[3][2] = 0;
264  eMc[3][3] = 1;
265 
266  cMe = eMc.inverse() ;
267 }
268 
281 void
283 {
284 
285 
286  eJe.resize(6,2) ;
287 
288  if (q.getRows() != 2) {
289  vpERROR_TRACE("Bad dimension for ptu-46 articular vector");
290  throw(vpException(vpException::dimensionError, "Bad dimension for ptu-46 articular vector"));
291  }
292 
293  double s2 = sin(q[1]) ;
294  double c2 = cos(q[1]) ;
295 
296  eJe = 0;
297 
298  eJe[3][0] = c2;
299  eJe[4][1] = 1;
300  eJe[5][0] = s2;
301 
302 }
303 
313 void
315 {
316 
317  if (q.getRows() != 2) {
318  vpERROR_TRACE("Bad dimension for ptu-46 articular vector");
319  throw(vpException(vpException::dimensionError, "Bad dimension for ptu-46 articular vector"));
320  }
321 
322  fJe.resize(6,2) ;
323 
324  double s1 = sin(q[0]) ;
325  double c1 = cos(q[0]) ;
326 
327  fJe = 0;
328 
329  fJe[3][1] = s1;
330  fJe[4][1] = -c1;
331  fJe[5][0] = 1;
332 }
333 
334 
335 
336 /*
337  * Local variables:
338  * c-basic-offset: 2
339  * End:
340  */
341 
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:174
static const float L
Definition: vpPtu46.h:89
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
#define vpERROR_TRACE
Definition: vpDebug.h:379
void computeMGD(const vpColVector &q, vpHomogeneousMatrix &fMc)
Definition: vpPtu46.cpp:83
vpPoseVector buildFrom(const vpHomogeneousMatrix &M)
void get_cMe(vpHomogeneousMatrix &_cMe)
Definition: vpPtu46.cpp:242
static const unsigned int ndof
Definition: vpPtu46.h:86
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static const float h
Definition: vpPtu46.h:90
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
#define vpCDEBUG(niv)
Definition: vpDebug.h:478
VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpImagePoint &ip)
Definition: vpImagePoint.h:529
void get_cVe(vpVelocityTwistMatrix &_cVe)
Definition: vpPtu46.cpp:224
Jacobian, geometric model functionnalities... for ptu46, pan, tilt head from Directed Perception...
Definition: vpPtu46.h:80
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
The pose is a complete representation of every rigid motion in the euclidian space.
Definition: vpPoseVector.h:92
vpHomogeneousMatrix inverse() const
void get_fJe(const vpColVector &q, vpMatrix &fJe)
Definition: vpPtu46.cpp:314
vpPtu46(void)
Definition: vpPtu46.cpp:174
void get_eJe(const vpColVector &q, vpMatrix &eJe)
Definition: vpPtu46.cpp:282
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:157
void init(void)
Definition: vpPtu46.cpp:188