Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpPoseVector.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2023 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 * Pose object. A pose is a size 6 vector [t, tu]^T where tu is
32 * a rotation vector (theta u representation) and t is a translation vector.
33 */
34
35#ifndef vpPOSEVECTOR_H
36#define vpPOSEVECTOR_H
37
49class vpThetaUVector;
50class vpRowVector;
51
52#include <visp3/core/vpArray2D.h>
53#include <visp3/core/vpHomogeneousMatrix.h>
54#include <visp3/core/vpMatrix.h>
55#include <visp3/core/vpRotationMatrix.h>
56
57#ifdef VISP_HAVE_NLOHMANN_JSON
58#include <nlohmann/json.hpp>
59#endif
60
191class VISP_EXPORT vpPoseVector : public vpArray2D<double>
192{
193public:
194 // constructor
195 vpPoseVector();
196 // constructor from 3 angles (in radian)
197 vpPoseVector(double tx, double ty, double tz, double tux, double tuy, double tuz);
198 // constructor convert an homogeneous matrix in a pose
199 explicit vpPoseVector(const vpHomogeneousMatrix &M);
200 // constructor convert a translation and a "thetau" vector into a pose
201 vpPoseVector(const vpTranslationVector &tv, const vpThetaUVector &tu);
202 // constructor convert a translation and a rotation matrix into a pose
207 virtual ~vpPoseVector() { };
208
209 vpPoseVector buildFrom(double tx, double ty, double tz, double tux, double tuy, double tuz);
210 // convert an homogeneous matrix in a pose
211 vpPoseVector buildFrom(const vpHomogeneousMatrix &M);
212 // convert a translation and a "thetau" vector into a pose
213 vpPoseVector buildFrom(const vpTranslationVector &tv, const vpThetaUVector &tu);
214 // convert a translation and a rotation matrix into a pose
215 vpPoseVector buildFrom(const vpTranslationVector &tv, const vpRotationMatrix &R);
216
217 void extract(vpRotationMatrix &R) const;
218 void extract(vpThetaUVector &tu) const;
219 void extract(vpTranslationVector &tv) const;
220 void extract(vpQuaternionVector &q) const;
221
222 vpRotationMatrix getRotationMatrix() const;
223 vpThetaUVector getThetaUVector() const;
224 vpTranslationVector getTranslationVector() const;
225
226 // Load an homogeneous matrix from a file
227 void load(std::ifstream &f);
228
253 inline double &operator[](unsigned int i) { return *(data + i); }
272 inline const double &operator[](unsigned int i) const { return *(data + i); }
273
274 // Print a vector [T thetaU] thetaU in degree
275 void print() const;
276 int print(std::ostream &s, unsigned int length, char const *intro = 0) const;
277
283 void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
284 {
285 (void)nrows;
286 (void)ncols;
287 (void)flagNullify;
288 throw(vpException(vpException::fatalError, "Cannot resize a pose vector"));
289 };
290
291 // Save an homogeneous matrix in a file
292 void save(std::ofstream &f) const;
293 void set(double tx, double ty, double tz, double tux, double tuy, double tuz);
294 vpRowVector t() const;
295
296 std::vector<double> toStdVector() const;
297
298#ifdef VISP_HAVE_NLOHMANN_JSON
299public:
300 static const std::string jsonTypeName;
301private:
302 friend void to_json(nlohmann::json &j, const vpPoseVector &cam);
303 friend void from_json(const nlohmann::json &j, vpPoseVector &cam);
304 // Conversion helper function to avoid circular dependencies and MSVC errors that are not exported in the DLL
305 void parse_json(const nlohmann::json &j);
306 void convert_to_json(nlohmann::json &j) const;
307public:
308#endif
309
310#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
319 vp_deprecated void init() { };
321#endif
322};
323
324#ifdef VISP_HAVE_NLOHMANN_JSON
325#include <nlohmann/json.hpp>
326inline void to_json(nlohmann::json &j, const vpPoseVector &r)
327{
328 r.convert_to_json(j);
329}
330inline void from_json(const nlohmann::json &j, vpPoseVector &r)
331{
332 r.parse_json(j);
333}
334#endif
335
336#endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition vpArray2D.h:131
static bool load(const std::string &filename, vpArray2D< Type > &A, bool binary=false, char *header=NULL)
Definition vpArray2D.h:582
friend void to_json(nlohmann::json &j, const vpArray2D< T > &array)
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition vpArray2D.h:1059
friend void from_json(const nlohmann::json &j, vpArray2D< T > &array)
error that can be emitted by ViSP classes.
Definition vpException.h:59
@ fatalError
Fatal error.
Definition vpException.h:84
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a pose vector and operations on poses.
vp_deprecated void init()
double & operator[](unsigned int i)
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
static const std::string jsonTypeName
const double & operator[](unsigned int i) const
virtual ~vpPoseVector()
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.