Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpAfma4.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Interface for the Irisa's Afma4 robot.
32  *
33  * Authors:
34  * Fabien Spindler
35  *
36  *****************************************************************************/
37 
46 #include <visp3/core/vpDebug.h>
47 #include <visp3/core/vpVelocityTwistMatrix.h>
48 #include <visp3/robot/vpRobotException.h>
49 #include <visp3/core/vpCameraParameters.h>
50 #include <visp3/core/vpRxyzVector.h>
51 #include <visp3/core/vpTranslationVector.h>
52 #include <visp3/core/vpRotationMatrix.h>
53 #include <visp3/robot/vpAfma4.h>
54 
55 
56 /* ----------------------------------------------------------------------- */
57 /* --- STATIC ------------------------------------------------------------ */
58 /* ---------------------------------------------------------------------- */
59 const unsigned int vpAfma4::njoint = 4;
60 
61 
68  : _a1(0), _d3(0), _d4(0), _etc(), _erc(), _eMc()
69 {
70  // Set the default parameters in case of the config files are not available.
71 
72  //
73  // Geometric model constant parameters
74  //
75  this->_a1 = 0.205; // distance along x2
76  this->_d3 = 0.403; // distance along z2
77  this->_d4 = 0.14; // distance along z3
78 
79  // Maximal value of the joints
80  this->_joint_max[0] = 1.8; // rad
81  this->_joint_max[1] = 0.9; // meter
82  this->_joint_max[2] = 0.9; // rad
83  this->_joint_max[3] = 0.76; // rad
84  // Minimal value of the joints
85  this->_joint_min[0] = -1.5; // rad
86  this->_joint_min[1] = -0.9; // meter
87  this->_joint_min[2] = -3.5; // rad
88  this->_joint_min[3] = -0.76;// rad
89 
90  // Camera extrinsic parameters: effector to camera frame
91  this->_etc[0] = 0.; // Translation
92  this->_etc[1] = 0.;
93  this->_etc[2] = 0.;
94  this->_erc[0] = 0.; // Rotation
95  this->_erc[1] = -M_PI/2.;
96  this->_erc[2] = 0;
97 
99  this->_eMc.buildFrom(_etc, eRc);
100 
101  init();
102 }
103 
104 
109 void
111 {
112  return;
113 }
114 
148 {
150  fMc = get_fMc(q);
151 
152  return fMc;
153 }
154 
185 vpAfma4::get_fMc (const vpColVector & q) const
186 {
188  get_fMc(q, fMc);
189 
190  return fMc;
191 }
192 
219 void
221 {
222 
223  // Compute the direct geometric model: fMe = transformation between
224  // fix and end effector frame.
226 
227  get_fMe(q, fMe);
228 
229  fMc = fMe * this->_eMc;
230 
231  return;
232 }
233 
267 void
269 {
270  double q1 = q[0]; // rot touret
271  double q2 = q[1]; // vertical translation
272  double q4 = q[2]; // pan
273  double q5 = q[3]; // tilt
274 
275  double c1 = cos(q1);
276  double s1 = sin(q1);
277  double c4 = cos(q4);
278  double s4 = sin(q4);
279  double c5 = cos(q5);
280  double s5 = sin(q5);
281 
282  /* Calcul du modele d'apres les angles. */
283  fMe[0][0] = c1*s4*c5 + s1*c4*c5;
284  fMe[0][1] = -c1*s4*s5 - s1*c4*s5;
285  fMe[0][2] = c1*c4 - s1*s4;
286  fMe[0][3] = c1*this->_a1 - s1*(this->_d3);
287 
288  fMe[1][0] = s1*s4*c5 - c1*c4*c5;
289  fMe[1][1] = -s1*s4*s5 + c1*c4*s5;
290  fMe[1][2] = s1*c4+c1*s4;
291  fMe[1][3] = s1*this->_a1 + c1*(this->_d3);
292 
293  fMe[2][0] = -s5;
294  fMe[2][1] = -c5;
295  fMe[2][2] = 0.f;
296  fMe[2][3] = this->_d4 + q2;
297 
298  fMe[3][0] = 0.f;
299  fMe[3][1] = 0.f;
300  fMe[3][2] = 0.f;
301  fMe[3][3] = 1;
302 
303  // vpCTRACE << "Effector position fMe: " << std::endl << fMe;
304 
305  return;
306 }
307 
318 void
320 {
321  cMe = this->_eMc.inverse();
322 }
323 
333 void
335 {
336  vpHomogeneousMatrix cMe ;
337  get_cMe(cMe) ;
338 
339  cVe.buildFrom(cMe) ;
340 
341  return;
342 }
343 
362 void
364 {
365  vpHomogeneousMatrix fMc, cMf ;
366  get_fMc(q, fMc) ;
367  cMf = fMc.inverse();
368 
369  cVf.buildFrom(cMf) ;
370 
371  return;
372 }
373 
410 void
411 vpAfma4::get_eJe(const vpColVector &q, vpMatrix &eJe) const
412 {
413  double q4 = q[2]; // pan
414  double q5 = q[3]; // tilt
415 
416  double c4 = cos(q4);
417  double s4 = sin(q4);
418  double c5 = cos(q5);
419  double s5 = sin(q5);
420 
421  eJe.resize(6, 4);
422 
423  eJe = 0;
424 
425  eJe[0][0] = -(this->_a1*c4 + this->_d3*s4)*c5; eJe[0][1] = -s5;
426  eJe[1][0] = (this->_a1*c4 + this->_d3*s4)*s5; eJe[1][1] = -c5;
427  eJe[2][0] = (this->_a1*s4 - this->_d3*c4);
428  eJe[3][0] = eJe[3][2] = -s5;
429  eJe[4][0] = eJe[4][2] = -c5;
430  eJe[5][3] = 1.;
431 }
432 
464 void
465 vpAfma4::get_fJe(const vpColVector &q, vpMatrix &fJe) const
466 {
467  fJe.resize(6,4) ;
468 
469  double q1 = q[0]; // rot touret
470  double q4 = q[2]; // pan
471 
472  double c1 = cos(q1);
473  double s1 = sin(q1);
474  double c14 = cos(q1 + q4);
475  double s14 = sin(q1 + q4);
476 
477  fJe = 0;
478 
479  fJe[0][0] = -s1*this->_a1 - c1*this->_d3;
480 
481  fJe[1][0] = c1*this->_a1 - s1*this->_d3;
482 
483  fJe[2][1] = 1.0;
484 
485  fJe[3][3] = c14;
486 
487  fJe[4][3] = s14;
488 
489  fJe[5][0] = fJe[5][2] = 1.0;
490 }
491 
521 void vpAfma4::get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) const
522 {
523  fJe_inverse.resize(4, 6) ;
524  fJe_inverse = 0;
525 
526  double q1 = q[0]; // rot touret
527  double q4 = q[2]; // pan
528 
529  double c1 = cos(q1);
530  double s1 = sin(q1);
531  double c14 = cos(q1 + q4);
532  double s14 = sin(q1 + q4);
533 
534  double det = this->_a1 * this->_a1 + this->_d3 * this->_d3;
535 
536  fJe_inverse[0][0] = (-s1*this->_a1 - c1*this->_d3)/det;
537  fJe_inverse[0][1] = (c1*this->_a1 - s1*this->_d3)/det;
538 
539  fJe_inverse[1][2] = fJe_inverse[2][5] = 1.;
540 
541  fJe_inverse[2][0] = - fJe_inverse[0][0];
542  fJe_inverse[2][1] = - fJe_inverse[0][1];
543 
544  fJe_inverse[3][3] = c14;
545  fJe_inverse[3][4] = s14;
546 }
547 
558 {
559  vpColVector qmin(4);
560  for (unsigned int i=0; i < 4; i ++)
561  qmin[i] = this->_joint_min[i];
562  return qmin;
563 }
564 
575 {
576  vpColVector qmax(4);
577  for (unsigned int i=0; i < 4; i ++)
578  qmax[i] = this->_joint_max[i];
579  return qmax;
580 }
581 
582 
583 
593 VISP_EXPORT std::ostream & operator << (std::ostream & os,
594  const vpAfma4 & afma4)
595 {
596  vpRotationMatrix eRc;
597  afma4._eMc.extract(eRc);
598  vpRxyzVector rxyz(eRc);
599 
600  os
601  << "Joint Max:" << std::endl
602  << "\t" << afma4._joint_max[0]
603  << "\t" << afma4._joint_max[1]
604  << "\t" << afma4._joint_max[2]
605  << "\t" << afma4._joint_max[3]
606  << "\t" << std::endl
607 
608  << "Joint Min: " << std::endl
609  << "\t" << afma4._joint_min[0]
610  << "\t" << afma4._joint_min[1]
611  << "\t" << afma4._joint_min[2]
612  << "\t" << afma4._joint_min[3]
613  << "\t" << std::endl
614 
615  << "a1: " << std::endl
616  << "\t" << afma4._a1
617  << "\t" << std::endl
618 
619  << "d3: " << std::endl
620  << "\t" << afma4._d3
621  << "\t" << std::endl
622 
623  << "d4: " << std::endl
624  << "\t" << afma4._d4
625  << "\t" << std::endl
626 
627  << "eMc: "<< std::endl
628  << "\tTranslation (m): "
629  << afma4._eMc[0][3] << " "
630  << afma4._eMc[1][3] << " "
631  << afma4._eMc[2][3]
632  << "\t" << std::endl
633  << "\tRotation Rxyz (rad) : "
634  << rxyz[0] << " "
635  << rxyz[1] << " "
636  << rxyz[2]
637  << "\t" << std::endl
638  << "\tRotation Rxyz (deg) : "
639  << vpMath::deg(rxyz[0]) << " "
640  << vpMath::deg(rxyz[1]) << " "
641  << vpMath::deg(rxyz[2])
642  << "\t" << std::endl;
643 
644  return os;
645 }
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
double _a1
Definition: vpAfma4.h:145
vpHomogeneousMatrix get_fMc(const vpColVector &q) const
Definition: vpAfma4.cpp:185
void get_fMe(const vpColVector &q, vpHomogeneousMatrix &fMe) const
Definition: vpAfma4.cpp:268
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpAfma4.cpp:319
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
Definition: vpArray2D.h:167
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix _eMc
Definition: vpAfma4.h:155
vpColVector getJointMax() const
Definition: vpAfma4.cpp:574
double _d4
Definition: vpAfma4.h:147
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpAfma4.cpp:334
void init(void)
Definition: vpAfma4.cpp:110
vpAfma4()
Definition: vpAfma4.cpp:67
void get_cVf(const vpColVector &q, vpVelocityTwistMatrix &cVf) const
Definition: vpAfma4.cpp:363
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Definition: vpAfma4.cpp:411
Implementation of a rotation matrix and operations on such kind of matrices.
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
static const unsigned int njoint
Number of joint.
Definition: vpAfma4.h:141
Modelisation of Irisa's cylindrical robot named Afma4.
Definition: vpAfma4.h:108
void extract(vpRotationMatrix &R) const
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:267
Implementation of a velocity twist matrix and operations on such kind of matrices.
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpHomogeneousMatrix getForwardKinematics(const vpColVector &q) const
Definition: vpAfma4.cpp:147
vpRxyzVector _erc
Definition: vpAfma4.h:153
static double deg(double rad)
Definition: vpMath.h:97
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
vpColVector getJointMin() const
Definition: vpAfma4.cpp:557
vpHomogeneousMatrix inverse() const
void get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) const
Definition: vpAfma4.cpp:521
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRxyzVector.h:154
double _d3
Definition: vpAfma4.h:146
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Definition: vpAfma4.cpp:465