Apollo  6.0
Open source self driving car software
iterative_anchoring_smoother.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 
17 /*
18  * @file
19  */
20 
21 #pragma once
22 
23 #include <utility>
24 #include <vector>
25 
26 #include "Eigen/Eigen"
34 #include "modules/planning/proto/planning.pb.h"
35 
36 namespace apollo {
37 namespace planning {
39  public:
41  const PlannerOpenSpaceConfig& planner_open_space_config);
42 
43  ~IterativeAnchoringSmoother() = default;
44 
45  bool Smooth(const Eigen::MatrixXd& xWS, const double init_a,
46  const double init_v,
47  const std::vector<std::vector<common::math::Vec2d>>&
48  obstacles_vertices_vec,
49  DiscretizedTrajectory* discretized_trajectory);
50 
51  private:
52  void AdjustStartEndHeading(
53  const Eigen::MatrixXd& xWS,
54  std::vector<std::pair<double, double>>* const point2d);
55 
56  bool ReAnchoring(const std::vector<size_t>& colliding_point_index,
57  DiscretizedPath* path_points);
58 
59  bool GenerateInitialBounds(const DiscretizedPath& path_points,
60  std::vector<double>* initial_bounds);
61 
62  bool SmoothPath(const DiscretizedPath& raw_path_points,
63  const std::vector<double>& bounds,
64  DiscretizedPath* smoothed_path_points);
65 
66  bool CheckCollisionAvoidance(const DiscretizedPath& path_points,
67  std::vector<size_t>* colliding_point_index);
68 
69  void AdjustPathBounds(const std::vector<size_t>& colliding_point_index,
70  std::vector<double>* bounds);
71 
72  bool SetPathProfile(const std::vector<std::pair<double, double>>& point2d,
73  DiscretizedPath* raw_path_points);
74 
75  bool CheckGear(const Eigen::MatrixXd& xWS);
76 
77  bool SmoothSpeed(const double init_a, const double init_v,
78  const double path_length, SpeedData* smoothed_speeds);
79 
80  bool CombinePathAndSpeed(const DiscretizedPath& path_points,
81  const SpeedData& speed_points,
82  DiscretizedTrajectory* discretized_trajectory);
83 
84  void AdjustPathAndSpeedByGear(DiscretizedTrajectory* discretized_trajectory);
85 
86  bool GenerateStopProfileFromPolynomial(const double init_acc,
87  const double init_speed,
88  const double stop_distance,
89  SpeedData* smoothed_speeds);
90 
91  bool IsValidPolynomialProfile(const QuinticPolynomialCurve1d& curve);
92 
93  // @brief: a helper function on discrete point heading adjustment
94  double CalcHeadings(const DiscretizedPath& path_points, const size_t index);
95 
96  private:
97  // vehicle_param
98  double ego_length_ = 0.0;
99  double ego_width_ = 0.0;
100  double center_shift_distance_ = 0.0;
101 
102  std::vector<std::vector<common::math::LineSegment2d>>
103  obstacles_linesegments_vec_;
104 
105  std::vector<size_t> input_colliding_point_index_;
106 
107  bool enforce_initial_kappa_ = true;
108 
109  // gear DRIVE as true and gear REVERSE as false
110  bool gear_ = false;
111 
112  PlannerOpenSpaceConfig planner_open_space_config_;
113 };
114 } // namespace planning
115 } // namespace apollo
Definition: discretized_path.h:31
Define the LineSegment2d class.
Defines the Vec2d class.
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: discretized_trajectory.h:32
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: quintic_polynomial_curve1d.h:33
IterativeAnchoringSmoother(const PlannerOpenSpaceConfig &planner_open_space_config)
bool Smooth(const Eigen::MatrixXd &xWS, const double init_a, const double init_v, const std::vector< std::vector< common::math::Vec2d >> &obstacles_vertices_vec, DiscretizedTrajectory *discretized_trajectory)
Definition: iterative_anchoring_smoother.h:38
The class of Box2d. Here, the x/y axes are respectively Forward/Left, as opposed to what happens in e...
Definition: speed_data.h:30