Unverified Commit 3a7d0382 authored by olivier stasse's avatar olivier stasse Committed by GitHub
Browse files

Merge pull request #5 from olivier-stasse/master

Change headers to UTF8 and fix problem with >>
parents 1de611c4 94568a81
Pipeline #1296 failed with stage
in 0 seconds
[submodule "cmake"] [submodule "cmake"]
path = cmake path = cmake
url = https://github.com/jrl-umi3218/jrl-cmakemodules.git url = https://github.com/jrl-umi3218/jrl-cmakemodules.git
[submodule ".travis"]
path = .travis
url = https://github.com/jrl-umi3218/jrl-travis.git
Subproject commit bad6dbd29cf70e852e5e427e876390d954ca7d6b
language: generic
python:
- "2.7"
sudo: required
dist: trusty
compiler:
- gcc
# - clang
env:
global:
- secure: "SnIBG/xLIHX3CSvUbqqsX8xTVqIqQ7fFS6HWO6KZQVBsT6yugTwYHbyhNiU531JejYJ/I3ZrDhXfYH3qFZiYxnH1sifvwV+fnTtMXpPN7qPZwIymkjcmm6gJF51e0C7VOfUbvKFv0ngwj+ul21rgZSMuoEvxPK0WxtE3/ZSfn9c="
- APT_DEPENDENCIES="doxygen libeigen3-dev "
- DEBSIGN_KEYID=5AE5CD75
- LCOV_IGNORE_RULES="*unittest* /opt/openrobots/*"
- CC=gcc
- DO_COVERAGE_ON_BRANCH="master;release"
- DO_CPPCHECK_ON_BRANCH=""
- DO_INSTALL_DOC_EXCEPT_ON_BRANCH=""
matrix:
# - BUILDTYPE=Release
- BUILDTYPE=Debug
notifications:
email:
- hpp@laas.fr
branches:
only:
- master
- debian
- devel
matrix:
allow_failures:
- compiler:
before_install: ./travis_custom/custom_before_install
install:
- pip install --user coveralls
- pip install --user numpy
script:
- export CMAKE_ADDITIONAL_OPTIONS="-DCMAKE_BUILD_TYPE=${BUILDTYPE}"
- sudo free -m -t
- ./.travis/run ../travis_custom/custom_build
after_failure: ./.travis/run after_failure
after_success:
- ./.travis/run after_success
Subproject commit 7b0b47cae2b082521ad674c8ee575f594f483cd7 Subproject commit 8474524906099169b05f5c2d0523519d8e383df1
/** /**
* \file sinusoid.hpp * \file sinusoid.hpp
* \brief Generates InfiniteSinusoidal trajectory * \brief Generates InfiniteSinusoidal trajectory
* \author Rohan Budhiraja * \author Rohan Budhiraja
* \date 2017 * \date 2017
* *
*/ */
#ifndef _parameteric_curves_constant_hpp #ifndef _parameteric_curves_constant_hpp
#define _parameteric_curves_constant_hpp #define _parameteric_curves_constant_hpp
#include <parametric-curves/abstract-curve.hpp> #include <parametric-curves/abstract-curve.hpp>
namespace parametriccurves namespace parametriccurves
{ {
/// \class InfiniteSinusoid /// \class InfiniteSinusoid
/// \brief Creates InfiniteSinusoid curve /// \brief Creates InfiniteSinusoid curve
/// The sinusoid is actually a cosine so that it starts with zero velocity. /// The sinusoid is actually a cosine so that it starts with zero velocity.
/// Returns x = x_init + A*cos(2*pi*f*t) where f is give by 1/(2*traj_time) /// Returns x = x_init + A*cos(2*pi*f*t) where f is give by 1/(2*traj_time)
template<typename Numeric=double, std::size_t Dim=1, template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1>> typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct Constant : struct Constant :
public AbstractCurve<Numeric, Point> public AbstractCurve<Numeric, Point>
{ {
typedef Point point_t; typedef Point point_t;
typedef Numeric time_t; typedef Numeric time_t;
typedef Numeric num_t; typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t; typedef AbstractCurve<Numeric, Point> curve_abc_t;
public: public:
///\brief Constructor ///\brief Constructor
Constant(const time_t& traj_time, const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero()) Constant(const time_t& traj_time, const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(0,traj_time), : curve_abc_t(0,traj_time),
x_init(x_init_) {} x_init(x_init_) {}
///\brief Destructor ///\brief Destructor
~Constant(){} ~Constant(){}
public: public:
virtual const point_t operator()(const time_t& t) const virtual const point_t operator()(const time_t& t) const
{ {
return x_init; return x_init;
} }
virtual const point_t derivate(const time_t& t, const std::size_t& order) const virtual const point_t derivate(const time_t& t, const std::size_t& order) const
{ {
return point_t::Zero(); return point_t::Zero();
} }
virtual bool setInitialPoint(const point_t& x_init_) virtual bool setInitialPoint(const point_t& x_init_)
{ {
if(x_init.size()!=x_init_.size()) if(x_init.size()!=x_init_.size())
return false; return false;
x_init = x_init_; x_init = x_init_;
} }
virtual bool setInitialPoint(const double& x_init_) virtual bool setInitialPoint(const double& x_init_)
{ {
if(Dim!=1) if(Dim!=1)
return false; return false;
x_init[0] = x_init_; x_init[0] = x_init_;
return true; return true;
} }
protected: protected:
/*Attributes*/ /*Attributes*/
point_t x_init; point_t x_init;
}; };
} }
#endif //_CLASS_EXACTCUBIC #endif //_CLASS_EXACTCUBIC
/** /**
* \file constant-acceleration.hpp * \file constant-acceleration.hpp
* \brief Generates InfiniteConstAcc trajectory * \brief Generates InfiniteConstAcc trajectory
* \author Rohan Budhiraja * \author Rohan Budhiraja
* \date 2017 * \date 2017
* *
*/ */
#ifndef _parameteric_curves_infinite_constant_acceleration_hpp #ifndef _parameteric_curves_infinite_constant_acceleration_hpp
#define _parameteric_curves_infinite_constant_acceleration_hpp #define _parameteric_curves_infinite_constant_acceleration_hpp
#include <parametric-curves/abstract-curve.hpp> #include <parametric-curves/abstract-curve.hpp>
#include <cmath> #include <cmath>
namespace parametriccurves namespace parametriccurves
{ {
/// \class InfiniteConstAcc /// \class InfiniteConstAcc
/// \brief Creates InfiniteConstAcc curve /// \brief Creates InfiniteConstAcc curve
/// s = s_0 + u_0*t+0.5*a_0*t^2 /// s = s_0 + u_0*t+0.5*a_0*t^2
template<typename Numeric=double, std::size_t Dim=1, template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1>> typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct InfiniteConstAcc : struct InfiniteConstAcc :
public AbstractCurve<Numeric, Point> public AbstractCurve<Numeric, Point>
{ {
typedef Point point_t; typedef Point point_t;
typedef Numeric time_t; typedef Numeric time_t;
typedef Numeric num_t; typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t; typedef AbstractCurve<Numeric, Point> curve_abc_t;
public: public:
///\brief Constructor ///\brief Constructor
InfiniteConstAcc(const time_t& traj_time_, InfiniteConstAcc(const time_t& traj_time_,
const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(), const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(),
const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero()) const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(-1,-1), : curve_abc_t(-1,-1),
traj_time(traj_time_), traj_time(traj_time_),
x_init(x_init_), x_init(x_init_),
x_final(x_final_) {} x_final(x_final_) {}
///\brief Destructor ///\brief Destructor
~InfiniteConstAcc(){} ~InfiniteConstAcc(){}
public: public:
virtual const point_t operator()(const time_t& t_) const virtual const point_t operator()(const time_t& t_) const
{ {
const time_t t = std::fmod(t_, 2*traj_time); const time_t t = std::fmod(t_, 2*traj_time);
const point_t& m_ddx0 = 4.0*(x_final-x_init)/(traj_time*traj_time); const point_t& m_ddx0 = 4.0*(x_final-x_init)/(traj_time*traj_time);
if(t<=0.5*traj_time) if(t<=0.5*traj_time)
return x_init + 0.5*m_ddx0*t*t; return x_init + 0.5*m_ddx0*t*t;
else if(t>0.5*traj_time && t<=1.5*traj_time) else if(t>0.5*traj_time && t<=1.5*traj_time)
return (x_init+x_final)/2 return (x_init+x_final)/2
+0.5*m_ddx0*traj_time*(t-0.5*traj_time) +0.5*m_ddx0*traj_time*(t-0.5*traj_time)
-0.5*m_ddx0*(t-0.5*traj_time)*(t-0.5*traj_time); -0.5*m_ddx0*(t-0.5*traj_time)*(t-0.5*traj_time);
else //(t>1.5*traj_time && t<=2*traj_time) else //(t>1.5*traj_time && t<=2*traj_time)
return (x_init+x_final)/2 return (x_init+x_final)/2
- 0.5*m_ddx0*traj_time*(t-1.5*traj_time) - 0.5*m_ddx0*traj_time*(t-1.5*traj_time)
+ 0.5*m_ddx0*(t-1.5*traj_time)*(t-1.5*traj_time); + 0.5*m_ddx0*(t-1.5*traj_time)*(t-1.5*traj_time);
} }
virtual const point_t derivate(const time_t& t_, const std::size_t& order) const virtual const point_t derivate(const time_t& t_, const std::size_t& order) const
{ {
const time_t t = std::fmod(t_, 2*traj_time); const time_t t = std::fmod(t_, 2*traj_time);
const point_t& m_ddx0 = 4.0*(x_final-x_init)/(traj_time*traj_time); const point_t& m_ddx0 = 4.0*(x_final-x_init)/(traj_time*traj_time);
if(order==1) { if(order==1) {
if(t<=0.5*traj_time) if(t<=0.5*traj_time)
return m_ddx0*t; return m_ddx0*t;
else if(t>0.5*traj_time && t<=1.5*traj_time) else if(t>0.5*traj_time && t<=1.5*traj_time)
return 0.5*m_ddx0*traj_time - m_ddx0*(t-0.5*traj_time); return 0.5*m_ddx0*traj_time - m_ddx0*(t-0.5*traj_time);
else //(t>1.5*traj_time && t<=2*traj_time) else //(t>1.5*traj_time && t<=2*traj_time)
return -0.5*m_ddx0*traj_time + m_ddx0*(t-1.5*traj_time); return -0.5*m_ddx0*traj_time + m_ddx0*(t-1.5*traj_time);
} }
else if(order==2) { else if(order==2) {
if(t<=0.5*traj_time) if(t<=0.5*traj_time)
return m_ddx0; return m_ddx0;
else if(t>0.5*traj_time && t<=1.5*traj_time) else if(t>0.5*traj_time && t<=1.5*traj_time)
return -m_ddx0; return -m_ddx0;
else //(t>1.5*traj_time && t<=2*traj_time) else //(t>1.5*traj_time && t<=2*traj_time)
return m_ddx0; return m_ddx0;
} }
else { else {
std::cerr<<"Higher order derivatives not supported"<<std::endl; std::cerr<<"Higher order derivatives not supported"<<std::endl;
return point_t::Zero(Dim); return point_t::Zero(Dim);
} }
} }
public: public:
virtual bool setInitialPoint(const point_t& x_init_) virtual bool setInitialPoint(const point_t& x_init_)
{ {
if(x_init_.size()!=x_init.size()) if(x_init_.size()!=x_init.size())
return false; return false;
x_init = x_init_; x_init = x_init_;
} }
virtual bool setInitialPoint(const double& x_init_) virtual bool setInitialPoint(const double& x_init_)
{ {
if(Dim!=1) if(Dim!=1)
return false; return false;
x_init[0] = x_init_; x_init[0] = x_init_;
return true; return true;
} }
virtual bool setFinalPoint(const Eigen::VectorXd& x_final_) virtual bool setFinalPoint(const Eigen::VectorXd& x_final_)
{ {
if(x_final.size()!=x_final_.size()) if(x_final.size()!=x_final_.size())
return false; return false;
x_final = x_final_; x_final = x_final_;
return true; return true;
} }
virtual bool setFinalPoint(const double& x_final_) virtual bool setFinalPoint(const double& x_final_)
{ {
if(Dim!=1) if(Dim!=1)
return false; return false;
x_final[0] = x_final_; x_final[0] = x_final_;
return true; return true;
} }
virtual bool setTrajectoryTime(double traj_time_) virtual bool setTrajectoryTime(double traj_time_)
{ {
if(traj_time_<=0.0) if(traj_time_<=0.0)
return false; return false;
traj_time = traj_time_; traj_time = traj_time_;
return true; return true;
} }
protected: protected:
/*Attributes*/ /*Attributes*/
point_t x_init; point_t x_init;
point_t x_final; point_t x_final;
time_t traj_time; time_t traj_time;
}; };
} }
#endif //_CLASS_EXACTCUBIC #endif //_CLASS_EXACTCUBIC
/** /**
* \file sinusoid.hpp * \file sinusoid.hpp
* \brief Generates InfiniteSinusoidal trajectory * \brief Generates InfiniteSinusoidal trajectory
* \author Rohan Budhiraja * \author Rohan Budhiraja
* \date 2017 * \date 2017
* *
*/ */
#ifndef _parameteric_curves_sinusoid_hpp #ifndef _parameteric_curves_sinusoid_hpp
#define _parameteric_curves_sinusoid_hpp #define _parameteric_curves_sinusoid_hpp
#include <parametric-curves/abstract-curve.hpp> #include <parametric-curves/abstract-curve.hpp>
namespace parametriccurves namespace parametriccurves
{ {
/// \class InfiniteSinusoid /// \class InfiniteSinusoid
/// \brief Creates InfiniteSinusoid curve /// \brief Creates InfiniteSinusoid curve
/// The sinusoid is actually a cosine so that it starts with zero velocity. /// The sinusoid is actually a cosine so that it starts with zero velocity.
/// Returns x = x_init + A*cos(2*pi*f*t) where f is give by 1/(2*traj_time) /// Returns x = x_init + A*cos(2*pi*f*t) where f is give by 1/(2*traj_time)
template<typename Numeric=double, std::size_t Dim=1, template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1>> typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct InfiniteSinusoid : struct InfiniteSinusoid :
public AbstractCurve<Numeric, Point> public AbstractCurve<Numeric, Point>
{ {
typedef Point point_t; typedef Point point_t;
typedef Numeric time_t; typedef Numeric time_t;
typedef Numeric num_t; typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t; typedef AbstractCurve<Numeric, Point> curve_abc_t;
public: public:
///\brief Constructor ///\brief Constructor
InfiniteSinusoid(const time_t& traj_time_, InfiniteSinusoid(const time_t& traj_time_,
const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(), const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(),
const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero()) const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(-1,-1), : curve_abc_t(-1,-1),
traj_time(traj_time_), traj_time(traj_time_),
x_init(x_init_), x_init(x_init_),
x_final(x_final_) {} x_final(x_final_) {}
///\brief Destructor ///\brief Destructor
~InfiniteSinusoid(){} ~InfiniteSinusoid(){}
public: public:
virtual const point_t operator()(const time_t& t) const virtual const point_t operator()(const time_t& t) const
{ {
return x_init + 0.5*(x_final-x_init)*(1.0-cos(two_pi_f(t))); return x_init + 0.5*(x_final-x_init)*(1.0-cos(two_pi_f(t)));
} }
virtual const point_t derivate(const time_t& t, const std::size_t& order) const virtual const point_t derivate(const time_t& t, const std::size_t& order) const
{ {
if(order==1) if(order==1)
return (x_final-x_init)*0.5*two_pi_f(1)*sin(two_pi_f(t)); return (x_final-x_init)*0.5*two_pi_f(1)*sin(two_pi_f(t));
else if(order==2) else if(order==2)
return (x_final-x_init)*0.5*two_pi_f(1)*two_pi_f(1)*cos(two_pi_f(t)); return (x_final-x_init)*0.5*two_pi_f(1)*two_pi_f(1)*cos(two_pi_f(t));
else { else {
std::cerr<<"Higher order derivatives not supported"<<std::endl; std::cerr<<"Higher order derivatives not supported"<<std::endl;
return point_t::Zero(Dim); return point_t::Zero(Dim);
} }
} }
public: public:
virtual bool setInitialPoint(const point_t& x_init_) virtual bool setInitialPoint(const point_t& x_init_)
{ {
if(x_init_.size()!=x_init.size()) if(x_init_.size()!=x_init.size())
return false; return false;
x_init = x_init_; x_init = x_init_;
} }
virtual bool setInitialPoint(const double& x_init_) virtual bool setInitialPoint(const double& x_init_)
{ {
if(Dim!=1) if(Dim!=1)
return false; return false;
x_init[0] = x_init_; x_init[0] = x_init_;
return true; return true;
} }
virtual bool setFinalPoint(const Eigen::VectorXd& x_final_) virtual bool setFinalPoint(const Eigen::VectorXd& x_final_)