From 0a87d54bbf6abf2419db8147fc1cb3b44ae5ce8f Mon Sep 17 00:00:00 2001
From: Steve Tonneau <stonneau@axle.laas.fr>
Date: Fri, 2 Dec 2016 17:24:23 +0100
Subject: [PATCH] renaming constrained splines

---
 ...l_acc_cons.h => spline_deriv_constraint.h} | 30 +++++++------------
 src/tests/spline_test/Main.cpp                | 10 +++----
 2 files changed, 15 insertions(+), 25 deletions(-)
 rename include/spline/{exact_cubic_vel_acc_cons.h => spline_deriv_constraint.h} (84%)

diff --git a/include/spline/exact_cubic_vel_acc_cons.h b/include/spline/spline_deriv_constraint.h
similarity index 84%
rename from include/spline/exact_cubic_vel_acc_cons.h
rename to include/spline/spline_deriv_constraint.h
index cb64418..9ab09ea 100644
--- a/include/spline/exact_cubic_vel_acc_cons.h
+++ b/include/spline/spline_deriv_constraint.h
@@ -29,17 +29,17 @@
 
 namespace spline
 {
-/// \class cubic_zero_vel.
+/// \class spline_deriv_constraint.
 /// \brief Represents a set of cubic splines defining a continuous function 
 /// crossing each of the waypoint given in its initialization. Additional constraints
-/// are used to increase the order of the last and first splines, to start and finish
-/// trajectory with zero velocity and acceleration. Thus the first and last splines
+/// 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> > >
-struct cubic_zero_vel : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Point>
+struct spline_deriv_constraint : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Point>
 {
     typedef Point 	point_t;
     typedef T_Point t_point_t;
@@ -57,20 +57,13 @@ struct cubic_zero_vel : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Po
     struct spline_constraints
     {
         spline_constraints():
-            init_vel(point_t::Zero()),init_acc(init_vel),end_vel(init_vel),end_acc(init_vel),
-            init_normal(init_vel),end_normal(init_vel) {}
-
-        spline_constraints(const point_t& n0, point_t& n1):
-            init_vel(point_t::Zero()),init_acc(init_vel),end_vel(init_vel),end_acc(init_vel),
-            init_normal(n0),end_normal(n1) {}
+            init_vel(point_t::Zero()),init_acc(init_vel),end_vel(init_vel),end_acc(init_vel){}
 
        ~spline_constraints(){}
         point_t init_vel;
         point_t init_acc;
         point_t end_vel;
         point_t end_acc;
-        point_t init_normal; //TODO
-        point_t end_normal; //TODO
     };
 
 	/* Constructors - destructors */
@@ -79,11 +72,11 @@ struct cubic_zero_vel : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Po
 	///\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
     template<typename In>
-    cubic_zero_vel(In wayPointsBegin, In wayPointsEnd, const spline_constraints& constraints = spline_constraints())
+    spline_deriv_constraint(In wayPointsBegin, In wayPointsEnd, const spline_constraints& constraints = spline_constraints())
         : exact_cubic_t(computeWayPoints<In>(wayPointsBegin, wayPointsEnd, constraints)) {}
 
 	///\brief Destructor
-    ~cubic_zero_vel(){}
+    ~spline_deriv_constraint(){}
 
     private:
     template<typename In>
@@ -135,11 +128,9 @@ struct cubic_zero_vel : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Po
     t_spline_t computeWayPoints(In wayPointsBegin, In wayPointsEnd, const spline_constraints& constraints) const
     {
         std::size_t const size(std::distance(wayPointsBegin, wayPointsEnd));
-        if(Safe && size < 1)
-            throw; // TODO
+        if(Safe && size < 1) throw; // TODO
         t_spline_t subSplines; subSplines.reserve(size-1);
         spline_constraints cons = constraints;
-
         In it(wayPointsBegin), next(wayPointsBegin), end(wayPointsEnd-1);
         ++next;
         for(std::size_t i(0); next != end; ++next, ++it, ++i)
@@ -148,10 +139,9 @@ struct cubic_zero_vel : public exact_cubic<Time, Numeric, Dim, Safe, Point, T_Po
         return subSplines;
     }
 
-
 	private:
-    cubic_zero_vel(const cubic_zero_vel&);
-    cubic_zero_vel& operator=(const cubic_zero_vel&);
+    spline_deriv_constraint(const spline_deriv_constraint&);
+    spline_deriv_constraint& operator=(const spline_deriv_constraint&);
     /* Constructors - destructors */
     /*Attributes*/
     public:
diff --git a/src/tests/spline_test/Main.cpp b/src/tests/spline_test/Main.cpp
index cb8cbda..f236a2a 100644
--- a/src/tests/spline_test/Main.cpp
+++ b/src/tests/spline_test/Main.cpp
@@ -1,8 +1,8 @@
 
 #include "spline/exact_cubic.h"
-#include "spline/exact_cubic_vel_acc_cons.h"
 #include "spline/bezier_curve.h"
 #include "spline/spline_curve.h"
+#include "spline/spline_deriv_constraint.h"
 
 #include <string>
 #include <iostream>
@@ -16,9 +16,9 @@ typedef Eigen::Vector3d point_t;
 typedef std::vector<point_t,Eigen::aligned_allocator<point_t> >  t_point_t;
 typedef spline_curve  <double, double, 3, true, point_t, t_point_t> cubic_function_t;
 typedef exact_cubic <double, double, 3, true, point_t> exact_cubic_t;
-typedef cubic_zero_vel <double, double, 3, true, point_t> cubic_zero_vel_t;
+typedef spline_deriv_constraint <double, double, 3, true, point_t> spline_deriv_constraint_t;
 typedef bezier_curve  <double, double, 3, true, point_t> bezier_curve_t;
-typedef cubic_zero_vel_t::spline_constraints spline_constraints_t;
+typedef spline_deriv_constraint_t::spline_constraints spline_constraints_t;
 typedef std::pair<double, point_t> Waypoint;
 typedef std::vector<Waypoint> T_Waypoint;
 
@@ -352,7 +352,7 @@ void ExactCubicVelocityConstraintsTest(bool& error)
     }
     std::string errmsg("Error in ExactCubicVelocityConstraintsTest (1); while checking that given wayPoints are crossed (expected / obtained)");
     spline_constraints_t constraints;
-    cubic_zero_vel_t exactCubic(waypoints.begin(), waypoints.end());
+    spline_deriv_constraint_t exactCubic(waypoints.begin(), waypoints.end());
     // now check that init and end velocity are 0
     CheckWayPointConstraint(errmsg, 0.2, waypoints, &exactCubic, error);
     std::string errmsg3("Error in ExactCubicVelocityConstraintsTest (2); while checking derivative (expected / obtained)");
@@ -367,7 +367,7 @@ void ExactCubicVelocityConstraintsTest(bool& error)
     constraints.end_acc = point_t(4,5,6);
     constraints.init_acc = point_t(-4,-4,-6);
     std::string errmsg2("Error in ExactCubicVelocityConstraintsTest (3); while checking that given wayPoints are crossed (expected / obtained)");
-    cubic_zero_vel_t exactCubic2(waypoints.begin(), waypoints.end(),constraints);
+    spline_deriv_constraint_t exactCubic2(waypoints.begin(), waypoints.end(),constraints);
     CheckWayPointConstraint(errmsg2, 0.2, waypoints, &exactCubic2, error);
 
     std::string errmsg4("Error in ExactCubicVelocityConstraintsTest (4); while checking derivative (expected / obtained)");
-- 
GitLab