ViSP  2.8.0
vpAfma4.cpp
1 /****************************************************************************
2  *
3  * $Id: vpAfma4.cpp 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 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 Irisa's Afma4 robot.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
50 #include <visp/vpDebug.h>
51 #include <visp/vpVelocityTwistMatrix.h>
52 #include <visp/vpRobotException.h>
53 #include <visp/vpCameraParameters.h>
54 #include <visp/vpRxyzVector.h>
55 #include <visp/vpTranslationVector.h>
56 #include <visp/vpRotationMatrix.h>
57 #include <visp/vpAfma4.h>
58 
59 
60 /* ----------------------------------------------------------------------- */
61 /* --- STATIC ------------------------------------------------------------ */
62 /* ---------------------------------------------------------------------- */
63 const unsigned int vpAfma4::njoint = 4;
64 
65 
72 {
73  // Set the default parameters in case of the config files on the NAS
74  // at Inria are not available.
75 
76  //
77  // Geometric model constant parameters
78  //
79  this->_a1 = 0.205; // distance along x2
80  this->_d3 = 0.403; // distance along z2
81  this->_d4 = 0.14; // distance along z3
82 
83  // Maximal value of the joints
84  this->_joint_max[0] = 1.8; // rad
85  this->_joint_max[1] = 0.9; // meter
86  this->_joint_max[2] = 0.9; // rad
87  this->_joint_max[3] = 0.76; // rad
88  // Minimal value of the joints
89  this->_joint_min[0] = -1.5; // rad
90  this->_joint_min[1] = -0.9; // meter
91  this->_joint_min[2] = -3.5; // rad
92  this->_joint_min[3] = -0.76;// rad
93 
94  // Camera extrinsic parameters: effector to camera frame
95  this->_etc[0] = 0.; // Translation
96  this->_etc[1] = 0.;
97  this->_etc[2] = 0.;
98  this->_erc[0] = 0.; // Rotation
99  this->_erc[1] = -M_PI/2.;
100  this->_erc[2] = 0;
101 
102  vpRotationMatrix eRc(_erc);
103  this->_eMc.buildFrom(_etc, eRc);
104 
105  init();
106 }
107 
108 
113 void
115 {
116  return;
117 }
118 
152 {
154  fMc = get_fMc(q);
155 
156  return fMc;
157 }
158 
190 {
192  get_fMc(q, fMc);
193 
194  return fMc;
195 }
196 
223 void
225 {
226 
227  // Compute the direct geometric model: fMe = transformation between
228  // fix and end effector frame.
230 
231  get_fMe(q, fMe);
232 
233  fMc = fMe * this->_eMc;
234 
235  return;
236 }
237 
271 void
273 {
274  double q1 = q[0]; // rot touret
275  double q2 = q[1]; // vertical translation
276  double q4 = q[2]; // pan
277  double q5 = q[3]; // tilt
278 
279  double c1 = cos(q1);
280  double s1 = sin(q1);
281  double c4 = cos(q4);
282  double s4 = sin(q4);
283  double c5 = cos(q5);
284  double s5 = sin(q5);
285 
286  /* Calcul du modele d'apres les angles. */
287  fMe[0][0] = c1*s4*c5 + s1*c4*c5;
288  fMe[0][1] = -c1*s4*s5 - s1*c4*s5;
289  fMe[0][2] = c1*c4 - s1*s4;
290  fMe[0][3] = c1*this->_a1 - s1*(this->_d3);
291 
292  fMe[1][0] = s1*s4*c5 - c1*c4*c5;
293  fMe[1][1] = -s1*s4*s5 + c1*c4*s5;
294  fMe[1][2] = s1*c4+c1*s4;
295  fMe[1][3] = s1*this->_a1 + c1*(this->_d3);
296 
297  fMe[2][0] = -s5;
298  fMe[2][1] = -c5;
299  fMe[2][2] = 0.f;
300  fMe[2][3] = this->_d4 + q2;
301 
302  fMe[3][0] = 0.f;
303  fMe[3][1] = 0.f;
304  fMe[3][2] = 0.f;
305  fMe[3][3] = 1;
306 
307  // vpCTRACE << "Effector position fMe: " << std::endl << fMe;
308 
309  return;
310 }
311 
322 void
324 {
325  cMe = this->_eMc.inverse();
326 }
327 
337 void
339 {
340  vpHomogeneousMatrix cMe ;
341  get_cMe(cMe) ;
342 
343  cVe.buildFrom(cMe) ;
344 
345  return;
346 }
347 
366 void
368 {
369  vpHomogeneousMatrix fMc, cMf ;
370  get_fMc(q, fMc) ;
371  cMf = fMc.inverse();
372 
373  cVf.buildFrom(cMf) ;
374 
375  return;
376 }
377 
378 
379 
416 void
418 {
419  double q4 = q[2]; // pan
420  double q5 = q[3]; // tilt
421 
422  double c4 = cos(q4);
423  double s4 = sin(q4);
424  double c5 = cos(q5);
425  double s5 = sin(q5);
426 
427  eJe.resize(6, 4);
428 
429  eJe = 0;
430 
431  eJe[0][0] = -(this->_a1*c4 + this->_d3*s4)*c5; eJe[0][1] = -s5;
432  eJe[1][0] = (this->_a1*c4 + this->_d3*s4)*s5; eJe[1][1] = -c5;
433  eJe[2][0] = (this->_a1*s4 - this->_d3*c4);
434  eJe[3][0] = eJe[3][2] = -s5;
435  eJe[4][0] = eJe[4][2] = -c5;
436  eJe[5][3] = 1.;
437 }
438 
470 void
472 {
473  fJe.resize(6,4) ;
474 
475  double q1 = q[0]; // rot touret
476  double q4 = q[2]; // pan
477 
478  double c1 = cos(q1);
479  double s1 = sin(q1);
480  double c14 = cos(q1 + q4);
481  double s14 = sin(q1 + q4);
482 
483  fJe = 0;
484 
485  fJe[0][0] = -s1*this->_a1 - c1*this->_d3;
486 
487  fJe[1][0] = c1*this->_a1 - s1*this->_d3;
488 
489  fJe[2][1] = 1.0;
490 
491  fJe[3][3] = c14;
492 
493  fJe[4][3] = s14;
494 
495  fJe[5][0] = fJe[5][2] = 1.0;
496 }
497 
527 void vpAfma4::get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse)
528 {
529  fJe_inverse.resize(4, 6) ;
530  fJe_inverse = 0;
531 
532  double q1 = q[0]; // rot touret
533  double q4 = q[2]; // pan
534 
535  double c1 = cos(q1);
536  double s1 = sin(q1);
537  double c14 = cos(q1 + q4);
538  double s14 = sin(q1 + q4);
539 
540  double det = this->_a1 * this->_a1 + this->_d3 * this->_d3;
541 
542  fJe_inverse[0][0] = (-s1*this->_a1 - c1*this->_d3)/det;
543  fJe_inverse[0][1] = (c1*this->_a1 - s1*this->_d3)/det;
544 
545  fJe_inverse[1][2] = fJe_inverse[2][5] = 1.;
546 
547  fJe_inverse[2][0] = - fJe_inverse[0][0];
548  fJe_inverse[2][1] = - fJe_inverse[0][1];
549 
550  fJe_inverse[3][3] = c14;
551  fJe_inverse[3][4] = s14;
552 }
553 
564 {
565  vpColVector qmin(4);
566  for (unsigned int i=0; i < 4; i ++)
567  qmin[i] = this->_joint_min[i];
568  return qmin;
569 }
570 
581 {
582  vpColVector qmax(4);
583  for (unsigned int i=0; i < 4; i ++)
584  qmax[i] = this->_joint_max[i];
585  return qmax;
586 }
587 
588 
589 
599 std::ostream & operator << (std::ostream & os,
600  const vpAfma4 & afma4)
601 {
602  vpRotationMatrix eRc;
603  afma4._eMc.extract(eRc);
604  vpRxyzVector rxyz(eRc);
605 
606  os
607  << "Joint Max:" << std::endl
608  << "\t" << afma4._joint_max[0]
609  << "\t" << afma4._joint_max[1]
610  << "\t" << afma4._joint_max[2]
611  << "\t" << afma4._joint_max[3]
612  << "\t" << std::endl
613 
614  << "Joint Min: " << std::endl
615  << "\t" << afma4._joint_min[0]
616  << "\t" << afma4._joint_min[1]
617  << "\t" << afma4._joint_min[2]
618  << "\t" << afma4._joint_min[3]
619  << "\t" << std::endl
620 
621  << "a1: " << std::endl
622  << "\t" << afma4._a1
623  << "\t" << std::endl
624 
625  << "d3: " << std::endl
626  << "\t" << afma4._d3
627  << "\t" << std::endl
628 
629  << "d4: " << std::endl
630  << "\t" << afma4._d4
631  << "\t" << std::endl
632 
633  << "eMc: "<< std::endl
634  << "\tTranslation (m): "
635  << afma4._eMc[0][3] << " "
636  << afma4._eMc[1][3] << " "
637  << afma4._eMc[2][3]
638  << "\t" << std::endl
639  << "\tRotation Rxyz (rad) : "
640  << rxyz[0] << " "
641  << rxyz[1] << " "
642  << rxyz[2]
643  << "\t" << std::endl
644  << "\tRotation Rxyz (deg) : "
645  << vpMath::deg(rxyz[0]) << " "
646  << vpMath::deg(rxyz[1]) << " "
647  << vpMath::deg(rxyz[2])
648  << "\t" << std::endl;
649 
650  return os;
651 }
652 
653 /*
654  * Local variables:
655  * c-basic-offset: 2
656  * End:
657  */
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
double _a1
Definition: vpAfma4.h:145
void get_eJe(const vpColVector &q, vpMatrix &eJe)
Definition: vpAfma4.cpp:417
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:174
void get_fMe(const vpColVector &q, vpHomogeneousMatrix &fMe)
Definition: vpAfma4.cpp:272
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
vpHomogeneousMatrix getForwardKinematics(const vpColVector &q)
Definition: vpAfma4.cpp:151
vpHomogeneousMatrix _eMc
Definition: vpAfma4.h:155
double _d4
Definition: vpAfma4.h:147
void get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse)
Definition: vpAfma4.cpp:527
void init(void)
Definition: vpAfma4.cpp:114
vpAfma4()
Definition: vpAfma4.cpp:71
vpColVector getJointMax()
Definition: vpAfma4.cpp:580
The vpRotationMatrix considers the particular case of a rotation matrix.
vpColVector getJointMin()
Definition: vpAfma4.cpp:563
double _joint_max[4]
Definition: vpAfma4.h:148
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpTranslationVector _etc
Definition: vpAfma4.h:152
double _joint_min[4]
Definition: vpAfma4.h:149
void get_fJe(const vpColVector &q, vpMatrix &fJe)
Definition: vpAfma4.cpp:471
static const unsigned int njoint
Number of joint.
Definition: vpAfma4.h:141
Modelisation of Irisa's cylindrical robot named Afma4.
Definition: vpAfma4.h:112
void extract(vpRotationMatrix &R) const
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpImagePoint &ip)
Definition: vpImagePoint.h:529
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Construction from translation vector and rotation matrix.
vpHomogeneousMatrix get_fMc(const vpColVector &q)
Definition: vpAfma4.cpp:189
void get_cVe(vpVelocityTwistMatrix &cVe)
Definition: vpAfma4.cpp:338
vpRxyzVector _erc
Definition: vpAfma4.h:153
static double deg(double rad)
Definition: vpMath.h:93
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
void get_cVf(const vpColVector &q, vpVelocityTwistMatrix &cVf)
Definition: vpAfma4.cpp:367
vpHomogeneousMatrix inverse() const
Class that consider the case of the Euler angle using the x-y-z convention, where are respectively ...
Definition: vpRxyzVector.h:152
double _d3
Definition: vpAfma4.h:146
void get_cMe(vpHomogeneousMatrix &cMe)
Definition: vpAfma4.cpp:323