Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpPoseVector.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2024 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
42
43#ifndef VP_POSE_VECTOR_H
44#define VP_POSE_VECTOR_H
45
46#include <visp3/core/vpConfig.h>
47#include <visp3/core/vpArray2D.h>
48#include <visp3/core/vpHomogeneousMatrix.h>
49#include <visp3/core/vpMatrix.h>
50#include <visp3/core/vpRotationMatrix.h>
51
56class vpThetaUVector;
57class vpRowVector;
58
202class VISP_EXPORT vpPoseVector : public vpArray2D<double>
203{
204public:
205 // constructor
206 vpPoseVector();
207 // constructor from 3 angles (in radian)
208 vpPoseVector(double tx, double ty, double tz, double tux, double tuy, double tuz);
209 // constructor convert an homogeneous matrix in a pose
210 VP_EXPLICIT vpPoseVector(const vpHomogeneousMatrix &M);
211 // constructor convert a translation and a "thetau" vector into a pose
212 vpPoseVector(const vpTranslationVector &tv, const vpThetaUVector &tu);
213 // constructor convert a translation and a rotation matrix into a pose
215
216 vpPoseVector &buildFrom(const double &tx, const double &ty, const double &tz, const double &tux, const double &tuy, const double &tuz);
217 // convert an homogeneous matrix in a pose
219 // convert a translation and a "thetau" vector into a pose
221 // convert a translation and a rotation matrix into a pose
223
224 void extract(vpRotationMatrix &R) const;
225 void extract(vpThetaUVector &tu) const;
226 void extract(vpTranslationVector &tv) const;
227 void extract(vpQuaternionVector &q) const;
228
232
233 // Load an homogeneous matrix from a file
234 void load(std::ifstream &f);
235
260 inline double &operator[](unsigned int i) { return *(data + i); }
279 inline const double &operator[](unsigned int i) const { return *(data + i); }
280
281 // Print a vector [T thetaU] thetaU in degree
282 void print() const;
283 int print(std::ostream &s, unsigned int length, char const *intro = nullptr) const;
284
290 VP_NORETURN void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
291 {
292 (void)nrows;
293 (void)ncols;
294 (void)flagNullify;
295 throw(vpException(vpException::fatalError, "Cannot resize a pose vector"));
296 }
297
298 // Save an homogeneous matrix in a file
299 void save(std::ofstream &f) const;
300 void set(double tx, double ty, double tz, double tux, double tuy, double tuz);
301 vpRowVector t() const;
302
303 std::vector<double> toStdVector() const;
304
305#ifdef VISP_HAVE_NLOHMANN_JSON
306public:
307 static const std::string jsonTypeName;
308private:
309 friend void to_json(nlohmann::json &j, const vpPoseVector &cam);
310 friend void from_json(const nlohmann::json &j, vpPoseVector &cam);
311 // Conversion helper function to avoid circular dependencies and MSVC errors that are not exported in the DLL
312 void parse_json(const nlohmann::json &j);
313 void convert_to_json(nlohmann::json &j) const;
314public:
315#endif
316
317private:
318 static const unsigned int constr_value_6;
319#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
324
328 VP_DEPRECATED void init() { }
330#endif
331};
332
333#ifdef VISP_HAVE_NLOHMANN_JSON
334#include VISP_NLOHMANN_JSON(json.hpp)
335inline void to_json(nlohmann::json &j, const vpPoseVector &r)
336{
337 r.convert_to_json(j);
338}
339
340inline void from_json(const nlohmann::json &j, vpPoseVector &r)
341{
342 r.parse_json(j);
343}
344#endif
345END_VISP_NAMESPACE
346#endif
friend void to_json(nlohmann::json &j, const vpArray2D< T > &array)
static bool load(const std::string &filename, vpArray2D< Type > &A, bool binary=false, char *header=nullptr)
Definition vpArray2D.h:760
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition vpArray2D.h:1273
static bool save(const std::string &filename, const vpArray2D< Type > &A, bool binary=false, const char *header="")
Definition vpArray2D.h:965
friend void from_json(const nlohmann::json &j, vpArray2D< T > &array)
error that can be emitted by ViSP classes.
Definition vpException.h:60
@ fatalError
Fatal error.
Definition vpException.h:72
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpTranslationVector getTranslationVector() const
double & operator[](unsigned int i)
friend void from_json(const nlohmann::json &j, vpPoseVector &cam)
static const std::string jsonTypeName
friend void to_json(nlohmann::json &j, const vpPoseVector &cam)
void extract(vpRotationMatrix &R) const
vpThetaUVector getThetaUVector() const
const double & operator[](unsigned int i) const
vpPoseVector & buildFrom(const double &tx, const double &ty, const double &tz, const double &tux, const double &tuy, const double &tuz)
vpRotationMatrix getRotationMatrix() const
VP_NORETURN void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
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.