tsid 1.9.0
Efficient Task Space Inverse Dynamics for Multi-body Systems based on Pinocchio
Loading...
Searching...
No Matches
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
28namespace tsid {
29namespace trajectories {
30
31typedef Eigen::Map<const Eigen::Matrix<double, 3, 3>> MapMatrix3;
32
34 public:
35 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
36
37 // TODO rename pos, vel, acc → value, derivative, second_derivative
38 TSID_DEPRECATED math::Vector pos, vel, acc;
39
42 // getters / setters with updated names for math::Vector
43 const math::Vector& getValue() const { return pos; }
44 const math::Vector& getDerivative() const { return vel; }
45 const math::Vector& getSecondDerivative() const { return acc; }
46 void setValue(const math::Vector& value) { pos = value; }
47 void setDerivative(const math::Vector& derivative) { vel = derivative; }
48 void setSecondDerivative(const math::Vector& second_derivative) {
49 acc = second_derivative;
50 }
51
52 TrajectorySample(unsigned int size = 0) { resize(size); }
53
54 TrajectorySample(unsigned int size_value, unsigned int size_derivative) {
55 resize(size_value, size_derivative);
56 }
57
58 void resize(unsigned int size) { resize(size, size); }
59
60 void resize(unsigned int size_value, unsigned int size_derivative) {
61 pos.setZero(size_value);
62 vel.setZero(size_derivative);
63 acc.setZero(size_derivative);
64 }
65
66 // declare default constructors / destructors to disable the deprecation
67 // message for them. TODO: Remove this after the
68 // pos/vel/acc → value/derivative/second_derivative rename
69 ~TrajectorySample() = default;
72};
73
75 public:
76 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
77
78 TrajectoryBase(const std::string& name) : m_name(name) {}
79
80 virtual ~TrajectoryBase() = default;
81
82 virtual unsigned int size() const = 0;
83
84 virtual const TrajectorySample& operator()(double time) = 0;
85
86 virtual const TrajectorySample& computeNext() = 0;
87
88 virtual const TrajectorySample& getLastSample() const { return m_sample; }
89
90 virtual void getLastSample(TrajectorySample& sample) const = 0;
91
92 virtual bool has_trajectory_ended() const = 0;
93
94 protected:
95 std::string m_name;
97};
98} // namespace trajectories
99} // namespace tsid
100
101#endif // ifndef __invdyn_trajectory_base_hpp__
TrajectorySample m_sample
Definition trajectory-base.hpp:96
virtual void getLastSample(TrajectorySample &sample) const =0
virtual const TrajectorySample & computeNext()=0
virtual const TrajectorySample & getLastSample() const
Definition trajectory-base.hpp:88
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TrajectoryBase(const std::string &name)
Definition trajectory-base.hpp:78
virtual const TrajectorySample & operator()(double time)=0
virtual bool has_trajectory_ended() const =0
virtual unsigned int size() const =0
std::string m_name
Definition trajectory-base.hpp:95
Definition trajectory-base.hpp:33
TSID_DISABLE_WARNING_PUSH TSID_DISABLE_WARNING_DEPRECATED const math::Vector & getValue() const
Definition trajectory-base.hpp:43
TrajectorySample(unsigned int size_value, unsigned int size_derivative)
Definition trajectory-base.hpp:54
void resize(unsigned int size_value, unsigned int size_derivative)
Definition trajectory-base.hpp:60
TrajectorySample(const TrajectorySample &)=default
TrajectorySample(unsigned int size=0)
Definition trajectory-base.hpp:52
void setSecondDerivative(const math::Vector &second_derivative)
Definition trajectory-base.hpp:48
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TSID_DEPRECATED math::Vector vel
Definition trajectory-base.hpp:38
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TSID_DEPRECATED math::Vector acc
Definition trajectory-base.hpp:38
const math::Vector & getSecondDerivative() const
Definition trajectory-base.hpp:45
void setDerivative(const math::Vector &derivative)
Definition trajectory-base.hpp:47
const math::Vector & getDerivative() const
Definition trajectory-base.hpp:44
void resize(unsigned int size)
Definition trajectory-base.hpp:58
void setValue(const math::Vector &value)
Definition trajectory-base.hpp:46
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TSID_DEPRECATED math::Vector pos
Definition trajectory-base.hpp:38
#define TSID_DISABLE_WARNING_PUSH
Definition macros.hpp:27
#define TSID_DISABLE_WARNING_DEPRECATED
Definition macros.hpp:29
#define TSID_DISABLE_WARNING_POP
Definition macros.hpp:28
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition fwd.hpp:22
Definition fwd.hpp:22
Eigen::Map< const Eigen::Matrix< double, 3, 3 > > MapMatrix3
Definition trajectory-base.hpp:31
Definition constraint-bound.hpp:25