Commit 39f69dbf authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

Fix compute_derivate return type when Point_derivate != Point

parent 2f385541
......@@ -37,6 +37,7 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
typedef Time time_t;
typedef Numeric num_t;
typedef curve_abc<Time, Numeric, Safe, point_t, point_derivate_t> curve_t; // parent class
typedef curve_abc<Time, Numeric, Safe, point_derivate_t> curve_derivate_t; // parent class
typedef boost::shared_ptr<curve_t> curve_ptr_t;
/* Constructors - destructors */
......@@ -57,7 +58,7 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
virtual curve_t* compute_derivate_ptr(const std::size_t order) const = 0;
virtual curve_derivate_t* compute_derivate_ptr(const std::size_t order) const = 0;
/// \brief Evaluate the derivative of order N of curve at time t.
/// \param t : time when to evaluate the spline.
......
......@@ -39,6 +39,9 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deri
typedef typename std::vector<curve_ptr_t> t_curve_ptr_t;
typedef typename std::vector<Time> t_time_t;
typedef piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveType> piecewise_curve_t;
typedef piecewise_curve<Time, Numeric, Safe, Point_derivate, Point_derivate,
typename CurveType::curve_derivate_t> piecewise_curve_derivate_t;
typedef boost::shared_ptr<typename piecewise_curve_derivate_t::curve_t> curve_derivate_ptr_t;
public:
/// \brief Empty constructor. Add at least one curve to call other class functions.
......@@ -124,10 +127,10 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deri
* @param order order of derivative
* @return
*/
piecewise_curve_t* compute_derivate_ptr(const std::size_t order) const {
piecewise_curve_t* res(new piecewise_curve_t());
piecewise_curve_derivate_t* compute_derivate_ptr(const std::size_t order) const {
piecewise_curve_derivate_t* res(new piecewise_curve_derivate_t());
for (typename t_curve_ptr_t::const_iterator itc = curves_.begin(); itc < curves_.end(); ++itc) {
curve_ptr_t ptr((*itc)->compute_derivate_ptr(order));
curve_derivate_ptr_t ptr((*itc)->compute_derivate_ptr(order));
res->add_curve_ptr(ptr);
}
return res;
......
......@@ -28,6 +28,7 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
typedef Eigen::Quaternion<Scalar> Quaternion;
typedef Time time_t;
typedef curve_abc<Time, Numeric, Safe, point_t, point_derivate_t> curve_abc_t; // parent class
typedef polynomial<Time, Numeric, Safe, point_derivate_t> curve_derivate_t;
typedef curve_abc<Time, Numeric, Safe, pointX_t> curve_X_t; // generic class of curve
typedef curve_abc<Time, Numeric, Safe, matrix3_t, point3_t>
curve_rotation_t; // templated class used for the rotation (return dimension are fixed)
......@@ -190,14 +191,14 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
return res;
}
SE3Curve_t compute_derivate(const std::size_t /*order*/) const {
curve_derivate_t compute_derivate(const std::size_t /*order*/) const {
throw std::logic_error("Compute derivate for SE3 is not implemented yet.");
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
SE3Curve_t* compute_derivate_ptr(const std::size_t order) const { return new SE3Curve_t(compute_derivate(order)); }
curve_derivate_t* compute_derivate_ptr(const std::size_t order) const { return new curve_derivate_t(compute_derivate(order)); }
/*Helpers*/
/// \brief Get dimension of curve.
......
......@@ -4,6 +4,7 @@
#include "MathDefs.h"
#include "curve_abc.h"
#include "fwd.h"
#include <Eigen/Geometry>
#include <boost/math/constants/constants.hpp>
......@@ -24,8 +25,10 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, matrix3_t, point3_t > {
typedef Eigen::Quaternion<Scalar> quaternion_t;
typedef Time time_t;
typedef curve_abc<Time, Numeric, Safe, point_t, point_derivate_t> curve_abc_t;
typedef polynomial<Time, Numeric, Safe, point_derivate_t, point_derivate_t> curve_derivate_t;
typedef SO3Linear<Time, Numeric, Safe> SO3Linear_t;
public:
/* Constructors - destructors */
/// \brief Empty constructor. Curve obtained this way can not perform other class functions.
......@@ -161,14 +164,14 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, matrix3_t, point3_t > {
}
}
SO3Linear_t compute_derivate(const std::size_t /*order*/) const {
curve_derivate_t compute_derivate(const std::size_t /*order*/) const {
throw std::logic_error("Compute derivate for SO3Linear is not implemented yet.");
}
/// \brief Compute the derived curve at order N.
/// \param order : order of derivative.
/// \return A pointer to \f$\frac{d^Nx(t)}{dt^N}\f$ derivative order N of the curve.
SO3Linear_t* compute_derivate_ptr(const std::size_t order) const { return new SO3Linear_t(compute_derivate(order)); }
curve_derivate_t* compute_derivate_ptr(const std::size_t order) const { return new curve_derivate_t(compute_derivate(order)); }
/*Helpers*/
/// \brief Get dimension of curve.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment