Apollo  6.0
Open source self driving car software
hdmap.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 <string>
20 #include <utility>
21 #include <vector>
22 
23 #include "cyber/common/macros.h"
24 
25 #include "modules/common/proto/geometry.pb.h"
26 #include "modules/map/proto/map_clear_area.pb.h"
27 #include "modules/map/proto/map_crosswalk.pb.h"
28 #include "modules/map/proto/map_junction.pb.h"
29 #include "modules/map/proto/map_lane.pb.h"
30 #include "modules/map/proto/map_overlap.pb.h"
31 #include "modules/map/proto/map_parking_space.pb.h"
32 #include "modules/map/proto/map_road.pb.h"
33 #include "modules/map/proto/map_signal.pb.h"
34 #include "modules/map/proto/map_speed_bump.pb.h"
35 #include "modules/map/proto/map_stop_sign.pb.h"
36 #include "modules/map/proto/map_yield_sign.pb.h"
37 
40 
45 namespace apollo {
46 namespace hdmap {
47 
53 class HDMap {
54  public:
60  int LoadMapFromFile(const std::string& map_filename);
61 
67  int LoadMapFromProto(const Map& map_proto);
68 
69  LaneInfoConstPtr GetLaneById(const Id& id) const;
70  JunctionInfoConstPtr GetJunctionById(const Id& id) const;
71  SignalInfoConstPtr GetSignalById(const Id& id) const;
72  CrosswalkInfoConstPtr GetCrosswalkById(const Id& id) const;
73  StopSignInfoConstPtr GetStopSignById(const Id& id) const;
74  YieldSignInfoConstPtr GetYieldSignById(const Id& id) const;
75  ClearAreaInfoConstPtr GetClearAreaById(const Id& id) const;
76  SpeedBumpInfoConstPtr GetSpeedBumpById(const Id& id) const;
77  OverlapInfoConstPtr GetOverlapById(const Id& id) const;
78  RoadInfoConstPtr GetRoadById(const Id& id) const;
80  PNCJunctionInfoConstPtr GetPNCJunctionById(const Id& id) const;
81  RSUInfoConstPtr GetRSUById(const Id& id) const;
82 
90  int GetLanes(const apollo::common::PointENU& point, double distance,
91  std::vector<LaneInfoConstPtr>* lanes) const;
99  int GetJunctions(const apollo::common::PointENU& point, double distance,
100  std::vector<JunctionInfoConstPtr>* junctions) const;
108  int GetSignals(const apollo::common::PointENU& point, double distance,
109  std::vector<SignalInfoConstPtr>* signals) const;
117  int GetCrosswalks(const apollo::common::PointENU& point, double distance,
118  std::vector<CrosswalkInfoConstPtr>* crosswalks) const;
126  int GetStopSigns(const apollo::common::PointENU& point, double distance,
127  std::vector<StopSignInfoConstPtr>* stop_signs) const;
135  int GetYieldSigns(const apollo::common::PointENU& point, double distance,
136  std::vector<YieldSignInfoConstPtr>* yield_signs) const;
144  int GetClearAreas(const apollo::common::PointENU& point, double distance,
145  std::vector<ClearAreaInfoConstPtr>* clear_areas) const;
153  int GetSpeedBumps(const apollo::common::PointENU& point, double distance,
154  std::vector<SpeedBumpInfoConstPtr>* speed_bumps) const;
162  int GetRoads(const apollo::common::PointENU& point, double distance,
163  std::vector<RoadInfoConstPtr>* roads) const;
171  int GetParkingSpaces(
172  const apollo::common::PointENU& point, double distance,
173  std::vector<ParkingSpaceInfoConstPtr>* parking_spaces) const;
181  int GetPNCJunctions(
182  const apollo::common::PointENU& point, double distance,
183  std::vector<PNCJunctionInfoConstPtr>* pnc_junctions) const;
192  int GetNearestLane(const apollo::common::PointENU& point,
193  LaneInfoConstPtr* nearest_lane, double* nearest_s,
194  double* nearest_l) const;
206  int GetNearestLaneWithHeading(const apollo::common::PointENU& point,
207  const double distance,
208  const double central_heading,
209  const double max_heading_difference,
210  LaneInfoConstPtr* nearest_lane,
211  double* nearest_s, double* nearest_l) const;
221  int GetLanesWithHeading(const apollo::common::PointENU& point,
222  const double distance, const double central_heading,
223  const double max_heading_difference,
224  std::vector<LaneInfoConstPtr>* lanes) const;
233  int GetRoadBoundaries(const apollo::common::PointENU& point, double radius,
234  std::vector<RoadROIBoundaryPtr>* road_boundaries,
235  std::vector<JunctionBoundaryPtr>* junctions) const;
244  int GetRoadBoundaries(const apollo::common::PointENU& point, double radius,
245  std::vector<RoadRoiPtr>* road_boundaries,
246  std::vector<JunctionInfoConstPtr>* junctions) const;
255  int GetRoi(const apollo::common::PointENU& point, double radius,
256  std::vector<RoadRoiPtr>* roads_roi,
257  std::vector<PolygonRoiPtr>* polygons_roi);
268  const apollo::common::PointENU& point, const double distance,
269  std::vector<SignalInfoConstPtr>* signals) const;
270 
279  const Id& id, std::vector<StopSignInfoConstPtr>* stop_signs) const;
280 
287  int GetStopSignAssociatedLanes(const Id& id,
288  std::vector<LaneInfoConstPtr>* lanes) const;
289 
298  int GetLocalMap(const apollo::common::PointENU& point,
299  const std::pair<double, double>& range, Map* local_map) const;
300 
310  int GetForwardNearestRSUs(const apollo::common::PointENU& point,
311  double distance, double central_heading,
312  double max_heading_difference,
313  std::vector<RSUInfoConstPtr>* rsus) const;
314 
315  private:
316  HDMapImpl impl_;
317 };
318 
319 } // namespace hdmap
320 } // namespace apollo
std::shared_ptr< const PNCJunctionInfo > PNCJunctionInfoConstPtr
Definition: hdmap_common.h:138
std::shared_ptr< const RoadInfo > RoadInfoConstPtr
Definition: hdmap_common.h:133
int GetNearestLane(const apollo::common::PointENU &point, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
get nearest lane from target point,
RSUInfoConstPtr GetRSUById(const Id &id) const
int GetClearAreas(const apollo::common::PointENU &point, double distance, std::vector< ClearAreaInfoConstPtr > *clear_areas) const
get all clear areas in certain range
std::shared_ptr< const ParkingSpaceInfo > ParkingSpaceInfoConstPtr
Definition: hdmap_common.h:134
SignalInfoConstPtr GetSignalById(const Id &id) const
CrosswalkInfoConstPtr GetCrosswalkById(const Id &id) const
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
int GetYieldSigns(const apollo::common::PointENU &point, double distance, std::vector< YieldSignInfoConstPtr > *yield_signs) const
get all yield signs in certain range
int GetStopSigns(const apollo::common::PointENU &point, double distance, std::vector< StopSignInfoConstPtr > *stop_signs) const
get all stop signs in certain range
JunctionInfoConstPtr GetJunctionById(const Id &id) const
ClearAreaInfoConstPtr GetClearAreaById(const Id &id) const
LaneInfoConstPtr GetLaneById(const Id &id) const
int GetSpeedBumps(const apollo::common::PointENU &point, double distance, std::vector< SpeedBumpInfoConstPtr > *speed_bumps) const
get all speed bumps in certain range
int GetForwardNearestSignalsOnLane(const apollo::common::PointENU &point, const double distance, std::vector< SignalInfoConstPtr > *signals) const
get forward nearest signals within certain range on the lane if there are two signals related to one ...
int GetParkingSpaces(const apollo::common::PointENU &point, double distance, std::vector< ParkingSpaceInfoConstPtr > *parking_spaces) const
get all parking spaces in certain range
int GetSignals(const apollo::common::PointENU &point, double distance, std::vector< SignalInfoConstPtr > *signals) const
get all signals in certain range
int GetRoadBoundaries(const apollo::common::PointENU &point, double radius, std::vector< RoadROIBoundaryPtr > *road_boundaries, std::vector< JunctionBoundaryPtr > *junctions) const
get all road and junctions boundaries within certain range
int GetRoi(const apollo::common::PointENU &point, double radius, std::vector< RoadRoiPtr > *roads_roi, std::vector< PolygonRoiPtr > *polygons_roi)
get ROI within certain range
int GetRoads(const apollo::common::PointENU &point, double distance, std::vector< RoadInfoConstPtr > *roads) const
get all roads in certain range
ParkingSpaceInfoConstPtr GetParkingSpaceById(const Id &id) const
int GetLanes(const apollo::common::PointENU &point, double distance, std::vector< LaneInfoConstPtr > *lanes) const
get all lanes in certain range
int GetForwardNearestRSUs(const apollo::common::PointENU &point, double distance, double central_heading, double max_heading_difference, std::vector< RSUInfoConstPtr > *rsus) const
get forward nearest rsus within certain range
YieldSignInfoConstPtr GetYieldSignById(const Id &id) const
OverlapInfoConstPtr GetOverlapById(const Id &id) const
int GetLocalMap(const apollo::common::PointENU &point, const std::pair< double, double > &range, Map *local_map) const
get a local map which is identical to the origin map except that all map elements without overlap wit...
SpeedBumpInfoConstPtr GetSpeedBumpById(const Id &id) const
int GetStopSignAssociatedStopSigns(const Id &id, std::vector< StopSignInfoConstPtr > *stop_signs) const
get all other stop signs associated with a stop sign in the same junction
StopSignInfoConstPtr GetStopSignById(const Id &id) const
std::shared_ptr< const CrosswalkInfo > CrosswalkInfoConstPtr
Definition: hdmap_common.h:128
RoadInfoConstPtr GetRoadById(const Id &id) const
std::shared_ptr< const YieldSignInfo > YieldSignInfoConstPtr
Definition: hdmap_common.h:130
High-precision map loader interface.
Definition: hdmap.h:53
std::shared_ptr< const SpeedBumpInfo > SpeedBumpInfoConstPtr
Definition: hdmap_common.h:132
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
Definition: hdmap_common.h:125
std::shared_ptr< const SignalInfo > SignalInfoConstPtr
Definition: hdmap_common.h:127
High-precision map loader implement.
Definition: hdmap_impl.h:56
int GetCrosswalks(const apollo::common::PointENU &point, double distance, std::vector< CrosswalkInfoConstPtr > *crosswalks) const
get all crosswalks in certain range
int GetPNCJunctions(const apollo::common::PointENU &point, double distance, std::vector< PNCJunctionInfoConstPtr > *pnc_junctions) const
get all pnc junctions in certain range
int GetJunctions(const apollo::common::PointENU &point, double distance, std::vector< JunctionInfoConstPtr > *junctions) const
get all junctions in certain range
std::shared_ptr< const RSUInfo > RSUInfoConstPtr
Definition: hdmap_common.h:139
int LoadMapFromFile(const std::string &map_filename)
load map from local file
std::shared_ptr< const ClearAreaInfo > ClearAreaInfoConstPtr
Definition: hdmap_common.h:131
int LoadMapFromProto(const Map &map_proto)
load map from a given protobuf message.
std::shared_ptr< const StopSignInfo > StopSignInfoConstPtr
Definition: hdmap_common.h:129
int GetNearestLaneWithHeading(const apollo::common::PointENU &point, const double distance, const double central_heading, const double max_heading_difference, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
get the nearest lane within a certain range by pose
std::shared_ptr< const OverlapInfo > OverlapInfoConstPtr
Definition: hdmap_common.h:124
std::shared_ptr< const JunctionInfo > JunctionInfoConstPtr
Definition: hdmap_common.h:126
PNCJunctionInfoConstPtr GetPNCJunctionById(const Id &id) const
int GetLanesWithHeading(const apollo::common::PointENU &point, const double distance, const double central_heading, const double max_heading_difference, std::vector< LaneInfoConstPtr > *lanes) const
get all lanes within a certain range by pose
int GetStopSignAssociatedLanes(const Id &id, std::vector< LaneInfoConstPtr > *lanes) const
get all lanes associated with a stop sign in the same junction