Apollo  6.0
Open source self driving car software
spline_2d_constraint.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 <vector>
24 
25 #include "Eigen/Core"
29 
30 namespace apollo {
31 namespace planning {
32 
34  public:
35  Spline2dConstraint(const std::vector<double>& t_knots, const uint32_t order);
36 
37  // direct method
38  bool AddInequalityConstraint(const Eigen::MatrixXd& constraint_matrix,
39  const Eigen::MatrixXd& constraint_boundary);
40  bool AddEqualityConstraint(const Eigen::MatrixXd& constraint_matrix,
41  const Eigen::MatrixXd& constraint_boundary);
42 
43  // preset method
49  bool Add2dBoundary(const std::vector<double>& t_coord,
50  const std::vector<double>& angle,
51  const std::vector<apollo::common::math::Vec2d>& ref_point,
52  const std::vector<double>& longitudinal_bound,
53  const std::vector<double>& lateral_bound);
54 
55  // ref point refer to derivative reference point
57  const std::vector<double>& t_coord, const std::vector<double>& angle,
58  const std::vector<apollo::common::math::Vec2d>& ref_point,
59  const std::vector<double>& longitudinal_bound,
60  const std::vector<double>& lateral_bound);
61 
62  // ref point refer to second derivative ref point
64  const std::vector<double>& t_coord, const std::vector<double>& angle,
65  const std::vector<apollo::common::math::Vec2d>& ref_point,
66  const std::vector<double>& longitudinal_bound,
67  const std::vector<double>& lateral_bound);
68 
69  // ref point refer to third derivative ref point
71  const std::vector<double>& t_coord, const std::vector<double>& angle,
72  const std::vector<apollo::common::math::Vec2d>& ref_point,
73  const std::vector<double>& longitudinal_bound,
74  const std::vector<double>& lateral_bound);
75 
76  bool AddPointConstraint(const double t, const double x, const double y);
77  bool AddPointSecondDerivativeConstraint(const double t, const double ddx,
78  const double ddy);
79  bool AddPointThirdDerivativeConstraint(const double t, const double dddx,
80  const double dddy);
81  bool AddPointAngleConstraint(const double t, const double angle);
82 
83  // guarantee up to values are joint
84  bool AddSmoothConstraint();
85 
86  // guarantee up to derivative are joint
88 
89  // guarantee up to second order derivative are joint
91 
92  // guarantee up to third order derivative are joint
94 
100 
101  private:
102  uint32_t FindIndex(const double t) const;
103  std::vector<double> AffineCoef(const double angle, const double t) const;
104  std::vector<double> AffineDerivativeCoef(const double angle,
105  const double t) const;
106  std::vector<double> AffineSecondDerivativeCoef(const double angle,
107  const double t) const;
108  std::vector<double> AffineThirdDerivativeCoef(const double angle,
109  const double t) const;
110  std::vector<double> PolyCoef(const double t) const;
111  std::vector<double> DerivativeCoef(const double t) const;
112  std::vector<double> SecondDerivativeCoef(const double t) const;
113  std::vector<double> ThirdDerivativeCoef(const double t) const;
114  double SignDistance(const apollo::common::math::Vec2d& xy_point,
115  const double angle) const;
116  bool AddPointKthOrderDerivativeConstraint(
117  const double t, const double x_kth_derivative,
118  const double y_kth_derivative, const std::vector<double>& kth_coeff);
119 
120  private:
121  AffineConstraint inequality_constraint_;
122  AffineConstraint equality_constraint_;
123  std::vector<double> t_knots_;
124  uint32_t spline_order_;
125  uint32_t total_param_;
126 };
127 
128 } // namespace planning
129 } // namespace apollo
: piecewise smoothing spline 2d class
bool AddInequalityConstraint(const Eigen::MatrixXd &constraint_matrix, const Eigen::MatrixXd &constraint_boundary)
Defines the Vec2d class.
bool AddEqualityConstraint(const Eigen::MatrixXd &constraint_matrix, const Eigen::MatrixXd &constraint_boundary)
const AffineConstraint & inequality_constraint() const
: output interface inequality constraint
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool AddPointSecondDerivativeConstraint(const double t, const double ddx, const double ddy)
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Spline2dConstraint(const std::vector< double > &t_knots, const uint32_t order)
Definition: spline_2d_constraint.h:33
bool AddPointConstraint(const double t, const double x, const double y)
Implements a class of 2-dimensional vectors.
Definition: vec2d.h:42
bool Add2dBoundary(const std::vector< double > &t_coord, const std::vector< double > &angle, const std::vector< apollo::common::math::Vec2d > &ref_point, const std::vector< double > &longitudinal_bound, const std::vector< double > &lateral_bound)
: inequality boundary constraints if no boundary, do specify either by std::infinity or let vector...
Definition: affine_constraint.h:29
bool Add2dThirdDerivativeBoundary(const std::vector< double > &t_coord, const std::vector< double > &angle, const std::vector< apollo::common::math::Vec2d > &ref_point, const std::vector< double > &longitudinal_bound, const std::vector< double > &lateral_bound)
bool Add2dDerivativeBoundary(const std::vector< double > &t_coord, const std::vector< double > &angle, const std::vector< apollo::common::math::Vec2d > &ref_point, const std::vector< double > &longitudinal_bound, const std::vector< double > &lateral_bound)
bool AddPointAngleConstraint(const double t, const double angle)
bool Add2dSecondDerivativeBoundary(const std::vector< double > &t_coord, const std::vector< double > &angle, const std::vector< apollo::common::math::Vec2d > &ref_point, const std::vector< double > &longitudinal_bound, const std::vector< double > &lateral_bound)
bool AddPointThirdDerivativeConstraint(const double t, const double dddx, const double dddy)
const AffineConstraint & equality_constraint() const