Apollo  6.0
Open source self driving car software
dual_variable_warm_start_osqp_interface.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 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 
17 /*
18  * @file
19  */
20 
21 #pragma once
22 
23 #include <limits>
24 #include <vector>
25 
26 #include "Eigen/Dense"
27 #include "modules/common/configs/proto/vehicle_config.pb.h"
29 #include "modules/planning/proto/planner_open_space_config.pb.h"
30 #include "osqp/osqp.h"
31 
32 namespace apollo {
33 namespace planning {
34 
36  public:
38  size_t horizon, double ts, const Eigen::MatrixXd& ego,
39  const Eigen::MatrixXi& obstacles_edges_num, const size_t obstacles_num,
40  const Eigen::MatrixXd& obstacles_A, const Eigen::MatrixXd& obstacles_b,
41  const Eigen::MatrixXd& xWS,
42  const PlannerOpenSpaceConfig& planner_open_space_config);
43 
44  virtual ~DualVariableWarmStartOSQPInterface() = default;
45 
46  void get_optimization_results(Eigen::MatrixXd* l_warm_up,
47  Eigen::MatrixXd* n_warm_up) const;
48 
49  bool optimize();
50 
51  void assemble_P(std::vector<c_float>* P_data, std::vector<c_int>* P_indices,
52  std::vector<c_int>* P_indptr);
53 
54  void assemble_constraint(std::vector<c_float>* A_data,
55  std::vector<c_int>* A_indices,
56  std::vector<c_int>* A_indptr);
57 
58  void assembleA(const int r, const int c, const std::vector<c_float>& P_data,
59  const std::vector<c_int>& P_indices,
60  const std::vector<c_int>& P_indptr);
61 
62  void check_solution(const Eigen::MatrixXd& l_warm_up,
63  const Eigen::MatrixXd& n_warm_up);
64 
65  private:
66  OSQPConfig osqp_config_;
67  int num_of_variables_;
68  int num_of_constraints_;
69  int horizon_;
70  double ts_;
71  Eigen::MatrixXd ego_;
72  int lambda_horizon_ = 0;
73  int miu_horizon_ = 0;
74 
75  Eigen::MatrixXd l_warm_up_;
76  Eigen::MatrixXd n_warm_up_;
77  double wheelbase_;
78 
79  double w_ev_;
80  double l_ev_;
81  std::vector<double> g_;
82  double offset_;
83  Eigen::MatrixXi obstacles_edges_num_;
84  int obstacles_num_;
85  int obstacles_edges_sum_;
86 
87  double min_safety_distance_;
88 
89  // lagrangian l start index
90  int l_start_index_ = 0;
91 
92  // lagrangian n start index
93  int n_start_index_ = 0;
94 
95  // obstacles_A
96  Eigen::MatrixXd obstacles_A_;
97 
98  // obstacles_b
99  Eigen::MatrixXd obstacles_b_;
100 
101  // states of warm up stage
102  Eigen::MatrixXd xWS_;
103 
104  // constraint A matrix in eigen format
105  Eigen::MatrixXf constraint_A_;
106 
107  bool check_mode_;
108 };
109 
110 } // namespace planning
111 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void check_solution(const Eigen::MatrixXd &l_warm_up, const Eigen::MatrixXd &n_warm_up)
Planning module main class. It processes GPS and IMU as input, to generate planning info...
void assembleA(const int r, const int c, const std::vector< c_float > &P_data, const std::vector< c_int > &P_indices, const std::vector< c_int > &P_indptr)
DualVariableWarmStartOSQPInterface(size_t horizon, double ts, const Eigen::MatrixXd &ego, const Eigen::MatrixXi &obstacles_edges_num, const size_t obstacles_num, const Eigen::MatrixXd &obstacles_A, const Eigen::MatrixXd &obstacles_b, const Eigen::MatrixXd &xWS, const PlannerOpenSpaceConfig &planner_open_space_config)
void get_optimization_results(Eigen::MatrixXd *l_warm_up, Eigen::MatrixXd *n_warm_up) const
Definition: dual_variable_warm_start_osqp_interface.h:35
void assemble_constraint(std::vector< c_float > *A_data, std::vector< c_int > *A_indices, std::vector< c_int > *A_indptr)
void assemble_P(std::vector< c_float > *P_data, std::vector< c_int > *P_indices, std::vector< c_int > *P_indptr)