Apollo 11.0
自动驾驶开放平台
reeds_shepp_path.h
浏览该文件的文档.
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 <memory>
25#include <string>
26#include <utility>
27#include <vector>
28
29#include <omp.h>
30
31#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
32#include "modules/planning/planning_open_space/proto/planner_open_space_config.pb.h"
33
34#include "cyber/common/log.h"
35#include "cyber/common/macros.h"
39
40namespace apollo {
41namespace planning {
42
44 std::vector<double> segs_lengths;
45 std::vector<char> segs_types;
46 double total_length = 0.0;
47 double cost = 0.0;
48 std::vector<double> x;
49 std::vector<double> y;
50 std::vector<double> phi;
51 // true for driving forward and false for driving backward
52 std::vector<bool> gear;
53 double radius = 1.0;
54};
55
56struct RSPParam {
57 bool flag = false;
58 double t = 0.0;
59 double u = 0.0;
60 double v = 0.0;
61};
62
63class ReedShepp {
64public:
65 ReedShepp(const common::VehicleParam& vehicle_param, const PlannerOpenSpaceConfig& open_space_conf);
66 virtual ~ReedShepp() = default;
67 // Pick the shortest path from all possible
68 // combination of movement primitives
69 // by Reed Shepp
70 bool ShortestRSP(
71 const std::shared_ptr<Node3d> start_node,
72 const std::shared_ptr<Node3d> end_node,
73 std::shared_ptr<ReedSheppPath> optimal_path);
74
75protected:
76 // Generate all possible combination of
77 // movement primitives by Reed Shepp and
78 // interpolate them
79 bool GenerateRSPs(
80 const std::shared_ptr<Node3d> start_node,
81 const std::shared_ptr<Node3d> end_node,
82 std::vector<ReedSheppPath>* all_possible_paths);
83 // Set the general profile of the movement primitives
84 bool GenerateRSP(
85 const std::shared_ptr<Node3d> start_node,
86 const std::shared_ptr<Node3d> end_node,
87 std::vector<ReedSheppPath>* all_possible_paths);
88 // Set the general profile of the movement primitives,
89 // parallel implementation
90 bool GenerateRSPPar(
91 const std::shared_ptr<Node3d> start_node,
92 const std::shared_ptr<Node3d> end_node,
93 std::vector<ReedSheppPath>* all_possible_paths);
94 // Set local exact configurations profile of
95 // each movement primitive
97 const std::shared_ptr<Node3d> start_node,
98 const std::shared_ptr<Node3d> end_node,
99 ReedSheppPath* shortest_path);
100 // Interpolation usde in GenetateLocalConfiguration
101 void Interpolation(
102 const int index,
103 const double pd,
104 const char m,
105 const double ox,
106 const double oy,
107 const double ophi,
108 const double radius,
109 std::vector<double>* px,
110 std::vector<double>* py,
111 std::vector<double>* pphi,
112 std::vector<bool>* pgear);
113 // motion primitives combination setup function
114 bool SetRSP(
115 const int size,
116 const double* lengths,
117 const char* types,
118 std::vector<ReedSheppPath>* all_possible_paths,
119 double radius = 1.0);
120 // setRSP parallel version
121 bool SetRSPPar(
122 const int size,
123 const double* lengths,
124 const std::string& types,
125 std::vector<ReedSheppPath>* all_possible_paths,
126 const int idx);
127 bool CS(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
128 // Six different combination of motion primitive in Reed Shepp path used in
129 // GenerateRSP()
130 bool SCS(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
131 bool CSC(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
132 bool CCC(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
133 bool CCCC(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
134 bool CCSC(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
135 bool CCSCC(const double x, const double y, const double phi, std::vector<ReedSheppPath>* all_possible_paths);
136 // different options for different combination of motion primitives
137 void LSL(const double x, const double y, const double phi, RSPParam* param);
138 void LSR(const double x, const double y, const double phi, RSPParam* param);
139 void LRL(const double x, const double y, const double phi, RSPParam* param);
140 void SLS(const double x, const double y, const double phi, RSPParam* param);
141 void LRLRn(const double x, const double y, const double phi, RSPParam* param);
142 void LRLRp(const double x, const double y, const double phi, RSPParam* param);
143 void LRSR(const double x, const double y, const double phi, RSPParam* param);
144 void LRSL(const double x, const double y, const double phi, RSPParam* param);
145 void LRSLR(const double x, const double y, const double phi, RSPParam* param);
146 void LS(const double x, const double y, const double phi, RSPParam* param);
147 std::pair<double, double> calc_tau_omega(
148 const double u,
149 const double v,
150 const double xi,
151 const double eta,
152 const double phi);
153
154protected:
165
166 // park generic
167public:
168 ReedShepp(const common::VehicleParam& vehicle_param, const WarmStartConfig& warm_start_conf);
169
171
172protected:
174};
175} // namespace planning
176} // namespace apollo
void LRLRn(const double x, const double y, const double phi, RSPParam *param)
void LRL(const double x, const double y, const double phi, RSPParam *param)
PlannerOpenSpaceConfig planner_open_space_config_
void LSL(const double x, const double y, const double phi, RSPParam *param)
bool SetRSP(const int size, const double *lengths, const char *types, std::vector< ReedSheppPath > *all_possible_paths, double radius=1.0)
void LRSL(const double x, const double y, const double phi, RSPParam *param)
bool CCCC(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
void LSR(const double x, const double y, const double phi, RSPParam *param)
void LRSLR(const double x, const double y, const double phi, RSPParam *param)
void SLS(const double x, const double y, const double phi, RSPParam *param)
bool GenerateLocalConfigurations(const std::shared_ptr< Node3d > start_node, const std::shared_ptr< Node3d > end_node, ReedSheppPath *shortest_path)
void Interpolation(const int index, const double pd, const char m, const double ox, const double oy, const double ophi, const double radius, std::vector< double > *px, std::vector< double > *py, std::vector< double > *pphi, std::vector< bool > *pgear)
void LRSR(const double x, const double y, const double phi, RSPParam *param)
common::VehicleParam vehicle_param_
std::pair< double, double > calc_tau_omega(const double u, const double v, const double xi, const double eta, const double phi)
bool ShortestRSP(const std::shared_ptr< Node3d > start_node, const std::shared_ptr< Node3d > end_node, std::shared_ptr< ReedSheppPath > optimal_path)
virtual ~ReedShepp()=default
bool CCC(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
bool CCSCC(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
bool CCSC(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
WarmStartConfig planner_warm_start_config_
bool GenerateRSPs(const std::shared_ptr< Node3d > start_node, const std::shared_ptr< Node3d > end_node, std::vector< ReedSheppPath > *all_possible_paths)
bool GenerateRSPPar(const std::shared_ptr< Node3d > start_node, const std::shared_ptr< Node3d > end_node, std::vector< ReedSheppPath > *all_possible_paths)
bool CS(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
bool CSC(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
bool SCS(const double x, const double y, const double phi, std::vector< ReedSheppPath > *all_possible_paths)
void LS(const double x, const double y, const double phi, RSPParam *param)
bool SetRSPPar(const int size, const double *lengths, const std::string &types, std::vector< ReedSheppPath > *all_possible_paths, const int idx)
bool GenerateRSP(const std::shared_ptr< Node3d > start_node, const std::shared_ptr< Node3d > end_node, std::vector< ReedSheppPath > *all_possible_paths)
void LRLRp(const double x, const double y, const double phi, RSPParam *param)
Planning module main class.
Math-related util functions.
class register implement
Definition arena_queue.h:37
std::vector< double > segs_lengths