Drake
random_piecewise_polynomial.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
5 #include <Eigen/Core>
6 
9 
10 namespace drake {
11 namespace trajectories {
12 namespace test {
13 
14 /**
15  * Obtains a random PiecewisePolynomial with the given @p segment_times. Each
16  * segment will have a matrix of random Polynomials of the specified size.
17  */
18 template<typename CoefficientType = double>
20 MakeRandomPiecewisePolynomial(Eigen::Index rows, Eigen::Index cols,
21  Eigen::Index num_coefficients_per_polynomial,
22  const std::vector<double> &segment_times) {
23  Eigen::Index num_segments =
24  static_cast<Eigen::Index>(segment_times.size() - 1);
25  typedef Polynomial<CoefficientType> PolynomialType;
26  typedef Eigen::Matrix<PolynomialType, Eigen::Dynamic, Eigen::Dynamic>
27  PolynomialMatrix;
28  std::vector<PolynomialMatrix> polynomials;
29  for (Eigen::Index segment_index = 0; segment_index < num_segments;
30  ++segment_index) {
31  polynomials.push_back(
32  drake::test::RandomPolynomialMatrix<CoefficientType>(
33  num_coefficients_per_polynomial, rows, cols));
34  }
35  return PiecewisePolynomial<CoefficientType>(polynomials,
36  segment_times);
37 }
38 
39 } // namespace test
40 } // namespace trajectories
41 } // namespace drake
Definition: automotive_demo.cc:105
A scalar multi-variate piecewise polynomial.
Definition: piecewise_polynomial.h:47
PiecewisePolynomial< CoefficientType > MakeRandomPiecewisePolynomial(Eigen::Index rows, Eigen::Index cols, Eigen::Index num_coefficients_per_polynomial, const std::vector< double > &segment_times)
Obtains a random PiecewisePolynomial with the given segment_times.
Definition: random_piecewise_polynomial.h:20