Apollo  6.0
Open source self driving car software
path_data.h
Go to the documentation of this file.
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 
21 #pragma once
22 
23 #include <list>
24 #include <string>
25 #include <tuple>
26 #include <utility>
27 #include <vector>
28 
32 
33 namespace apollo {
34 namespace planning {
35 
36 class PathData {
37  public:
38  enum class PathPointType {
39  IN_LANE,
42  OFF_ROAD,
43  UNKNOWN,
44  };
45 
46  PathData() = default;
47 
49 
50  bool SetFrenetPath(FrenetFramePath frenet_path);
51 
52  void SetReferenceLine(const ReferenceLine *reference_line);
53 
55  std::vector<std::tuple<double, PathPointType, double>>
57 
58  const DiscretizedPath &discretized_path() const;
59 
60  const FrenetFramePath &frenet_frame_path() const;
61 
62  const std::vector<std::tuple<double, PathPointType, double>>
64 
65  common::PathPoint GetPathPointWithPathS(const double s) const;
66 
67  /*
68  * brief: this function will find the path_point in discretized_path whose
69  * projection to reference line has s value closest to ref_s.
70  */
71  bool GetPathPointWithRefS(const double ref_s,
72  common::PathPoint *const path_point) const;
73 
74  bool LeftTrimWithRefS(const common::FrenetFramePoint &frenet_point);
75 
76  bool UpdateFrenetFramePath(const ReferenceLine *reference_line);
77 
78  void Clear();
79 
80  bool Empty() const;
81 
82  std::string DebugString() const;
83 
84  void set_path_label(const std::string &label);
85 
86  const std::string &path_label() const;
87 
88  void set_blocking_obstacle_id(const std::string &obs_id) {
89  blocking_obstacle_id_ = obs_id;
90  }
91  const std::string &blocking_obstacle_id() const {
92  return blocking_obstacle_id_;
93  }
94 
95  const bool is_valid_path_reference() const {
96  return is_valid_path_reference_;
97  }
99  is_valid_path_reference_ = is_valid_path_reference;
100  }
101 
103  return is_optimized_towards_trajectory_reference_;
104  }
107  is_optimized_towards_trajectory_reference_ =
109  }
110 
111  const std::vector<common::PathPoint> &path_reference() const;
112  void set_path_reference(const std::vector<common::PathPoint> &path_reference);
113 
114  private:
115  /*
116  * convert frenet path to cartesian path by reference line
117  */
118  bool SLToXY(const FrenetFramePath &frenet_path,
119  DiscretizedPath *const discretized_path);
120  bool XYToSL(const DiscretizedPath &discretized_path,
121  FrenetFramePath *const frenet_path);
122  const ReferenceLine *reference_line_ = nullptr;
123  DiscretizedPath discretized_path_;
124  FrenetFramePath frenet_path_;
131  std::vector<std::tuple<double, PathPointType, double>>
132  path_point_decision_guide_;
133 
134  std::string path_label_ = "";
135  std::string blocking_obstacle_id_;
136 
141  // wheter this PathData is a path reference serving as an optimization target
142  // for later modules
143  bool is_valid_path_reference_ = false;
144 
151  bool is_optimized_towards_trajectory_reference_ = false;
152 
153  // path reference
154  std::vector<common::PathPoint> path_reference_;
155 };
156 
157 } // namespace planning
158 } // namespace apollo
bool GetPathPointWithRefS(const double ref_s, common::PathPoint *const path_point) const
Definition: discretized_path.h:31
void set_path_reference(const std::vector< common::PathPoint > &path_reference)
std::string DebugString() const
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
const std::string & blocking_obstacle_id() const
Definition: path_data.h:91
bool LeftTrimWithRefS(const common::FrenetFramePoint &frenet_point)
PathPointType
Definition: path_data.h:38
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: frenet_frame_path.h:32
const DiscretizedPath & discretized_path() const
const FrenetFramePath & frenet_frame_path() const
const std::vector< common::PathPoint > & path_reference() const
const bool is_valid_path_reference() const
Definition: path_data.h:95
bool SetFrenetPath(FrenetFramePath frenet_path)
Definition: path_data.h:36
void set_is_optimized_towards_trajectory_reference(bool is_optimized_towards_trajectory_reference)
Definition: path_data.h:105
common::PathPoint GetPathPointWithPathS(const double s) const
void set_path_label(const std::string &label)
Definition: reference_line.h:39
bool UpdateFrenetFramePath(const ReferenceLine *reference_line)
void set_blocking_obstacle_id(const std::string &obs_id)
Definition: path_data.h:88
void set_is_valid_path_reference(bool is_valid_path_reference)
Definition: path_data.h:98
bool SetDiscretizedPath(DiscretizedPath path)
void SetReferenceLine(const ReferenceLine *reference_line)
const std::string & path_label() const
const bool is_optimized_towards_trajectory_reference() const
Definition: path_data.h:102
bool SetPathPointDecisionGuide(std::vector< std::tuple< double, PathPointType, double >> path_point_decision_guide)
const std::vector< std::tuple< double, PathPointType, double > > & path_point_decision_guide() const