Drake
piecewise_polynomial_trajectory.h
Go to the documentation of this file.
1 #pragma once
2
3 #include <memory>
4 #include <vector>
5
6 #include <Eigen/Core>
7
8
10
11 namespace drake {
12
13 /**
14  * A PiecewisePolynomialTrajectory is a Trajectory that is represented by
15  * (implemented in terms of) a PiecewisePolynomial.
16  */
18  public:
19  /**
20  * Construct a PiecewisePolynomialTrajectory from a PiecewisePolynomial.
21  */
23  : pp_(pp) {}
24
25  std::unique_ptr<Trajectory> Clone() const override {
26  return std::make_unique<PiecewisePolynomialTrajectory>(pp_);
27  }
28
29  /**
30  * Evaluate this PiecewisePolynomial at a particular time.
31  * @param t The time to evaluate.
32  * @return a Matrix that is the value of the wrapped
33  * PiecewisePolynomial.
34  */
35  drake::MatrixX<double> value(double t) const override {
36  return pp_.value(t);
37  }
38
39  /**
40  * Takes the derivative of this PiecewisePolynomialTrajectory.
41  * Each segment of the returned PiecewisePolynomialTrajectory is the
42  * derivative of the segment in the original PiecewisePolynomialTrajectory.
43  * @param derivative_order The number of times to take the derivative before
44  * returning.
45  * @return The nth derivative of this object.
46  */
47  std::unique_ptr<Trajectory> derivative(
48  int derivative_order = 1) const override {
49  return std::make_unique<PiecewisePolynomialTrajectory>(
50  pp_.derivative(derivative_order));
51  }
52
53  /**
54  * @return The number of rows of the output vector, which is also
55  * the number of rows in the PiecewisePolynomial.
56  */
57  Eigen::Index rows() const override { return pp_.rows(); }
58
59  /**
60  * @return The number of columns of the output vector, which is also
61  * the number of columns in the PiecewisePolynomial.
62  */
63  Eigen::Index cols() const override { return pp_.cols(); }
64
65
66  double get_start_time() const override { return pp_.getStartTime(); }
67
68  double get_end_time() const override { return pp_.getEndTime(); }
69
70  /**
71  * @return A reference to the underlying piecewise polynomial.
72  */
74  return pp_;
75  }
76
77  private:
79 };
80
81 } // namespace drake
A PiecewisePolynomialTrajectory is a Trajectory that is represented by (implemented in terms of) a Pi...
Definition: piecewise_polynomial_trajectory.h:17
Eigen::Index rows() const override
Definition: piecewise_polynomial_trajectory.h:57
double getStartTime(int segment_number) const
Definition: piecewise_function.cc:37
double get_start_time() const override
Definition: piecewise_polynomial_trajectory.h:66
const PiecewisePolynomial< double > & get_piecewise_polynomial() const
Definition: piecewise_polynomial_trajectory.h:73
A Trajectory represents a time-varying matrix of doubles.
Definition: trajectory.h:14
Definition: automotive_demo.cc:88
PiecewisePolynomialTrajectory(const PiecewisePolynomial< double > &pp)
Construct a PiecewisePolynomialTrajectory from a PiecewisePolynomial.
Definition: piecewise_polynomial_trajectory.h:22
drake::MatrixX< double > value(double t) const override
Evaluate this PiecewisePolynomial at a particular time.
Definition: piecewise_polynomial_trajectory.h:35
double getEndTime(int segment_number) const
Definition: piecewise_function.cc:42
std::unique_ptr< Trajectory > derivative(int derivative_order=1) const override
Takes the derivative of this PiecewisePolynomialTrajectory.
Definition: piecewise_polynomial_trajectory.h:47
Eigen::Index cols() const override
Definition: piecewise_polynomial.cc:321
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > MatrixX
A matrix of dynamic size, templated on scalar type.
Definition: eigen_types.h:87
Eigen::Index rows() const override
Definition: piecewise_polynomial.cc:312
std::unique_ptr< Trajectory > Clone() const override
Definition: piecewise_polynomial_trajectory.h:25
double get_end_time() const override
Definition: piecewise_polynomial_trajectory.h:68
PiecewisePolynomial derivative(int derivative_order=1) const
Takes the derivative of this PiecewisePolynomial.
Definition: piecewise_polynomial.cc:49
drake::MatrixX< double > value(double t) const
Evaluates the PiecewisePolynomial at the given time t.
Definition: piecewise_polynomial.cc:109
Eigen::Index cols() const override
Definition: piecewise_polynomial_trajectory.h:63