Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleCovTransformPose.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 /**
26  @example ExampleCovTransformPose.cpp
27  @relates CovTransformPose
28  @brief Example for pose covariance transformation
29  @ingroup g_examples
30  @author MIP
31 */
32 
33 #include <Base/Common/W32Compat.hh>
34 #include <Geometry/CovTransformPose.hh>
35 
36 #include <Base/Math/Vector3.hh>
37 #include <Base/Math/Matrix.hh>
38 #include <Geometry/RMatrix.hh>
39 #include <Base/Geometry/Quaternion.hh>
40 #include <MathAlgo/SVD.hh>
41 
42 using namespace BIAS;
43 using namespace std;
44 
45 int main()
46 {
47  //create test-data...
48  Vector3<double> angles(0.2, 1.2, 1.01);
49  Vector3<double> posAngles(1.0, 3.0, 0.0);
50  Matrix<double> covAngles(6,6);
51  //...and covariance
52  covAngles.SetIdentity();
53  covAngles *= 0.3;
54  covAngles[3][3] *= 0.1;
55  covAngles[4][4] *= 0.1;
56  covAngles[5][5] *= 0.1;
57 
58  cout << "Pos. for angles: " << posAngles << endl;
59  cout << "Angles: " << angles << endl;
60  cout << "Cov for pos./angles: " << covAngles << endl << endl;
61  cout << "==============================================================="
62  << endl;
63 
64  //get transformed values for Euler-angles to quaternions
65  Quaternion<double> quat;
66  Vector3<double> posQuat;
67  Matrix<double> covQuat;
68 
69  CovTransformPose trans;
70  if (trans.PoseEulerZYXToQuat(posAngles, angles, covAngles,
71  posQuat, quat, covQuat) !=0)
72  exit(-1);
73 
74  cout << "Pos. for quat: " << posQuat << endl;
75  cout << "Quaternion: " << quat << endl;
76  cout << "Cov for pos./quat: " << covQuat << endl << endl;
77  cout << "==============================================================="
78  << endl;
79 
80  //get back-transformed values for quaternions to Euler-angles
81  if (trans.PoseQuatToEulerZYX(posQuat, quat, covQuat,
82  posAngles, angles, covAngles) !=0)
83  exit(-1);
84 
85  cout << "Re-Pos. for angles: " << posAngles << endl;
86  cout << "Re-Angles: " << angles << endl;
87  cout << "Re-Cov for pos./angles: " << covAngles << endl;
88 
89  return 0;
90 }
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
int PoseQuatToEulerZYX(const Vector3< double > &posQ, const Quaternion< double > &rotQ, const Matrix< double > &covQ, Vector3< double > &posE, Vector3< double > &rotE, Matrix< double > &covE)
Convert a pose given as a position, a quaternion and the according 7x7-covariance-matrix to a pose gi...
Transformations between different representations of poses and their covariances (e.g.
int PoseEulerZYXToQuat(const Vector3< double > &posE, const Vector3< double > &rotE, const Matrix< double > &covE, Vector3< double > &posQ, Quaternion< double > &rotQ, Matrix< double > &covQ)
Same as above, just other way around!