Control Libraries 6.3.4
Loading...
Searching...
No Matches
DualQuaternionPose.hpp
1#pragma once
2
3#include "state_representation/space/dual_quaternion/DualQuaternionState.hpp"
4
5namespace state_representation {
11private:
12 Eigen::Vector3d position;
13
14public:
20 explicit DualQuaternionPose(const std::string& name, const std::string& reference = "world");
21
26
31
35 explicit DualQuaternionPose(const std::string& name,
36 const Eigen::Vector3d& position,
37 const Eigen::Quaterniond& rotation,
38 const std::string& reference = "world");
39
43 const Eigen::Vector3d get_position() const;
44
48 const Eigen::Quaterniond& get_orientation() const;
49
53 void set_orientation(const Eigen::Quaterniond& orientation);
54
58 void set_position(const Eigen::Vector3d& position);
59
63 void set_position(const Eigen::Quaterniond& dual);
64
69 const DualQuaternionPose conjugate() const;
70
75 const DualQuaternionPose inverse() const;
76
83
90
97
104
109 void operator=(const DualQuaternionState& s);
110
114 void initialize();
115
120 const DualQuaternionPose copy() const;
121
127 friend const DualQuaternionState log(const DualQuaternionPose& state);
128
135 friend std::ostream& operator<<(std::ostream& os, const DualQuaternionPose& state);
136};
137
138inline const Eigen::Vector3d DualQuaternionPose::get_position() const {
139 return 2 * (this->get_dual() * this->get_primary().conjugate()).vec();
140}
141
142inline const Eigen::Quaterniond& DualQuaternionPose::get_orientation() const {
143 return this->get_primary();
144}
145
146inline void DualQuaternionPose::set_orientation(const Eigen::Quaterniond& orientation) {
147 Eigen::Quaterniond temp = orientation;
148 if (orientation.norm() - 1 < 1e-4) { temp.normalize(); }
149 if (orientation.w() < 0) {
150 temp = Eigen::Quaterniond(-orientation.w(),
151 -orientation.x(),
152 -orientation.y(),
153 -orientation.z());
154 }
155 this->set_primary(temp);
156 this->set_dual(Eigen::Quaterniond(0.5 * (Eigen::Quaterniond(0,
157 this->position(0),
158 this->position(1),
159 this->position(2)) * this->get_primary()).coeffs()));
160}
161
162inline void DualQuaternionPose::set_position(const Eigen::Vector3d& position) {
163 this->position = position;
164 this->set_dual(Eigen::Quaterniond(0.5 * (Eigen::Quaterniond(0,
165 this->position(0),
166 this->position(1),
167 this->position(2)) * this->get_primary()).coeffs()));
168}
169
170inline void DualQuaternionPose::set_position(const Eigen::Quaterniond& dual) {
171 // WARNING - position is updated, but not dual. This might lead to conficts / different result between position and get_position
172 this->position = 2 * (dual * this->get_primary().conjugate()).vec();
173 this->set_dual(dual);
174}
175}
Class to represent a Pose in Dual Quaternion space.
void set_orientation(const Eigen::Quaterniond &orientation)
Setter of the orientation.
const DualQuaternionPose inverse() const
compute the inverse of the current DualQuaternionPose
void set_position(const Eigen::Vector3d &position)
Setter of the psotion from a vector.
void initialize()
Initialize the DualQuaternionPose to a zero value.
friend std::ostream & operator<<(std::ostream &os, const DualQuaternionPose &state)
Overload the ostream operator for printing.
DualQuaternionPose & operator*=(const DualQuaternionPose &q)
Overload the *= operator.
friend const DualQuaternionState log(const DualQuaternionPose &state)
Calculate the log of a dual quaternion.
void operator=(const DualQuaternionState &s)
Overload the = operator with a DualQuaternionState.
const DualQuaternionPose conjugate() const
compute the conjugate of the current DualQuaternionPose
const Eigen::Quaterniond & get_orientation() const
Getter of the orientation from the primary.
const Eigen::Vector3d get_position() const
Getter of the position attribute.
const DualQuaternionPose copy() const
Return a copy of the DualQuaternionPose.
Class to represent a state in Dual Quaternion space.
const Eigen::Quaterniond & get_dual() const
Getter of the dual attribute.
const Eigen::Quaterniond & get_primary() const
Getter of the primary attribute.
void set_primary(const Eigen::Quaterniond &primary)
Setter of the primary attribute.
void set_dual(const Eigen::Quaterniond &dual)
Setter of the dual attribute.
friend const DualQuaternionState operator*(const float &lambda, const DualQuaternionState &state)
Overload the * operator with a scalar.
Core state variables and objects.