Apollo 11.0
自动驾驶开放平台
apollo::hdmap::HDMapImpl类 参考

High-precision map loader implement. 更多...

#include <hdmap_impl.h>

apollo::hdmap::HDMapImpl 的协作图:

Public 类型

using LaneTable = std::unordered_map< std::string, std::shared_ptr< LaneInfo > >
 
using JunctionTable = std::unordered_map< std::string, std::shared_ptr< JunctionInfo > >
 
using AreaTable = std::unordered_map< std::string, std::shared_ptr< AreaInfo > >
 
using SignalTable = std::unordered_map< std::string, std::shared_ptr< SignalInfo > >
 
using BarrierGateTable = std::unordered_map< std::string, std::shared_ptr< BarrierGateInfo > >
 
using CrosswalkTable = std::unordered_map< std::string, std::shared_ptr< CrosswalkInfo > >
 
using StopSignTable = std::unordered_map< std::string, std::shared_ptr< StopSignInfo > >
 
using YieldSignTable = std::unordered_map< std::string, std::shared_ptr< YieldSignInfo > >
 
using ClearAreaTable = std::unordered_map< std::string, std::shared_ptr< ClearAreaInfo > >
 
using SpeedBumpTable = std::unordered_map< std::string, std::shared_ptr< SpeedBumpInfo > >
 
using OverlapTable = std::unordered_map< std::string, std::shared_ptr< OverlapInfo > >
 
using RoadTable = std::unordered_map< std::string, std::shared_ptr< RoadInfo > >
 
using ParkingSpaceTable = std::unordered_map< std::string, std::shared_ptr< ParkingSpaceInfo > >
 
using PNCJunctionTable = std::unordered_map< std::string, std::shared_ptr< PNCJunctionInfo > >
 
using RSUTable = std::unordered_map< std::string, std::shared_ptr< RSUInfo > >
 

Public 成员函数

int LoadMapFromFile (const std::string &map_filename)
 load map from local file
 
int LoadMapFromProto (const Map &map_proto)
 load map from a protobuf message
 
LaneInfoConstPtr GetLaneById (const Id &id) const
 
JunctionInfoConstPtr GetJunctionById (const Id &id) const
 
SignalInfoConstPtr GetSignalById (const Id &id) const
 
CrosswalkInfoConstPtr GetCrosswalkById (const Id &id) const
 
StopSignInfoConstPtr GetStopSignById (const Id &id) const
 
YieldSignInfoConstPtr GetYieldSignById (const Id &id) const
 
ClearAreaInfoConstPtr GetClearAreaById (const Id &id) const
 
SpeedBumpInfoConstPtr GetSpeedBumpById (const Id &id) const
 
OverlapInfoConstPtr GetOverlapById (const Id &id) const
 
RoadInfoConstPtr GetRoadById (const Id &id) const
 
ParkingSpaceInfoConstPtr GetParkingSpaceById (const Id &id) const
 
PNCJunctionInfoConstPtr GetPNCJunctionById (const Id &id) const
 
RSUInfoConstPtr GetRSUById (const Id &id) const
 
AreaInfoConstPtr GetAreaById (const Id &id) const
 
BarrierGateInfoConstPtr GetBarrierGateById (const Id &id) const
 
Id CreateHDMapId (const std::string &string_id) const
 convert id data type
 
int GetAreas (const apollo::common::PointENU &point, double distance, std::vector< AreaInfoConstPtr > *areas) const
 get all areas in certain range
 
int GetLanes (const apollo::common::PointENU &point, double distance, std::vector< LaneInfoConstPtr > *lanes) const
 get all lanes in certain range
 
int GetJunctions (const apollo::common::PointENU &point, double distance, std::vector< JunctionInfoConstPtr > *junctions) const
 get all junctions in certain range
 
int GetCrosswalks (const apollo::common::PointENU &point, double distance, std::vector< CrosswalkInfoConstPtr > *crosswalks) const
 get all crosswalks in certain range
 
int GetSignals (const apollo::common::PointENU &point, double distance, std::vector< SignalInfoConstPtr > *signals) const
 get all signals in certain range
 
int GetBarrierGates (const apollo::common::PointENU &point, double distance, std::vector< BarrierGateInfoConstPtr > *barrier_gates) const
 get all barrier_gates 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
 
int GetYieldSigns (const apollo::common::PointENU &point, double distance, std::vector< YieldSignInfoConstPtr > *yield_signs) const
 get all yield signs in certain range
 
int GetClearAreas (const apollo::common::PointENU &point, double distance, std::vector< ClearAreaInfoConstPtr > *clear_areas) const
 get all clear areas in certain range
 
int GetSpeedBumps (const apollo::common::PointENU &point, double distance, std::vector< SpeedBumpInfoConstPtr > *speed_bumps) const
 get all speed bumps in certain range
 
int GetRoads (const apollo::common::PointENU &point, double distance, std::vector< RoadInfoConstPtr > *roads) const
 get all roads in certain range
 
int GetParkingSpaces (const apollo::common::PointENU &point, double distance, std::vector< ParkingSpaceInfoConstPtr > *parking_spaces) const
 get all parking space 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 GetNearestLaneWithDistance (const apollo::common::PointENU &point, const double distance, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
 get nearest lane from target point with search radius,
 
int GetNearestLane (const apollo::common::PointENU &point, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
 get nearest lane from target point,
 
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
 
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 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 GetRoadBoundaries (const apollo::common::PointENU &point, double radius, std::vector< RoadRoiPtr > *road_boundaries, std::vector< JunctionInfoConstPtr > *junctions) const
 get all road boundaries and junctions 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 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 stop line, return both signals.
 
int GetForwardNearestBarriersOnLane (const apollo::common::PointENU &point, const double distance, std::vector< BarrierGateInfoConstPtr > *barrier_gates) const
 get forward nearest barrier_gates within certain range on the lane
 
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
 
int GetStopSignAssociatedLanes (const Id &id, std::vector< LaneInfoConstPtr > *lanes) const
 get all lanes associated with a stop sign in the same junction
 
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 with the given region are deleted.
 
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
 
bool GetMapHeader (Header *map_header) const
 
template<class Table , class BoxTable , class KDTree >
void BuildSegmentKDTree (const Table &table, const AABoxKDTreeParams &params, BoxTable *const box_table, std::unique_ptr< KDTree > *const kdtree)
 
template<class Table , class BoxTable , class KDTree >
void BuildPolygonKDTree (const Table &table, const AABoxKDTreeParams &params, BoxTable *const box_table, std::unique_ptr< KDTree > *const kdtree)
 

详细描述

High-precision map loader implement.

在文件 hdmap_impl.h 第 59 行定义.

成员类型定义说明

◆ AreaTable

using apollo::hdmap::HDMapImpl::AreaTable = std::unordered_map<std::string, std::shared_ptr<AreaInfo> >

在文件 hdmap_impl.h 第 64 行定义.

◆ BarrierGateTable

using apollo::hdmap::HDMapImpl::BarrierGateTable = std::unordered_map<std::string, std::shared_ptr<BarrierGateInfo> >

在文件 hdmap_impl.h 第 67 行定义.

◆ ClearAreaTable

using apollo::hdmap::HDMapImpl::ClearAreaTable = std::unordered_map<std::string, std::shared_ptr<ClearAreaInfo> >

在文件 hdmap_impl.h 第 75 行定义.

◆ CrosswalkTable

using apollo::hdmap::HDMapImpl::CrosswalkTable = std::unordered_map<std::string, std::shared_ptr<CrosswalkInfo> >

在文件 hdmap_impl.h 第 69 行定义.

◆ JunctionTable

using apollo::hdmap::HDMapImpl::JunctionTable = std::unordered_map<std::string, std::shared_ptr<JunctionInfo> >

在文件 hdmap_impl.h 第 62 行定义.

◆ LaneTable

using apollo::hdmap::HDMapImpl::LaneTable = std::unordered_map<std::string, std::shared_ptr<LaneInfo> >

在文件 hdmap_impl.h 第 61 行定义.

◆ OverlapTable

using apollo::hdmap::HDMapImpl::OverlapTable = std::unordered_map<std::string, std::shared_ptr<OverlapInfo> >

在文件 hdmap_impl.h 第 79 行定义.

◆ ParkingSpaceTable

using apollo::hdmap::HDMapImpl::ParkingSpaceTable = std::unordered_map<std::string, std::shared_ptr<ParkingSpaceInfo> >

在文件 hdmap_impl.h 第 82 行定义.

◆ PNCJunctionTable

using apollo::hdmap::HDMapImpl::PNCJunctionTable = std::unordered_map<std::string, std::shared_ptr<PNCJunctionInfo> >

在文件 hdmap_impl.h 第 84 行定义.

◆ RoadTable

using apollo::hdmap::HDMapImpl::RoadTable = std::unordered_map<std::string, std::shared_ptr<RoadInfo> >

在文件 hdmap_impl.h 第 81 行定义.

◆ RSUTable

using apollo::hdmap::HDMapImpl::RSUTable = std::unordered_map<std::string, std::shared_ptr<RSUInfo> >

在文件 hdmap_impl.h 第 86 行定义.

◆ SignalTable

using apollo::hdmap::HDMapImpl::SignalTable = std::unordered_map<std::string, std::shared_ptr<SignalInfo> >

在文件 hdmap_impl.h 第 65 行定义.

◆ SpeedBumpTable

using apollo::hdmap::HDMapImpl::SpeedBumpTable = std::unordered_map<std::string, std::shared_ptr<SpeedBumpInfo> >

在文件 hdmap_impl.h 第 77 行定义.

◆ StopSignTable

using apollo::hdmap::HDMapImpl::StopSignTable = std::unordered_map<std::string, std::shared_ptr<StopSignInfo> >

在文件 hdmap_impl.h 第 71 行定义.

◆ YieldSignTable

using apollo::hdmap::HDMapImpl::YieldSignTable = std::unordered_map<std::string, std::shared_ptr<YieldSignInfo> >

在文件 hdmap_impl.h 第 73 行定义.

成员函数说明

◆ BuildPolygonKDTree()

template<class Table , class BoxTable , class KDTree >
void apollo::hdmap::HDMapImpl::BuildPolygonKDTree ( const Table &  table,
const AABoxKDTreeParams &  params,
BoxTable *const  box_table,
std::unique_ptr< KDTree > *const  kdtree 
)

在文件 hdmap_impl.cc 第 1554 行定义.

1557 {
1558 box_table->clear();
1559 for (const auto& info_with_id : table) {
1560 const auto* info = info_with_id.second.get();
1561 const auto& polygon = info->polygon();
1562 box_table->emplace_back(polygon.AABoundingBox(), info, &polygon, 0);
1563 }
1564 kdtree->reset(new KDTree(*box_table, params));
1565}

◆ BuildSegmentKDTree()

template<class Table , class BoxTable , class KDTree >
void apollo::hdmap::HDMapImpl::BuildSegmentKDTree ( const Table &  table,
const AABoxKDTreeParams &  params,
BoxTable *const  box_table,
std::unique_ptr< KDTree > *const  kdtree 
)

在文件 hdmap_impl.cc 第 1536 行定义.

1539 {
1540 box_table->clear();
1541 for (const auto& info_with_id : table) {
1542 const auto* info = info_with_id.second.get();
1543 for (size_t id = 0; id < info->segments().size(); ++id) {
1544 const auto& segment = info->segments()[id];
1545 box_table->emplace_back(
1546 apollo::common::math::AABox2d(segment.start(), segment.end()), info,
1547 &segment, id);
1548 }
1549 }
1550 kdtree->reset(new KDTree(*box_table, params));
1551}
Implements a class of (undirected) axes-aligned bounding boxes in 2-D.
Definition aabox2d.h:42

◆ CreateHDMapId()

Id apollo::hdmap::HDMapImpl::CreateHDMapId ( const std::string &  string_id) const

convert id data type

参数
string_idstring type of id
返回
proto type of id

在文件 hdmap_impl.cc 第 46 行定义.

46 {
47 Id id;
48 id.set_id(string_id);
49 return id;
50}

◆ GetAreaById()

AreaInfoConstPtr apollo::hdmap::HDMapImpl::GetAreaById ( const Id &  id) const

在文件 hdmap_impl.cc 第 191 行定义.

191 {
192 AreaTable::const_iterator it = area_table_.find(id.id());
193 return it != area_table_.end() ? it->second : nullptr;
194}

◆ GetAreas()

int apollo::hdmap::HDMapImpl::GetAreas ( const apollo::common::PointENU &  point,
double  distance,
std::vector< AreaInfoConstPtr > *  areas 
) const

get all areas in certain range

参数
pointthe central point of the range
distancethe search radius
areasstore all areas in target range
返回
0:success, otherwise failed

◆ GetBarrierGateById()

BarrierGateInfoConstPtr apollo::hdmap::HDMapImpl::GetBarrierGateById ( const Id &  id) const

在文件 hdmap_impl.cc 第 201 行定义.

201 {
202 BarrierGateTable::const_iterator it = barrier_gate_table_.find(id.id());
203 return it != barrier_gate_table_.end() ? it->second : nullptr;
204}

◆ GetBarrierGates()

int apollo::hdmap::HDMapImpl::GetBarrierGates ( const apollo::common::PointENU &  point,
double  distance,
std::vector< BarrierGateInfoConstPtr > *  barrier_gates 
) const

get all barrier_gates in certain range

参数
pointthe central point of the range
distancethe search radius
barrier_gatesstore all barrier_gates in target range
返回
0:success, otherwise failed

◆ GetClearAreaById()

ClearAreaInfoConstPtr apollo::hdmap::HDMapImpl::GetClearAreaById ( const Id &  id) const

在文件 hdmap_impl.cc 第 221 行定义.

221 {
222 ClearAreaTable::const_iterator it = clear_area_table_.find(id.id());
223 return it != clear_area_table_.end() ? it->second : nullptr;
224}

◆ GetClearAreas()

int apollo::hdmap::HDMapImpl::GetClearAreas ( const apollo::common::PointENU &  point,
double  distance,
std::vector< ClearAreaInfoConstPtr > *  clear_areas 
) const

get all clear areas in certain range

参数
pointthe central point of the range
distancethe search radius
clear_areasstore all clear areas in target range
返回
0:success, otherwise failed

◆ GetCrosswalkById()

CrosswalkInfoConstPtr apollo::hdmap::HDMapImpl::GetCrosswalkById ( const Id &  id) const

在文件 hdmap_impl.cc 第 206 行定义.

206 {
207 CrosswalkTable::const_iterator it = crosswalk_table_.find(id.id());
208 return it != crosswalk_table_.end() ? it->second : nullptr;
209}

◆ GetCrosswalks()

int apollo::hdmap::HDMapImpl::GetCrosswalks ( const apollo::common::PointENU &  point,
double  distance,
std::vector< CrosswalkInfoConstPtr > *  crosswalks 
) const

get all crosswalks in certain range

参数
pointthe central point of the range
distancethe search radius
crosswalksstore all crosswalks in target range
返回
0:success, otherwise failed

◆ GetForwardNearestBarriersOnLane()

int apollo::hdmap::HDMapImpl::GetForwardNearestBarriersOnLane ( const apollo::common::PointENU &  point,
const double  distance,
std::vector< BarrierGateInfoConstPtr > *  barrier_gates 
) const

get forward nearest barrier_gates within certain range on the lane

参数
pointthe target position
distancethe forward search distance
barrier_gatesall barrier_gates match conditions
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 1130 行定义.

1132 {
1133 CHECK_NOTNULL(barrier_gates);
1134
1135 barrier_gates->clear();
1136 LaneInfoConstPtr lane_ptr = nullptr;
1137 double nearest_s = 0.0;
1138 double nearest_l = 0.0;
1139
1140 std::vector<LaneInfoConstPtr> temp_surrounding_lanes;
1141 std::vector<LaneInfoConstPtr> surrounding_lanes;
1142 int s_index = 0;
1144 car_point.set_x(point.x());
1145 car_point.set_y(point.y());
1147 if (GetLanes(point, kLanesSearchRange, &temp_surrounding_lanes) == -1) {
1148 AINFO << "Can not find lanes around car.";
1149 return -1;
1150 }
1151 for (const auto& surround_lane : temp_surrounding_lanes) {
1152 if (surround_lane->IsOnLane(car_point)) {
1153 surrounding_lanes.push_back(surround_lane);
1154 }
1155 }
1156 if (surrounding_lanes.empty()) {
1157 AINFO << "Car is not on lane.";
1158 return -1;
1159 }
1160 for (const auto& lane : surrounding_lanes) {
1161 if (!lane->barrier_gates().empty()) {
1162 lane_ptr = lane;
1163 nearest_l =
1164 lane_ptr->DistanceTo(car_point, &map_point, &nearest_s, &s_index);
1165 break;
1166 }
1167 }
1168 if (lane_ptr == nullptr) {
1169 GetNearestLane(point, &lane_ptr, &nearest_s, &nearest_l);
1170 if (lane_ptr == nullptr) {
1171 return -1;
1172 }
1173 }
1174
1175 double unused_distance = distance + kBackwardDistance;
1176 double back_distance = kBackwardDistance;
1177 double s = nearest_s;
1178 while (s < back_distance) {
1179 for (const auto& predecessor_lane_id : lane_ptr->lane().predecessor_id()) {
1180 lane_ptr = GetLaneById(predecessor_lane_id);
1181 if (lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1182 break;
1183 }
1184 }
1185 back_distance = back_distance - s;
1186 s = lane_ptr->total_length();
1187 }
1188 double s_start = s - back_distance;
1189 while (lane_ptr != nullptr) {
1190 double barrier_min_dist = std::numeric_limits<double>::infinity();
1191 std::vector<BarrierGateInfoConstPtr> min_dist_barrier_ptr;
1192 for (const auto& overlap_id : lane_ptr->lane().overlap_id()) {
1193 OverlapInfoConstPtr overlap_ptr = GetOverlapById(overlap_id);
1194 double lane_overlap_offset_s = 0.0;
1195 BarrierGateInfoConstPtr barrier_ptr = nullptr;
1196 for (int i = 0; i < overlap_ptr->overlap().object_size(); ++i) {
1197 if (overlap_ptr->overlap().object(i).id().id() == lane_ptr->id().id()) {
1198 lane_overlap_offset_s =
1199 overlap_ptr->overlap().object(i).lane_overlap_info().start_s() -
1200 s_start;
1201 continue;
1202 }
1203 barrier_ptr = GetBarrierGateById(overlap_ptr->overlap().object(i).id());
1204 if (barrier_ptr == nullptr || lane_overlap_offset_s < 0.0) {
1205 break;
1206 }
1207 if (lane_overlap_offset_s < barrier_min_dist) {
1208 barrier_min_dist = lane_overlap_offset_s;
1209 min_dist_barrier_ptr.clear();
1210 min_dist_barrier_ptr.push_back(barrier_ptr);
1211 } else if (lane_overlap_offset_s < (barrier_min_dist + 0.1) &&
1212 lane_overlap_offset_s > (barrier_min_dist - 0.1)) {
1213 min_dist_barrier_ptr.push_back(barrier_ptr);
1214 }
1215 }
1216 }
1217 if (!min_dist_barrier_ptr.empty() && unused_distance >= barrier_min_dist) {
1218 *barrier_gates = min_dist_barrier_ptr;
1219 break;
1220 }
1221 unused_distance = unused_distance - (lane_ptr->total_length() - s_start);
1222 if (unused_distance <= 0) {
1223 break;
1224 }
1225 LaneInfoConstPtr tmp_lane_ptr = nullptr;
1226 for (const auto& successor_lane_id : lane_ptr->lane().successor_id()) {
1227 tmp_lane_ptr = GetLaneById(successor_lane_id);
1228 if (tmp_lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1229 break;
1230 }
1231 }
1232 lane_ptr = tmp_lane_ptr;
1233 s_start = 0;
1234 }
1235 return 0;
1236}
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
void set_x(const double x)
Setter for x component
Definition vec2d.h:60
double DistanceTo(const Vec2d &other) const
Returns the distance to the given vector
Definition vec2d.cc:47
void set_y(const double y)
Setter for y component
Definition vec2d.h:63
int GetNearestLane(const apollo::common::PointENU &point, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
get nearest lane from target point,
OverlapInfoConstPtr GetOverlapById(const Id &id) const
LaneInfoConstPtr GetLaneById(const Id &id) const
BarrierGateInfoConstPtr GetBarrierGateById(const Id &id) const
int GetLanes(const apollo::common::PointENU &point, double distance, std::vector< LaneInfoConstPtr > *lanes) const
get all lanes in certain range
#define AINFO
Definition log.h:42
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
std::shared_ptr< const BarrierGateInfo > BarrierGateInfoConstPtr
std::shared_ptr< const OverlapInfo > OverlapInfoConstPtr

◆ GetForwardNearestRSUs()

int apollo::hdmap::HDMapImpl::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

参数
pointthe target position
distancethe forward search distance
central_headingthe base heading
max_heading_differencethe heading range
rsusall rsus that match search conditions
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 1425 行定义.

1428 {
1429 CHECK_NOTNULL(rsus);
1430
1431 rsus->clear();
1432 LaneInfoConstPtr lane_ptr = nullptr;
1433 apollo::common::math::Vec2d target_point(point.x(), point.y());
1434
1435 double nearest_s = 0.0;
1436 double nearest_l = 0.0;
1437 if (GetNearestLaneWithHeading(target_point, distance, central_heading,
1438 max_heading_difference, &lane_ptr, &nearest_s,
1439 &nearest_l) == -1) {
1440 AERROR << "Fail to get nearest lanes";
1441 return -1;
1442 }
1443
1444 if (lane_ptr == nullptr) {
1445 AERROR << "Fail to get nearest lanes";
1446 return -1;
1447 }
1448
1449 double s = 0;
1450 double real_distance = distance + nearest_s;
1451 const std::string nearst_lane_id = lane_ptr->id().id();
1452
1453 while (s < real_distance) {
1454 s += lane_ptr->total_length();
1455 std::vector<std::pair<double, JunctionInfoConstPtr>> overlap_junctions;
1456 double start_s = 0;
1457 for (size_t x = 0; x < lane_ptr->junctions().size(); ++x) {
1458 const auto overlap_ptr = lane_ptr->junctions()[x];
1459 for (int i = 0; i < overlap_ptr->overlap().object_size(); ++i) {
1460 const auto& overlap_object = overlap_ptr->overlap().object(i);
1461 if (overlap_object.id().id() == lane_ptr->id().id()) {
1462 start_s = overlap_object.lane_overlap_info().start_s();
1463 continue;
1464 }
1465
1466 const auto junction_ptr = GetJunctionById(overlap_object.id());
1467 CHECK_NOTNULL(junction_ptr);
1468 if (nearst_lane_id == lane_ptr->id().id() &&
1469 !junction_ptr->polygon().IsPointIn(target_point)) {
1470 if (nearest_s > start_s) {
1471 continue;
1472 }
1473 }
1474
1475 overlap_junctions.push_back(std::make_pair(start_s, junction_ptr));
1476 }
1477 }
1478
1479 std::sort(overlap_junctions.begin(), overlap_junctions.end());
1480
1481 std::set<std::string> duplicate_checker;
1482 for (const auto& overlap_junction : overlap_junctions) {
1483 const auto& junction = overlap_junction.second;
1484 if (duplicate_checker.count(junction->id().id()) > 0) {
1485 continue;
1486 }
1487 duplicate_checker.insert(junction->id().id());
1488
1489 for (const auto& overlap_id : junction->junction().overlap_id()) {
1490 OverlapInfoConstPtr overlap_ptr = GetOverlapById(overlap_id);
1491 CHECK_NOTNULL(overlap_ptr);
1492 for (int i = 0; i < overlap_ptr->overlap().object_size(); ++i) {
1493 const auto& overlap_object = overlap_ptr->overlap().object(i);
1494 if (!overlap_object.has_rsu_overlap_info()) {
1495 continue;
1496 }
1497
1498 const auto rsu_ptr = GetRSUById(overlap_object.id());
1499 if (rsu_ptr != nullptr) {
1500 rsus->push_back(rsu_ptr);
1501 }
1502 }
1503 }
1504
1505 if (!rsus->empty()) {
1506 break;
1507 }
1508 }
1509
1510 if (!rsus->empty()) {
1511 break;
1512 }
1513
1514 for (const auto suc_lane_id : lane_ptr->lane().successor_id()) {
1515 LaneInfoConstPtr suc_lane_ptr = GetLaneById(suc_lane_id);
1516 if (lane_ptr->lane().successor_id_size() > 1) {
1517 if (suc_lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1518 lane_ptr = suc_lane_ptr;
1519 break;
1520 }
1521 } else {
1522 lane_ptr = suc_lane_ptr;
1523 break;
1524 }
1525 }
1526 }
1527
1528 if (rsus->empty()) {
1529 return -1;
1530 }
1531
1532 return 0;
1533}
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
JunctionInfoConstPtr GetJunctionById(const Id &id) const
RSUInfoConstPtr GetRSUById(const Id &id) const
#define AERROR
Definition log.h:44

◆ GetForwardNearestSignalsOnLane()

int apollo::hdmap::HDMapImpl::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 stop line, return both signals.

参数
pointthe target position
distancethe forward search distance
signalsall signals match conditions
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 985 行定义.

987 {
988 CHECK_NOTNULL(signals);
989
990 signals->clear();
991 LaneInfoConstPtr lane_ptr = nullptr;
992 double nearest_s = 0.0;
993 double nearest_l = 0.0;
994
995 std::vector<LaneInfoConstPtr> temp_surrounding_lanes;
996 std::vector<LaneInfoConstPtr> surrounding_lanes;
997 int s_index = 0;
999 car_point.set_x(point.x());
1000 car_point.set_y(point.y());
1002 if (GetLanes(point, kLanesSearchRange, &temp_surrounding_lanes) == -1) {
1003 AINFO << "Can not find lanes around car.";
1004 return -1;
1005 }
1006 for (const auto& surround_lane : temp_surrounding_lanes) {
1007 if (surround_lane->IsOnLane(car_point)) {
1008 surrounding_lanes.push_back(surround_lane);
1009 }
1010 }
1011 if (surrounding_lanes.empty()) {
1012 AINFO << "Car is not on lane.";
1013 return -1;
1014 }
1015 for (const auto& lane : surrounding_lanes) {
1016 if (!lane->signals().empty()) {
1017 lane_ptr = lane;
1018 nearest_l =
1019 lane_ptr->DistanceTo(car_point, &map_point, &nearest_s, &s_index);
1020 break;
1021 }
1022 }
1023 if (lane_ptr == nullptr) {
1024 GetNearestLane(point, &lane_ptr, &nearest_s, &nearest_l);
1025 if (lane_ptr == nullptr) {
1026 return -1;
1027 }
1028 }
1029
1030 double unused_distance = distance + kBackwardDistance;
1031 double back_distance = kBackwardDistance;
1032 double s = nearest_s;
1033 while (s < back_distance) {
1034 for (const auto& predecessor_lane_id : lane_ptr->lane().predecessor_id()) {
1035 lane_ptr = GetLaneById(predecessor_lane_id);
1036 if (lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1037 break;
1038 }
1039 }
1040 back_distance = back_distance - s;
1041 s = lane_ptr->total_length();
1042 }
1043 double s_start = s - back_distance;
1044 while (lane_ptr != nullptr) {
1045 double signal_min_dist = std::numeric_limits<double>::infinity();
1046 std::vector<SignalInfoConstPtr> min_dist_signal_ptr;
1047 for (const auto& overlap_id : lane_ptr->lane().overlap_id()) {
1048 OverlapInfoConstPtr overlap_ptr = GetOverlapById(overlap_id);
1049 double lane_overlap_offset_s = 0.0;
1050 SignalInfoConstPtr signal_ptr = nullptr;
1051 for (int i = 0; i < overlap_ptr->overlap().object_size(); ++i) {
1052 if (overlap_ptr->overlap().object(i).id().id() == lane_ptr->id().id()) {
1053 lane_overlap_offset_s =
1054 overlap_ptr->overlap().object(i).lane_overlap_info().start_s() -
1055 s_start;
1056 continue;
1057 }
1058 signal_ptr = GetSignalById(overlap_ptr->overlap().object(i).id());
1059 if (signal_ptr == nullptr || lane_overlap_offset_s < 0.0) {
1060 break;
1061 }
1062 if (lane_overlap_offset_s < signal_min_dist) {
1063 signal_min_dist = lane_overlap_offset_s;
1064 min_dist_signal_ptr.clear();
1065 min_dist_signal_ptr.push_back(signal_ptr);
1066 } else if (lane_overlap_offset_s < (signal_min_dist + 0.1) &&
1067 lane_overlap_offset_s > (signal_min_dist - 0.1)) {
1068 min_dist_signal_ptr.push_back(signal_ptr);
1069 }
1070 }
1071 }
1072 if (!min_dist_signal_ptr.empty() && unused_distance >= signal_min_dist) {
1073 *signals = min_dist_signal_ptr;
1074 break;
1075 }
1076 unused_distance = unused_distance - (lane_ptr->total_length() - s_start);
1077 if (unused_distance <= 0) {
1078 break;
1079 }
1080 LaneInfoConstPtr tmp_lane_ptr = nullptr;
1081 for (const auto& successor_lane_id : lane_ptr->lane().successor_id()) {
1082 tmp_lane_ptr = GetLaneById(successor_lane_id);
1083 if (tmp_lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1084 break;
1085 }
1086 }
1087 lane_ptr = tmp_lane_ptr;
1088 s_start = 0;
1089 }
1090 return 0;
1091}
SignalInfoConstPtr GetSignalById(const Id &id) const
std::shared_ptr< const SignalInfo > SignalInfoConstPtr

◆ GetJunctionById()

JunctionInfoConstPtr apollo::hdmap::HDMapImpl::GetJunctionById ( const Id &  id) const

在文件 hdmap_impl.cc 第 186 行定义.

186 {
187 JunctionTable::const_iterator it = junction_table_.find(id.id());
188 return it != junction_table_.end() ? it->second : nullptr;
189}

◆ GetJunctions()

int apollo::hdmap::HDMapImpl::GetJunctions ( const apollo::common::PointENU &  point,
double  distance,
std::vector< JunctionInfoConstPtr > *  junctions 
) const

get all junctions in certain range

参数
pointthe central point of the range
distancethe search radius
junctionsstore all junctions in target range
返回
0:success, otherwise failed

◆ GetLaneById()

LaneInfoConstPtr apollo::hdmap::HDMapImpl::GetLaneById ( const Id &  id) const

在文件 hdmap_impl.cc 第 181 行定义.

181 {
182 LaneTable::const_iterator it = lane_table_.find(id.id());
183 return it != lane_table_.end() ? it->second : nullptr;
184}

◆ GetLanes()

int apollo::hdmap::HDMapImpl::GetLanes ( const apollo::common::PointENU &  point,
double  distance,
std::vector< LaneInfoConstPtr > *  lanes 
) const

get all lanes in certain range

参数
pointthe central point of the range
distancethe search radius
lanesstore all lanes in target range
返回
0:success, otherwise failed

◆ GetLanesWithHeading()

int apollo::hdmap::HDMapImpl::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

参数
pointthe target position
distancethe search radius
central_headingthe base heading
max_heading_differencethe heading range
nearest_laneall lanes that match search conditions
返回
0:success, otherwise, failed.

◆ GetLocalMap()

int apollo::hdmap::HDMapImpl::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 with the given region are deleted.

参数
pointthe target position
rangethe size of local map region, [width, height]
local_maplocal map in proto format
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 1285 行定义.

1287 {
1288 CHECK_NOTNULL(local_map);
1289
1290 double distance = std::max(range.first, range.second);
1291 CHECK_GT(distance, 0.0);
1292
1293 std::vector<LaneInfoConstPtr> lanes;
1294 GetLanes(point, distance, &lanes);
1295
1296 std::vector<JunctionInfoConstPtr> junctions;
1297 GetJunctions(point, distance, &junctions);
1298
1299 std::vector<CrosswalkInfoConstPtr> crosswalks;
1300 GetCrosswalks(point, distance, &crosswalks);
1301
1302 std::vector<SignalInfoConstPtr> signals;
1303 GetSignals(point, distance, &signals);
1304
1305 std::vector<StopSignInfoConstPtr> stop_signs;
1306 GetStopSigns(point, distance, &stop_signs);
1307
1308 std::vector<YieldSignInfoConstPtr> yield_signs;
1309 GetYieldSigns(point, distance, &yield_signs);
1310
1311 std::vector<ClearAreaInfoConstPtr> clear_areas;
1312 GetClearAreas(point, distance, &clear_areas);
1313
1314 std::vector<SpeedBumpInfoConstPtr> speed_bumps;
1315 GetSpeedBumps(point, distance, &speed_bumps);
1316
1317 std::vector<RoadInfoConstPtr> roads;
1318 GetRoads(point, distance, &roads);
1319
1320 std::vector<ParkingSpaceInfoConstPtr> parking_spaces;
1321 GetParkingSpaces(point, distance, &parking_spaces);
1322
1323 std::unordered_set<std::string> map_element_ids;
1324 std::vector<Id> overlap_ids;
1325
1326 for (auto& lane_ptr : lanes) {
1327 map_element_ids.insert(lane_ptr->id().id());
1328 std::copy(lane_ptr->lane().overlap_id().begin(),
1329 lane_ptr->lane().overlap_id().end(),
1330 std::back_inserter(overlap_ids));
1331 *local_map->add_lane() = lane_ptr->lane();
1332 }
1333
1334 for (auto& crosswalk_ptr : crosswalks) {
1335 map_element_ids.insert(crosswalk_ptr->id().id());
1336 std::copy(crosswalk_ptr->crosswalk().overlap_id().begin(),
1337 crosswalk_ptr->crosswalk().overlap_id().end(),
1338 std::back_inserter(overlap_ids));
1339 *local_map->add_crosswalk() = crosswalk_ptr->crosswalk();
1340 }
1341
1342 for (auto& junction_ptr : junctions) {
1343 map_element_ids.insert(junction_ptr->id().id());
1344 std::copy(junction_ptr->junction().overlap_id().begin(),
1345 junction_ptr->junction().overlap_id().end(),
1346 std::back_inserter(overlap_ids));
1347 *local_map->add_junction() = junction_ptr->junction();
1348 }
1349
1350 for (auto& signal_ptr : signals) {
1351 map_element_ids.insert(signal_ptr->id().id());
1352 std::copy(signal_ptr->signal().overlap_id().begin(),
1353 signal_ptr->signal().overlap_id().end(),
1354 std::back_inserter(overlap_ids));
1355 *local_map->add_signal() = signal_ptr->signal();
1356 }
1357
1358 for (auto& stop_sign_ptr : stop_signs) {
1359 map_element_ids.insert(stop_sign_ptr->id().id());
1360 std::copy(stop_sign_ptr->stop_sign().overlap_id().begin(),
1361 stop_sign_ptr->stop_sign().overlap_id().end(),
1362 std::back_inserter(overlap_ids));
1363 *local_map->add_stop_sign() = stop_sign_ptr->stop_sign();
1364 }
1365
1366 for (auto& yield_sign_ptr : yield_signs) {
1367 std::copy(yield_sign_ptr->yield_sign().overlap_id().begin(),
1368 yield_sign_ptr->yield_sign().overlap_id().end(),
1369 std::back_inserter(overlap_ids));
1370 map_element_ids.insert(yield_sign_ptr->id().id());
1371 *local_map->add_yield() = yield_sign_ptr->yield_sign();
1372 }
1373
1374 for (auto& clear_area_ptr : clear_areas) {
1375 map_element_ids.insert(clear_area_ptr->id().id());
1376 std::copy(clear_area_ptr->clear_area().overlap_id().begin(),
1377 clear_area_ptr->clear_area().overlap_id().end(),
1378 std::back_inserter(overlap_ids));
1379 *local_map->add_clear_area() = clear_area_ptr->clear_area();
1380 }
1381
1382 for (auto& speed_bump_ptr : speed_bumps) {
1383 map_element_ids.insert(speed_bump_ptr->id().id());
1384 std::copy(speed_bump_ptr->speed_bump().overlap_id().begin(),
1385 speed_bump_ptr->speed_bump().overlap_id().end(),
1386 std::back_inserter(overlap_ids));
1387 *local_map->add_speed_bump() = speed_bump_ptr->speed_bump();
1388 }
1389
1390 for (auto& road_ptr : roads) {
1391 map_element_ids.insert(road_ptr->id().id());
1392 *local_map->add_road() = road_ptr->road();
1393 }
1394
1395 for (auto& parking_space_ptr : parking_spaces) {
1396 map_element_ids.insert(parking_space_ptr->id().id());
1397 std::copy(parking_space_ptr->parking_space().overlap_id().begin(),
1398 parking_space_ptr->parking_space().overlap_id().end(),
1399 std::back_inserter(overlap_ids));
1400 *local_map->add_parking_space() = parking_space_ptr->parking_space();
1401 }
1402
1403 for (auto& overlap_id : overlap_ids) {
1404 auto overlap_ptr = GetOverlapById(overlap_id);
1405 if (overlap_ptr == nullptr) {
1406 AERROR << "overlpa id [" << overlap_id.id() << "] is not found.";
1407 continue;
1408 }
1409
1410 bool need_delete = false;
1411 for (auto& overlap_object : overlap_ptr->overlap().object()) {
1412 if (map_element_ids.count(overlap_object.id().id()) <= 0) {
1413 need_delete = true;
1414 }
1415 }
1416
1417 if (!need_delete) {
1418 *local_map->add_overlap() = overlap_ptr->overlap();
1419 }
1420 }
1421
1422 return 0;
1423}
int GetJunctions(const apollo::common::PointENU &point, double distance, std::vector< JunctionInfoConstPtr > *junctions) const
get all junctions 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
int GetRoads(const apollo::common::PointENU &point, double distance, std::vector< RoadInfoConstPtr > *roads) const
get all roads in certain range
int GetSignals(const apollo::common::PointENU &point, double distance, std::vector< SignalInfoConstPtr > *signals) const
get all signals in certain range
int GetCrosswalks(const apollo::common::PointENU &point, double distance, std::vector< CrosswalkInfoConstPtr > *crosswalks) const
get all crosswalks in certain range
int GetClearAreas(const apollo::common::PointENU &point, double distance, std::vector< ClearAreaInfoConstPtr > *clear_areas) const
get all clear areas in certain range
int GetYieldSigns(const apollo::common::PointENU &point, double distance, std::vector< YieldSignInfoConstPtr > *yield_signs) const
get all yield signs in certain range
int GetParkingSpaces(const apollo::common::PointENU &point, double distance, std::vector< ParkingSpaceInfoConstPtr > *parking_spaces) const
get all parking space in certain range
int GetSpeedBumps(const apollo::common::PointENU &point, double distance, std::vector< SpeedBumpInfoConstPtr > *speed_bumps) const
get all speed bumps in certain range

◆ GetMapHeader()

bool apollo::hdmap::HDMapImpl::GetMapHeader ( Header *  map_header) const

在文件 hdmap_impl.cc 第 67 行定义.

67 {
68 if (!map_.has_header()) {
69 return false;
70 }
71 *map_header = map_.header();
72 return true;
73}
optional Header header
Definition map.proto:45

◆ GetNearestLane()

int apollo::hdmap::HDMapImpl::GetNearestLane ( const apollo::common::PointENU &  point,
LaneInfoConstPtr *  nearest_lane,
double *  nearest_s,
double *  nearest_l 
) const

get nearest lane from target point,

参数
pointthe target point
nearest_lanethe nearest lane that match search conditions
nearest_sthe offset from lane start point along lane center line
nearest_lthe lateral offset from lane center line
返回
0:success, otherwise, failed.

◆ GetNearestLaneWithDistance()

int apollo::hdmap::HDMapImpl::GetNearestLaneWithDistance ( const apollo::common::PointENU &  point,
const double  distance,
LaneInfoConstPtr *  nearest_lane,
double *  nearest_s,
double *  nearest_l 
) const

get nearest lane from target point with search radius,

参数
pointthe target point
distancethe search radius
nearest_lanethe nearest lane that match search conditions
nearest_sthe offset from lane start point along lane center line
nearest_lthe lateral offset from lane center line
返回
0:success, otherwise, failed.

在文件 hdmap_impl.cc 第 583 行定义.

587 {
588 return GetNearestLaneWithDistance({point.x(), point.y()}, distance,
589 nearest_lane, nearest_s, nearest_l);
590}
int GetNearestLaneWithDistance(const apollo::common::PointENU &point, const double distance, LaneInfoConstPtr *nearest_lane, double *nearest_s, double *nearest_l) const
get nearest lane from target point with search radius,

◆ GetNearestLaneWithHeading()

int apollo::hdmap::HDMapImpl::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

参数
pointthe target position
distancethe search radius
central_headingthe base heading
max_heading_differencethe heading range
nearest_lanethe nearest lane that match search conditions
nearest_sthe offset from lane start point along lane center line
nearest_lthe lateral offset from lane center line
返回
0:success, otherwise, failed.

◆ GetOverlapById()

OverlapInfoConstPtr apollo::hdmap::HDMapImpl::GetOverlapById ( const Id &  id) const

在文件 hdmap_impl.cc 第 231 行定义.

231 {
232 OverlapTable::const_iterator it = overlap_table_.find(id.id());
233 return it != overlap_table_.end() ? it->second : nullptr;
234}

◆ GetParkingSpaceById()

ParkingSpaceInfoConstPtr apollo::hdmap::HDMapImpl::GetParkingSpaceById ( const Id &  id) const

在文件 hdmap_impl.cc 第 241 行定义.

241 {
242 ParkingSpaceTable::const_iterator it = parking_space_table_.find(id.id());
243 return it != parking_space_table_.end() ? it->second : nullptr;
244}

◆ GetParkingSpaces()

int apollo::hdmap::HDMapImpl::GetParkingSpaces ( const apollo::common::PointENU &  point,
double  distance,
std::vector< ParkingSpaceInfoConstPtr > *  parking_spaces 
) const

get all parking space in certain range

参数
pointthe central point of the range
distancethe search radius
parking_spacesstore all parking spaces in target range
返回
0:success, otherwise failed

◆ GetPNCJunctionById()

PNCJunctionInfoConstPtr apollo::hdmap::HDMapImpl::GetPNCJunctionById ( const Id &  id) const

在文件 hdmap_impl.cc 第 246 行定义.

246 {
247 PNCJunctionTable::const_iterator it = pnc_junction_table_.find(id.id());
248 return it != pnc_junction_table_.end() ? it->second : nullptr;
249}

◆ GetPNCJunctions()

int apollo::hdmap::HDMapImpl::GetPNCJunctions ( const apollo::common::PointENU &  point,
double  distance,
std::vector< PNCJunctionInfoConstPtr > *  pnc_junctions 
) const

get all pnc junctions in certain range

参数
pointthe central point of the range
distancethe search radius
junctionsstore all junctions in target range
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 555 行定义.

557 {
558 return GetPNCJunctions({point.x(), point.y()}, distance, pnc_junctions);
559}
int GetPNCJunctions(const apollo::common::PointENU &point, double distance, std::vector< PNCJunctionInfoConstPtr > *pnc_junctions) const
get all pnc junctions in certain range

◆ GetRoadBoundaries() [1/2]

int apollo::hdmap::HDMapImpl::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

参数
pointthe target position
radiusthe search radius
road_boundariesthe roads' boundaries
junctionsthe junctions' boundaries
返回
0:success, otherwise failed

◆ GetRoadBoundaries() [2/2]

int apollo::hdmap::HDMapImpl::GetRoadBoundaries ( const apollo::common::PointENU &  point,
double  radius,
std::vector< RoadRoiPtr > *  road_boundaries,
std::vector< JunctionInfoConstPtr > *  junctions 
) const

get all road boundaries and junctions within certain range

参数
pointthe target position
radiusthe search radius
road_boundariesthe roads' boundaries
junctionsthe junctions
返回
0:success, otherwise failed

◆ GetRoadById()

RoadInfoConstPtr apollo::hdmap::HDMapImpl::GetRoadById ( const Id &  id) const

在文件 hdmap_impl.cc 第 236 行定义.

236 {
237 RoadTable::const_iterator it = road_table_.find(id.id());
238 return it != road_table_.end() ? it->second : nullptr;
239}

◆ GetRoads()

int apollo::hdmap::HDMapImpl::GetRoads ( const apollo::common::PointENU &  point,
double  distance,
std::vector< RoadInfoConstPtr > *  roads 
) const

get all roads in certain range

参数
pointthe central point of the range
distancethe search radius
roadsstore all roads in target range
返回
0:success, otherwise failed

◆ GetRoi()

int apollo::hdmap::HDMapImpl::GetRoi ( const apollo::common::PointENU &  point,
double  radius,
std::vector< RoadRoiPtr > *  roads_roi,
std::vector< PolygonRoiPtr > *  polygons_roi 
)

get ROI within certain range

参数
pointthe target position
radiusthe search radius
roads_roithe roads' boundaries
polygons_roithe junctions' boundaries
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 875 行定义.

877 {
878 if (roads_roi == nullptr || polygons_roi == nullptr) {
879 AERROR << "the pointer in parameter is null";
880 return -1;
881 }
882 roads_roi->clear();
883 polygons_roi->clear();
884 std::set<std::string> polygon_id_set;
885 std::vector<RoadInfoConstPtr> roads;
886 std::vector<LaneInfoConstPtr> lanes;
887 if (GetRoads(point, radius, &roads) != 0) {
888 AERROR << "can not get roads in the range.";
889 return -1;
890 }
891 if (GetLanes(point, radius, &lanes) != 0) {
892 AERROR << "can not get lanes in the range.";
893 return -1;
894 }
895 for (const auto& road_ptr : roads) {
896 // get junction polygon
897 if (road_ptr->has_junction_id()) {
898 JunctionInfoConstPtr junction_ptr =
899 GetJunctionById(road_ptr->junction_id());
900 if (polygon_id_set.find(junction_ptr->id().id()) ==
901 polygon_id_set.end()) {
902 PolygonRoiPtr polygon_roi_ptr(new PolygonRoi());
903 polygon_roi_ptr->polygon = junction_ptr->polygon();
904 polygon_roi_ptr->attribute.type = PolygonType::JUNCTION_POLYGON;
905 polygon_roi_ptr->attribute.id = junction_ptr->id();
906 polygons_roi->push_back(polygon_roi_ptr);
907 polygon_id_set.insert(junction_ptr->id().id());
908 }
909 } else {
910 // get road boundary
911 RoadRoiPtr road_boundary_ptr(new RoadRoi());
912 std::vector<apollo::hdmap::RoadBoundary> temp_roads_roi;
913 temp_roads_roi = road_ptr->GetBoundaries();
914 if (!temp_roads_roi.empty()) {
915 road_boundary_ptr->id = road_ptr->id();
916 for (const auto& temp_road_boundary : temp_roads_roi) {
917 apollo::hdmap::BoundaryPolygon boundary_polygon =
918 temp_road_boundary.outer_polygon();
919 for (const auto& edge : boundary_polygon.edge()) {
921 for (const auto& s : edge.curve().segment()) {
922 for (const auto& p : s.line_segment().point()) {
923 road_boundary_ptr->left_boundary.line_points.push_back(p);
924 }
925 }
926 }
928 for (const auto& s : edge.curve().segment()) {
929 for (const auto& p : s.line_segment().point()) {
930 road_boundary_ptr->right_boundary.line_points.push_back(p);
931 }
932 }
933 }
934 }
935 if (temp_road_boundary.hole_size() != 0) {
936 for (const auto& hole : temp_road_boundary.hole()) {
937 PolygonBoundary hole_boundary;
938 for (const auto& edge : hole.edge()) {
939 if (edge.type() == apollo::hdmap::BoundaryEdge::NORMAL) {
940 for (const auto& s : edge.curve().segment()) {
941 for (const auto& p : s.line_segment().point()) {
942 hole_boundary.polygon_points.push_back(p);
943 }
944 }
945 }
946 }
947 road_boundary_ptr->holes_boundary.push_back(hole_boundary);
948 }
949 }
950 }
951 roads_roi->push_back(road_boundary_ptr);
952 }
953 }
954 }
955
956 for (const auto& lane_ptr : lanes) {
957 // get parking space polygon
958 for (const auto& overlap_id : lane_ptr->lane().overlap_id()) {
959 OverlapInfoConstPtr overlap_ptr = GetOverlapById(overlap_id);
960 for (int i = 0; i < overlap_ptr->overlap().object_size(); ++i) {
961 if (overlap_ptr->overlap().object(i).id().id() == lane_ptr->id().id()) {
962 continue;
963 } else {
964 ParkingSpaceInfoConstPtr parkingspace_ptr =
965 GetParkingSpaceById(overlap_ptr->overlap().object(i).id());
966 if (parkingspace_ptr != nullptr) {
967 if (polygon_id_set.find(parkingspace_ptr->id().id()) ==
968 polygon_id_set.end()) {
969 PolygonRoiPtr polygon_roi_ptr(new PolygonRoi());
970 polygon_roi_ptr->polygon = parkingspace_ptr->polygon();
971 polygon_roi_ptr->attribute.type =
973 polygon_roi_ptr->attribute.id = parkingspace_ptr->id();
974 polygons_roi->push_back(polygon_roi_ptr);
975 polygon_id_set.insert(parkingspace_ptr->id().id());
976 }
977 }
978 }
979 }
980 }
981 }
982 return 0;
983}
ParkingSpaceInfoConstPtr GetParkingSpaceById(const Id &id) const
std::shared_ptr< const JunctionInfo > JunctionInfoConstPtr
std::shared_ptr< const ParkingSpaceInfo > ParkingSpaceInfoConstPtr
std::shared_ptr< PolygonRoi > PolygonRoiPtr
std::shared_ptr< RoadRoi > RoadRoiPtr

◆ GetRSUById()

RSUInfoConstPtr apollo::hdmap::HDMapImpl::GetRSUById ( const Id &  id) const

在文件 hdmap_impl.cc 第 251 行定义.

251 {
252 RSUTable::const_iterator it = rsu_table_.find(id.id());
253 return it != rsu_table_.end() ? it->second : nullptr;
254}

◆ GetSignalById()

SignalInfoConstPtr apollo::hdmap::HDMapImpl::GetSignalById ( const Id &  id) const

在文件 hdmap_impl.cc 第 196 行定义.

196 {
197 SignalTable::const_iterator it = signal_table_.find(id.id());
198 return it != signal_table_.end() ? it->second : nullptr;
199}

◆ GetSignals()

int apollo::hdmap::HDMapImpl::GetSignals ( const apollo::common::PointENU &  point,
double  distance,
std::vector< SignalInfoConstPtr > *  signals 
) const

get all signals in certain range

参数
pointthe central point of the range
distancethe search radius
signalsstore all signals in target range
返回
0:success, otherwise failed

◆ GetSpeedBumpById()

SpeedBumpInfoConstPtr apollo::hdmap::HDMapImpl::GetSpeedBumpById ( const Id &  id) const

在文件 hdmap_impl.cc 第 226 行定义.

226 {
227 SpeedBumpTable::const_iterator it = speed_bump_table_.find(id.id());
228 return it != speed_bump_table_.end() ? it->second : nullptr;
229}

◆ GetSpeedBumps()

int apollo::hdmap::HDMapImpl::GetSpeedBumps ( const apollo::common::PointENU &  point,
double  distance,
std::vector< SpeedBumpInfoConstPtr > *  speed_bumps 
) const

get all speed bumps in certain range

参数
pointthe central point of the range
distancethe search radius
speed_bumpsstore all speed bumps in target range
返回
0:success, otherwise failed

◆ GetStopSignAssociatedLanes()

int apollo::hdmap::HDMapImpl::GetStopSignAssociatedLanes ( const Id &  id,
std::vector< LaneInfoConstPtr > *  lanes 
) const

get all lanes associated with a stop sign in the same junction

参数
idid of stop sign
lanesall lanes match conditions
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 1238 行定义.

1239 {
1240 CHECK_NOTNULL(lanes);
1241
1242 const auto& stop_sign = GetStopSignById(id);
1243 if (stop_sign == nullptr) {
1244 return -1;
1245 }
1246
1247 std::vector<Id> associate_stop_sign_ids;
1248 const auto junction_ids = stop_sign->OverlapJunctionIds();
1249 for (const auto& junction_id : junction_ids) {
1250 const auto& junction = GetJunctionById(junction_id);
1251 if (junction == nullptr) {
1252 continue;
1253 }
1254 const auto stop_sign_ids = junction->OverlapStopSignIds();
1255 std::copy(stop_sign_ids.begin(), stop_sign_ids.end(),
1256 std::back_inserter(associate_stop_sign_ids));
1257 }
1258
1259 std::vector<Id> associate_lane_ids;
1260 for (const auto& stop_sign_id : associate_stop_sign_ids) {
1261 if (stop_sign_id.id() == id.id()) {
1262 // exclude current stop sign
1263 continue;
1264 }
1265 const auto& stop_sign = GetStopSignById(stop_sign_id);
1266 if (stop_sign == nullptr) {
1267 continue;
1268 }
1269 const auto lane_ids = stop_sign->OverlapLaneIds();
1270 std::copy(lane_ids.begin(), lane_ids.end(),
1271 std::back_inserter(associate_lane_ids));
1272 }
1273
1274 for (const auto lane_id : associate_lane_ids) {
1275 const auto& lane = GetLaneById(lane_id);
1276 if (lane == nullptr) {
1277 continue;
1278 }
1279 lanes->push_back(lane);
1280 }
1281
1282 return 0;
1283}
StopSignInfoConstPtr GetStopSignById(const Id &id) const

◆ GetStopSignAssociatedStopSigns()

int apollo::hdmap::HDMapImpl::GetStopSignAssociatedStopSigns ( const Id &  id,
std::vector< StopSignInfoConstPtr > *  stop_signs 
) const

get all other stop signs associated with a stop sign in the same junction

参数
idid of stop sign
stop_signsstop signs associated
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 1093 行定义.

1094 {
1095 CHECK_NOTNULL(stop_signs);
1096
1097 const auto& stop_sign = GetStopSignById(id);
1098 if (stop_sign == nullptr) {
1099 return -1;
1100 }
1101
1102 std::vector<Id> associate_stop_sign_ids;
1103 const auto junction_ids = stop_sign->OverlapJunctionIds();
1104 for (const auto& junction_id : junction_ids) {
1105 const auto& junction = GetJunctionById(junction_id);
1106 if (junction == nullptr) {
1107 continue;
1108 }
1109 const auto stop_sign_ids = junction->OverlapStopSignIds();
1110 std::copy(stop_sign_ids.begin(), stop_sign_ids.end(),
1111 std::back_inserter(associate_stop_sign_ids));
1112 }
1113
1114 std::vector<Id> associate_lane_ids;
1115 for (const auto& stop_sign_id : associate_stop_sign_ids) {
1116 if (stop_sign_id.id() == id.id()) {
1117 // exclude current stop sign
1118 continue;
1119 }
1120 const auto& stop_sign = GetStopSignById(stop_sign_id);
1121 if (stop_sign == nullptr) {
1122 continue;
1123 }
1124 stop_signs->push_back(stop_sign);
1125 }
1126
1127 return 0;
1128}

◆ GetStopSignById()

StopSignInfoConstPtr apollo::hdmap::HDMapImpl::GetStopSignById ( const Id &  id) const

在文件 hdmap_impl.cc 第 211 行定义.

211 {
212 StopSignTable::const_iterator it = stop_sign_table_.find(id.id());
213 return it != stop_sign_table_.end() ? it->second : nullptr;
214}

◆ GetStopSigns()

int apollo::hdmap::HDMapImpl::GetStopSigns ( const apollo::common::PointENU &  point,
double  distance,
std::vector< StopSignInfoConstPtr > *  stop_signs 
) const

get all stop signs in certain range

参数
pointthe central point of the range
distancethe search radius
stopsigns store all stop signs in target range
返回
0:success, otherwise failed

◆ GetYieldSignById()

YieldSignInfoConstPtr apollo::hdmap::HDMapImpl::GetYieldSignById ( const Id &  id) const

在文件 hdmap_impl.cc 第 216 行定义.

216 {
217 YieldSignTable::const_iterator it = yield_sign_table_.find(id.id());
218 return it != yield_sign_table_.end() ? it->second : nullptr;
219}

◆ GetYieldSigns()

int apollo::hdmap::HDMapImpl::GetYieldSigns ( const apollo::common::PointENU &  point,
double  distance,
std::vector< YieldSignInfoConstPtr > *  yield_signs 
) const

get all yield signs in certain range

参数
pointthe central point of the range
distancethe search radius
yieldsigns store all yield signs in target range
返回
0:success, otherwise failed

◆ LoadMapFromFile()

int apollo::hdmap::HDMapImpl::LoadMapFromFile ( const std::string &  map_filename)

load map from local file

参数
map_filenamepath of map data file
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 52 行定义.

52 {
53 Clear();
54 // TODO(All) seems map_ can be changed to a local variable of this
55 // function, but test will fail if I do so. if so.
56 if (absl::EndsWith(map_filename, ".xml")) {
57 if (!adapter::OpendriveAdapter::LoadData(map_filename, &map_)) {
58 return -1;
59 }
60 } else if (!cyber::common::GetProtoFromFile(map_filename, &map_)) {
61 return -1;
62 }
63
64 return LoadMapFromProto(map_);
65}
int LoadMapFromProto(const Map &map_proto)
load map from a protobuf message
Definition hdmap_impl.cc:75
static bool LoadData(const std::string &filename, apollo::hdmap::Map *pb_map)
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132

◆ LoadMapFromProto()

int apollo::hdmap::HDMapImpl::LoadMapFromProto ( const Map &  map_proto)

load map from a protobuf message

参数
map_protomap data in protobuf format
返回
0:success, otherwise failed

在文件 hdmap_impl.cc 第 75 行定义.

75 {
76 if (&map_proto != &map_) { // avoid an unnecessary copy
77 Clear();
78 map_ = map_proto;
79 }
80 for (const auto& lane : map_.lane()) {
81 lane_table_[lane.id().id()].reset(new LaneInfo(lane));
82 }
83 for (const auto& junction : map_.junction()) {
84 junction_table_[junction.id().id()].reset(new JunctionInfo(junction));
85 }
86
87 for (const auto& ad_area : map_.ad_area()) {
88 area_table_[ad_area.id().id()].reset(new AreaInfo(ad_area));
89 }
90
91 for (const auto& BarrierGate : map_.barrier_gate()) {
92 barrier_gate_table_[BarrierGate.id().id()].reset(
93 new BarrierGateInfo(BarrierGate));
94 }
95
96 for (const auto& signal : map_.signal()) {
97 signal_table_[signal.id().id()].reset(new SignalInfo(signal));
98 }
99 for (const auto& crosswalk : map_.crosswalk()) {
100 crosswalk_table_[crosswalk.id().id()].reset(new CrosswalkInfo(crosswalk));
101 }
102 for (const auto& stop_sign : map_.stop_sign()) {
103 stop_sign_table_[stop_sign.id().id()].reset(new StopSignInfo(stop_sign));
104 }
105 for (const auto& yield_sign : map_.yield()) {
106 yield_sign_table_[yield_sign.id().id()].reset(
107 new YieldSignInfo(yield_sign));
108 }
109 for (const auto& clear_area : map_.clear_area()) {
110 clear_area_table_[clear_area.id().id()].reset(
111 new ClearAreaInfo(clear_area));
112 }
113 for (const auto& speed_bump : map_.speed_bump()) {
114 speed_bump_table_[speed_bump.id().id()].reset(
115 new SpeedBumpInfo(speed_bump));
116 }
117 for (const auto& parking_space : map_.parking_space()) {
118 parking_space_table_[parking_space.id().id()].reset(
119 new ParkingSpaceInfo(parking_space));
120 }
121 for (const auto& pnc_junction : map_.pnc_junction()) {
122 pnc_junction_table_[pnc_junction.id().id()].reset(
123 new PNCJunctionInfo(pnc_junction));
124 }
125 for (const auto& rsu : map_.rsu()) {
126 rsu_table_[rsu.id().id()].reset(new RSUInfo(rsu));
127 }
128 for (const auto& overlap : map_.overlap()) {
129 overlap_table_[overlap.id().id()].reset(new OverlapInfo(overlap));
130 }
131
132 for (const auto& road : map_.road()) {
133 road_table_[road.id().id()].reset(new RoadInfo(road));
134 }
135 for (const auto& rsu : map_.rsu()) {
136 rsu_table_[rsu.id().id()].reset(new RSUInfo(rsu));
137 }
138 for (const auto& road_ptr_pair : road_table_) {
139 const auto& road_id = road_ptr_pair.second->id();
140 for (const auto& road_section : road_ptr_pair.second->sections()) {
141 const auto& section_id = road_section.id();
142 for (const auto& lane_id : road_section.lane_id()) {
143 auto iter = lane_table_.find(lane_id.id());
144 if (iter != lane_table_.end()) {
145 iter->second->set_road_id(road_id);
146 iter->second->set_section_id(section_id);
147 } else {
148 AFATAL << "Unknown lane id: " << lane_id.id();
149 }
150 }
151 }
152 }
153 for (const auto& lane_ptr_pair : lane_table_) {
154 lane_ptr_pair.second->PostProcess(*this);
155 }
156 for (const auto& junction_ptr_pair : junction_table_) {
157 junction_ptr_pair.second->PostProcess(*this);
158 }
159 for (const auto& stop_sign_ptr_pair : stop_sign_table_) {
160 stop_sign_ptr_pair.second->PostProcess(*this);
161 }
162 for (const auto& area_ptr_pair : area_table_) {
163 area_ptr_pair.second->PostProcess(*this);
164 }
165
166 BuildLaneSegmentKDTree();
167 BuildJunctionPolygonKDTree();
168 BuildSignalSegmentKDTree();
169 BuildCrosswalkPolygonKDTree();
170 BuildStopSignSegmentKDTree();
171 BuildYieldSignSegmentKDTree();
172 BuildClearAreaPolygonKDTree();
173 BuildSpeedBumpSegmentKDTree();
174 BuildParkingSpacePolygonKDTree();
175 BuildPNCJunctionPolygonKDTree();
176 BuildAreaPolygonKDTree();
177 BuildBarrierGateSegmentKDTree();
178 return 0;
179}
#define AFATAL
Definition log.h:45

该类的文档由以下文件生成: