Control Libraries 6.3.4
Loading...
Searching...
No Matches
Shape.hpp
1#pragma once
2
3#include <eigen3/Eigen/Core>
4#include "state_representation/State.hpp"
5#include "state_representation/space/cartesian/CartesianState.hpp"
6#include "state_representation/space/cartesian/CartesianPose.hpp"
7#include "state_representation/space/cartesian/CartesianTwist.hpp"
8#include "state_representation/exceptions/EmptyStateException.hpp"
9#include "state_representation/exceptions/IncompatibleStatesException.hpp"
10#include "state_representation/exceptions/IncompatibleReferenceFramesException.hpp"
11
12namespace state_representation {
16class Shape : public State {
17private:
18 CartesianState center_state_;
19
20public:
25 explicit Shape(const StateType& type);
26
33 explicit Shape(const StateType& type, const std::string& name, const std::string& reference_frame = "world");
34
39 explicit Shape(const Shape& shape);
40
46 Shape& operator=(const Shape& state);
47
52 const CartesianState& get_center_state() const;
53
58 const CartesianPose& get_center_pose() const;
59
64 const Eigen::Vector3d get_center_position() const;
65
70 const Eigen::Quaterniond get_center_orientation() const;
71
76 const CartesianTwist& get_center_twist() const;
77
82 void set_center_state(const CartesianState& state);
83
88 void set_center_pose(const CartesianPose& pose);
89
94 void set_center_position(const Eigen::Vector3d& position);
95
100 void set_center_orientation(const Eigen::Quaterniond& orientation);
101
108 friend std::ostream& operator<<(std::ostream& os, const Shape& shape);
109};
110
111inline Shape& Shape::operator=(const Shape& state) {
112 State::operator=(state);
113 this->center_state_ = state.center_state_;
114 return (*this);
115}
116
118 return this->center_state_;
119}
120
122 return static_cast<const CartesianPose&>(this->center_state_);
123}
124
125inline const Eigen::Vector3d Shape::get_center_position() const {
126 return this->center_state_.get_position();
127}
128
129inline const Eigen::Quaterniond Shape::get_center_orientation() const {
130 return this->center_state_.get_orientation();
131}
132
134 return static_cast<const CartesianTwist&>(this->center_state_);
135}
136
137inline void Shape::set_center_state(const CartesianState& state) {
138 this->set_name(state.get_name());
139 this->center_state_ = state;
140}
141
142inline void Shape::set_center_pose(const CartesianPose& pose) {
143 if (!this->center_state_.is_empty() && this->center_state_.get_reference_frame() != pose.get_reference_frame()) {
145 "The shape state and the given pose are not expressed in the same reference frame");
146 }
147 this->center_state_.set_pose(pose.get_position(), pose.get_orientation());
148}
149
150inline void Shape::set_center_position(const Eigen::Vector3d& position) {
151 if (this->get_center_state().is_empty()) {
152 throw exceptions::EmptyStateException("The center state of the Shape is not set yet.");
153 }
154 this->center_state_.set_position(position);
155}
156
157inline void Shape::set_center_orientation(const Eigen::Quaterniond& orientation) {
158 if (this->get_center_state().is_empty()) {
159 throw exceptions::EmptyStateException("The center state of the Shape is not set yet.");
160 }
161 this->center_state_.set_orientation(orientation);
162}
163}
Class to define CartesianPose in cartesian space as 3D position and quaternion based orientation.
Class to represent a state in Cartesian space.
void set_orientation(const Eigen::Quaterniond &orientation)
Setter of the orientation.
const Eigen::Vector3d & get_position() const
Getter of the position attribute.
void set_position(const Eigen::Vector3d &position)
Setter of the position.
const Eigen::Quaterniond & get_orientation() const
Getter of the orientation attribute.
void set_pose(const Eigen::Vector3d &position, const Eigen::Quaterniond &orientation)
Setter of the pose from both position and orientation.
Class to define twist in cartesian space as 3D linear and angular velocity vectors.
void set_center_orientation(const Eigen::Quaterniond &orientation)
Setter of the pose.
Definition: Shape.hpp:157
void set_center_state(const CartesianState &state)
Setter of the state.
Definition: Shape.hpp:137
Shape & operator=(const Shape &state)
Copy assignment operator that have to be defined to the custom assignment operator.
Definition: Shape.hpp:111
const Eigen::Vector3d get_center_position() const
Getter of the position from the state.
Definition: Shape.hpp:125
const CartesianState & get_center_state() const
Getter of the state.
Definition: Shape.hpp:117
friend std::ostream & operator<<(std::ostream &os, const Shape &shape)
Overload the ostream operator for printing.
Definition: Shape.cpp:12
const CartesianPose & get_center_pose() const
Getter of the pose from the state.
Definition: Shape.hpp:121
const Eigen::Quaterniond get_center_orientation() const
Getter of the orientation from the state.
Definition: Shape.hpp:129
void set_center_pose(const CartesianPose &pose)
Setter of the pose.
Definition: Shape.hpp:142
void set_center_position(const Eigen::Vector3d &position)
Setter of the position.
Definition: Shape.hpp:150
const CartesianTwist & get_center_twist() const
Getter of the twist from the state.
Definition: Shape.hpp:133
const std::string & get_reference_frame() const
Getter of the reference frame as const reference.
Abstract class to represent a state.
Definition: State.hpp:25
const std::string & get_name() const
Getter of the name as const reference.
Definition: State.cpp:48
virtual void set_name(const std::string &name)
Setter of the name.
Definition: State.cpp:52
State & operator=(const State &state)
Copy assignment operator that have to be defined to the custom assignment operator.
Definition: State.hpp:189
bool is_empty() const
Getter of the empty attribute.
Definition: State.cpp:23
Core state variables and objects.
StateType
The class types inheriting from State.
Definition: StateType.hpp:13