Unverified Commit 7f791ea8 authored by Guilhem Saurel's avatar Guilhem Saurel Committed by GitHub
Browse files

Merge pull request #58 from loco-3d/nd_curves

curves → ndcurves, fix #2
parents 991a37b3 8fe7090a
......@@ -15,7 +15,7 @@
#include <fstream>
#include <sstream>
namespace curves {
namespace ndcurves {
/// \class PiecewiseCurve.
/// \brief Represent a piecewise curve. We can add some new curve,
/// but the starting time of the curve to add should be equal to the ending time of the actual
......@@ -601,10 +601,10 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deri
ar& boost::serialization::make_nvp("T_max", T_max_);
}
}; // End struct piecewise curve
} // namespace curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point,
typename Point_derivate, typename CurveType),
SINGLE_ARG(curves::piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveType>))
SINGLE_ARG(ndcurves::piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveType>))
#endif // _CLASS_PIECEWISE_CURVE
......@@ -22,7 +22,7 @@
#include <functional>
#include <stdexcept>
namespace curves {
namespace ndcurves {
/// \class polynomial.
/// \brief Represents a polynomial of an arbitrary order defined on the interval
/// \f$[t_{min}, t_{max}]\f$. It follows the equation :<br>
......@@ -295,7 +295,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
* @return true is the two curves are approximately equals
*/
bool isApprox(const polynomial_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
return curves::isApprox<num_t>(T_min_, other.min()) && curves::isApprox<num_t>(T_max_, other.max()) &&
return ndcurves::isApprox<num_t>(T_min_, other.min()) && ndcurves::isApprox<num_t>(T_max_, other.max()) &&
dim_ == other.dim() && degree_ == other.degree() && coefficients_.isApprox(other.coefficients_, prec);
}
......@@ -471,7 +471,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
}
// remove last degrees is they are equal to 0
long final_degree = new_degree;
while(nCoeffs.col(final_degree).norm() <= curves::MARGIN && final_degree >0){
while(nCoeffs.col(final_degree).norm() <= ndcurves::MARGIN && final_degree >0){
--final_degree;
}
return polynomial_t(nCoeffs.leftCols(final_degree+1), min(), max());
......@@ -495,7 +495,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
}
// remove last degrees is they are equal to 0
long final_degree = degree();
while(nCoeffs.col(final_degree).norm() <= curves::MARGIN && final_degree >0){
while(nCoeffs.col(final_degree).norm() <= ndcurves::MARGIN && final_degree >0){
--final_degree;
}
return polynomial_t(nCoeffs.leftCols(final_degree+1), min(), max());
......@@ -511,7 +511,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
private:
void assert_operator_compatible(const polynomial_t& other) const{
if ((fabs(min() - other.min()) > curves::MARGIN) || (fabs(max() - other.max()) > curves::MARGIN) || dim() != other.dim()){
if ((fabs(min() - other.min()) > ndcurves::MARGIN) || (fabs(max() - other.max()) > ndcurves::MARGIN) || dim() != other.dim()){
throw std::invalid_argument("Can't perform base operation (+ - ) on two polynomials with different time ranges or different dimensions");
}
}
......@@ -608,8 +608,8 @@ polynomial<T,N,S,P,TP> operator*(const double k, const polynomial<T,N,S,P,TP>& p
return res*=k;
}
} // namespace curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename T_Point),
SINGLE_ARG(curves::polynomial<Time, Numeric, Safe, Point, T_Point>))
SINGLE_ARG(ndcurves::polynomial<Time, Numeric, Safe, Point, T_Point>))
#endif //_STRUCT_POLYNOMIAL
#include "curves/fwd.h"
#include "curves/bezier_curve.h"
#include "curves/polynomial.h"
#include "curves/linear_variable.h"
#include "curves/quadratic_variable.h"
#include "ndcurves/fwd.h"
#include "ndcurves/bezier_curve.h"
#include "ndcurves/polynomial.h"
#include "ndcurves/linear_variable.h"
#include "ndcurves/quadratic_variable.h"
#include <vector>
#ifndef _DEFINITION_PYTHON_BINDINGS
#define _DEFINITION_PYTHON_BINDINGS
namespace curves {
namespace ndcurves {
/*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
typedef double real;
typedef std::vector<real> t_time_t;
......@@ -19,8 +19,8 @@ typedef Eigen::Matrix<double, Eigen::Dynamic, 1, 0, Eigen::Dynamic, 1> ret_point
typedef std::pair<pointX_t, pointX_t> pair_pointX_tangent_t;
typedef Eigen::MatrixXd pointX_list_t;
typedef std::vector<pair_pointX_tangent_t, Eigen::aligned_allocator<pair_pointX_tangent_t> > t_pair_pointX_tangent_t;
typedef curves::curve_constraints<pointX_t> curve_constraints_t;
typedef curves::curve_constraints<point3_t> curve_constraints3_t;
typedef ndcurves::curve_constraints<pointX_t> curve_constraints_t;
typedef ndcurves::curve_constraints<point3_t> curve_constraints3_t;
typedef std::pair<real, pointX_t> waypoint_t;
typedef std::vector<waypoint_t> t_waypoint_t;
typedef Eigen::Matrix<real, Eigen::Dynamic, Eigen::Dynamic> point_listX_t;
......@@ -28,7 +28,7 @@ typedef Eigen::Matrix<real, 3, Eigen::Dynamic> point_list3_t;
typedef Eigen::Matrix<real, 6, Eigen::Dynamic> point_list6_t;
typedef polynomial_t::coeff_t coeff_t;
typedef curves::Bern<double> bernstein_t;
typedef ndcurves::Bern<double> bernstein_t;
template <typename PointList, typename T_Point>
T_Point vectorFromEigenArray(const PointList& array) {
......@@ -57,5 +57,5 @@ PointList vectorToEigenArray(const T_point& vect) {
}
return res;
}
} // namespace curves
} // namespace ndcurves
#endif //_DEFINITION_PYTHON_BINDINGS
......@@ -9,8 +9,8 @@
#ifndef _CLASS_QUADRATIC_VARIABLE
#define _CLASS_QUADRATIC_VARIABLE
#include "curves/curve_abc.h"
#include "curves/linear_variable.h"
#include "ndcurves/curve_abc.h"
#include "ndcurves/linear_variable.h"
#include "MathDefs.h"
......@@ -19,7 +19,7 @@
#include <Eigen/Core>
#include <stdexcept>
namespace curves {
namespace ndcurves {
template <typename Numeric = double>
struct quadratic_variable {
......@@ -189,5 +189,5 @@ quadratic_variable<N> operator/(const quadratic_variable<N>& w, const double k)
return res /= k;
}
} // namespace curves
} // namespace ndcurves
#endif //_CLASS_QUADRATIC_VARIABLE
......@@ -8,7 +8,7 @@
#include <boost/math/constants/constants.hpp>
#include <Eigen/Dense>
namespace curves {
namespace ndcurves {
/// \class SE3Curve.
/// \brief Composition of a curve of any type of dimension 3 and a curve representing an rotation
......@@ -158,7 +158,7 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
* @return true is the two curves are approximately equals
*/
bool isApprox(const SE3Curve_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
return curves::isApprox<Numeric>(T_min_, other.min()) && curves::isApprox<Numeric>(T_max_, other.max()) &&
return ndcurves::isApprox<Numeric>(T_min_, other.min()) && ndcurves::isApprox<Numeric>(T_max_, other.max()) &&
(translation_curve_ == other.translation_curve_ ||
translation_curve_->isApprox(other.translation_curve_.get(), prec)) &&
(rotation_curve_ == other.rotation_curve_ || rotation_curve_->isApprox(other.rotation_curve_.get(), prec));
......@@ -256,9 +256,9 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
}; // SE3Curve
} // namespace curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe),
SINGLE_ARG(curves::SE3Curve<Time, Numeric, Safe>))
SINGLE_ARG(ndcurves::SE3Curve<Time, Numeric, Safe>))
#endif // SE3_CURVE_H
......@@ -34,7 +34,7 @@ const unsigned int CURVES_API_VERSION = 1;
} \
}
namespace curves {
namespace ndcurves {
namespace serialization {
struct Serializable {
private:
......@@ -135,6 +135,6 @@ struct Serializable {
} // namespace serialization
} // namespace curves
} // namespace ndcurves
#endif // ifndef __multicontact_api_serialization_archive_hpp__
......@@ -7,22 +7,22 @@
/**
* This file must be included by all classes containing
* pointer of abstract curves as member and serializing them.
* curves::serialization::register_types(ar) must be called before serializing them.
* ndcurves::serialization::register_types(ar) must be called before serializing them.
*/
#include <boost/shared_ptr.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "registeration.hpp"
#include "curves/curve_abc.h"
#include "curves/so3_linear.h"
#include "curves/se3_curve.h"
#include "curves/sinusoidal.h"
#include "curves/polynomial.h"
#include "curves/bezier_curve.h"
#include "curves/constant_curve.h"
#include "curves/piecewise_curve.h"
#include "curves/exact_cubic.h"
#include "curves/cubic_hermite_spline.h"
#include "ndcurves/curve_abc.h"
#include "ndcurves/so3_linear.h"
#include "ndcurves/se3_curve.h"
#include "ndcurves/sinusoidal.h"
#include "ndcurves/polynomial.h"
#include "ndcurves/bezier_curve.h"
#include "ndcurves/constant_curve.h"
#include "ndcurves/piecewise_curve.h"
#include "ndcurves/exact_cubic.h"
#include "ndcurves/cubic_hermite_spline.h"
#endif // ifndef CURVES_SERIALIZAION
......@@ -18,7 +18,7 @@
#include <Eigen/Dense>
#include <vector>
#include "curves/fwd.h"
#include "ndcurves/fwd.h"
/**
*This file define a method register_types that
......@@ -26,7 +26,7 @@
* This is used to serialize pointer of the abstract class curve_abc
*/
namespace curves {
namespace ndcurves {
namespace serialization {
template <class Archive>
......@@ -53,6 +53,6 @@ void register_types(Archive& ar, const unsigned int version) {
}
} // namespace serialization
} // namespace curves
} // namespace ndcurves
#endif // CURVES_REGISTERATION_H
......@@ -12,7 +12,7 @@
#include "curve_abc.h"
#include <cmath>
namespace curves {
namespace ndcurves {
/// \class sinusoidal.
/// \brief Represents a sinusoidal curve, evaluating the following equation:
/// p0 + amplitude * (sin(2pi/T + phi)
......@@ -147,9 +147,9 @@ struct sinusoidal : public curve_abc<Time, Numeric, Safe, Point> {
*/
virtual bool isApprox(const sinusoidal_t& other,
const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
return curves::isApprox<time_t>(T_min_, other.min()) && curves::isApprox<time_t>(T_max_, other.max()) &&
return ndcurves::isApprox<time_t>(T_min_, other.min()) && ndcurves::isApprox<time_t>(T_max_, other.max()) &&
dim_ == other.dim() && p0_.isApprox(other.p0_, prec) && amplitude_.isApprox(other.amplitude_, prec) &&
curves::isApprox<time_t>(T_, other.T_) && curves::isApprox<time_t>(phi_, other.phi_);
ndcurves::isApprox<time_t>(T_, other.T_) && ndcurves::isApprox<time_t>(phi_, other.phi_);
}
virtual bool isApprox(const curve_abc_t* other,
......@@ -211,9 +211,9 @@ struct sinusoidal : public curve_abc<Time, Numeric, Safe, Point> {
inline const num_t two_pi_f(const time_t& t) const { return (2 * M_PI / T_) * t; }
}; // struct sinusoidal
} // namespace curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point),
SINGLE_ARG(curves::sinusoidal<Time, Numeric, Safe, Point>))
SINGLE_ARG(ndcurves::sinusoidal<Time, Numeric, Safe, Point>))
#endif // _CLASS_SINUSOIDALCURVE
......@@ -11,7 +11,7 @@
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/vector.hpp>
namespace curves {
namespace ndcurves {
/// \class SO3Linear.
/// \brief Represents a linear interpolation in SO3, using the slerp method provided by Eigen::Quaternion
......@@ -128,7 +128,7 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, matrix3_t, point3_t > {
* @return true is the two curves are approximately equals
*/
bool isApprox(const SO3Linear_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
return curves::isApprox<Numeric>(T_min_, other.min()) && curves::isApprox<Numeric>(T_max_, other.max()) &&
return ndcurves::isApprox<Numeric>(T_min_, other.min()) && ndcurves::isApprox<Numeric>(T_max_, other.max()) &&
dim_ == other.dim() && init_rot_.toRotationMatrix().isApprox(other.init_rot_.toRotationMatrix(), prec) &&
end_rot_.toRotationMatrix().isApprox(other.end_rot_.toRotationMatrix(), prec);
}
......@@ -300,9 +300,9 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, matrix3_t, point3_t > {
}; // struct SO3Linear
} // namespace curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe),
SINGLE_ARG(curves::SO3Linear<Time, Numeric, Safe>))
SINGLE_ARG(ndcurves::SO3Linear<Time, Numeric, Safe>))
#endif // _STRUCT_SO3_LINEAR_H
......@@ -2,4 +2,4 @@
# Copyright (c) 2019 CNRS
# Author : Steve Tonneau
from .curves import * # noqa
from .ndcurves import * # noqa
......@@ -6,7 +6,7 @@
#include <boost/python.hpp>
namespace curves {
namespace ndcurves {
namespace bp = boost::python;
template <typename Derived>
struct SerializableVisitor : public boost::python::def_visitor<SerializableVisitor<Derived> > {
......@@ -25,6 +25,6 @@ struct SerializableVisitor : public boost::python::def_visitor<SerializableVisit
;
}
};
} // namespace curves
} // namespace ndcurves
#endif // ifndef __multicontact_api_python_serialization_archive_hpp__
......@@ -6,7 +6,7 @@
#include "python_variables.h"
#include "archive_python_binding.h"
#include "optimization_python.h"
#include <curves/serialization/curves.hpp>
#include <ndcurves/serialization/curves.hpp>
#include <boost/python.hpp>
#include <boost/python/class.hpp>
......@@ -17,7 +17,7 @@
#include <boost/utility.hpp>
#include <boost/python/register_ptr_to_python.hpp>
namespace curves {
namespace ndcurves {
using namespace boost::python;
/* base wrap of curve_abc and others parent abstract class: must implement all pure virtual methods */
......@@ -509,7 +509,7 @@ sinusoidal_t* wrapSinusoidalConstructorStationary(const real time_traj,
/* End wrap sinusoidal */
// TO DO : Replace all load and save function for serialization in class by using
// SerializableVisitor in archive_python_binding.
BOOST_PYTHON_MODULE(curves) {
BOOST_PYTHON_MODULE(ndcurves) {
/** BEGIN eigenpy init**/
eigenpy::enableEigenPy();
ENABLE_SPECIFIC_MATRIX_TYPE(pointX_t);
......@@ -1306,4 +1306,4 @@ BOOST_PYTHON_MODULE(curves) {
#endif
} // End BOOST_PYTHON_MODULE
} // namespace curves
} // namespace ndcurves
......@@ -4,7 +4,7 @@
#include "namespace.h"
namespace curves {
namespace ndcurves {
namespace python {
bp::object getOrCreatePythonNamespace(const std::string& submodule_name) {
......@@ -18,4 +18,4 @@ bp::object getOrCreatePythonNamespace(const std::string& submodule_name) {
return submodule;
}
} // namespace python
} // namespace curves
} // namespace ndcurves
......@@ -7,7 +7,7 @@
#include <boost/python.hpp>
namespace curves {
namespace ndcurves {
namespace python {
namespace bp = boost::python;
......@@ -20,6 +20,6 @@ namespace bp = boost::python;
///
bp::object getOrCreatePythonNamespace(const std::string& submodule_name);
} // namespace python
} // namespace curves
} // namespace ndcurves
#endif // ifndef __python_namespace_h__
......@@ -2,4 +2,4 @@
# Copyright (c) 2019 CNRS
# Author : Steve Tonneau
from .curves.optimization import * # noqa
from .ndcurves.optimization import * # noqa
#include "python_variables.h"
#include "archive_python_binding.h"
#include "namespace.h"
#include "curves/optimization/definitions.h"
#include "curves/optimization/quadratic_problem.h"
#include "ndcurves/optimization/definitions.h"
#include "ndcurves/optimization/quadratic_problem.h"
#include <boost/python.hpp>
#include <boost/python/enum.hpp>
#include <boost/python/bases.hpp>
namespace curves {
namespace ndcurves {
namespace optimization {
namespace python {
static const bool safe = true;
......@@ -92,7 +92,7 @@ problem_definition_t* wrapProblemDefinitionConstructor(const curve_constraints_t
void exposeOptimization() {
// using the optimization scope
bp::scope current_scope = curves::python::getOrCreatePythonNamespace("optimization");
bp::scope current_scope = ndcurves::python::getOrCreatePythonNamespace("optimization");
/** BEGIN enums**/
bp::enum_<constraint_flag>("constraint_flag")
.value("INIT_POS", INIT_POS)
......@@ -148,4 +148,4 @@ void exposeOptimization() {
} // namespace python
} // namespace optimization
} // namespace curves
} // namespace ndcurves
#include "python_variables.h"
#include "namespace.h"
#include "curves/optimization/definitions.h"
#include "curves/optimization/quadratic_problem.h"
#include "ndcurves/optimization/definitions.h"
#include "ndcurves/optimization/quadratic_problem.h"
#include <boost/python.hpp>
#ifndef _OPTIMIZATION_PYTHON
#define _OPTIMIZATION_PYTHON
namespace curves {
namespace ndcurves {
namespace optimization {
namespace python {
void exposeOptimization();
} // namespace python
} // namespace optimization
} // namespace curves
} // namespace ndcurves
#endif //_OPTIMIZATION_PYTHON
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