diff --git a/include/curve/bernstein.h b/include/curve/bernstein.h index c96dd457ceade6eb871d6c7d50db340396d4ee2d..a20784359176b17c11936001e351fb252cb7a57c 100644 --- a/include/curve/bernstein.h +++ b/include/curve/bernstein.h @@ -21,7 +21,7 @@ namespace curve { /// -/// \brief Computes factorial of a number +/// \brief Computes factorial of a number. /// inline unsigned int fact(const unsigned int n) { @@ -32,15 +32,15 @@ inline unsigned int fact(const unsigned int n) } /// -/// \brief Computes a binomal coefficient +/// \brief Computes a binomal coefficient. /// inline unsigned int bin(const unsigned int n, const unsigned int k) { return fact(n) / (fact(k) * fact(n - k)); } -/// \class Bernstein -/// \brief Computes a Bernstein polynome +/// \class Bernstein. +/// \brief Computes a Bernstein polynome. /// template <typename Numeric = double> struct Bern{ @@ -64,7 +64,7 @@ Numeric bin_m_i_; /// -/// \brief Computes all Bernstein polynomes for a certain degree +/// \brief Computes all Bernstein polynomes for a certain degree. /// template <typename Numeric> std::vector<Bern<Numeric> > makeBernstein(const unsigned int n) diff --git a/include/curve/bezier_curve.h b/include/curve/bezier_curve.h index 8586230da90e796033bdfe98ebeee357953b6fac..74e7767e6a02382276f9ce8f15901651e657bc26 100644 --- a/include/curve/bezier_curve.h +++ b/include/curve/bezier_curve.h @@ -23,9 +23,9 @@ namespace curve { -/// \class BezierCurve +/// \class BezierCurve. /// \brief Represents a Bezier curve of arbitrary dimension and order. -/// For degree lesser than 4, the evaluation is analitycal.Otherwise +/// For degree lesser than 4, the evaluation is analitycal. Otherwise /// the bernstein polynoms are used to evaluate the spline at a given location. /// template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false @@ -42,8 +42,11 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> /* Constructors - destructors */ public: - ///\brief Constructor - ///\param PointsBegin, PointsEnd : the points parametering the Bezier curve + + /// \brief Constructor. + /// Given the first and last point of a control points set, automatically create the bezier curve. + /// \param PointsBegin : an iterator pointing to the first element of a control point container. + /// \param PointsEnd : an iterator pointing to the last element of a control point container. /// template<typename In> bezier_curve(In PointsBegin, In PointsEnd) @@ -61,8 +64,11 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> pts_.push_back(*it); } - ///\brief Constructor - ///\param PointsBegin, PointsEnd : the points parametering the Bezier curve + /// \brief Constructor. + /// Given the first and last point of a control points set, automatically create the bezier curve. + /// \param PointsBegin : an iterator pointing to the first element of a control point container. + /// \param PointsEnd : an iterator pointing to the last element of a control point container. + /// \param T : upper bound of curve parameter which is between \f$[0;T]\f$ (default \f$[0;1]\f$). /// template<typename In> bezier_curve(In PointsBegin, In PointsEnd, const time_t T) @@ -82,8 +88,12 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> - ///\brief Constructor - ///\param PointsBegin, PointsEnd : the points parametering the Bezier curve + /// \brief Constructor. + /// Given the first and last point of a control points set, automatically create the bezier curve. + /// \param PointsBegin : an iterator pointing to the first element of a control point container. + /// \param PointsEnd : an iterator pointing to the last element of a control point container. + /// \param T : upper bound of time which is between \f$[0;T]\f$ (default \f$[0;1]\f$). + /// \param mult_T : /// template<typename In> bezier_curve(In PointsBegin, In PointsEnd, const time_t T, const time_t mult_T) @@ -101,11 +111,12 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> pts_.push_back(*it); } - ///\brief Constructor + /// \brief Constructor /// This constructor will add 4 points (2 after the first one, 2 before the last one) - /// to ensure that velocity and acceleration constraints are respected - ///\param PointsBegin, PointsEnd : the points parametering the Bezier curve - ///\param constraints : constraints applying on start / end velocities and acceleration + /// to ensure that velocity and acceleration constraints are respected. + /// \param PointsBegin : an iterator pointing to the first element of a control point container. + /// \param PointsEnd : an iterator pointing to the last element of a control point container. + /// \param constraints : constraints applying on start / end velocities and acceleration. /// template<typename In> bezier_curve(In PointsBegin, In PointsEnd, const curve_constraints_t& constraints, const time_t T=1.) @@ -135,19 +146,24 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> /*Operations*/ public: - /// \brief Evaluation of the cubic spline at time t. - /// \param t : the time when to evaluate the spine - /// \param return : the value x(t) + /// \brief Evaluation of the bezier curve at time t. + /// \param t : time when to evaluate the curve. + /// \return Point corresponding on curve at time t. virtual point_t operator()(const time_t t) const { if(Safe &! (0 <= t && t <= T_)) throw std::out_of_range("can't evaluate bezier curve, out of range"); // TODO - return evalHorner(t); + if (size_ == 1){ + return mult_T_*pts_[0]; + }else{ + return evalHorner(t); + } } - /// \brief Computes the derivative curve at order N. - /// \param order : order of the derivative - /// \param return : the value x(t) + /// \brief Compute the derivative curve at order N. + /// Computes the derivative at order N, \f$\frac{d^Nx(t)}{dt^N}\f$ of bezier curve of parametric equation x(t). + /// \param order : order of the derivative. + /// \return Derivative \f$\frac{dx(t)}{dt}\f$. bezier_curve_t compute_derivate(const std::size_t order) const { if(order == 0) return *this; @@ -160,9 +176,11 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> return deriv.compute_derivate(order-1); } - /// \brief Computes the primitive of the curve at order N. - /// \param constant : value of the primitive at t = 0 - /// \param return : the curve x_1(t) such that d/dt(x_1(t)) = x_1(t) + /// \brief Compute the primitive of the curve at order N. + /// Computes the primitive at order N of bezier curve of parametric equation \f$x(t)\f$. At order \f$N=1\f$, + /// the primitve \f$X(t)\f$ of \f$x(t)\f$ is such as \f$\frac{dX(t)}{dt} = x(t)\f$. + /// \param order : order of the primitive. + /// \return Primitive of x(t). bezier_curve_t compute_primitive(const std::size_t order) const { if(order == 0) return *this; @@ -181,22 +199,23 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> return integ.compute_primitive(order-1); } - /// \brief Evaluates the derivative at order N of the curve. + /// \brief Evaluate the derivative at order N of the curve. /// If the derivative is to be evaluated several times, it is - /// rather recommended to compute the derivative curve using compute_derivate + /// rather recommended to compute the derivative curve using compute_derivate. /// \param order : order of the derivative - /// \param t : the time when to evaluate the spine - /// \param return : the value x(t) + /// \param t : time when to evaluate the curve. + /// \return Point corresponding on derivative curve at time t. virtual point_t derivate(const time_t t, const std::size_t order) const { bezier_curve_t deriv =compute_derivate(order); return deriv(t); } - /// - /// \brief Evaluates all Bernstein polynomes for a certain degree + /// \brief Evaluate all Bernstein polynomes for a certain degree. /// Warning: the horner scheme is about 100 times faster than this method. - /// This method will probably be removed in the future + /// This method will probably be removed in the future. + /// \param t : unNormalized time + /// \return Point corresponding on curve at time t. /// point_t evalBernstein(const Numeric t) const { @@ -209,9 +228,9 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> return res*mult_T_; } - - /// - /// \brief Evaluates all Bernstein polynomes for a certain degree using horner's scheme + /// \brief Evaluate all Bernstein polynomes for a certain degree using horner's scheme. + /// \param t : unNormalized time + /// \return Point corresponding on curve at time t. /// point_t evalHorner(const Numeric t) const { @@ -233,12 +252,10 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> const t_point_t& waypoints() const {return pts_;} - - /** - * @brief evalDeCasteljau evaluate the curve value at time t using deCasteljau algorithm - * @param t unNormalized time - * @return the point at time t - */ + /// \brief Evaluate the curve value at time t using deCasteljau algorithm. + /// \param t : unNormalized time + /// \return Point corresponding on curve at time t. + /// point_t evalDeCasteljau(const Numeric t) const { // normalize time : const Numeric u = t/T_; @@ -253,12 +270,11 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> return deCasteljauReduction(waypoints(),t/T_); } - /** - * @brief deCasteljauReduction compute the de Casteljau's reduction of the given list of points at time t - * @param pts the original list of points - * @param u the NORMALIZED time - * @return the reduced list of point (size of pts - 1) - */ + /// \brief Compute de Casteljau's reduction of the given list of points at time t. + /// \param pts : list of points. + /// \param u : NORMALIZED time. + /// \return Reduced list of point (size of pts - 1). + /// t_point_t deCasteljauReduction(const t_point_t& pts, const Numeric u) const{ if(u < 0 || u > 1) throw std::out_of_range("In deCasteljau reduction : u is not in [0;1]"); @@ -272,12 +288,11 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> return new_pts; } - - /** - * @brief split split the curve in 2 at time t - * @param t - * @return - */ + /// \brief Split the bezier curve in 2 at time t. + /// \param t : list of points. + /// \param u : unNormalized time. + /// \return A pair containing the first element of both bezier curve obtained. + /// std::pair<bezier_curve_t,bezier_curve_t> split(const Numeric t){ if (t == T_) throw std::runtime_error("can't split curve, interval range is equal to original curve"); diff --git a/include/curve/bezier_polynom_conversion.h b/include/curve/bezier_polynom_conversion.h index 0a4910842718a5077fb94ee378ddd47524c2b59a..a2700b163717ced8b9d915685fc263cae4443069 100644 --- a/include/curve/bezier_polynom_conversion.h +++ b/include/curve/bezier_polynom_conversion.h @@ -24,15 +24,12 @@ namespace curve { /// \brief Provides methods for converting a curve from a bernstein representation -/// to a polynom representation +/// to a polynom representation. /// -/// -/// - -///\brief Converts a Bezier curve to a polynom -///\param bezier: the Bezier curve to be converted from -///\return the equivalent polynom +/// \brief Converts a Bezier curve to a polynom. +/// \param bezier: the Bezier curve to convert. +/// \return The equivalent polynom. template<typename Bezier, typename Polynom> Polynom from_bezier(const Bezier& curve) { diff --git a/include/curve/cubic_spline.h b/include/curve/cubic_spline.h index 9715f16fcd35e59a12819f7bd4600d41d139a48f..a852d8e72d3a8a828347fb114f447729d10a0ea4 100644 --- a/include/curve/cubic_spline.h +++ b/include/curve/cubic_spline.h @@ -23,8 +23,8 @@ namespace curve { /// \brief Creates coefficient vector of a cubic spline defined on the interval -/// [tBegin, tEnd]. It follows the equation -/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3 +/// \f$[t_{min}, t_{max}]\f$. It follows the equation : +/// \f$ x(t) = a + b(t - t_{min}) + c(t - t_{min})^2 + d(t - t_{min})^3 \f$ where \f$ t \in [t_{min}, t_{max}] \f$. /// template<typename Point, typename T_Point> T_Point make_cubic_vector(Point const& a, Point const& b, Point const& c, Point const &d) @@ -36,10 +36,10 @@ T_Point make_cubic_vector(Point const& a, Point const& b, Point const& c, Point template<typename Time, typename Numeric, std::size_t Dim, bool Safe, typename Point, typename T_Point> polynom<Time,Numeric,Dim,Safe,Point,T_Point> create_cubic(Point const& a, Point const& b, Point const& c, Point const &d, - const Time min, const Time max) + const Time t_min, const Time t_max) { T_Point coeffs = make_cubic_vector<Point, T_Point>(a,b,c,d); - return polynom<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), min, max); + return polynom<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max); } } // namespace curve #endif //_STRUCT_CUBICSPLINE diff --git a/include/curve/exact_cubic.h b/include/curve/exact_cubic.h index d71cfa0ff6ce132c5ae4b8e5e6b9855ff2b97edb..e33f934b8feaa2354d7387f61a54d65232a19072 100644 --- a/include/curve/exact_cubic.h +++ b/include/curve/exact_cubic.h @@ -31,9 +31,9 @@ namespace curve { -/// \class ExactCubic +/// \class ExactCubic. /// \brief Represents a set of cubic splines defining a continuous function -/// crossing each of the waypoint given in its initialization +/// crossing each of the waypoint given in its initialization. /// template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false , typename Point= Eigen::Matrix<Numeric, Dim, 1>, typename T_Point =std::vector<Point,Eigen::aligned_allocator<Point> > @@ -53,24 +53,25 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point> /* Constructors - destructors */ public: - ///\brief Constructor - ///\param wayPointsBegin : an iterator pointing to the first element of a waypoint container - ///\param wayPointsEns : an iterator pointing to the end of a waypoint container + /// \brief Constructor. + /// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container. + /// \param wayPointsEns : an iterator pointing to the last element of a waypoint container. + /// template<typename In> exact_cubic(In wayPointsBegin, In wayPointsEnd) : curve_abc_t(), subSplines_(computeWayPoints<In>(wayPointsBegin, wayPointsEnd)) {} - ///\brief Constructor - ///\param subSplines: vector of subsplines + /// \brief Constructor. + /// \param subSplines: vector of subsplines. exact_cubic(const t_spline_t& subSplines) : curve_abc_t(), subSplines_(subSplines) {} - ///\brief Copy Constructor + /// \brief Copy Constructor. exact_cubic(const exact_cubic& other) : curve_abc_t(), subSplines_(other.subSplines_) {} - ///\brief Destructor + /// \brief Destructor. virtual ~exact_cubic(){} private: @@ -156,8 +157,9 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point> /*Operations*/ public: /// \brief Evaluation of the cubic spline at time t. - /// \param t : the time when to evaluate the spline - /// \param return : the value x(t) + /// \param t : time when to evaluate the spline + /// \return Point corresponding on spline at time t. + /// virtual point_t operator()(const time_t t) const { if(Safe && (t < subSplines_.front().min() || t > subSplines_.back().max())){throw std::out_of_range("TODO");} @@ -171,9 +173,10 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point> } /// \brief Evaluation of the derivative spline at time t. - /// \param t : the time when to evaluate the spline - /// \param order : order of the derivative - /// \param return : the value x(t) + /// \param t : time when to evaluate the spline. + /// \param order : order of the derivative. + /// \return Point corresponding on derivative spline at time t. + /// virtual point_t derivate(const time_t t, const std::size_t order) const { if(Safe && (t < subSplines_.front().min() || t > subSplines_.back().max())){throw std::out_of_range("TODO");} diff --git a/include/curve/helpers/effector_spline.h b/include/curve/helpers/effector_spline.h index fbd78375641093a1bc68ed3983873b9a4280c219..b4cfa07e3af38101e772dedb352863edc7917194 100644 --- a/include/curve/helpers/effector_spline.h +++ b/include/curve/helpers/effector_spline.h @@ -83,15 +83,15 @@ spline_constraints_t compute_required_offset_velocity_acceleration(const spline_ /// Given a set of waypoints, and the normal vector of the start and /// ending positions, automatically create the spline such that: /// + init and end velocities / accelerations are 0. -/// + the effector lifts and lands exactly in the direction of the specified normals -/// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container -/// \param wayPointsEnd : an iterator pointing to the end of a waypoint container -/// \param lift_normal : normal to be followed by end effector at take-off -/// \param land_normal : normal to be followed by end effector at landing -/// \param lift_offset : length of the straight line along normal at take-off -/// \param land_offset : length of the straight line along normal at landing -/// \param lift_offset_duration : time travelled along straight line at take-off -/// \param land_offset_duration : time travelled along straight line at landing +/// + the effector lifts and lands exactly in the direction of the specified normals. +/// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container. +/// \param wayPointsEnd : an iterator pointing to the last element of a waypoint container. +/// \param lift_normal : normal to be followed by end effector at take-off. +/// \param land_normal : normal to be followed by end effector at landing. +/// \param lift_offset : length of the straight line along normal at take-off. +/// \param land_offset : length of the straight line along normal at landing. +/// \param lift_offset_duration : time travelled along straight line at take-off. +/// \param land_offset_duration : time travelled along straight line at landing. /// template<typename In> exact_cubic_t* effector_spline( diff --git a/include/curve/helpers/effector_spline_rotation.h b/include/curve/helpers/effector_spline_rotation.h index 42efa1cb960026db1f01ad5b4af3dd30f88922f4..391a6c46f090602214042e1000510608984ab65f 100644 --- a/include/curve/helpers/effector_spline_rotation.h +++ b/include/curve/helpers/effector_spline_rotation.h @@ -104,8 +104,8 @@ class rotation_spline: public curve_abc_quat_t typedef exact_cubic<Time, Numeric, 4, false, quat_t, std::vector<quat_t,Eigen::aligned_allocator<quat_t> >, rotation_spline> exact_cubic_quat_t; -/// \class effector_spline_rotation -/// \brief Represents a trajectory for and end effector +/// \class effector_spline_rotation. +/// \brief Represents a trajectory for and end effector. /// uses the method effector_spline to create a spline trajectory. /// Additionally, handles the rotation of the effector as follows: /// does not rotate during the take off and landing phase, @@ -118,18 +118,18 @@ class effector_spline_rotation /// \brief Constructor. /// Given a set of waypoints, and the normal vector of the start and /// ending positions, automatically create the spline such that: - /// + init and end velocities / accelerations are 0. - /// + the effector lifts and lands exactly in the direction of the specified normals - /// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container - /// \param wayPointsEnd : an iterator pointing to the end of a waypoint container - /// \param to_quat : 4D vector, quaternion indicating rotation at take off(x, y, z, w) - /// \param land_quat : 4D vector, quaternion indicating rotation at landing (x, y, z, w) - /// \param lift_normal : normal to be followed by end effector at take-off - /// \param land_normal : normal to be followed by end effector at landing - /// \param lift_offset : length of the straight line along normal at take-off - /// \param land_offset : length of the straight line along normal at landing - /// \param lift_offset_duration : time travelled along straight line at take-off - /// \param land_offset_duration : time travelled along straight line at landing + /// + init and end velocities / accelerations are 0 + /// + the effector lifts and lands exactly in the direction of the specified normals. + /// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container. + /// \param wayPointsEnd : an iterator pointing to the last element of a waypoint container. + /// \param to_quat : 4D vector, quaternion indicating rotation at take off(x, y, z, w). + /// \param land_quat : 4D vector, quaternion indicating rotation at landing (x, y, z, w). + /// \param lift_normal : normal to be followed by end effector at take-off. + /// \param land_normal : normal to be followed by end effector at landing. + /// \param lift_offset : length of the straight line along normal at take-off. + /// \param land_offset : length of the straight line along normal at landing. + /// \param lift_offset_duration : time travelled along straight line at take-off. + /// \param land_offset_duration : time travelled along straight line at landing. /// template<typename In> effector_spline_rotation(In wayPointsBegin, In wayPointsEnd, @@ -149,20 +149,20 @@ class effector_spline_rotation /// \brief Constructor. /// Given a set of waypoints, and the normal vector of the start and /// ending positions, automatically create the spline such that: - /// + init and end velocities / accelerations are 0. - /// + the effector lifts and lands exactly in the direction of the specified normals - /// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container - /// \param wayPointsEnd : an iterator pointing to the end of a waypoint container + /// + init and end velocities / accelerations are 0 + /// + the effector lifts and lands exactly in the direction of the specified normals. + /// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container. + /// \param wayPointsEnd : an iterator pointing to the last element of a waypoint container. /// \param quatWayPointsBegin : en iterator pointing to the first element of a 4D vector (x, y, z, w) container of /// quaternions indicating rotation at specific time steps. - /// \param quatWayPointsEnd : en iterator pointing to the end of a 4D vector (x, y, z, w) container of + /// \param quatWayPointsEnd : en iterator pointing to the last element of a 4D vector (x, y, z, w) container of /// quaternions indicating rotation at specific time steps. - /// \param lift_normal : normal to be followed by end effector at take-off - /// \param land_normal : normal to be followed by end effector at landing - /// \param lift_offset : length of the straight line along normal at take-off - /// \param land_offset : length of the straight line along normal at landing - /// \param lift_offset_duration : time travelled along straight line at take-off - /// \param land_offset_duration : time travelled along straight line at landing + /// \param lift_normal : normal to be followed by end effector at take-off. + /// \param land_normal : normal to be followed by end effector at landing. + /// \param lift_offset : length of the straight line along normal at take-off. + /// \param land_offset : length of the straight line along normal at landing. + /// \param lift_offset_duration : time travelled along straight line at take-off. + /// \param land_offset_duration : time travelled along straight line at landing. /// template<typename In, typename InQuat> effector_spline_rotation(In wayPointsBegin, In wayPointsEnd, @@ -191,9 +191,9 @@ class effector_spline_rotation /*Operations*/ public: /// \brief Evaluation of the effector position and rotation at time t. - /// \param t : the time when to evaluate the spline - /// \param return : a 7D vector; The 3 first values are the 3D position, the 4 last the - /// quaternion describing the rotation + /// \param t : the time when to evaluate the spline. + /// \return A 7D vector where the 3 first values are the 3D position and the 4 last are the + /// quaternion describing the rotation. /// config_t operator()(const Numeric t) const { diff --git a/include/curve/optimization/OptimizeSpline.h b/include/curve/optimization/OptimizeSpline.h index a7d9e161993cbaa69f1e769474bea4d757d26eb3..8a779a7bb3299b25cbbe90f291f1bfdcb76ac2e8 100644 --- a/include/curve/optimization/OptimizeSpline.h +++ b/include/curve/optimization/OptimizeSpline.h @@ -37,14 +37,14 @@ typedef SplineOptimizer<time_t, Numeric, Dim, Safe, Point> splineOptimizer_t; /* Constructors - destructors */ public: - ///\brief Initializes optimizer environment + ///\brief Initializes optimizer environment. SplineOptimizer() { MSKrescodee r_ = MSK_makeenv(&env_,NULL); assert(r_ == MSK_RES_OK); } - ///\brief Destructor + ///\brief Destructor. ~SplineOptimizer() { MSK_deleteenv(&env_); @@ -57,9 +57,9 @@ private: /*Operations*/ public: - /// \brief Starts an optimization loop to create curve - /// \param waypoints : a list comprising at least 2 waypoints in ascending time order - /// \return An Optimised curve + /// \brief Start an optimization loop to create curve. + /// \param waypoints : a list containing at least 2 waypoints in ascending time order. + /// \return An Optimised curve. template<typename In> exact_cubic_t* GenerateOptimizedCurve(In wayPointsBegin, In wayPointsEnd) const; /*Operations*/ diff --git a/include/curve/quintic_spline.h b/include/curve/quintic_spline.h index 31f6bf98303ccfa27e10a102070c4d98f7c7f079..8a4553bdb787c821787a7109d6185d6941e62539 100644 --- a/include/curve/quintic_spline.h +++ b/include/curve/quintic_spline.h @@ -23,8 +23,9 @@ namespace curve { /// \brief Creates coefficient vector of a quintic spline defined on the interval -/// [tBegin, tEnd]. It follows the equation -/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3 + e(t - t_min_)^4 + f(t - t_min_)^5 +/// \f$[t_{min}, t_{max}]\f$. It follows the equation : +/// \f$ x(t) = a + b(t - t_{min}) + c(t - t_{min})^2 + d(t - t_{min})^3 + e(t - t_{min})^4 + f(t - t_{min})^5 \f$ +/// where \f$ t \in [t_{min}, t_{max}] \f$. /// template<typename Point, typename T_Point> T_Point make_quintic_vector(Point const& a, Point const& b, Point const& c, @@ -38,10 +39,10 @@ T_Point make_quintic_vector(Point const& a, Point const& b, Point const& c, template<typename Time, typename Numeric, std::size_t Dim, bool Safe, typename Point, typename T_Point> polynom<Time,Numeric,Dim,Safe,Point,T_Point> create_quintic(Point const& a, Point const& b, Point const& c, Point const &d, Point const &e, Point const &f, - const Time min, const Time max) + const Time t_min, const Time t_max) { T_Point coeffs = make_quintic_vector<Point, T_Point>(a,b,c,d,e,f); - return polynom<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), min, max); + return polynom<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max); } } // namespace curve #endif //_STRUCT_QUINTIC_SPLINE diff --git a/include/curve/spline_deriv_constraint.h b/include/curve/spline_deriv_constraint.h index 9c2ed3ecefbb00366dde13767fe5081c064b4981..16ececf72e4a23984b635e02a0ffd40ce274ecbc 100644 --- a/include/curve/spline_deriv_constraint.h +++ b/include/curve/spline_deriv_constraint.h @@ -36,7 +36,6 @@ namespace curve /// are used to increase the order of the last spline, to start and finish /// trajectory with user defined velocity and acceleration. /// -/// template<typename Time= double, typename Numeric=Time, std::size_t Dim=3, bool Safe=false, typename Point= Eigen::Matrix<Numeric, Dim, 1>, typename T_Point =std::vector<Point,Eigen::aligned_allocator<Point> >, @@ -58,10 +57,11 @@ struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Po /* Constructors - destructors */ public: - ///\brief Constructor - ///\param wayPointsBegin : an iterator pointing to the first element of a waypoint container - ///\param wayPointsEnd : an iterator pointing to the end of a waypoint container - ///\param constraints : constraints on the init and end velocity / accelerations of the spline + /// \brief Constructor. + /// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container. + /// \param wayPointsEnd : an iterator pointing to the last element of a waypoint container. + /// \param constraints : constraints on the init and end velocity / accelerations of the spline. + /// template<typename In> spline_deriv_constraint(In wayPointsBegin, In wayPointsEnd, const spline_constraints& constraints = spline_constraints()) : exact_cubic_t(computeWayPoints<In>(wayPointsBegin, wayPointsEnd, constraints)) {} diff --git a/python/curve_python.cpp b/python/curve_python.cpp index f1141c18bb61fe084213dade37171875ff3d16f8..ee96e7f13055bd13e76c4e855c3b3e0ec6b6b423 100644 --- a/python/curve_python.cpp +++ b/python/curve_python.cpp @@ -76,19 +76,19 @@ Bezier* wrapBezierConstructorConstraintsTemplate(const PointList& array, const C } /*3D constructors */ -bezier3_t* wrapBezierConstructor(const point_list_t& array) +bezier3_t* wrapBezierConstructor3(const point_list_t& array) { return wrapBezierConstructorTemplate<bezier3_t, point_list_t, t_point_t>(array) ; } -bezier3_t* wrapBezierConstructorBounds(const point_list_t& array, const real ub) +bezier3_t* wrapBezierConstructorBounds3(const point_list_t& array, const real ub) { return wrapBezierConstructorTemplate<bezier3_t, point_list_t, t_point_t>(array, ub) ; } -bezier3_t* wrapBezierConstructorConstraints(const point_list_t& array, const curve_constraints_t& constraints) +bezier3_t* wrapBezierConstructor3Constraints(const point_list_t& array, const curve_constraints_t& constraints) { return wrapBezierConstructorConstraintsTemplate<bezier3_t, point_list_t, t_point_t, curve_constraints_t>(array, constraints) ; } -bezier3_t* wrapBezierConstructorBoundsConstraints(const point_list_t& array, const curve_constraints_t& constraints, const real ub) +bezier3_t* wrapBezierConstructorBounds3Constraints(const point_list_t& array, const curve_constraints_t& constraints, const real ub) { return wrapBezierConstructorConstraintsTemplate<bezier3_t, point_list_t, t_point_t, curve_constraints_t>(array, constraints, ub) ; } @@ -238,10 +238,10 @@ BOOST_PYTHON_MODULE(curves) /** BEGIN bezier curve**/ class_<bezier3_t> ("bezier3", no_init) - .def("__init__", make_constructor(&wrapBezierConstructor)) - .def("__init__", make_constructor(&wrapBezierConstructorBounds)) - .def("__init__", make_constructor(&wrapBezierConstructorConstraints)) - .def("__init__", make_constructor(&wrapBezierConstructorBoundsConstraints)) + .def("__init__", make_constructor(&wrapBezierConstructor3)) + .def("__init__", make_constructor(&wrapBezierConstructorBounds3)) + .def("__init__", make_constructor(&wrapBezierConstructor3Constraints)) + .def("__init__", make_constructor(&wrapBezierConstructorBounds3Constraints)) .def("min", &bezier3_t::min) .def("max", &bezier3_t::max) .def("__call__", &bezier3_t::operator()) diff --git a/python/test/curves.so b/python/test/curves.so new file mode 100755 index 0000000000000000000000000000000000000000..981ba4b789bd9e0a7f9f20bff7992aa8aa81e0e4 Binary files /dev/null and b/python/test/curves.so differ diff --git a/python/test/test.py b/python/test/test.py index 9f61b24e502b40b77573e72b11697b0574de30ba..d42bb3ce120cd97c4807f4c8c3b41c8ef60e8843 100644 --- a/python/test/test.py +++ b/python/test/test.py @@ -22,6 +22,12 @@ class TestCurve(unittest.TestCase): # - Functions : constructor, min, max, derivate,compute_derivate, compute_primitive # - Variables : degree, nbWayPoints __EPS = 1e-6 + waypoints = matrix([[1., 2., 3.]]).T + a = bezier3(waypoints,2.) + t = 0. + while t < 2.: + self.assertTrue (norm(a(t) - matrix([1., 2., 3.]).T) < __EPS) + t += 0.1 waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose() waypoints6 = matrix([[1., 2., 3., 7., 5., 5.], [4., 5., 6., 4., 5., 6.]]).transpose() time_waypoints = matrix([0., 1.]).transpose() diff --git a/tests/Main.cpp b/tests/Main.cpp index 00065db7c600e863db3d76d56e92f7dcbe853cc1..7c0e004b43423c74bee40b112f960199048ce9e9 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -151,17 +151,25 @@ void BezierCurveTest(bool& error) std::vector<point_t> params; params.push_back(a); - params.push_back(b); + + // 1d curve + bezier_curve_t cf1(params.begin(), params.end()); + point_t res1; + res1 = cf1(0); + point_t x10 = a ; + ComparePoints(x10, res1, errMsg + "1(0) ", error); + res1 = cf1(1); + ComparePoints(x10, res1, errMsg + "1(1) ", error); // 2d curve - bezier_curve_t cf(params.begin(), params.end()); - point_t res1; - res1 = cf(0); + params.push_back(b); + bezier_curve_t cf(params.begin(), params.end()); + res1 = cf(0); point_t x20 = a ; ComparePoints(x20, res1, errMsg + "2(0) ", error); point_t x21 = b; - res1 = cf(1); + res1 = cf(1); ComparePoints(x21, res1, errMsg + "2(1) ", error); //3d curve