Apollo  6.0
Open source self driving car software
quartic_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 quartic polynomial curve: (x0, dx0, ddx0) -- [0, param] --> (dx1, ddx1)
33  public:
34  QuarticPolynomialCurve1d() = default;
35 
36  QuarticPolynomialCurve1d(const std::array<double, 3>& start,
37  const std::array<double, 2>& end,
38  const double param);
39 
40  QuarticPolynomialCurve1d(const double x0, const double dx0, const double ddx0,
41  const double dx1, const double ddx1,
42  const double param);
43 
45 
46  virtual ~QuarticPolynomialCurve1d() = default;
47 
48  double Evaluate(const std::uint32_t order, const double p) const override;
49 
62  const double x0, const double dx0, const double ddx0, const double x1,
63  const double dx1, const double param);
64 
70  const double x0, const double dx0, const double x1, const double dx1,
71  const double ddx1, const double param);
72 
73  /*
74  * Integrated from cubic curve with init value
75  */
77  const PolynomialCurve1d& other, const double init_value);
78 
79  /*
80  * Derived from quintic curve
81  */
83  const PolynomialCurve1d& other);
84 
85  double ParamLength() const override { return param_; }
86 
87  std::string ToString() const override;
88 
89  double Coef(const size_t order) const override;
90 
91  size_t Order() const override { return 4; }
92 
93  private:
94  void ComputeCoefficients(const double x0, const double dx0, const double ddx0,
95  const double dx1, const double ddx1,
96  const double param);
97 
98  std::array<double, 5> coef_ = {{0.0, 0.0, 0.0, 0.0, 0.0}};
99  std::array<double, 3> start_condition_ = {{0.0, 0.0, 0.0}};
100  std::array<double, 2> end_condition_ = {{0.0, 0.0}};
101 };
102 
103 } // namespace planning
104 } // namespace apollo
QuarticPolynomialCurve1d & IntegratedFromCubicCurve(const PolynomialCurve1d &other, const double init_value)
double Evaluate(const std::uint32_t order, const double p) const override
size_t Order() const override
Definition: quartic_polynomial_curve1d.h:91
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
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: quartic_polynomial_curve1d.h:32
QuarticPolynomialCurve1d & FitWithEndPointSecondOrder(const double x0, const double dx0, const double x1, const double dx1, const double ddx1, const double param)
Definition: polynomial_curve1d.h:28
double param_
Definition: polynomial_curve1d.h:37
double ParamLength() const override
Definition: quartic_polynomial_curve1d.h:85
std::string ToString() const override
QuarticPolynomialCurve1d & DerivedFromQuinticCurve(const PolynomialCurve1d &other)
QuarticPolynomialCurve1d & FitWithEndPointFirstOrder(const double x0, const double dx0, const double ddx0, const double x1, const double dx1, const double param)