Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
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
49
int
main()
50
{
51
#ifdef ENABLE_VISP_NAMESPACE
52
using namespace
VISP_NAMESPACE_NAME
;
53
#endif
54
try
{
55
vpTranslationVector
t
;
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
66
vpThetaUVector
tu
;
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
80
vpHomogeneousMatrix
M;
81
82
// Compute the displacement from the velocity applied during 1 second
83
M =
vpExponentialMap::direct
(v);
84
85
{
86
// Extract translation from homogenous matrix
87
vpTranslationVector
dt
;
// translation displacement
88
M.
extract
(dt);
89
90
// Extract rotation from homogenous matrix
91
vpRotationMatrix
R
;
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
107
vpRotationMatrix
R
;
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
115
v
=
vpExponentialMap::inverse
(M, 2.f);
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
}
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpExponentialMap::direct
static vpHomogeneousMatrix direct(const vpColVector &v)
Definition
vpExponentialMap.cpp:54
vpExponentialMap::inverse
static vpColVector inverse(const vpHomogeneousMatrix &M)
Definition
vpExponentialMap.cpp:141
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpHomogeneousMatrix::extract
void extract(vpRotationMatrix &R) const
Definition
vpHomogeneousMatrix.cpp:912
vpMath::rad
static double rad(double deg)
Definition
vpMath.h:129
vpRotationMatrix
Implementation of a rotation matrix and operations on such kind of matrices.
Definition
vpRotationMatrix.h:130
vpRxyzVector
Implementation of a rotation vector as Euler angle minimal representation.
Definition
vpRxyzVector.h:183
vpThetaUVector
Implementation of a rotation vector as axis-angle minimal representation.
Definition
vpThetaUVector.h:172
vpTranslationVector
Class that consider the case of a translation vector.
Definition
vpTranslationVector.h:119
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
ibvs-four-points.v
v
Definition
ibvs-four-points.py:271
ibvs-four-points.e
e
Definition
ibvs-four-points.py:272
pbvs-four-points.t
t
Definition
pbvs-four-points.py:220
pbvs-four-points.tu
tu
Definition
pbvs-four-points.py:221
ukf-linear-example.dt
float dt
Definition
ukf-linear-example.py:143
ukf-linear-example.R
R
Definition
ukf-linear-example.py:157
example
math
exponentialMap.cpp
Generated by
1.17.0