Trajectory.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarX
19  * @author Mirko Waechter( mirko.waechter at kit dot edu)
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include <boost/multi_index/hashed_index.hpp>
27 #include <boost/multi_index/member.hpp>
28 #include <boost/multi_index/ordered_index.hpp>
29 #include <boost/multi_index/random_access_index.hpp>
30 #include <boost/multi_index_container.hpp>
31 
32 #include <Eigen/Core>
33 
38 
39 #include <RobotAPI/interface/core/Trajectory.h>
40 
41 namespace armarx::VariantType
42 {
43  // Variant types
44  const VariantTypeId Trajectory = Variant::addTypeName("::armarx::TrajectoryBase");
45 } // namespace armarx::VariantType
46 
47 namespace armarx
48 {
49  using DoubleSeqPtr = std::shared_ptr<Ice::DoubleSeq>;
50 
51  class Trajectory;
53 
54  /**
55  * @class Trajectory
56  * @brief The Trajectory class represents n-dimensional sampled trajectories.
57  * @ingroup VariantsGrp
58  *
59  * The class interpolates all missing values with linear interpolation and calculates derivations.
60  * This means trajectories with different timestamps can easily be used.
61  * Velocities or accelerations can easily be queried with the *derivation* parameters of many functions.
62  * Access complexity for a query with a timestamp is like from an unordered_map.
63  *
64  * \image html tut-img-traj-1.svg "Internal structure of the Trajectory class"
65  *
66  * Basic usage:
67  * @snippet RobotAPI/libraries/core/test/TrajectoryTest.cpp TrajectoryDocumentation BasicUsage
68  *
69  * The trajectory offers normal iterator capabilities:
70  * @snippet RobotAPI/libraries/core/test/TrajectoryTest.cpp TrajectoryDocumentation IteratorUsage
71  * @note Only const iterators are currently available.
72  *
73  * With the iterators it can be used like a std container:
74  * @snippet RobotAPI/libraries/core/test/TrajectoryTest.cpp TrajectoryDocumentation CopyIf
75  */
76  class Trajectory : public TrajectoryBase
77  {
78  protected:
79  ~Trajectory() override;
80 
81  public:
82  using TrajMap = std::map<double, std::vector<DoubleSeqPtr>>;
83 
84  struct TrajData
85  {
87  {
88  }
89 
90  TrajData(Trajectory* traj);
91  DoubleSeqPtr operator[](size_t dim) const;
92 
93  inline TrajData&
95  {
96  timestamp = s.timestamp;
97  data.resize(s.data.size());
98  int i = 0;
99  for (auto& elem : s.data)
100  {
101  data[i++].reset(new Ice::DoubleSeq(*elem));
102  }
103  trajectory = nullptr;
104  return *this;
105  }
106 
107  double getTimestamp() const;
108  double getPosition(size_t dim) const;
109 
110  template <class T = double>
111  std::vector<T>
113  {
114  if (!trajectory)
115  {
116  throw LocalException("Ptr to trajectory is NULL");
117  }
118  auto numDim = trajectory->dim();
119  std::vector<T> result;
120  result.reserve(numDim);
121  for (std::size_t i = 0; i < numDim; ++i)
122  {
123  result.emplace_back(getPosition(i));
124  }
125  return result;
126  }
127 
128  std::vector<double>
129  getPositions() const
130  {
131  return getPositionsAs<double>();
132  }
133 
134  Eigen::VectorXf getPositionsAsVectorXf() const;
135  Eigen::VectorXd getPositionsAsVectorXd() const;
136 
137  template <class T>
138  void
139  writePositionsToNameValueMap(std::map<std::string, T>& map) const
140  {
141  if (!trajectory)
142  {
143  throw LocalException("Ptr to trajectory is NULL");
144  }
145  auto numDim = trajectory->dim();
146  for (std::size_t i = 0; i < numDim; ++i)
147  {
149  }
150  }
151 
152  template <class T>
153  std::map<std::string, T>
155  {
156  std::map<std::string, T> result;
158  return result;
159  }
160 
161  double getDeriv(size_t dim, size_t derivation) const;
162  const std::vector<DoubleSeqPtr>& getData() const;
163 
164  friend std::ostream&
165  operator<<(std::ostream& stream, const TrajData& rhs)
166  {
167  stream << rhs.timestamp << ": ";
168  for (size_t d = 0; d < rhs.data.size(); ++d)
169  {
170  stream << (rhs.data[d] && rhs.data[d]->size() > 0
171  ? to_string(rhs.data[d]->at(0))
172  : std::string("-"));
173  if (d <= rhs.data.size() - 1)
174  {
175  stream << ", ";
176  }
177  }
178  return stream;
179  }
180 
181  double timestamp;
182  mutable std::vector<DoubleSeqPtr> data; // mutable so that it can be changed
183  protected:
184  Trajectory* trajectory = nullptr;
185  // friend class Trajectory;
186  };
187 
188  // structs for indices
190  {
191  };
192 
193  struct TagOrdered
194  {
195  };
196 
197  // Trajectory data container
198  typedef boost::multi_index::multi_index_container<
199  TrajData,
200  boost::multi_index::indexed_by<
201  boost::multi_index::hashed_unique<
202  boost::multi_index::tag<TagTimestamp>,
203  boost::multi_index::member<TrajData, double, &TrajData::timestamp>>,
204  boost::multi_index::ordered_unique<
205  boost::multi_index::tag<TagOrdered>,
206  boost::multi_index::member<
207  TrajData,
208  double,
209  &TrajData::timestamp>> // this index represents timestamp incremental order
210  >>
212  using timestamp_view =
213  typename boost::multi_index::index<TrajDataContainer, TagTimestamp>::type;
214  using ordered_view =
215  typename boost::multi_index::index<TrajDataContainer, TagOrdered>::type;
216 
218  {
219  }
220 
221  Trajectory(const Trajectory& source);
222 
223  template <typename T>
224  Trajectory(const std::vector<T>& data,
225  const Ice::DoubleSeq timestamps = Ice::DoubleSeq(),
226  const std::string& dimensionName = "",
227  typename std::enable_if_t<std::is_arithmetic_v<T>>* t = 0)
228  {
229  if (data.size() == 0)
230  {
231  return;
232  }
233  Ice::DoubleSeq dvec(data.begin(), data.end());
234  addDimension(dvec, timestamps, dimensionName);
235  }
236 
237  /**
238  * Constructor to add n-dimensions with m-values.
239  * @param data data vector (size n) with positions (size m). Dimension 1 is the joint dimension and Dimension 2 is the position of that joint.
240  * @param timestamps timestamps of the trajectory. If not empty, need to be of same size as the inner values of data.
241  * If empty, timestamps from 0..1 are generated with a stepsize aligned with the size of the inner vector of data.
242  *
243  */
244  template <typename T>
245  Trajectory(const std::vector<std::vector<T>>& data,
246  const Ice::DoubleSeq timestamps = Ice::DoubleSeq(),
247  const Ice::StringSeq& dimensionNames = {})
248  {
249  if (data.size() == 0)
250  {
251  return;
252  }
253  const auto& tempTimestamps =
254  timestamps.size() > 0 ? timestamps : GenerateTimestamps(data.at(0));
255  size_t i = 0;
256  for (const auto& subvec : data)
257  {
258  Ice::DoubleSeq dvec(subvec.begin(), subvec.end());
259  addDimension(
260  dvec, tempTimestamps, i < dimensionNames.size() ? dimensionNames.at(i++) : "");
261  }
262  }
263 
264  template <typename T>
265  Trajectory(const std::vector<std::vector<std::vector<T>>>& data,
266  const Ice::DoubleSeq timestamps = Ice::DoubleSeq(),
267  const Ice::StringSeq& dimensionNames = {})
268  {
269  this->dataVec = data;
270  this->timestamps = timestamps;
271  this->dimensionNames = dimensionNames;
272 
274  }
275 
276  Trajectory(const std::map<double, Ice::DoubleSeq>& data);
277 
278 
280 
281  // Basic Manipulators
282  size_t addDimension(const Ice::DoubleSeq& values,
283  const Ice::DoubleSeq& timestamps = Ice::DoubleSeq(),
284  const std::string name = "");
285  void addPositionsToDimension(size_t dimension,
286  const Ice::DoubleSeq& values,
287  const Ice::DoubleSeq& timestamps);
288  void
289  addDerivationsToDimension(size_t dimension, const double t, const Ice::DoubleSeq& derivs);
290  Trajectory& operator+=(const Trajectory traj);
291  void removeDimension(size_t dimension);
292  void removeDerivation(size_t derivation);
293  void removeDerivation(size_t dimension, size_t derivation);
294 
295  // iterators
296  /**
297  * @brief Iterators that iterates in incremental order of the timestamps through the trajectory.
298  * @note Only const versions are available currently.
299  * @see end(), rbegin(), rend()
300  */
301  typename ordered_view::const_iterator begin() const;
302  typename ordered_view::const_iterator end() const;
303  typename ordered_view::const_reverse_iterator rbegin() const;
304  typename ordered_view::const_reverse_iterator rend() const;
305 
306  ///// getters
307  std::vector<DoubleSeqPtr>& operator[](double timestamp);
308  Ice::DoubleSeq getTimestamps() const;
309  Ice::FloatSeq getTimestampsFloat() const;
310  std::vector<DoubleSeqPtr>& getStates(double t);
311  std::vector<DoubleSeqPtr> getStates(double t) const;
312  Ice::DoubleSeq getStates(double t, size_t derivation) const;
313 
314  template <typename T>
315  std::map<std::string, T>
316  getStatesMap(double t, size_t derivation = 0) const
317  {
318  std::map<std::string, T> result;
319  size_t dimensions = dim();
320 
321  for (size_t dim = 0; dim < dimensions; dim++)
322  {
323  result[getDimensionName(dim)] = getState(t, dim, derivation);
324  }
325 
326  return result;
327  }
328 
329  double getState(double t, size_t dim = 0, size_t derivation = 0);
330  double getState(double t, size_t dim = 0, size_t derivation = 0) const;
331  std::vector<Ice::DoubleSeq> getAllStates(double t, int maxDeriv = 1);
332  Ice::DoubleSeq getDerivations(double t, size_t dimension, size_t derivations) const;
333  std::string getDimensionName(size_t dim) const;
334  const Ice::StringSeq& getDimensionNames() const;
335 
337 
338  /**
339  * @brief getDimensionData gets all entries for one dimensions with order of increasing timestamps
340  * @param dimension
341  * @param derivation
342  * @return
343  */
344  Ice::DoubleSeq getDimensionData(size_t dimension, size_t derivation = 0) const;
345  Eigen::VectorXd getDimensionDataAsEigen(size_t dimension, size_t derivation) const;
346  Eigen::VectorXd getDimensionDataAsEigen(size_t dimension,
347  size_t derivation,
348  double startTime,
349  double endTime) const;
350  Eigen::MatrixXd toEigen(size_t derivation, double startTime, double endTime) const;
351  Eigen::MatrixXd toEigen(size_t derivation = 0) const;
353  getPart(double startTime, double endTime, size_t numberOfDerivations = 0) const;
354  /**
355  * @brief dim returns the trajectory dimension count for this trajectory (e.g. taskspace w/o orientation would be 3)
356  * @return
357  */
358  size_t dim() const;
359 
360  /**
361  * @brief Returns number of data entries (i.e. positions) in the trajectory.
362  */
363  size_t size() const;
364 
365  /**
366  * @brief Difference between biggest and smallest timestamp. If size() <=1 -> return 0.
367  */
368  double getTimeLength() const;
369 
370  /**
371  * @brief Returns the sum of a all subsequent distances of the entries in the trajectories over all dimensions
372  * @param derivation Derivation for which the length is calculated
373  */
374  double getLength(size_t derivation = 0) const;
375  double getLength(size_t derivation, double startTime, double endTime) const;
376  double getLength(size_t dimension, size_t derivation) const;
377  double
378  getLength(size_t dimension, size_t derivation, double startTime, double endTime) const;
379  double getSquaredLength(size_t dimension, size_t derivation) const;
380  double getSquaredLength(size_t dimension,
381  size_t derivation,
382  double startTime,
383  double endTime) const;
384  double getMax(size_t dimension, size_t derivation, double startTime, double endTime) const;
385  double getMin(size_t dimension, size_t derivation, double startTime, double endTime) const;
386  double getWithFunc(const double& (*foo)(const double&, const double&),
387  double initValue,
388  size_t dimension,
389  size_t derivation,
390  double startTime,
391  double endTime) const;
392  double
393  getAmplitude(size_t dimension, size_t derivation, double startTime, double endTime) const;
394 
395  /**
396  * @brief Calculate *all* minima.
397  * @param dimension
398  * @param derivation
399  * @param startTime
400  * @param endTime
401  * @return
402  */
403  Ice::DoubleSeq
404  getMinima(size_t dimension, size_t derivation, double startTime, double endTime) const;
405  Ice::DoubleSeq
406  getMaxima(size_t dimension, size_t derivation, double startTime, double endTime) const;
407  Ice::DoubleSeq getMinimaTimestamps(size_t dimension,
408  size_t derivation,
409  double startTime,
410  double endTime) const;
411  Ice::DoubleSeq getMaximaTimestamps(size_t dimension,
412  size_t derivation,
413  double startTime,
414  double endTime) const;
415 
416  // calculations
417 
418  Ice::DoubleSeq getDiscreteDifferentiationForDim(size_t trajDimension,
419  size_t derivation) const;
420  static Ice::DoubleSeq DifferentiateDiscretly(const Ice::DoubleSeq& timestamps,
421  const Ice::DoubleSeq& values,
422  int derivationCount = 1);
423  double
424  getDiscretDifferentiationForDimAtT(double t, size_t trajDimension, size_t derivation) const;
425 
426  void differentiateDiscretlyForDim(size_t trajDimension, size_t derivation);
427  void differentiateDiscretly(size_t derivation);
428  void reconstructFromDerivativeForDim(double valueAtFirstTimestamp,
429  size_t trajDimension,
430  size_t sourceDimOfSystemState,
431  size_t targetDimOfSystemState);
432 
433  /**
434  * @brief negateDim changes the sign of all values of the given dimension.
435  */
436  void negateDim(size_t trajDimension);
437 
438  /**
439  * @brief gaussianFilter smoothes the trajectory
440  * @param filterRadius, in easy words: time range to left and right from center that
441  * influences the resulting center value
442  */
443  void gaussianFilter(double filterRadius);
444 
445  static Trajectory NormalizeTimestamps(const Trajectory& traj,
446  const double startTime = 0.0,
447  const double endTime = 1.0);
448  TrajectoryPtr normalize(const double startTime = 0.0, const double endTime = 1.0);
450  double maxAcceleration,
451  double maxDeviation,
452  IceUtil::Time const& timestep);
453  TrajectoryPtr calculateTimeOptimalTrajectory(const Eigen::VectorXd& maxVelocities,
454  const Eigen::VectorXd& maxAccelerations,
455  double maxDeviation,
456  IceUtil::Time const& timestep);
457  static Ice::DoubleSeq NormalizeTimestamps(const Ice::DoubleSeq& timestamps,
458  const double startTime = 0.0,
459  const double endTime = 1.0);
460  static Ice::DoubleSeq
461  GenerateTimestamps(double startTime = 0.0, double endTime = 1.0, double stepSize = 0.001);
462 
463  template <typename T>
464  static Ice::DoubleSeq
465  GenerateTimestamps(const std::vector<T>& values)
466  {
467  return GenerateTimestamps(0, 1, 1.0 / (values.size() - 1));
468  }
469 
470  void shiftTime(double shift);
471  void shiftValue(const Ice::DoubleSeq& shift);
472  void scaleValue(const Ice::DoubleSeq& factor);
473 
474 
475  static void CopyData(const Trajectory& source, Trajectory& destination);
476  static void CopyMetaData(const Trajectory& source, Trajectory& destination);
477 
478  void clear(bool keepMetaData = false);
479  void setPositionEntry(const double t, const size_t dimIndex, const double& y);
480  void setEntries(const double t, const size_t dimIndex, const Ice::DoubleSeq& y);
481  bool dataExists(double t, size_t dimension = 0, size_t derivation = 0) const;
482 
483 
484  std::map<double, Ice::DoubleSeq>
485  getStatesAround(double t, size_t derivation, size_t extend) const;
486 
487 
488  // Object interface
489  void ice_preMarshal() override;
490  void ice_postUnmarshal() override;
491 
492  // Serializable interface
493  void serialize(const ObjectSerializerBasePtr& obj,
494  const Ice::Current& = Ice::emptyCurrent) const override;
495  void deserialize(const ObjectSerializerBasePtr&,
496  const Ice::Current& = Ice::emptyCurrent) override;
497 
498  // VariantDataClass interface
499  VariantDataClassPtr clone(const Ice::Current& c = Ice::emptyCurrent) const override;
501  std::string output(const Ice::Current& c = Ice::emptyCurrent) const override;
502  Ice::Int getType(const Ice::Current& c = Ice::emptyCurrent) const override;
503  bool validate(const Ice::Current& c = Ice::emptyCurrent) override;
504 
505  Ice::ObjectPtr ice_clone() const override;
506 
507  void
508  setDimensionNames(const Ice::StringSeq dimNames)
509  {
510  dimensionNames = dimNames;
511  }
512 
513  void setLimitless(const LimitlessStateSeq& limitlessStates);
514  LimitlessStateSeq getLimitless() const;
515 
516  protected:
517  void __addDimension();
518  void __fillAllEmptyFields();
519  double __interpolate(typename ordered_view::const_iterator itMap,
520  size_t dimension,
521  size_t derivation) const;
522  double __gaussianFilter(double filterRadius,
523  typename ordered_view::iterator centerIt,
524  size_t trajNum,
525  size_t dim);
526  timestamp_view::iterator __fillBaseDataAtTimestamp(const double& t);
527  std::vector<DoubleSeqPtr> __calcBaseDataAtTimestamp(const double& t) const;
528 
529 
531 
532  virtual double __interpolate(double t,
533  ordered_view::const_iterator itPrev,
534  ordered_view::const_iterator itNext,
535  size_t dimension,
536  size_t derivation) const;
537  double __interpolate(double t, size_t dimension, size_t derivation) const;
538  };
539 
540 } // namespace armarx
armarx::Trajectory::clone
VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: Trajectory.cpp:138
armarx::Trajectory::TrajData::getTimestamp
double getTimestamp() const
Definition: Trajectory.cpp:2085
armarx::Trajectory::cloneMetaData
TrajectoryPtr cloneMetaData() const
Definition: Trajectory.cpp:144
armarx::Trajectory::CopyMetaData
static void CopyMetaData(const Trajectory &source, Trajectory &destination)
Definition: Trajectory.cpp:1735
armarx::Trajectory::getMinimaTimestamps
Ice::DoubleSeq getMinimaTimestamps(size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:784
armarx::Trajectory::getMin
double getMin(size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:700
armarx::Trajectory::gaussianFilter
void gaussianFilter(double filterRadius)
gaussianFilter smoothes the trajectory
Definition: Trajectory.cpp:1642
armarx::Trajectory::scaleValue
void scaleValue(const Ice::DoubleSeq &factor)
Definition: Trajectory.cpp:2186
armarx::Trajectory::TrajData::getPositionsAsVectorXd
Eigen::VectorXd getPositionsAsVectorXd() const
Definition: Trajectory.cpp:2113
armarx::Trajectory::getSquaredLength
double getSquaredLength(size_t dimension, size_t derivation) const
Definition: Trajectory.cpp:656
armarx::Trajectory::addDerivationsToDimension
void addDerivationsToDimension(size_t dimension, const double t, const Ice::DoubleSeq &derivs)
Definition: Trajectory.cpp:2066
armarx::Trajectory::normalize
TrajectoryPtr normalize(const double startTime=0.0, const double endTime=1.0)
Definition: Trajectory.cpp:1830
armarx::Trajectory::TrajData::operator<<
friend std::ostream & operator<<(std::ostream &stream, const TrajData &rhs)
Definition: Trajectory.h:165
armarx::Trajectory::getAllStates
std::vector< Ice::DoubleSeq > getAllStates(double t, int maxDeriv=1)
Definition: Trajectory.cpp:333
armarx::Trajectory::setLimitless
void setLimitless(const LimitlessStateSeq &limitlessStates)
Definition: Trajectory.cpp:2208
armarx::Trajectory::TrajData::getPositionsAsNameValueMap
std::map< std::string, T > getPositionsAsNameValueMap() const
Definition: Trajectory.h:154
armarx::Trajectory::TrajData::TrajData
TrajData()
Definition: Trajectory.h:86
armarx::Trajectory::negateDim
void negateDim(size_t trajDimension)
negateDim changes the sign of all values of the given dimension.
Definition: Trajectory.cpp:1509
armarx::Trajectory::clear
void clear(bool keepMetaData=false)
Definition: Trajectory.cpp:1743
armarx::Trajectory::timestamp_view
typename boost::multi_index::index< TrajDataContainer, TagTimestamp >::type timestamp_view
Definition: Trajectory.h:213
armarx::Trajectory::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: Trajectory.cpp:185
armarx::Trajectory::TrajData
Definition: Trajectory.h:84
armarx::Trajectory::data
TrajDataContainer & data()
Definition: Trajectory.cpp:384
armarx::Trajectory::TagOrdered
Definition: Trajectory.h:193
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::Trajectory::GenerateTimestamps
static Ice::DoubleSeq GenerateTimestamps(double startTime=0.0, double endTime=1.0, double stepSize=0.001)
Definition: Trajectory.cpp:1754
armarx::Trajectory::TrajData::data
std::vector< DoubleSeqPtr > data
Definition: Trajectory.h:182
armarx::Trajectory::TrajData::operator=
TrajData & operator=(const TrajData &s)
Definition: Trajectory.h:94
armarx::Trajectory::TagTimestamp
Definition: Trajectory.h:189
armarx::Trajectory::__fillAllEmptyFields
void __fillAllEmptyFields()
Definition: Trajectory.cpp:1150
armarx::Trajectory::getDiscreteDifferentiationForDim
Ice::DoubleSeq getDiscreteDifferentiationForDim(size_t trajDimension, size_t derivation) const
Definition: Trajectory.cpp:1201
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::Trajectory::getStatesAround
std::map< double, Ice::DoubleSeq > getStatesAround(double t, size_t derivation, size_t extend) const
Definition: Trajectory.cpp:1015
armarx::Trajectory::getState
double getState(double t, size_t dim=0, size_t derivation=0)
Definition: Trajectory.cpp:237
armarx::Trajectory::rbegin
ordered_view::const_reverse_iterator rbegin() const
Definition: Trajectory.cpp:2025
armarx::Trajectory::getDiscretDifferentiationForDimAtT
double getDiscretDifferentiationForDimAtT(double t, size_t trajDimension, size_t derivation) const
Definition: Trajectory.cpp:1296
armarx::Trajectory::addDimension
size_t addDimension(const Ice::DoubleSeq &values, const Ice::DoubleSeq &timestamps=Ice::DoubleSeq(), const std::string name="")
Definition: Trajectory.cpp:1933
armarx::Trajectory::end
ordered_view::const_iterator end() const
Definition: Trajectory.cpp:2019
armarx::Trajectory::operator[]
std::vector< DoubleSeqPtr > & operator[](double timestamp)
Definition: Trajectory.cpp:2037
armarx::Trajectory::~Trajectory
~Trajectory() override
armarx::Trajectory::getDimensionDataAsEigen
Eigen::VectorXd getDimensionDataAsEigen(size_t dimension, size_t derivation) const
Definition: Trajectory.cpp:416
armarx::Trajectory::getLength
double getLength(size_t derivation=0) const
Returns the sum of a all subsequent distances of the entries in the trajectories over all dimensions.
Definition: Trajectory.cpp:556
armarx::Trajectory::TrajData::getPositionsAs
std::vector< T > getPositionsAs() const
Definition: Trajectory.h:112
armarx::Trajectory::TrajData::writePositionsToNameValueMap
void writePositionsToNameValueMap(std::map< std::string, T > &map) const
Definition: Trajectory.h:139
armarx::Trajectory::rend
ordered_view::const_reverse_iterator rend() const
Definition: Trajectory.cpp:2031
StringHelpers.h
armarx::Trajectory::calculateTimeOptimalTrajectory
TrajectoryPtr calculateTimeOptimalTrajectory(double maxVelocity, double maxAcceleration, double maxDeviation, IceUtil::Time const &timestep)
Definition: Trajectory.cpp:1838
armarx::Trajectory::getType
Ice::Int getType(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: Trajectory.cpp:173
armarx::Trajectory::ice_preMarshal
void ice_preMarshal() override
Definition: Trajectory.cpp:44
armarx::Trajectory::getPart
TrajectoryPtr getPart(double startTime, double endTime, size_t numberOfDerivations=0) const
Definition: Trajectory.cpp:492
armarx::Trajectory::dataMap
TrajDataContainer dataMap
Definition: Trajectory.h:530
IceInternal::Handle< Trajectory >
armarx::Trajectory::getMax
double getMax(size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:689
armarx::Trajectory::shiftValue
void shiftValue(const Ice::DoubleSeq &shift)
Definition: Trajectory.cpp:2164
armarx::Trajectory::begin
ordered_view::const_iterator begin() const
Iterators that iterates in incremental order of the timestamps through the trajectory.
Definition: Trajectory.cpp:2013
armarx::Trajectory::removeDerivation
void removeDerivation(size_t derivation)
Definition: Trajectory.cpp:1978
armarx::Trajectory::reconstructFromDerivativeForDim
void reconstructFromDerivativeForDim(double valueAtFirstTimestamp, size_t trajDimension, size_t sourceDimOfSystemState, size_t targetDimOfSystemState)
Definition: Trajectory.cpp:1471
armarx::Trajectory::__gaussianFilter
double __gaussianFilter(double filterRadius, typename ordered_view::iterator centerIt, size_t trajNum, size_t dim)
Definition: Trajectory.cpp:1666
armarx::Trajectory::GenerateTimestamps
static Ice::DoubleSeq GenerateTimestamps(const std::vector< T > &values)
Definition: Trajectory.h:465
armarx::Trajectory::ice_postUnmarshal
void ice_postUnmarshal() override
Definition: Trajectory.cpp:71
armarx::Trajectory::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: Trajectory.cpp:152
armarx::Trajectory::TrajMap
std::map< double, std::vector< DoubleSeqPtr > > TrajMap
Definition: Trajectory.h:82
armarx::Trajectory::differentiateDiscretly
void differentiateDiscretly(size_t derivation)
Definition: Trajectory.cpp:1449
armarx::Trajectory::TrajData::getPositionsAsVectorXf
Eigen::VectorXf getPositionsAsVectorXf() const
Definition: Trajectory.cpp:2097
armarx::Trajectory::getMinima
Ice::DoubleSeq getMinima(size_t dimension, size_t derivation, double startTime, double endTime) const
Calculate all minima.
Definition: Trajectory.cpp:746
armarx::Trajectory::getDimensionName
std::string getDimensionName(size_t dim) const
Definition: Trajectory.cpp:372
armarx::Trajectory::setDimensionNames
void setDimensionNames(const Ice::StringSeq dimNames)
Definition: Trajectory.h:508
armarx::Trajectory::TrajData::operator[]
DoubleSeqPtr operator[](size_t dim) const
Definition: Trajectory.cpp:2079
armarx::Trajectory::NormalizeTimestamps
static Trajectory NormalizeTimestamps(const Trajectory &traj, const double startTime=0.0, const double endTime=1.0)
Definition: Trajectory.cpp:1801
armarx::Trajectory::getDimensionNames
const Ice::StringSeq & getDimensionNames() const
Definition: Trajectory.cpp:378
armarx::Trajectory::setEntries
void setEntries(const double t, const size_t dimIndex, const Ice::DoubleSeq &y)
Definition: Trajectory.cpp:1094
armarx::VariantType
Definition: ChannelRef.h:167
armarx::Trajectory::__calcBaseDataAtTimestamp
std::vector< DoubleSeqPtr > __calcBaseDataAtTimestamp(const double &t) const
Definition: Trajectory.cpp:897
armarx::Trajectory::differentiateDiscretlyForDim
void differentiateDiscretlyForDim(size_t trajDimension, size_t derivation)
Definition: Trajectory.cpp:1459
armarx::Trajectory::getStates
std::vector< DoubleSeqPtr > & getStates(double t)
Definition: Trajectory.cpp:971
armarx::Trajectory::ordered_view
typename boost::multi_index::index< TrajDataContainer, TagOrdered >::type ordered_view
Definition: Trajectory.h:215
armarx::Trajectory::getStatesMap
std::map< std::string, T > getStatesMap(double t, size_t derivation=0) const
Definition: Trajectory.h:316
armarx::Trajectory::size
size_t size() const
Returns number of data entries (i.e.
Definition: Trajectory.cpp:535
armarx::Trajectory::getDimensionData
Ice::DoubleSeq getDimensionData(size_t dimension, size_t derivation=0) const
getDimensionData gets all entries for one dimensions with order of increasing timestamps
Definition: Trajectory.cpp:390
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:43
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
armarx::Trajectory::shiftTime
void shiftTime(double shift)
Definition: Trajectory.cpp:2145
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::Trajectory::removeDimension
void removeDimension(size_t dimension)
Definition: Trajectory.cpp:1958
armarx::Trajectory::getMaxima
Ice::DoubleSeq getMaxima(size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:822
armarx::Trajectory::Trajectory
Trajectory(const std::vector< std::vector< std::vector< T >>> &data, const Ice::DoubleSeq timestamps=Ice::DoubleSeq(), const Ice::StringSeq &dimensionNames={})
Definition: Trajectory.h:265
armarx::Trajectory::Trajectory
Trajectory()
Definition: Trajectory.h:217
armarx::Trajectory::addPositionsToDimension
void addPositionsToDimension(size_t dimension, const Ice::DoubleSeq &values, const Ice::DoubleSeq &timestamps)
Definition: Trajectory.cpp:2043
armarx::Trajectory::TrajData::getDeriv
double getDeriv(size_t dim, size_t derivation) const
Definition: Trajectory.cpp:2129
armarx::Trajectory::operator+=
Trajectory & operator+=(const Trajectory traj)
Definition: Trajectory.cpp:1067
armarx::Trajectory::DifferentiateDiscretly
static Ice::DoubleSeq DifferentiateDiscretly(const Ice::DoubleSeq &timestamps, const Ice::DoubleSeq &values, int derivationCount=1)
Definition: Trajectory.cpp:1250
armarx::Trajectory::__fillBaseDataAtTimestamp
timestamp_view::iterator __fillBaseDataAtTimestamp(const double &t)
Definition: Trajectory.cpp:932
ExpressionException.h
armarx::Trajectory::__addDimension
void __addDimension()
Definition: Trajectory.cpp:1081
armarx::Trajectory::toEigen
Eigen::MatrixXd toEigen(size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:459
armarx::Trajectory::TrajDataContainer
boost::multi_index::multi_index_container< TrajData, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag< TagTimestamp >, boost::multi_index::member< TrajData, double, &TrajData::timestamp > >, boost::multi_index::ordered_unique< boost::multi_index::tag< TagOrdered >, boost::multi_index::member< TrajData, double, &TrajData::timestamp > > > > TrajDataContainer
Definition: Trajectory.h:211
armarx::Trajectory::getAmplitude
double getAmplitude(size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:736
armarx::Trajectory::TrajData::timestamp
double timestamp
Definition: Trajectory.h:181
armarx::Trajectory::getTimestampsFloat
Ice::FloatSeq getTimestampsFloat() const
Definition: Trajectory.cpp:1185
armarx::Trajectory
The Trajectory class represents n-dimensional sampled trajectories.
Definition: Trajectory.h:76
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:917
armarx::Trajectory::operator=
Trajectory & operator=(const Trajectory &source)
Definition: Trajectory.cpp:230
armarx::Trajectory::TrajData::getPositions
std::vector< double > getPositions() const
Definition: Trajectory.h:129
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::Trajectory::validate
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Trajectory.cpp:179
armarx::Trajectory::dim
size_t dim() const
dim returns the trajectory dimension count for this trajectory (e.g.
Definition: Trajectory.cpp:522
armarx::Trajectory::serialize
void serialize(const ObjectSerializerBasePtr &obj, const Ice::Current &=Ice::emptyCurrent) const override
Definition: Trajectory.cpp:90
armarx::Trajectory::getTimeLength
double getTimeLength() const
Difference between biggest and smallest timestamp.
Definition: Trajectory.cpp:541
armarx::Trajectory::dataExists
bool dataExists(double t, size_t dimension=0, size_t derivation=0) const
Definition: Trajectory.cpp:916
armarx::Trajectory::getTimestamps
Ice::DoubleSeq getTimestamps() const
Definition: Trajectory.cpp:1169
armarx::Trajectory::getWithFunc
double getWithFunc(const double &(*foo)(const double &, const double &), double initValue, size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:711
armarx::Trajectory::CopyData
static void CopyData(const Trajectory &source, Trajectory &destination)
Definition: Trajectory.cpp:1716
Variant.h
armarx::Trajectory::getMaximaTimestamps
Ice::DoubleSeq getMaximaTimestamps(size_t dimension, size_t derivation, double startTime, double endTime) const
Definition: Trajectory.cpp:859
armarx::Trajectory::TrajData::getPosition
double getPosition(size_t dim) const
Definition: Trajectory.cpp:2091
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::Trajectory::__interpolate
double __interpolate(typename ordered_view::const_iterator itMap, size_t dimension, size_t derivation) const
Definition: Trajectory.cpp:1554
armarx::Trajectory::getDerivations
Ice::DoubleSeq getDerivations(double t, size_t dimension, size_t derivations) const
Definition: Trajectory.cpp:353
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::Trajectory::Trajectory
Trajectory(const std::vector< std::vector< T >> &data, const Ice::DoubleSeq timestamps=Ice::DoubleSeq(), const Ice::StringSeq &dimensionNames={})
Constructor to add n-dimensions with m-values.
Definition: Trajectory.h:245
Exception.h
armarx::Variant::addTypeName
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
Definition: Variant.cpp:869
armarx::Trajectory::TrajData::trajectory
Trajectory * trajectory
Definition: Trajectory.h:184
armarx::DoubleSeqPtr
std::shared_ptr< Ice::DoubleSeq > DoubleSeqPtr
Definition: Trajectory.h:49
armarx::Trajectory::TrajData::getData
const std::vector< DoubleSeqPtr > & getData() const
Definition: Trajectory.cpp:2139
armarx::Trajectory::deserialize
void deserialize(const ObjectSerializerBasePtr &, const Ice::Current &=Ice::emptyCurrent) override
Definition: Trajectory.cpp:114
armarx::Trajectory::getLimitless
LimitlessStateSeq getLimitless() const
Definition: Trajectory.cpp:2214
armarx::Trajectory::setPositionEntry
void setPositionEntry(const double t, const size_t dimIndex, const double &y)
Definition: Trajectory.cpp:1123
armarx::Trajectory::Trajectory
Trajectory(const std::vector< T > &data, const Ice::DoubleSeq timestamps=Ice::DoubleSeq(), const std::string &dimensionName="", typename std::enable_if_t< std::is_arithmetic_v< T >> *t=0)
Definition: Trajectory.h:224