Apollo  6.0
Open source self driving car software
road_graph.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 
17 #pragma once
18 
19 #include <list>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
26 #include "modules/prediction/proto/lane_graph.pb.h"
27 
28 namespace apollo {
29 namespace prediction {
30 
31 class RoadGraph {
32  public:
40  RoadGraph(const double start_s, const double length,
41  const bool consider_divide,
42  std::shared_ptr<const hdmap::LaneInfo> lane_info_ptr);
43 
49  common::Status BuildLaneGraph(LaneGraph* const lane_graph);
50 
51  common::Status BuildLaneGraphBidirection(LaneGraph* const lane_graph_ptr);
52 
60  bool IsOnLaneGraph(std::shared_ptr<const hdmap::LaneInfo> lane_info_ptr,
61  const LaneGraph& lane_graph);
62 
63  private:
67  LaneGraph CombineLaneGraphs(const LaneGraph& lane_graph_predecessor,
68  const LaneGraph& lane_graph_successor);
69 
84  void ConstructLaneSequence(
85  const bool search_forward_direction, const double accumulated_s,
86  const double curr_lane_seg_s,
87  std::shared_ptr<const hdmap::LaneInfo> lane_info_ptr,
88  const int graph_search_horizon, const bool consider_lane_split,
89  std::list<LaneSegment>* const lane_segments,
90  LaneGraph* const lane_graph_ptr) const;
91 
94  void ConstructLaneSequence(
95  const double accumulated_s, const double curr_lane_seg_s,
96  std::shared_ptr<const hdmap::LaneInfo> lane_info_ptr,
97  const int graph_search_horizon, const bool consider_lane_split,
98  std::list<LaneSegment>* const lane_segments,
99  LaneGraph* const lane_graph_ptr) const;
100 
101  private:
102  // The s of the obstacle on its own lane_segment.
103  double start_s_ = 0;
104 
105  // The total length to search for lane_graph.
106  double length_ = -1.0;
107 
108  // If we consider all successor lanes after dividing
109  bool consider_divide_ = false;
110 
111  // The lane_info of the lane_segment where the obstacle is on.
112  std::shared_ptr<const hdmap::LaneInfo> lane_info_ptr_ = nullptr;
113 };
114 
115 } // namespace prediction
116 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: road_graph.h:31
common::Status BuildLaneGraphBidirection(LaneGraph *const lane_graph_ptr)
common::Status BuildLaneGraph(LaneGraph *const lane_graph)
Build the lane graph.
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
bool IsOnLaneGraph(std::shared_ptr< const hdmap::LaneInfo > lane_info_ptr, const LaneGraph &lane_graph)
Check if a lane with an s is on the lane graph.
RoadGraph(const double start_s, const double length, const bool consider_divide, std::shared_ptr< const hdmap::LaneInfo > lane_info_ptr)
Constructor.