trajectory-base.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2021 CNRS
3 //
4 // This file is part of tsid
5 // tsid is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 // tsid is distributed in the hope that it will be
10 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Lesser Public License for more details. You should have
13 // received a copy of the GNU Lesser General Public License along with
14 // tsid If not, see
15 // <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef __invdyn_trajectory_base_hpp__
19 #define __invdyn_trajectory_base_hpp__
20 
21 #include "tsid/deprecated.hh"
22 #include "tsid/macros.hpp"
23 #include "tsid/math/fwd.hpp"
24 #include "tsid/math/utils.hpp"
25 
26 #include <string>
27 
28 namespace tsid
29 {
30  namespace trajectories
31  {
32 
33  typedef Eigen::Map<const Eigen::Matrix<double, 3, 3>> MapMatrix3;
34 
36  {
37  public:
38  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
39 
40  // TODO rename pos, vel, acc → value, derivative, second_derivative
41  TSID_DEPRECATED math::Vector pos, vel, acc;
42 
45  // getters / setters with updated names for math::Vector
46  const math::Vector & getValue() const { return pos; }
47  const math::Vector & getDerivative() const { return vel; }
48  const math::Vector & getSecondDerivative() const { return acc; }
49  void setValue(const math::Vector & value) { pos = value; }
50  void setDerivative(const math::Vector & derivative) { vel = derivative; }
51  void setSecondDerivative(const math::Vector & second_derivative) { acc = second_derivative; }
52 
53  TrajectorySample(unsigned int size=0)
54  {
55  resize(size);
56  }
57 
58  TrajectorySample(unsigned int size_value, unsigned int size_derivative)
59  {
60  resize(size_value, size_derivative);
61  }
62 
63  void resize(unsigned int size)
64  {
65  resize(size, size);
66  }
67 
68  void resize(unsigned int size_value, unsigned int size_derivative)
69  {
70  pos.setZero(size_value);
71  vel.setZero(size_derivative);
72  acc.setZero(size_derivative);
73  }
74 
75  // declare default constructors / destructors to disable the deprecation
76  // message for them. TODO: Remove this after the
77  // pos/vel/acc → value/derivative/second_derivative rename
78  ~TrajectorySample() = default;
79  TrajectorySample(const TrajectorySample&) = default;
81  };
82 
83 
85  {
86  public:
87  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
88 
89  TrajectoryBase(const std::string & name):
90  m_name(name){}
91 
92  virtual unsigned int size() const = 0;
93 
94  virtual const TrajectorySample & operator()(double time) = 0;
95 
96  virtual const TrajectorySample & computeNext() = 0;
97 
98  virtual const TrajectorySample & getLastSample() const { return m_sample; }
99 
100  virtual void getLastSample(TrajectorySample & sample) const = 0;
101 
102  virtual bool has_trajectory_ended() const = 0;
103 
104  protected:
105  std::string m_name;
107  };
108  }
109 }
110 
111 #endif // ifndef __invdyn_trajectory_base_hpp__
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TrajectoryBase(const std::string &name)
Definition: trajectory-base.hpp:89
#define TSID_DISABLE_WARNING_POP
Definition: macros.hpp:23
void resize(unsigned int size)
Definition: trajectory-base.hpp:63
TrajectorySample m_sample
Definition: trajectory-base.hpp:106
#define TSID_DISABLE_WARNING_PUSH
Definition: macros.hpp:22
const math::Vector & getDerivative() const
Definition: trajectory-base.hpp:47
#define TSID_DISABLE_WARNING_DEPRECATED
Definition: macros.hpp:24
void setDerivative(const math::Vector &derivative)
Definition: trajectory-base.hpp:50
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TSID_DEPRECATED math::Vector pos
Definition: trajectory-base.hpp:41
TrajectorySample(unsigned int size=0)
Definition: trajectory-base.hpp:53
void setSecondDerivative(const math::Vector &second_derivative)
Definition: trajectory-base.hpp:51
void resize(unsigned int size_value, unsigned int size_derivative)
Definition: trajectory-base.hpp:68
Definition: trajectory-base.hpp:35
TSID_DISABLE_WARNING_PUSH TSID_DISABLE_WARNING_DEPRECATED const math::Vector & getValue() const
Definition: trajectory-base.hpp:46
Eigen::Map< const Eigen::Matrix< double, 3, 3 > > MapMatrix3
Definition: trajectory-base.hpp:33
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: fwd.hpp:37
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TSID_DEPRECATED math::Vector acc
Definition: trajectory-base.hpp:41
const math::Vector & getSecondDerivative() const
Definition: trajectory-base.hpp:48
void setValue(const math::Vector &value)
Definition: trajectory-base.hpp:49
std::string m_name
Definition: trajectory-base.hpp:105
Definition: constraint-bound.hpp:26
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TSID_DEPRECATED math::Vector vel
Definition: trajectory-base.hpp:41
virtual const TrajectorySample & getLastSample() const
Definition: trajectory-base.hpp:98
TrajectorySample(unsigned int size_value, unsigned int size_derivative)
Definition: trajectory-base.hpp:58
Definition: trajectory-base.hpp:84