Aikido
StepSequence.hpp
Go to the documentation of this file.
1 #ifndef AIKIDO_COMMON_STEPSEQUENCE_HPP_
2 #define AIKIDO_COMMON_STEPSEQUENCE_HPP_
3 
4 #include <cassert>
5 #include <limits>
6 #include <tuple>
7 
8 #include <boost/iterator/iterator_facade.hpp>
9 
10 namespace aikido {
11 namespace common {
12 
16 {
17 public:
18  class const_iterator;
19 
34  double stepSize,
35  bool includeStartpoint = true,
36  bool includeEndpoint = true,
37  double startPoint = 0.0,
38  double endPoint = 1.0);
39 
42  double startPoint,
43  double endPoint,
44  std::size_t numSteps,
45  bool includeEndpoint = true);
46 
50  const_iterator begin() const;
51 
56  const_iterator end() const;
57 
61  double operator[](std::size_t n) const;
62 
66  std::size_t getLength() const;
67 
68 private:
71  void updateNumSteps();
72 
75  void updateStepSize();
76 
78  double mStepSize;
79 
81  const bool mIncludeStartPoint;
82 
84  const bool mIncludeEndPoint;
85 
87  const double mStartPoint;
88 
90  const double mEndPoint;
91 
93  std::size_t mNumSteps;
94 };
95 
97  : public boost::iterator_facade<
98  StepSequence::const_iterator,
99  double,
100  boost::forward_traversal_tag,
101  double>
102 {
103 public:
105  double dereference() const;
106 
108  void increment();
109 
113  bool equal(const StepSequence::const_iterator& other) const;
114 
115 private:
116  friend class StepSequence;
117 
120  const_iterator(const StepSequence& seq, std::size_t step);
121 
124 
126  std::size_t mStep;
127 
129  double mValue;
130 };
131 
132 } // namespace common
133 } // namespace aikido
134 
135 #endif // AIKIDO_COMMON_STEPSEQUENCE_HPP_
aikido::common::StepSequence::end
const_iterator end() const
Returns an iterator to the element following the last element of the sequence.
aikido::common::StepSequence::mNumSteps
std::size_t mNumSteps
The total length of sequence.
Definition: StepSequence.hpp:93
aikido::common::StepSequence::const_iterator::dereference
double dereference() const
Dereference implementation for boost::iterator_facade.
aikido::common::StepSequence::getLength
std::size_t getLength() const
Returns the total length of sequence.
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::common::StepSequence::begin
const_iterator begin() const
Returns an iterator to the first element of the sequence.
aikido::common::StepSequence::updateNumSteps
void updateNumSteps()
Computes the total length of sequence given step size.
aikido::common::StepSequence::const_iterator::equal
bool equal(const StepSequence::const_iterator &other) const
Equal implementation for boost::iterator_facade.
aikido::common::StepSequence::const_iterator
Definition: StepSequence.hpp:96
aikido::common::StepSequence::mIncludeEndPoint
const bool mIncludeEndPoint
Whether the end point in the sequence will be the end point.
Definition: StepSequence.hpp:84
aikido::common::StepSequence::updateStepSize
void updateStepSize()
Computes the step size of sequence given number of steps.
aikido::common::StepSequence::mEndPoint
const double mEndPoint
The end point that defines the sequence.
Definition: StepSequence.hpp:90
aikido::common::StepSequence::mStartPoint
const double mStartPoint
The start point that defines the sequence.
Definition: StepSequence.hpp:87
aikido::common::StepSequence::operator[]
double operator[](std::size_t n) const
Returns the n-th element of the sequence.
aikido::common::StepSequence
An iterator that returns a sequence of numbers between start point and end point stepping at a fixed ...
Definition: StepSequence.hpp:15
aikido::common::StepSequence::const_iterator::mSeq
const StepSequence & mSeq
StepSequence associated with this iterator.
Definition: StepSequence.hpp:123
aikido::common::StepSequence::const_iterator::increment
void increment()
Increment implementation for boost::iterator_facade.
aikido::common::StepSequence::const_iterator::mValue
double mValue
Value of the current step.
Definition: StepSequence.hpp:129
aikido::common::StepSequence::StepSequence
StepSequence(double stepSize, bool includeStartpoint=true, bool includeEndpoint=true, double startPoint=0.0, double endPoint=1.0)
Constructor.
aikido::common::StepSequence::const_iterator::const_iterator
const_iterator(const StepSequence &seq, std::size_t step)
Private constructor that should always be constructed from StepSequence::begin().
aikido::common::StepSequence::mStepSize
double mStepSize
Step size increments from the start point to the end point.
Definition: StepSequence.hpp:78
aikido::common::StepSequence::const_iterator::mStep
std::size_t mStep
Current step number.
Definition: StepSequence.hpp:126
aikido::common::StepSequence::mIncludeStartPoint
const bool mIncludeStartPoint
Whether the start point in the sequence will be the start point.
Definition: StepSequence.hpp:81