Apollo  6.0
Open source self driving car software
spline_1d_kernel.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 
23 #pragma once
24 
25 #include <vector>
26 
27 #include "Eigen/Core"
29 
30 namespace apollo {
31 namespace planning {
32 
34  public:
35  explicit Spline1dKernel(const Spline1d& spline1d);
36  Spline1dKernel(const std::vector<double>& x_knots,
37  const uint32_t spline_order);
38 
39  // customized input / output method
40  void AddRegularization(const double regularized_param);
41  bool AddKernel(const Eigen::MatrixXd& kernel, const Eigen::MatrixXd& offset,
42  const double weight);
43  bool AddKernel(const Eigen::MatrixXd& kernel, const double weight);
44 
45  Eigen::MatrixXd* mutable_kernel_matrix();
46  Eigen::MatrixXd* mutable_offset();
47 
48  const Eigen::MatrixXd& kernel_matrix() const;
49  const Eigen::MatrixXd& offset() const;
50 
51  // build-in kernel methods
52  void AddDerivativeKernelMatrix(const double weight);
53  void AddSecondOrderDerivativeMatrix(const double weight);
54  void AddThirdOrderDerivativeMatrix(const double weight);
55  void AddDerivativeKernelMatrixForSplineK(const uint32_t k,
56  const double weight);
57  void AddSecondOrderDerivativeMatrixForSplineK(const uint32_t k,
58  const double weight);
59  void AddThirdOrderDerivativeMatrixForSplineK(const uint32_t k,
60  const double weight);
61 
62  // reference line kernel, x_coord in strictly increasing order (for path
63  // optimizer)
64  bool AddReferenceLineKernelMatrix(const std::vector<double>& x_coord,
65  const std::vector<double>& ref_fx,
66  const double weight);
67 
68  // distance offset (for speed optimizer, given time optimize the distance can
69  // go)
70  void AddDistanceOffset(const double weight);
71 
72  private:
73  void AddNthDerivativekernelMatrix(const uint32_t n, const double weight);
74  void AddNthDerivativekernelMatrixForSplineK(const uint32_t n,
75  const uint32_t k,
76  const double weight);
77  uint32_t FindIndex(const double x) const;
78 
79  private:
80  Eigen::MatrixXd kernel_matrix_;
81  Eigen::MatrixXd offset_;
82  std::vector<double> x_knots_;
83  uint32_t spline_order_;
84  uint32_t total_params_;
85 };
86 
87 } // namespace planning
88 } // namespace apollo
bool AddKernel(const Eigen::MatrixXd &kernel, const Eigen::MatrixXd &offset, const double weight)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
const Eigen::MatrixXd & offset() const
Planning module main class. It processes GPS and IMU as input, to generate planning info...
void AddDistanceOffset(const double weight)
Eigen::MatrixXd * mutable_offset()
void AddSecondOrderDerivativeMatrixForSplineK(const uint32_t k, const double weight)
Definition: spline_1d_kernel.h:33
void AddSecondOrderDerivativeMatrix(const double weight)
const Eigen::MatrixXd & kernel_matrix() const
void AddRegularization(const double regularized_param)
void AddDerivativeKernelMatrix(const double weight)
Definition: spline_1d.h:40
void AddDerivativeKernelMatrixForSplineK(const uint32_t k, const double weight)
Eigen::MatrixXd * mutable_kernel_matrix()
void AddThirdOrderDerivativeMatrixForSplineK(const uint32_t k, const double weight)
void AddThirdOrderDerivativeMatrix(const double weight)
: piecewise smoothing spline class
Spline1dKernel(const Spline1d &spline1d)
bool AddReferenceLineKernelMatrix(const std::vector< double > &x_coord, const std::vector< double > &ref_fx, const double weight)