Control Libraries 7.4.0
Loading...
Searching...
No Matches
Ellipsoid.hpp
1#pragma once
2
3#include <list>
4
5#include "state_representation/geometry/Shape.hpp"
6#include "state_representation/space/cartesian/CartesianPose.hpp"
7
8namespace state_representation {
12class Ellipsoid : public Shape {
13public:
17 Ellipsoid();
18
24 explicit Ellipsoid(const std::string& name, const std::string& reference_frame = "world");
25
30 Ellipsoid(const Ellipsoid& ellipsoid);
31
37 static Ellipsoid Unit(const std::string& name, const std::string& reference_frame = "world");
38
44 friend void swap(Ellipsoid& state1, Ellipsoid& state2);
45
51 Ellipsoid& operator=(const Ellipsoid& state);
52
57 const std::vector<double>& get_axis_lengths() const;
58
64 double get_axis_length(unsigned int index) const;
65
70 double get_rotation_angle() const;
71
75 const CartesianPose get_rotation() const;
76
81 void set_axis_lengths(const std::vector<double>& axis_lengths);
82
88 void set_axis_lengths(unsigned int index, double axis_length);
89
94 void set_rotation_angle(double rotation_angle);
95
100 void set_data(const Eigen::VectorXd& data) override;
101
106 void set_data(const std::vector<double>& data) override;
107
114 static const Ellipsoid fit(
115 const std::string& name, const std::list<CartesianPose>& points, const std::string& reference_frame = "world",
116 double noise_level = 0.01
117 );
118
124 const std::string& name, const std::vector<double>& coefficients, const std::string& reference_frame = "world"
125 );
126
132 const std::list<CartesianPose> sample_from_parameterization(unsigned int nb_samples) const;
133
138 const std::vector<double> to_std_vector() const;
139
146 friend std::ostream& operator<<(std::ostream& os, const Ellipsoid& ellipsoid);
147
148private:
149 std::vector<double> axis_lengths_;
150 double rotation_angle_;
151};
152
153inline void swap(Ellipsoid& state1, Ellipsoid& state2) {
154 swap(static_cast<Shape&>(state1), static_cast<Shape&>(state2));
155 std::swap(state1.axis_lengths_, state2.axis_lengths_);
156 std::swap(state1.rotation_angle_, state2.rotation_angle_);
157}
158}// namespace state_representation
Class to define Cartesian pose in Cartesian space as 3D position and quaternion based orientation.
static Ellipsoid Unit(const std::string &name, const std::string &reference_frame="world")
Constructor for a Ellipsoid with identity state, unit axis lengths and zero rotation angle.
Definition Ellipsoid.cpp:29
void set_data(const Eigen::VectorXd &data) override
Set the ellipsoid data from an Eigen vector.
Definition Ellipsoid.cpp:79
Ellipsoid & operator=(const Ellipsoid &state)
Copy assignment operator that has to be defined to the custom assignment operator.
Definition Ellipsoid.cpp:35
friend void swap(Ellipsoid &state1, Ellipsoid &state2)
Swap the values of the two Ellipsoids.
void set_rotation_angle(double rotation_angle)
Setter of the rotation angle.
Definition Ellipsoid.cpp:74
double get_axis_length(unsigned int index) const
Getter of the axis length in one direction.
Definition Ellipsoid.cpp:46
static const Ellipsoid from_algebraic_equation(const std::string &name, const std::vector< double > &coefficients, const std::string &reference_frame="world")
Compute an Ellipsoid from its algebraic equation ax2 + bxy + cy2 + cx + ey + f.
const std::list< CartesianPose > sample_from_parameterization(unsigned int nb_samples) const
Function to sample an obstacle from its parameterization.
const CartesianPose get_rotation() const
Getter of the rotation as a pose.
Definition Ellipsoid.cpp:56
void set_axis_lengths(const std::vector< double > &axis_lengths)
Setter of the axis lengths.
Definition Ellipsoid.cpp:64
double get_rotation_angle() const
Getter of the rotation angle.
Definition Ellipsoid.cpp:51
const std::vector< double > to_std_vector() const
Convert the Ellipsoid to an std vector representation of its parameter.
Ellipsoid()
Empty constructor.
Definition Ellipsoid.cpp:12
const std::vector< double > & get_axis_lengths() const
Getter of the axis lengths.
Definition Ellipsoid.cpp:41
friend std::ostream & operator<<(std::ostream &os, const Ellipsoid &ellipsoid)
Overload the ostream operator for printing.
static const Ellipsoid fit(const std::string &name, const std::list< CartesianPose > &points, const std::string &reference_frame="world", double noise_level=0.01)
Fit an Ellipsoid on a set of points This method uses direct least square fitting from Fitzgibbon,...
Definition Ellipsoid.cpp:93
Core state variables and objects.
void swap(AnalogIOState &state1, AnalogIOState &state2)