- 3.0.2 core module.
ScalarTrajectory.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
9 
10 namespace ct {
11 namespace core {
12 
13 
15 
18 template <class SCALAR = double, class TIME_SCALAR = double>
19 class ScalarTrajectory : public DiscreteTrajectoryBase<SCALAR, Eigen::aligned_allocator<SCALAR>, TIME_SCALAR>
20 {
21 public:
22  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
23 
26 
28 
33  ScalarTrajectory(size_t n, const SCALAR& value = SCALAR()) : DiscreteTrajectoryBase<SCALAR>(n, value){};
34 
37 
39  ScalarTrajectory(const std::vector<SCALAR>& arg) : DiscreteTrajectoryBase<SCALAR>()
40  {
41  for (size_t i = 0; i < arg.size(); i++)
42  this->push_back(arg[i]);
43  }
44 
46  virtual ~ScalarTrajectory() {}
48  std::vector<Eigen::Matrix<SCALAR, 1, 1>, Eigen::aligned_allocator<Eigen::Matrix<SCALAR, 1, 1>>> toEigenTrajectory()
49  {
50  std::vector<Eigen::Matrix<SCALAR, 1, 1>, Eigen::aligned_allocator<Eigen::Matrix<SCALAR, 1, 1>>> eigenTraj;
51  for (size_t i = 0; i < this->size(); i++)
52  {
53  Eigen::Matrix<SCALAR, 1, 1> newElement;
54  newElement(0, 0) = (*this)[i];
55  eigenTraj.push_back(newElement);
56  }
57  return eigenTraj;
58  }
59 
60 private:
61 };
62 }
63 }
Specialized type of a discrete trajectory for scalar types.
Definition: ScalarTrajectory.h:19
size_t size() const
returns the size of the trajectory
Definition: DiscreteTrajectoryBase.h:146
virtual ~ScalarTrajectory()
destructor
Definition: ScalarTrajectory.h:46
std::vector< Eigen::Matrix< SCALAR, 1, 1 >, Eigen::aligned_allocator< Eigen::Matrix< SCALAR, 1, 1 > > > toEigenTrajectory()
convert to an Eigen trajectory
Definition: ScalarTrajectory.h:48
CppAD::AD< CppAD::cg::CG< double > > SCALAR
A discrete, timed trajectory with interpolation.
Definition: DiscreteTrajectoryBase.h:31
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
for i
ScalarTrajectory(size_t n, const SCALAR &value=SCALAR())
resize constructor
Definition: ScalarTrajectory.h:33
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ScalarTrajectory()
default constructor
Definition: ScalarTrajectory.h:25
void push_back(const SCALAR &data, const TIME_SCALAR &time, const bool timeIsAbsolute)
Add a data and time point at the end.
Definition: DiscreteTrajectoryBase.h:181
ScalarTrajectory(const ScalarTrajectory &other)
copy constructor
Definition: ScalarTrajectory.h:36
ScalarTrajectory(const std::vector< SCALAR > &arg)
constructor from std::vector
Definition: ScalarTrajectory.h:39