5#include "state_representation/State.hpp" 
   11  std::deque<StateT> points_;
 
   12  std::deque<std::chrono::nanoseconds> times_;
 
   13  std::string reference_frame_; 
 
   14  std::vector<std::string> joint_names_; 
 
   61  template<
typename DurationT>
 
   62  void add_point(
const StateT& new_point, 
const std::chrono::duration<int64_t, DurationT>& new_time);
 
   67  template<
typename DurationT>
 
   68  void insert_point(
const StateT& new_point, 
const std::chrono::duration<int64_t, DurationT>& new_time, 
int pos);
 
   89  const StateT& 
get_point(
unsigned int index) 
const;
 
  100  const std::deque<std::chrono::nanoseconds>& 
get_times() 
const;
 
  110  const std::pair<StateT, std::chrono::nanoseconds> 
operator[](
unsigned int idx) 
const;
 
  115  std::pair<StateT, std::chrono::nanoseconds> 
operator[](
unsigned int idx);
 
 
  119template<
class StateT>
 
  122  this->
set_type(StateType::TRAJECTORY);
 
 
  126template<
class StateT>
 
  129    reference_frame_(
"") {
 
  130  this->
set_type(StateType::TRAJECTORY);
 
 
  134template<
class StateT>
 
  136  return this->reference_frame_;
 
 
  139template<
class StateT>
 
  141  this->reference_frame_ = reference_frame;
 
 
  144template<
class StateT>
 
  146  return this->joint_names_;
 
 
  149template<
class StateT>
 
  151  this->joint_names_.resize(nb_joints);
 
  152  for (
unsigned int i = 0; i < nb_joints; i++) {
 
  153    this->joint_names_[i] = 
"joint_" + std::to_string(i + 1);
 
 
  157template<
class StateT>
 
  159  this->joint_names_ = joint_names;
 
 
  162template<
class StateT>
 
  165  this->points_.clear();
 
  166  this->times_.clear();
 
 
  169template<
class StateT>
 
  170template<
typename DurationT>
 
  172  this->set_empty(
false);
 
  173  this->points_.push_back(new_point);
 
  175  if (!this->times_.empty()) {
 
  176    auto const previous_time = this->times_.back();
 
  177    this->times_.push_back(previous_time + new_time);
 
  179    this->times_.push_back(new_time);
 
 
  183template<
class StateT>
 
  184template<
typename DurationT>
 
  186                                      const std::chrono::duration<int64_t, DurationT>& new_time,
 
  188  this->set_empty(
false);
 
  190  auto it_points = this->points_.begin();
 
  191  auto it_times = this->times_.begin();
 
  192  std::advance(it_points, pos);
 
  193  std::advance(it_times, pos);
 
  195  this->points_.insert(it_points, new_point);
 
  197  auto previous_time = this->times_[pos - 1];
 
  198  this->times_.insert(it_times, previous_time + new_time);
 
  200  for (
unsigned int i = pos + 1; i <= this->points_.size(); i++) {
 
  201    this->times_[i] += new_time;
 
 
  205template<
class StateT>
 
  207  this->set_empty(
false);
 
  208  if (!this->points_.empty()) {
 
  209    this->points_.pop_back();
 
  211  if (!this->times_.empty()) {
 
  212    this->times_.pop_back();
 
 
  216template<
class StateT>
 
  218  this->points_.clear();
 
  219  this->times_.clear();
 
 
  222template<
class StateT>
 
  224  return this->points_;
 
 
  227template<
class StateT>
 
  229  return this->points_[index];
 
 
  232template<
class StateT>
 
  234  return this->points_[index];
 
 
  237template<
class StateT>
 
  242template<
class StateT>
 
  244  return this->points_.size();
 
 
  247template<
class StateT>
 
  249  return std::make_pair(this->points_[idx], this->times_[idx]);
 
 
  252template<
class StateT>
 
  254  this->set_empty(
false);
 
  255  return std::make_pair(this->points_[idx], this->times_[idx]);
 
 
Abstract class to represent a state.
 
void set_type(const StateType &type)
Setter of the state type attribute.
 
virtual void reset()
Reset the object to a post-construction state.
 
virtual void set_reference_frame(const std::string &reference_frame)
Setter of the reference frame.
 
const std::vector< std::string > & get_joint_names() const
Getter of the names attribute.
 
void set_joint_names(unsigned int nb_joints)
Setter of the names attribute from the number of joints.
 
const StateT & get_point(unsigned int index) const
Get the trajectory point at given index.
 
void delete_point()
Delete last point and corresponding time from trajectory.
 
const std::deque< std::chrono::nanoseconds > & get_times() const
Get attribute list of trajectory times.
 
const std::pair< StateT, std::chrono::nanoseconds > operator[](unsigned int idx) const
Operator overload for returning a single trajectory point and corresponding time.
 
void insert_point(const StateT &new_point, const std::chrono::duration< int64_t, DurationT > &new_time, int pos)
Insert new point and corresponding time to trajectory between two already existing points.
 
int get_size() const
Get attribute number of point in trajectory.
 
const std::deque< StateT > & get_points() const
Get attribute list of trajectory points.
 
void reset()
Initialize trajectory.
 
Trajectory()
Empty constructor.
 
void add_point(const StateT &new_point, const std::chrono::duration< int64_t, DurationT > &new_time)
Add new point and corresponding time to trajectory.
 
const std::string get_reference_frame() const
Getter of the reference frame as const reference.
 
void clear()
Clear trajectory.
 
Core state variables and objects.