Apollo  6.0
Open source self driving car software
piecewise_jerk_speed_problem.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 <utility>
24 #include <vector>
25 
27 
28 namespace apollo {
29 namespace planning {
30 
31 /*
32  * @brief:
33  * This class solve the path time optimization problem:
34  * s
35  * |
36  * | P(t1, s1) P(t2, s2)
37  * | P(t0, s0) ... P(t(k-1), s(k-1))
38  * |P(start)
39  * |
40  * |________________________________________________________ t
41  *
42  * we suppose t(k+1) - t(k) == t(k) - t(k-1)
43  *
44  * Given the s, s', s'' at P(start), The goal is to find t0, t1, ... t(k-1)
45  * which makes the line P(start), P0, P(1) ... P(k-1) "smooth".
46  */
47 
49  public:
50  PiecewiseJerkSpeedProblem(const size_t num_of_knots, const double delta_s,
51  const std::array<double, 3>& x_init);
52 
53  virtual ~PiecewiseJerkSpeedProblem() = default;
54 
55  void set_dx_ref(const double weight_dx_ref, const double dx_ref);
56 
57  void set_penalty_dx(std::vector<double> penalty_dx);
58 
59  protected:
60  // naming convention follows osqp solver.
61  void CalculateKernel(std::vector<c_float>* P_data,
62  std::vector<c_int>* P_indices,
63  std::vector<c_int>* P_indptr) override;
64 
65  void CalculateOffset(std::vector<c_float>* q) override;
66 
67  OSQPSettings* SolverDefaultSettings() override;
68 
69  bool has_dx_ref_ = false;
70  double weight_dx_ref_ = 0.0;
71  double dx_ref_ = 0.0;
72 
73  std::vector<double> penalty_dx_;
74 };
75 
76 } // namespace planning
77 } // namespace apollo
void CalculateKernel(std::vector< c_float > *P_data, std::vector< c_int > *P_indices, std::vector< c_int > *P_indptr) override
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Planning module main class. It processes GPS and IMU as input, to generate planning info...
double weight_dx_ref_
Definition: piecewise_jerk_speed_problem.h:70
Definition: piecewise_jerk_problem.h:49
double dx_ref_
Definition: piecewise_jerk_speed_problem.h:71
void set_dx_ref(const double weight_dx_ref, const double dx_ref)
void CalculateOffset(std::vector< c_float > *q) override
OSQPSettings * SolverDefaultSettings() override
void set_penalty_dx(std::vector< double > penalty_dx)
std::vector< double > penalty_dx_
Definition: piecewise_jerk_speed_problem.h:73
bool has_dx_ref_
Definition: piecewise_jerk_speed_problem.h:69
PiecewiseJerkSpeedProblem(const size_t num_of_knots, const double delta_s, const std::array< double, 3 > &x_init)
Definition: piecewise_jerk_speed_problem.h:48