YARP
Yet Another Robot Platform
FrameTransform.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_MATH_TRANSFORM_H
7 #define YARP_MATH_TRANSFORM_H
8 
9 #include <yarp/sig/Vector.h>
10 #include <yarp/sig/Matrix.h>
11 #include <yarp/math/api.h>
12 #include <yarp/math/Quaternion.h>
13 
14 namespace yarp {
15 namespace math {
16 
18 {
19 public:
22  double timestamp = 0;
23  bool isStatic = false;
24 
26  {
27  double tX;
28  double tY;
29  double tZ;
30 
31  void set(double x, double y, double z)
32  {
33  tX = x;
34  tY = y;
35  tZ = z;
36  }
37  } translation;
38 
40 
41  bool isValid() const;
42 
44 
45  FrameTransform(const std::string& parent,
46  const std::string& child,
47  double inTX,
48  double inTY,
49  double inTZ,
50  double inRX,
51  double inRY,
52  double inRZ,
53  double inRW);
54 
56 
57  void transFromVec(double X, double Y, double Z);
58  void rotFromRPY(double R, double P, double Y);
59  yarp::sig::Vector getRPYRot() const;
60 
61  yarp::sig::Matrix toMatrix() const;
62  bool fromMatrix(const yarp::sig::Matrix& mat);
63 
65  {
66  rotation_as_quaternion=0,
67  rotation_as_matrix=1,
68  rotation_as_rpy=2
69  };
70 
71  std::string toString(display_transform_mode_t format= rotation_as_quaternion) const;
72 
74  /*
75  * Read data from a connection.
76  * return true iff data was read correctly
77  */
78  bool read(yarp::os::ConnectionReader& connection) override;
79 
84  bool write(yarp::os::ConnectionWriter& connection) const override;
85 
86  yarp::os::Type getType() const override
87  {
88  return yarp::os::Type::byName("yarp/frameTransform");
89  }
90 };
91 
92 } // namespace sig
93 } // namespace yarp
94 
95 #endif // YARP_MATH_TRANSFORM_H
contains the definition of a Matrix type
contains the definition of a Vector type
yarp::os::Type getType() const override
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:26
static Type byName(const char *name)
Definition: Type.cpp:171
A class for a Matrix.
Definition: Matrix.h:43
std::string toString(const T &value)
convert an arbitrary type to string.
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:314
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:922
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1098
The main, catch-all namespace for YARP.
Definition: dirs.h:16
void set(double x, double y, double z)
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:336
#define YARP_math_API
Definition: api.h:17