ViSP  2.9.0
vpPtu46.cpp
1 /****************************************************************************
2  *
3  * $Id: vpPtu46.cpp 4620 2014-01-27 21:28:32Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 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 /* --- COMPUTE ------------------------------------------------------------ */
60 /* ------------------------------------------------------------------------ */
61 const unsigned int vpPtu46::ndof = 2; /*<! Pan and tilt are considered. */
62 const float vpPtu46::L = 0.0765f;
64 const float vpPtu46::h = 0.068f; /*<! Vertical offset from last joint to
65  camera frame. */
66 
67 
78 void
80 {
81  if (q.getRows() != 2) {
82  vpERROR_TRACE("Bad dimension for ptu-46 articular vector");
83  throw(vpException(vpException::dimensionError, "Bad dimension for ptu-46 articular vector"));
84  }
85 
86  double q1 = q[0]; // pan
87  double q2 = q[1]; // tilt
88 
89  double c1 = cos(q1);
90  double s1 = sin(q1);
91  double c2 = cos(q2);
92  double s2 = sin(q2);
93 
94  fMc[0][0] = s1;
95  fMc[0][1] = c1*s2;
96  fMc[0][2] = c1*c2;
97  fMc[0][3] = -h*c1*s2 - L*s1;
98 
99  fMc[1][0] = -c1;
100  fMc[1][1] = s1*s2;
101  fMc[1][2] = s1*c2;
102  fMc[1][3] = -h*s1*s2 + L*c1;
103 
104  fMc[2][0] = 0;
105  fMc[2][1] = -c2;
106  fMc[2][2] = s2;
107  fMc[2][3] = h*c2;
108 
109  fMc[3][0] = 0;
110  fMc[3][1] = 0;
111  fMc[3][2] = 0;
112  fMc[3][3] = 1;
113 
114  vpCDEBUG (6) << "Position de la camera: " << std::endl << fMc;
115 
116  return ;
117 }
118 
131 {
133 
134  computeMGD (q, fMc);
135 
136  return fMc;
137 }
138 
148 void
150 {
152 
153  computeMGD (q, fMc);
154  r.buildFrom(fMc.inverse());
155 
156  return ;
157 }
158 
159 
160 
161 /* ---------------------------------------------------------------------- */
162 /* --- CONSTRUCTOR ------------------------------------------------------ */
163 /* ---------------------------------------------------------------------- */
164 
171 {
172  init();
173 }
174 /* ---------------------------------------------------------------------- */
175 /* --- PRIVATE ---------------------------------------------------------- */
176 /* ---------------------------------------------------------------------- */
177 
178 
183 void
185 {
186  return ;
187 }
188 
189 
190 /* ----------------------------------------------------------------------- */
191 /* --- DISPLAY ----------------------------------------------------------- */
192 /* ----------------------------------------------------------------------- */
193 
194 VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpPtu46 & /* constant */)
195 {
196  os
197  << "Geometric parameters: " << std::endl
198  << "L: "
199  << "\t" << vpPtu46::L << std::endl
200  << "h: "
201  << "\t" << vpPtu46::h << std::endl;
202 
203  return os;
204 }
205 
206 
217 void
219 {
220  vpHomogeneousMatrix cMe ;
221  get_cMe(cMe) ;
222 
223  cVe.buildFrom(cMe) ;
224 }
225 
235 void
237 {
238  vpHomogeneousMatrix eMc ;
239 
240  eMc[0][0] = 0;
241  eMc[0][1] = -1;
242  eMc[0][2] = 0;
243  eMc[0][3] = h;
244 
245  eMc[1][0] = 1;
246  eMc[1][1] = 0;
247  eMc[1][2] = 0;
248  eMc[1][3] = -L;
249 
250  eMc[2][0] = 0;
251  eMc[2][1] = 0;
252  eMc[2][2] = 1;
253  eMc[2][3] = 0;
254 
255  eMc[3][0] = 0;
256  eMc[3][1] = 0;
257  eMc[3][2] = 0;
258  eMc[3][3] = 1;
259 
260  cMe = eMc.inverse() ;
261 }
262 
275 void
276 vpPtu46::get_eJe(const vpColVector &q, vpMatrix &eJe) const
277 {
278 
279 
280  eJe.resize(6,2) ;
281 
282  if (q.getRows() != 2) {
283  vpERROR_TRACE("Bad dimension for ptu-46 articular vector");
284  throw(vpException(vpException::dimensionError, "Bad dimension for ptu-46 articular vector"));
285  }
286 
287  double s2 = sin(q[1]) ;
288  double c2 = cos(q[1]) ;
289 
290  eJe = 0;
291 
292  eJe[3][0] = c2;
293  eJe[4][1] = 1;
294  eJe[5][0] = s2;
295 }
296 
306 void
307 vpPtu46::get_fJe(const vpColVector &q, vpMatrix &fJe) const
308 {
309 
310  if (q.getRows() != 2) {
311  vpERROR_TRACE("Bad dimension for ptu-46 articular vector");
312  throw(vpException(vpException::dimensionError, "Bad dimension for ptu-46 articular vector"));
313  }
314 
315  fJe.resize(6,2) ;
316 
317  double s1 = sin(q[0]) ;
318  double c1 = cos(q[0]) ;
319 
320  fJe = 0;
321 
322  fJe[3][1] = s1;
323  fJe[4][1] = -c1;
324  fJe[5][0] = 1;
325 }
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Definition: vpPtu46.cpp:307
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:183
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:395
error that can be emited by ViSP classes.
Definition: vpException.h:76
vpPoseVector buildFrom(const vpHomogeneousMatrix &M)
void get_cMe(vpHomogeneousMatrix &_cMe) const
Definition: vpPtu46.cpp:236
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...
void computeMGD(const vpColVector &q, vpHomogeneousMatrix &fMc) const
Definition: vpPtu46.cpp:79
void get_cVe(vpVelocityTwistMatrix &_cVe) const
Definition: vpPtu46.cpp:218
#define vpCDEBUG(level)
Definition: vpDebug.h:506
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Definition: vpPtu46.cpp:276
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
vpPtu46(void)
Definition: vpPtu46.cpp:170
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:161
void init(void)
Definition: vpPtu46.cpp:184