1#ifndef _STRUCT_SO3_LINEAR_H
2#define _STRUCT_SO3_LINEAR_H
4#include <Eigen/Geometry>
5#include <boost/math/constants/constants.hpp>
6#include <boost/serialization/split_free.hpp>
7#include <boost/serialization/vector.hpp>
20template <
typename Time =
double,
typename Numeric = Time,
bool Safe = false>
115 const double t_max) {
117 return point3_t::Zero();
125 throw std::invalid_argument(
126 "can't evaluate bezier curve, time t is out of range");
152 const Numeric
prec = Eigen::NumTraits<Numeric>::dummy_precision())
const {
157 other.init_rot_.toRotationMatrix(),
prec) &&
158 end_rot_.toRotationMatrix().isApprox(
159 other.end_rot_.toRotationMatrix(),
prec);
164 const Numeric
prec = Eigen::NumTraits<Numeric>::dummy_precision())
const {
177 return !(*
this ==
other);
186 const std::size_t
order)
const {
188 throw std::invalid_argument(
189 "error in SO3_linear : time t to evaluate derivative should be in "
190 "range [Tmin, Tmax] of the curve");
193 return point3_t::Zero(3);
194 }
else if (
order == 1) {
197 throw std::invalid_argument(
"Order must be > 0 ");
216 std::size_t
virtual dim()
const {
return dim_; };
225 virtual std::size_t
degree()
const {
return 1; }
243 template <
class Archive>
249 ar >> boost::serialization::make_nvp(
"dim",
dim_);
251 ar >> boost::serialization::make_nvp(
"init_rotation",
init);
252 ar >> boost::serialization::make_nvp(
"end_rotation",
end);
255 ar >> boost::serialization::make_nvp(
"angular_vel",
angular_vel_);
256 ar >> boost::serialization::make_nvp(
"T_min",
T_min_);
257 ar >> boost::serialization::make_nvp(
"T_max",
T_max_);
260 template <
class Archive>
266 ar << boost::serialization::make_nvp(
"dim",
dim_);
269 ar << boost::serialization::make_nvp(
"init_rotation",
init_matrix);
270 ar << boost::serialization::make_nvp(
"end_rotation",
end_matrix);
271 ar << boost::serialization::make_nvp(
"angular_vel",
angular_vel_);
272 ar << boost::serialization::make_nvp(
"T_min",
T_min_);
273 ar << boost::serialization::make_nvp(
"T_max",
T_max_);
289 static const Scalar PI_value = boost::math::constants::pi<Scalar>();
299 if (!std::isfinite(
theta)) {
300 throw std::runtime_error(
"theta contains some NaN");
307 std::pow(std::numeric_limits<Scalar>::epsilon(),
313 res(0) =
t * (
R(2, 1) -
R(1, 2));
314 res(1) =
t * (
R(0, 2) -
R(2, 0));
315 res(2) =
t * (
R(1, 0) -
R(0, 1));
339 throw std::invalid_argument(
"Tmin should be inferior to Tmax");
349 SINGLE_ARG(
typename Time,
typename Numeric,
bool Safe),
#define DEFINE_CLASS_TEMPLATE_VERSION(Template, Type)
Definition archive.hpp:27
#define SINGLE_ARG(...)
Definition archive.hpp:23
class allowing to create a constant_curve curve.
interface for a Curve of arbitrary dimension.
Definition bernstein.h:20
Eigen::Vector3d point3_t
Definition fwd.h:71
Eigen::Matrix< double, 3, 3 > matrix3_t
Definition fwd.h:74
bool isApprox(const T a, const T b, const T eps=1e-6)
Definition curve_abc.h:25
Represents a linear interpolation in SO3, using the slerp method provided by Eigen::Quaternion.
Definition so3_linear.h:21
virtual std::size_t degree() const
Get the degree of the curve.
Definition so3_linear.h:225
curve_abc< Time, Numeric, Safe, point_t, point_derivate_t > curve_abc_t
Definition so3_linear.h:27
void load(Archive &ar, const unsigned int version)
Definition so3_linear.h:244
SO3Linear(const SO3Linear &other)
Definition so3_linear.h:105
Eigen::Quaternion< Scalar > quaternion_t
Definition so3_linear.h:25
point3_t computeAngularVelocity(const matrix3_t &init_rot, const matrix3_t &end_rot, const double t_min, const double t_max)
Definition so3_linear.h:113
time_t T_min_
Definition so3_linear.h:237
quaternion_t init_rot_
Definition so3_linear.h:235
time_t max() const
Get the maximum time for which the curve is defined.
Definition so3_linear.h:222
virtual point_derivate_t derivate(const time_t t, const std::size_t order) const
Evaluation of the derivative of order N of spline at time t.
Definition so3_linear.h:185
virtual bool isApprox(const curve_abc_t *other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
isApprox check if other and *this are approximately equal given a precision threshold Only two curves...
Definition so3_linear.h:162
virtual ~SO3Linear()
Destructor.
Definition so3_linear.h:103
matrix3_t point_t
Definition so3_linear.h:23
SO3Linear(const matrix3_t &init_rot, const matrix3_t &end_rot, const time_t t_min, const time_t t_max)
constructor with initial and final rotation expressed as rotation matrix and time bounds
Definition so3_linear.h:63
matrix3_t getEndRotation() const
Definition so3_linear.h:227
SO3Linear()
Empty constructor. Curve obtained this way can not perform other class functions.
Definition so3_linear.h:37
curve_derivate_t * compute_derivate_ptr(const std::size_t order) const
Compute the derived curve at order N.
Definition so3_linear.h:209
virtual bool operator!=(const SO3Linear_t &other) const
Definition so3_linear.h:176
quaternion_t end_rot_
Definition so3_linear.h:235
virtual point_t operator()(const time_t t) const
Evaluation of the SO3Linear at time t using Eigen slerp.
Definition so3_linear.h:137
matrix3_t getEndRotation()
Definition so3_linear.h:229
matrix3_t getInitRotation() const
Definition so3_linear.h:226
Time time_t
Definition so3_linear.h:26
curve_derivate_t compute_derivate(const std::size_t order) const
Definition so3_linear.h:201
time_t T_max_
Definition so3_linear.h:237
SO3Linear(const quaternion_t &init_rot, const quaternion_t &end_rot, const time_t t_min, const time_t t_max)
constructor with initial and final rotation and time bounds
Definition so3_linear.h:47
void save(Archive &ar, const unsigned int version) const
Definition so3_linear.h:261
Numeric Scalar
Definition so3_linear.h:22
matrix3_t getInitRotation()
Definition so3_linear.h:228
point3_t point_derivate_t
Definition so3_linear.h:24
point3_t log3(const matrix3_t &R)
Log: SO3 -> so3.
Definition so3_linear.h:287
quaternion_t computeAsQuaternion(const time_t t) const
Definition so3_linear.h:123
friend class boost::serialization::access
Definition so3_linear.h:241
bool isApprox(const SO3Linear_t &other, const Numeric prec=Eigen::NumTraits< Numeric >::dummy_precision()) const
isApprox check if other and *this are approximately equals. Only two curves of the same class can be ...
Definition so3_linear.h:150
virtual std::size_t dim() const
Get dimension of curve.
Definition so3_linear.h:216
time_t min() const
Get the minimum time for which the curve is defined.
Definition so3_linear.h:219
SO3Linear(const quaternion_t &init_rot, const quaternion_t &end_rot)
constructor with initial and final rotation, time bounds are set to [0;1]
Definition so3_linear.h:77
SO3Linear(const matrix3_t &init_rot, const matrix3_t &end_rot)
constructor with initial and final rotation expressed as rotation matrix, time bounds are set to [0;1...
Definition so3_linear.h:91
point3_t angular_vel_
Definition so3_linear.h:236
SO3Linear< Time, Numeric, Safe > SO3Linear_t
Definition so3_linear.h:30
std::size_t dim_
Definition so3_linear.h:234
virtual bool operator==(const SO3Linear_t &other) const
Definition so3_linear.h:172
constant_curve< Time, Numeric, Safe, point_derivate_t > curve_derivate_t
Definition so3_linear.h:29
Represents a constant_curve curve, always returning the same value and a null derivative.
Definition constant_curve.h:23
Represents a curve of dimension Dim. If value of parameter Safe is false, no verification is made on ...
Definition curve_abc.h:36