Control Libraries 7.4.0
Loading...
Searching...
No Matches
DualQuaternionTwist.cpp
1#include "state_representation/space/dual_quaternion/DualQuaternionTwist.hpp"
2
3namespace state_representation {
4DualQuaternionTwist::DualQuaternionTwist(const std::string& name, const std::string& reference) :
5 DualQuaternionState(name, reference) {
6 this->initialize();
7}
8
10 DualQuaternionState(state), position(state.position), linear_velocity(state.linear_velocity) {}
11
13 const Eigen::Vector3d& linear_velocity,
14 const Eigen::Vector3d& angular_velocity,
15 const Eigen::Vector3d& position,
16 const std::string& reference) :
17 DualQuaternionState(name, reference) {
18 this->initialize();
19 this->set_linear_velocity(linear_velocity);
20 this->set_angular_velocity(angular_velocity);
21 this->set_position(position);
22}
23
25 this->set_primary(q.get_primary());
26 this->set_dual(q.get_dual());
27 this->linear_velocity = this->get_dual().vec() - this->get_position().cross(this->get_angular_velocity());
28}
29
32 this->position = Eigen::Vector3d(0, 0, 0);
33 this->linear_velocity = Eigen::Vector3d(0, 0, 0);
34}
35
37 DualQuaternionTwist result(*this);
38 return result;
39}
40
41std::ostream& operator<<(std::ostream& os, const DualQuaternionTwist& state) {
42 if (state.is_empty()) {
43 os << "Empty DualQuaternionTwist";
44 } else {
45 os << state.get_name() << " DualQuaternionTwist state expressed in " << state.get_reference_frame() << " frame"
46 << std::endl;
47 os << "primary: (" << state.get_primary().w() << ", ";
48 os << state.get_primary().x() << ", ";
49 os << state.get_primary().y() << ", ";
50 os << state.get_primary().z() << ")";
51 os << " <=> angular_velocity: (" << state.get_primary().x() << ", ";
52 os << state.get_primary().y() << ", ";
53 os << state.get_primary().z() << ")" << std::endl;
54 os << "dual: (" << state.get_dual().w() << ", ";
55 os << state.get_dual().x() << ", ";
56 os << state.get_dual().y() << ", ";
57 os << state.get_dual().z() << ")";
58 Eigen::Vector3d linear_velocity = state.get_linear_velocity();
59 os << " => linear_velocity: (" << linear_velocity(0) << ", ";
60 os << linear_velocity(1) << ", ";
61 os << linear_velocity(2) << ")";
62 Eigen::Vector3d position = state.get_position();
63 os << " & position: (" << position(0) << ", ";
64 os << position(1) << ", ";
65 os << position(2) << ")";
66 }
67 return os;
68}
69}
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.
virtual void initialize()
Initialize the DualQuaternionState to a zero value.
Class to represent a Twist in Dual Quaternion space.
void set_position(const Eigen::Vector3d &position)
Setter of the position.
void initialize()
Initialize the DualQuaternionPose to a zero value.
void set_angular_velocity(const Eigen::Vector3d &angular_velocity)
Setter of the angular_velocity.
void operator=(const DualQuaternionState &q)
Overload the = operator to create a twist from a DualQuaternionState. Note that the linear velocity w...
const Eigen::Vector3d & get_position() const
Getter of the position attribute.
void set_linear_velocity(const Eigen::Vector3d &linear_velocity)
Setter of the linear_velocity.
DualQuaternionTwist(const std::string &name, const std::string &reference="world")
Constructor with name and reference frame provided.
const DualQuaternionTwist copy() const
Return a copy of the DualQuaternionTwist.
const Eigen::Vector3d get_angular_velocity() const
Getter of the angular_velocity attribute.
Core state variables and objects.
std::ostream & operator<<(std::ostream &os, const AnalogIOState &state)