Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
exponentialMap.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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 * Test some vpColVector functionalities.
32 */
33
39
40#include <visp3/core/vpColVector.h>
41#include <visp3/core/vpConfig.h>
42#include <visp3/core/vpExponentialMap.h>
43#include <visp3/core/vpHomogeneousMatrix.h>
44#include <visp3/core/vpRotationVector.h>
45#include <visp3/core/vpRxyzVector.h>
46#include <visp3/core/vpThetaUVector.h>
47#include <visp3/core/vpTranslationVector.h>
48
49int main()
50{
51#ifdef ENABLE_VISP_NAMESPACE
52 using namespace VISP_NAMESPACE_NAME;
53#endif
54 try {
56 t[0] = 0.1; // t_x in m/s
57 t[1] = 0.2f; // t_y in m/s
58 t[2] = 0.f; // t_z in m/s
59
60 vpRxyzVector rxyz;
61 rxyz[0] = vpMath::rad(0.f); // r_x in rad/s
62 rxyz[1] = vpMath::rad(0.f); // r_y in rad/s
63 rxyz[2] = vpMath::rad(90.f); // r_z in rad/s
64
65 // Build a ThetaU rotation vector from a Rxyz vector
67 tu.buildFrom(rxyz);
68
69 vpColVector v(6); // Velocity vector [t, thetaU]^t
70
71 v[0] = t[0]; // t_x
72 v[1] = t[1]; // t_y
73 v[2] = t[2]; // t_z
74 v[3] = tu[0]; // ThetaU_x
75 v[4] = tu[1]; // ThetaU_y
76 v[5] = tu[2]; // ThetaU_z
77
78 std::cout << "Considered velocity : \n" << v << std::endl;
79
81
82 // Compute the displacement from the velocity applied during 1 second
84
85 {
86 // Extract translation from homogenous matrix
87 vpTranslationVector dt; // translation displacement
88 M.extract(dt);
89
90 // Extract rotation from homogenous matrix
92 M.extract(R);
93 vpRxyzVector drxyz(R); // rotational displacement
94
95 std::cout << "Displacement if velocity is applied during 1 s : \n" << dt << " " << drxyz << std::endl;
96 }
97
98 // Compute the displacement from the velocity applied during 2 seconds
99 M = vpExponentialMap::direct(v, 2.f);
100
101 {
102 // Extract translation from homogenous matrix
103 vpTranslationVector dt; // translation displacement
104 M.extract(dt);
105
106 // Extract rotation from homogenous matrix
108 M.extract(R);
109 vpRxyzVector drxyz(R); // rotational displacement
110
111 std::cout << "Displacement if velocity is applied during 2 s : \n" << dt << " " << drxyz << std::endl;
112 }
113
114 // Compute the velocity from the displacement observed during 2 seconds
116
117 std::cout << "Velocity from displacement observed during 2 s: \n" << v << std::endl;
118 return EXIT_SUCCESS;
119 }
120 catch (const vpException &e) {
121 std::cout << "Catch an exception: " << e << std::endl;
122 return EXIT_FAILURE;
123 }
124}
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
Definition vpException.h:60
static vpHomogeneousMatrix direct(const vpColVector &v)
static vpColVector inverse(const vpHomogeneousMatrix &M)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
static double rad(double deg)
Definition vpMath.h:129
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.