Visual Servoing Platform  version 3.6.1 under development (2024-03-28)
testTwistMatrix.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Tests some vpMatrix functionalities.
33  *
34 *****************************************************************************/
35 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDebug.h>
44 
45 #include <stdio.h>
46 #include <stdlib.h>
47 
48 #include <visp3/core/vpColVector.h>
49 #include <visp3/core/vpMath.h>
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/core/vpRotationMatrix.h>
52 #include <visp3/core/vpRxyzVector.h>
53 #include <visp3/core/vpTranslationVector.h>
54 #include <visp3/core/vpVelocityTwistMatrix.h>
55 
56 int main()
57 {
58  try {
59  vpTRACE("--------------------------");
60  vpTRACE("--- TEST vpVelocityTwistMatrix ---");
61  vpTRACE("--------------------------");
62 
63  // Set the translation
65  cte[0] = 1.;
66  cte[1] = 0.5;
67  cte[2] = -1.;
68 
69  // Set the rotation
70  vpRxyzVector cre;
71  cre[0] = M_PI / 2.;
72  cre[1] = -M_PI / 2.;
73  cre[2] = -M_PI / 4.;
74 
75  // Build rotation matrix
76  vpRotationMatrix cRe(cre);
77 
78  // Build the twist matrix
79  vpVelocityTwistMatrix cVe(cte, cRe);
80 
81  vpTRACE("cVe twist matrix:");
82  cVe.print(std::cout, 6);
83 
84  // Set a speed skew
85  vpColVector ev(6);
86 
87  ev[0] = 1.;
88  ev[1] = 0.1;
89  ev[2] = -0.5;
90  ev[3] = M_PI / 180.;
91  ev[4] = M_PI / 18.;
92  ev[5] = M_PI / 10.;
93 
94  vpTRACE("ev colvector:");
95  ev.print(std::cout, 6);
96 
97  // Set a speed skew
98  vpColVector cv;
99 
100  cv = cVe * ev;
101 
102  vpTRACE("cv = cVe * ev:");
103  cv.print(std::cout, 6);
104  return EXIT_SUCCESS;
105  } catch (const vpException &e) {
106  std::cout << "Catch an exception: " << e << std::endl;
107  return EXIT_FAILURE;
108  }
109 }
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
int print(std::ostream &s, unsigned int length, char const *intro=0) const
error that can be emitted by ViSP classes.
Definition: vpException.h:59
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRxyzVector.h:176
Class that consider the case of a translation vector.
#define vpTRACE
Definition: vpDebug.h:405