Apollo  6.0
Open source self driving car software
quintic_polynomial_curve1d.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
21 #pragma once
22 
23 #include <array>
24 #include <string>
25 
27 
28 namespace apollo {
29 namespace planning {
30 
31 // 1D quintic polynomial curve:
32 // (x0, dx0, ddx0) -- [0, param] --> (x1, dx1, ddx1)
34  public:
35  QuinticPolynomialCurve1d() = default;
36 
37  QuinticPolynomialCurve1d(const std::array<double, 3>& start,
38  const std::array<double, 3>& end,
39  const double param);
40 
41  QuinticPolynomialCurve1d(const double x0, const double dx0, const double ddx0,
42  const double x1, const double dx1, const double ddx1,
43  const double param);
44 
46 
47  void SetParam(const double x0, const double dx0, const double ddx0,
48  const double x1, const double dx1, const double ddx1,
49  const double param);
50 
52  const double init_value);
53 
54  virtual ~QuinticPolynomialCurve1d() = default;
55 
56  double Evaluate(const std::uint32_t order, const double p) const override;
57 
58  double ParamLength() const override { return param_; }
59  std::string ToString() const override;
60 
61  double Coef(const size_t order) const override;
62 
63  size_t Order() const override { return 5; }
64 
65  protected:
66  void ComputeCoefficients(const double x0, const double dx0, const double ddx0,
67  const double x1, const double dx1, const double ddx1,
68  const double param);
69 
70  // f = sum(coef_[i] * x^i), i from 0 to 5
71  std::array<double, 6> coef_{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}};
72  std::array<double, 3> start_condition_{{0.0, 0.0, 0.0}};
73  std::array<double, 3> end_condition_{{0.0, 0.0, 0.0}};
74 };
75 
76 } // namespace planning
77 } // namespace apollo
void SetParam(const double x0, const double dx0, const double ddx0, const double x1, const double dx1, const double ddx1, const double param)
double ParamLength() const override
Definition: quintic_polynomial_curve1d.h:58
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
double Coef(const size_t order) const override
std::array< double, 6 > coef_
Definition: quintic_polynomial_curve1d.h:71
Planning module main class. It processes GPS and IMU as input, to generate planning info...
double Evaluate(const std::uint32_t order, const double p) const override
Definition: quintic_polynomial_curve1d.h:33
Definition: polynomial_curve1d.h:28
double param_
Definition: polynomial_curve1d.h:37
std::array< double, 3 > end_condition_
Definition: quintic_polynomial_curve1d.h:73
std::array< double, 3 > start_condition_
Definition: quintic_polynomial_curve1d.h:72
void IntegratedFromQuarticCurve(const PolynomialCurve1d &other, const double init_value)
std::string ToString() const override
void ComputeCoefficients(const double x0, const double dx0, const double ddx0, const double x1, const double dx1, const double ddx1, const double param)
size_t Order() const override
Definition: quintic_polynomial_curve1d.h:63