ViSP  2.8.0
exponentialMap.cpp
1 /****************************************************************************
2  *
3  * $Id: exponentialMap.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  * Test some vpColVector functionalities.
36  *
37  * Authors:
38  * Eric Marchand
39  *
40  *****************************************************************************/
41 
49 #include <visp/vpTranslationVector.h>
50 #include <visp/vpRotationVector.h>
51 #include <visp/vpThetaUVector.h>
52 #include <visp/vpRxyzVector.h>
53 #include <visp/vpColVector.h>
54 #include <visp/vpHomogeneousMatrix.h>
55 #include <visp/vpExponentialMap.h>
56 
57 
58 int
59 main()
60 {
61 
63  t[0] = 0.1; // t_x in m/s
64  t[1] = 0.2f; // t_y in m/s
65  t[2] = 0.f; // t_z in m/s
66 
67  vpRxyzVector rxyz;
68  rxyz[0] = vpMath::rad(0.f); // r_x in rad/s
69  rxyz[1] = vpMath::rad(0.f); // r_y in rad/s
70  rxyz[2] = vpMath::rad(90.f); // r_z in rad/s
71 
72  // Build a ThetaU rotation vector from a Rxyz vector
73  vpThetaUVector tu;
74  tu.buildFrom(rxyz);
75 
76  vpColVector v(6); // Velocity vector [t, thetaU]^t
77 
78  v[0] = t[0]; // t_x
79  v[1] = t[1]; // t_y
80  v[2] = t[2]; // t_z
81  v[3] = tu[0]; // ThetaU_x
82  v[4] = tu[1]; // ThetaU_y
83  v[5] = tu[2]; // ThetaU_z
84 
85  std::cout << "Considered velocity : \n" << v << std::endl;
86 
88 
89  // Compute the displacement from the velocity applied during 1 second
91 
92  {
93  // Extract translation from homogenous matrix
94  vpTranslationVector dt; // translation displacement
95  M.extract(dt);
96 
97  // Extract rotation from homogenous matrix
99  M.extract(R);
100  vpRxyzVector drxyz(R); // rotational displacement
101 
102  std::cout << "Displacement if velocity is applied during 1 s : \n"
103  << dt << " " << drxyz << std::endl;
104  }
105 
106  // Compute the displacement from the velocity applied during 2 seconds
107  M = vpExponentialMap::direct(v, 2.f);
108 
109  {
110  // Extract translation from homogenous matrix
111  vpTranslationVector dt; // translation displacement
112  M.extract(dt);
113 
114  // Extract rotation from homogenous matrix
116  M.extract(R);
117  vpRxyzVector drxyz(R); // rotational displacement
118 
119  std::cout << "Displacement if velocity is applied during 2 s : \n"
120  << dt << " " << drxyz << std::endl;
121  }
122 
123  // Compute the velocity from the displacement observed during 2 seconds
124  v = vpExponentialMap::inverse(M, 2.f);
125 
126  std::cout << "Velocity from displacement observed during 2 s: \n"
127  << v << std::endl;
128 
129 }
static vpColVector inverse(const vpHomogeneousMatrix &M)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
vpThetaUVector buildFrom(const vpHomogeneousMatrix &M)
The vpRotationMatrix considers the particular case of a rotation matrix.
void extract(vpRotationMatrix &R) const
static double rad(double deg)
Definition: vpMath.h:100
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
static vpHomogeneousMatrix direct(const vpColVector &v)
Class that consider the case of the Euler angle using the x-y-z convention, where are respectively ...
Definition: vpRxyzVector.h:152
Class that consider the case of a translation vector.
Class that consider the case of the parameterization for the rotation.