Apollo 11.0
自动驾驶开放平台
spline_1d_constraint.h
浏览该文件的文档.
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 <algorithm>
26#include <vector>
27
28#include "Eigen/Core"
29
32
33namespace apollo {
34namespace planning {
35
37 public:
38 explicit Spline1dConstraint(const Spline1d& pss);
39 Spline1dConstraint(const std::vector<double>& x_knots, const uint32_t order);
40
41 // direct methods
42 bool AddInequalityConstraint(const Eigen::MatrixXd& constraint_matrix,
43 const Eigen::MatrixXd& constraint_boundary);
44 bool AddEqualityConstraint(const Eigen::MatrixXd& constraint_matrix,
45 const Eigen::MatrixXd& constraint_boundary);
46
47 // preset method
53 bool AddBoundary(const std::vector<double>& x_coord,
54 const std::vector<double>& lower_bound,
55 const std::vector<double>& upper_bound);
56
57 bool AddDerivativeBoundary(const std::vector<double>& x_coord,
58 const std::vector<double>& lower_bound,
59 const std::vector<double>& upper_bound);
60
61 bool AddSecondDerivativeBoundary(const std::vector<double>& x_coord,
62 const std::vector<double>& lower_bound,
63 const std::vector<double>& upper_bound);
64
65 bool AddThirdDerivativeBoundary(const std::vector<double>& x_coord,
66 const std::vector<double>& lower_bound,
67 const std::vector<double>& upper_bound);
68
74 bool AddPointConstraint(const double x, const double fx);
75 bool AddPointDerivativeConstraint(const double x, const double dfx);
76 bool AddPointSecondDerivativeConstraint(const double x, const double ddfx);
77 bool AddPointThirdDerivativeConstraint(const double x, const double dddfx);
78
79 bool AddPointConstraintInRange(const double x, const double fx,
80 const double range);
81 bool AddPointDerivativeConstraintInRange(const double x, const double dfx,
82 const double range);
84 const double ddfx,
85 const double range);
87 const double dddfx,
88 const double range);
89 // guarantee up to values are joint
91
92 // guarantee up to derivative are joint
94
95 // guarantee up to second order derivative are joint
97
98 // guarantee up to third order derivative are joint
100
105 bool AddMonotoneInequalityConstraint(const std::vector<double>& x_coord);
106
107 // default inequality constraint at knots
109
115
116 private:
117 uint32_t FindIndex(const double x) const;
118
119 bool FilterConstraints(const std::vector<double>& x_coord,
120 const std::vector<double>& lower_bound,
121 const std::vector<double>& upper_bound,
122 std::vector<double>* const filtered_lower_bound_x,
123 std::vector<double>* const filtered_lower_bound,
124 std::vector<double>* const filtered_upper_bound_x,
125 std::vector<double>* const filtered_upper_bound);
126 void GeneratePowerX(const double x, const uint32_t order,
127 std::vector<double>* const power_x) const;
128
129 using AddConstraintInRangeFunc =
130 std::function<bool(const std::vector<double>&, const std::vector<double>&,
131 const std::vector<double>&)>;
132 bool AddConstraintInRange(AddConstraintInRangeFunc func, const double x,
133 const double val, const double range);
134
135 private:
136 AffineConstraint inequality_constraint_;
137 AffineConstraint equality_constraint_;
138 std::vector<double> x_knots_;
139 uint32_t spline_order_;
140};
141
142} // namespace planning
143} // namespace apollo
bool AddPointSecondDerivativeConstraint(const double x, const double ddfx)
bool AddDerivativeBoundary(const std::vector< double > &x_coord, const std::vector< double > &lower_bound, const std::vector< double > &upper_bound)
bool AddPointThirdDerivativeConstraintInRange(const double x, const double dddfx, const double range)
const AffineConstraint & equality_constraint() const
bool AddBoundary(const std::vector< double > &x_coord, const std::vector< double > &lower_bound, const std::vector< double > &upper_bound)
: inequality boundary constraints if no boundary, do specify either by std::infinity or let vector....
bool AddEqualityConstraint(const Eigen::MatrixXd &constraint_matrix, const Eigen::MatrixXd &constraint_boundary)
bool AddThirdDerivativeBoundary(const std::vector< double > &x_coord, const std::vector< double > &lower_bound, const std::vector< double > &upper_bound)
bool AddPointDerivativeConstraint(const double x, const double dfx)
const AffineConstraint & inequality_constraint() const
: output interface inequality constraint
bool AddInequalityConstraint(const Eigen::MatrixXd &constraint_matrix, const Eigen::MatrixXd &constraint_boundary)
bool AddMonotoneInequalityConstraint(const std::vector< double > &x_coord)
: Add monotone constraint inequality, guarantee the monotone city at evaluated point.
bool AddSecondDerivativeBoundary(const std::vector< double > &x_coord, const std::vector< double > &lower_bound, const std::vector< double > &upper_bound)
bool AddPointSecondDerivativeConstraintInRange(const double x, const double ddfx, const double range)
bool AddPointDerivativeConstraintInRange(const double x, const double dfx, const double range)
bool AddPointThirdDerivativeConstraint(const double x, const double dddfx)
bool AddPointConstraintInRange(const double x, const double fx, const double range)
bool AddPointConstraint(const double x, const double fx)
: equality constraint to guarantee joint smoothness boundary equality constriant constraint on fx,...
Planning module main class.
class register implement
Definition arena_queue.h:37
: piecewise smoothing spline class