MoveG 1.0.0
A modern C++ library for Robotics
Loading...
Searching...
No Matches
pose_lib.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <eigen3/Eigen/Dense>
12#include <eigen3/Eigen/Geometry>
13
14#include <cmath>
15#include <iostream>
16#include <stdexcept>
17#include <string>
18#include <vector>
19
20#include "rotation_lib.h"
21
25namespace MoveG
26{
34class Pose
35{
36public:
37 // Constructors
38
44 Pose() noexcept;
45
52 Pose(const Eigen::Vector3d &position, const Eigen::Quaterniond &orientation);
53
60 Pose(const Eigen::Vector3d &position, const Eigen::Matrix3d &rotation_matrix);
61
67 explicit Pose(const Eigen::Affine3d &transformation);
68
75 Pose(const Eigen::Vector3d &position, const Rotation &orientation);
76
83 explicit Pose(const Eigen::Matrix4d &homogeneousT);
84
88 ~Pose();
89
95 Pose(const Pose &other);
96
102 Pose(Pose &&other) noexcept;
103
110 Pose &operator=(const Pose &other);
111
118 Pose &operator=(Pose &&other) noexcept;
119
127 friend std::ostream &operator<<(std::ostream &os, const Pose &pose);
128
129 // Getters
130
136 [[nodiscard]] Eigen::Vector3d getPosition() const;
137
143 [[nodiscard]] Eigen::Quaterniond getQuaternion() const;
144
150 [[nodiscard]] Eigen::Matrix3d getRotationMatrix() const;
151
157 [[nodiscard]] Eigen::Affine3d getAffineTransformation() const;
158
164 [[nodiscard]] Eigen::Matrix4d getHomogeneousT() const;
165
171 [[nodiscard]] double getX() const;
172
178 [[nodiscard]] double getY() const;
179
185 [[nodiscard]] double getZ() const;
186
192 [[nodiscard]] double getQx() const;
193
199 [[nodiscard]] double getQy() const;
200
206 [[nodiscard]] double getQz() const;
207
213 [[nodiscard]] double getQw() const;
214
215 // Setters
216
222 void setPosition(const Eigen::Vector3d &position);
223
229 void setOrientation(const Eigen::Quaterniond &orientation);
230
236 void setRotationMatrix(const Eigen::Matrix3d &rotation_matrix);
237
243 void setAffineTransformation(const Eigen::Affine3d &transformation);
244
251 void setHomogeneousT(const Eigen::Matrix4d &homogeneousT);
252
253 // Distance metrics
254
261 [[nodiscard]] double positionDistance(const Pose &other) const;
262
269 [[nodiscard]] double orientationDistance(const Pose &other) const;
270
271 // Operations
272
279 [[nodiscard]] Pose operator*(const Pose &other) const; // Compose poses
280
286 [[nodiscard]] Pose inverse() const;
287
294 [[nodiscard]] Pose transformPose(const Pose &transform) const;
295
302 [[nodiscard]] Eigen::Vector3d localToGlobal(const Eigen::Vector3d &local_point) const;
303
310 [[nodiscard]] Eigen::Vector3d globalToLocal(const Eigen::Vector3d &global_point) const;
311
312private:
313 Eigen::Vector3d position_;
314 Eigen::Quaterniond orientation_;
315
324 static void validateHomogeneousMatrix(const Eigen::Matrix4d &homogeneousT);
325};
326
327} // namespace MoveG
Class representing a pose in 3D space.
Definition pose_lib.h:35
Eigen::Vector3d globalToLocal(const Eigen::Vector3d &global_point) const
Transforms a point from the global frame to the pose's local frame.
Definition pose_lib.cpp:305
double getQw() const
Gets the W component of the quaternion.
Definition pose_lib.cpp:165
double getQz() const
Gets the Z component of the quaternion.
Definition pose_lib.cpp:160
double getY() const
Gets the Y coordinate of the position.
Definition pose_lib.cpp:140
double getQy() const
Gets the Y component of the quaternion.
Definition pose_lib.cpp:155
Eigen::Quaterniond orientation_
Orientation represented as quaternion.
Definition pose_lib.h:314
double positionDistance(const Pose &other) const
Calculates the Euclidean distance between the positions of two poses.
Definition pose_lib.cpp:206
void setOrientation(const Eigen::Quaterniond &orientation)
Sets the orientation via quaternion.
Definition pose_lib.cpp:177
double getX() const
Gets the X coordinate of the position.
Definition pose_lib.cpp:135
Pose transformPose(const Pose &transform) const
Transforms this pose from one coordinate frame to another.
Definition pose_lib.cpp:291
Eigen::Vector3d getPosition() const
Gets the position.
Definition pose_lib.cpp:102
void setAffineTransformation(const Eigen::Affine3d &transformation)
Sets the affine transformation.
Definition pose_lib.cpp:187
Eigen::Vector3d position_
Position in 3D space.
Definition pose_lib.h:313
Pose() noexcept
Default constructor.
Definition pose_lib.cpp:14
void setRotationMatrix(const Eigen::Matrix3d &rotation_matrix)
Sets the rotation matrix.
Definition pose_lib.cpp:182
Eigen::Affine3d getAffineTransformation() const
Gets the affine transformation.
Definition pose_lib.cpp:117
Eigen::Vector3d localToGlobal(const Eigen::Vector3d &local_point) const
Transforms a point from the pose's local frame to the global frame.
Definition pose_lib.cpp:298
Pose & operator=(const Pose &other)
Copy assignment operator.
Definition pose_lib.cpp:79
void setPosition(const Eigen::Vector3d &position)
Sets the position.
Definition pose_lib.cpp:172
static void validateHomogeneousMatrix(const Eigen::Matrix4d &homogeneousT)
Validates a homogeneous transformation matrix.
Definition pose_lib.cpp:237
double getQx() const
Gets the X component of the quaternion.
Definition pose_lib.cpp:150
void setHomogeneousT(const Eigen::Matrix4d &homogeneousT)
Sets the homogeneous transformation matrix.
Definition pose_lib.cpp:193
friend std::ostream & operator<<(std::ostream &os, const Pose &pose)
Overloads the stream insertion operator.
Definition pose_lib.cpp:281
~Pose()
Destructor.
Definition pose_lib.cpp:62
Pose inverse() const
Calculates the inverse of the pose.
Definition pose_lib.cpp:229
Eigen::Quaterniond getQuaternion() const
Gets the orientation quaternion.
Definition pose_lib.cpp:107
double getZ() const
Gets the Z coordinate of the position.
Definition pose_lib.cpp:145
double orientationDistance(const Pose &other) const
Calculates the angular distance between the orientations of two poses.
Definition pose_lib.cpp:211
Pose operator*(const Pose &other) const
Composition of two poses.
Definition pose_lib.cpp:221
Eigen::Matrix3d getRotationMatrix() const
Gets the rotation matrix.
Definition pose_lib.cpp:112
Eigen::Matrix4d getHomogeneousT() const
Gets the homogeneous transformation matrix.
Definition pose_lib.cpp:125
Class for representing and managing rotations in three-dimensional space.
Namespace for movement and manipulation of poses.
Definition pose_lib.cpp:12
Class for representing and manipulating 3D rotations.