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"]
path = cmake
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
* \brief Generates InfiniteSinusoidal trajectory
* \author Rohan Budhiraja
* \date 2017
*
*/
#ifndef _parameteric_curves_constant_hpp
#define _parameteric_curves_constant_hpp
#include <parametric-curves/abstract-curve.hpp>
namespace parametriccurves
{
/// \class InfiniteSinusoid
/// \brief Creates InfiniteSinusoid curve
/// 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)
template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1>>
struct Constant :
public AbstractCurve<Numeric, Point>
{
typedef Point point_t;
typedef Numeric time_t;
typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t;
public:
///\brief Constructor
Constant(const time_t& traj_time, const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(0,traj_time),
x_init(x_init_) {}
///\brief Destructor
~Constant(){}
public:
virtual const point_t operator()(const time_t& t) const
{
return x_init;
}
virtual const point_t derivate(const time_t& t, const std::size_t& order) const
{
return point_t::Zero();
}
virtual bool setInitialPoint(const point_t& x_init_)
{
if(x_init.size()!=x_init_.size())
return false;
x_init = x_init_;
}
virtual bool setInitialPoint(const double& x_init_)
{
if(Dim!=1)
return false;
x_init[0] = x_init_;
return true;
}
protected:
/*Attributes*/
point_t x_init;
};
}
#endif //_CLASS_EXACTCUBIC
/**
* \file sinusoid.hpp
* \brief Generates InfiniteSinusoidal trajectory
* \author Rohan Budhiraja
* \date 2017
*
*/
#ifndef _parameteric_curves_constant_hpp
#define _parameteric_curves_constant_hpp
#include <parametric-curves/abstract-curve.hpp>
namespace parametriccurves
{
/// \class InfiniteSinusoid
/// \brief Creates InfiniteSinusoid curve
/// 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)
template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct Constant :
public AbstractCurve<Numeric, Point>
{
typedef Point point_t;
typedef Numeric time_t;
typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t;
public:
///\brief Constructor
Constant(const time_t& traj_time, const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(0,traj_time),
x_init(x_init_) {}
///\brief Destructor
~Constant(){}
public:
virtual const point_t operator()(const time_t& t) const
{
return x_init;
}
virtual const point_t derivate(const time_t& t, const std::size_t& order) const
{
return point_t::Zero();
}
virtual bool setInitialPoint(const point_t& x_init_)
{
if(x_init.size()!=x_init_.size())
return false;
x_init = x_init_;
}
virtual bool setInitialPoint(const double& x_init_)
{
if(Dim!=1)
return false;
x_init[0] = x_init_;
return true;
}
protected:
/*Attributes*/
point_t x_init;
};
}
#endif //_CLASS_EXACTCUBIC
/**
* \file constant-acceleration.hpp
* \brief Generates InfiniteConstAcc trajectory
* \author Rohan Budhiraja
* \date 2017
*
*/
#ifndef _parameteric_curves_infinite_constant_acceleration_hpp
#define _parameteric_curves_infinite_constant_acceleration_hpp
#include <parametric-curves/abstract-curve.hpp>
#include <cmath>
namespace parametriccurves
{
/// \class InfiniteConstAcc
/// \brief Creates InfiniteConstAcc curve
/// s = s_0 + u_0*t+0.5*a_0*t^2
template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1>>
struct InfiniteConstAcc :
public AbstractCurve<Numeric, Point>
{
typedef Point point_t;
typedef Numeric time_t;
typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t;
public:
///\brief Constructor
InfiniteConstAcc(const time_t& traj_time_,
const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(),
const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(-1,-1),
traj_time(traj_time_),
x_init(x_init_),
x_final(x_final_) {}
///\brief Destructor
~InfiniteConstAcc(){}
public:
virtual const point_t operator()(const time_t& t_) const
{
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);
if(t<=0.5*traj_time)
return x_init + 0.5*m_ddx0*t*t;
else if(t>0.5*traj_time && t<=1.5*traj_time)
return (x_init+x_final)/2
+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);
else //(t>1.5*traj_time && t<=2*traj_time)
return (x_init+x_final)/2
- 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);
}
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 point_t& m_ddx0 = 4.0*(x_final-x_init)/(traj_time*traj_time);
if(order==1) {
if(t<=0.5*traj_time)
return m_ddx0*t;
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);
else //(t>1.5*traj_time && t<=2*traj_time)
return -0.5*m_ddx0*traj_time + m_ddx0*(t-1.5*traj_time);
}
else if(order==2) {
if(t<=0.5*traj_time)
return m_ddx0;
else if(t>0.5*traj_time && t<=1.5*traj_time)
return -m_ddx0;
else //(t>1.5*traj_time && t<=2*traj_time)
return m_ddx0;
}
else {
std::cerr<<"Higher order derivatives not supported"<<std::endl;
return point_t::Zero(Dim);
}
}
public:
virtual bool setInitialPoint(const point_t& x_init_)
{
if(x_init_.size()!=x_init.size())
return false;
x_init = x_init_;
}
virtual bool setInitialPoint(const double& x_init_)
{
if(Dim!=1)
return false;
x_init[0] = x_init_;
return true;
}
virtual bool setFinalPoint(const Eigen::VectorXd& x_final_)
{
if(x_final.size()!=x_final_.size())
return false;
x_final = x_final_;
return true;
}
virtual bool setFinalPoint(const double& x_final_)
{
if(Dim!=1)
return false;
x_final[0] = x_final_;
return true;
}
virtual bool setTrajectoryTime(double traj_time_)
{
if(traj_time_<=0.0)
return false;
traj_time = traj_time_;
return true;
}
protected:
/*Attributes*/
point_t x_init;
point_t x_final;
time_t traj_time;
};
}
#endif //_CLASS_EXACTCUBIC
/**
* \file constant-acceleration.hpp
* \brief Generates InfiniteConstAcc trajectory
* \author Rohan Budhiraja
* \date 2017
*
*/
#ifndef _parameteric_curves_infinite_constant_acceleration_hpp
#define _parameteric_curves_infinite_constant_acceleration_hpp
#include <parametric-curves/abstract-curve.hpp>
#include <cmath>
namespace parametriccurves
{
/// \class InfiniteConstAcc
/// \brief Creates InfiniteConstAcc curve
/// s = s_0 + u_0*t+0.5*a_0*t^2
template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct InfiniteConstAcc :
public AbstractCurve<Numeric, Point>
{
typedef Point point_t;
typedef Numeric time_t;
typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t;
public:
///\brief Constructor
InfiniteConstAcc(const time_t& traj_time_,
const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(),
const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(-1,-1),
traj_time(traj_time_),
x_init(x_init_),
x_final(x_final_) {}
///\brief Destructor
~InfiniteConstAcc(){}
public:
virtual const point_t operator()(const time_t& t_) const
{
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);
if(t<=0.5*traj_time)
return x_init + 0.5*m_ddx0*t*t;
else if(t>0.5*traj_time && t<=1.5*traj_time)
return (x_init+x_final)/2
+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);
else //(t>1.5*traj_time && t<=2*traj_time)
return (x_init+x_final)/2
- 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);
}
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 point_t& m_ddx0 = 4.0*(x_final-x_init)/(traj_time*traj_time);
if(order==1) {
if(t<=0.5*traj_time)
return m_ddx0*t;
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);
else //(t>1.5*traj_time && t<=2*traj_time)
return -0.5*m_ddx0*traj_time + m_ddx0*(t-1.5*traj_time);
}
else if(order==2) {
if(t<=0.5*traj_time)
return m_ddx0;
else if(t>0.5*traj_time && t<=1.5*traj_time)
return -m_ddx0;
else //(t>1.5*traj_time && t<=2*traj_time)
return m_ddx0;
}
else {
std::cerr<<"Higher order derivatives not supported"<<std::endl;
return point_t::Zero(Dim);
}
}
public:
virtual bool setInitialPoint(const point_t& x_init_)
{
if(x_init_.size()!=x_init.size())
return false;
x_init = x_init_;
}
virtual bool setInitialPoint(const double& x_init_)
{
if(Dim!=1)
return false;
x_init[0] = x_init_;
return true;
}
virtual bool setFinalPoint(const Eigen::VectorXd& x_final_)
{
if(x_final.size()!=x_final_.size())
return false;
x_final = x_final_;
return true;
}
virtual bool setFinalPoint(const double& x_final_)
{
if(Dim!=1)
return false;
x_final[0] = x_final_;
return true;
}
virtual bool setTrajectoryTime(double traj_time_)
{
if(traj_time_<=0.0)
return false;
traj_time = traj_time_;
return true;
}
protected:
/*Attributes*/
point_t x_init;
point_t x_final;
time_t traj_time;
};
}
#endif //_CLASS_EXACTCUBIC
/**
* \file sinusoid.hpp
* \brief Generates InfiniteSinusoidal trajectory
* \author Rohan Budhiraja
* \date 2017
*
*/
#ifndef _parameteric_curves_sinusoid_hpp
#define _parameteric_curves_sinusoid_hpp
#include <parametric-curves/abstract-curve.hpp>
namespace parametriccurves
{
/// \class InfiniteSinusoid
/// \brief Creates InfiniteSinusoid curve
/// 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)
template<typename Numeric=double, std::size_t Dim=1,
typename Point= Eigen::Matrix<Numeric, Dim, 1>>
struct InfiniteSinusoid :
public AbstractCurve<Numeric, Point>
{
typedef Point point_t;
typedef Numeric time_t;
typedef Numeric num_t;
typedef AbstractCurve<Numeric, Point> curve_abc_t;
public:
///\brief Constructor
InfiniteSinusoid(const time_t& traj_time_,
const point_t& x_init_= Eigen::Matrix<Numeric, Dim, 1>::Zero(),
const point_t& x_final_= Eigen::Matrix<Numeric, Dim, 1>::Zero())
: curve_abc_t(-1,-1),
traj_time(traj_time_),
x_init(x_init_),
x_final(x_final_) {}
///\brief Destructor
~InfiniteSinusoid(){}
public:
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)));
}
virtual const point_t derivate(const time_t& t, const std::size_t& order) const
{
if(order==1)
return (x_final-x_init)*0.5*two_pi_f(1)*sin(two_pi_f(t));
else if(order==2)
return (x_final-x_init)*0.5*two_pi_f(1)*two_pi_f(1)*cos(two_pi_f(t));
else {
std::cerr<<"Higher order derivatives not supported"<<std::endl;
return point_t::Zero(Dim);
}
}
public:
virtual bool setInitialPoint(const point_t& x_init_)
{
if(x_init_.size()!=x_init.size())
return false;
x_init = x_init_;
}
virtual bool setInitialPoint(const double& x_init_)
{
if(Dim!=1)
return false;
x_init[0] = x_init_;
return true;
}
virtual bool setFinalPoint(const Eigen::VectorXd& x_final_)
{
if(x_final.size()!=x_final_.size())
return false;
x_final = x_final_;
return true;
}
virtual bool setFinalPoint(const double& x_final_)
{
if(Dim!=1)
return false;
x_final[0] = x_final_;
return true;
}
virtual bool setTrajectoryTime(double traj_time_)
{
if(traj_time_<=0.0)
return false;
traj_time = traj_time_;
return true;
}
protected:
/*Attributes*/
point_t x_init;
point_t x_final;
time_t traj_time;
private: