Apollo 10.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.h59 行定义.

成员类型定义说明

◆ AreaTable

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

在文件 hdmap_impl.h64 行定义.

◆ BarrierGateTable

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

在文件 hdmap_impl.h67 行定义.

◆ ClearAreaTable

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

在文件 hdmap_impl.h75 行定义.

◆ CrosswalkTable

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

在文件 hdmap_impl.h69 行定义.

◆ JunctionTable

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

在文件 hdmap_impl.h62 行定义.

◆ LaneTable

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

在文件 hdmap_impl.h61 行定义.

◆ OverlapTable

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

在文件 hdmap_impl.h79 行定义.

◆ ParkingSpaceTable

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

在文件 hdmap_impl.h82 行定义.

◆ PNCJunctionTable

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

在文件 hdmap_impl.h84 行定义.

◆ RoadTable

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

在文件 hdmap_impl.h81 行定义.

◆ RSUTable

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

在文件 hdmap_impl.h86 行定义.

◆ SignalTable

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

在文件 hdmap_impl.h65 行定义.

◆ SpeedBumpTable

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

在文件 hdmap_impl.h77 行定义.

◆ StopSignTable

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

在文件 hdmap_impl.h71 行定义.

◆ YieldSignTable

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

在文件 hdmap_impl.h73 行定义.

成员函数说明

◆ 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.cc1553 行定义.

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

◆ 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.cc1535 行定义.

1538 {
1539 box_table->clear();
1540 for (const auto& info_with_id : table) {
1541 const auto* info = info_with_id.second.get();
1542 for (size_t id = 0; id < info->segments().size(); ++id) {
1543 const auto& segment = info->segments()[id];
1544 box_table->emplace_back(
1545 apollo::common::math::AABox2d(segment.start(), segment.end()), info,
1546 &segment, id);
1547 }
1548 }
1549 kdtree->reset(new KDTree(*box_table, params));
1550}
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.cc45 行定义.

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

◆ GetAreaById()

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

在文件 hdmap_impl.cc190 行定义.

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

◆ 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.cc200 行定义.

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

◆ 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.cc220 行定义.

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

◆ 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.cc205 行定义.

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

◆ 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.cc1129 行定义.

1131 {
1132 CHECK_NOTNULL(barrier_gates);
1133
1134 barrier_gates->clear();
1135 LaneInfoConstPtr lane_ptr = nullptr;
1136 double nearest_s = 0.0;
1137 double nearest_l = 0.0;
1138
1139 std::vector<LaneInfoConstPtr> temp_surrounding_lanes;
1140 std::vector<LaneInfoConstPtr> surrounding_lanes;
1141 int s_index = 0;
1143 car_point.set_x(point.x());
1144 car_point.set_y(point.y());
1146 if (GetLanes(point, kLanesSearchRange, &temp_surrounding_lanes) == -1) {
1147 AINFO << "Can not find lanes around car.";
1148 return -1;
1149 }
1150 for (const auto& surround_lane : temp_surrounding_lanes) {
1151 if (surround_lane->IsOnLane(car_point)) {
1152 surrounding_lanes.push_back(surround_lane);
1153 }
1154 }
1155 if (surrounding_lanes.empty()) {
1156 AINFO << "Car is not on lane.";
1157 return -1;
1158 }
1159 for (const auto& lane : surrounding_lanes) {
1160 if (!lane->barrier_gates().empty()) {
1161 lane_ptr = lane;
1162 nearest_l =
1163 lane_ptr->DistanceTo(car_point, &map_point, &nearest_s, &s_index);
1164 break;
1165 }
1166 }
1167 if (lane_ptr == nullptr) {
1168 GetNearestLane(point, &lane_ptr, &nearest_s, &nearest_l);
1169 if (lane_ptr == nullptr) {
1170 return -1;
1171 }
1172 }
1173
1174 double unused_distance = distance + kBackwardDistance;
1175 double back_distance = kBackwardDistance;
1176 double s = nearest_s;
1177 while (s < back_distance) {
1178 for (const auto& predecessor_lane_id : lane_ptr->lane().predecessor_id()) {
1179 lane_ptr = GetLaneById(predecessor_lane_id);
1180 if (lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1181 break;
1182 }
1183 }
1184 back_distance = back_distance - s;
1185 s = lane_ptr->total_length();
1186 }
1187 double s_start = s - back_distance;
1188 while (lane_ptr != nullptr) {
1189 double barrier_min_dist = std::numeric_limits<double>::infinity();
1190 std::vector<BarrierGateInfoConstPtr> min_dist_barrier_ptr;
1191 for (const auto& overlap_id : lane_ptr->lane().overlap_id()) {
1192 OverlapInfoConstPtr overlap_ptr = GetOverlapById(overlap_id);
1193 double lane_overlap_offset_s = 0.0;
1194 BarrierGateInfoConstPtr barrier_ptr = nullptr;
1195 for (int i = 0; i < overlap_ptr->overlap().object_size(); ++i) {
1196 if (overlap_ptr->overlap().object(i).id().id() == lane_ptr->id().id()) {
1197 lane_overlap_offset_s =
1198 overlap_ptr->overlap().object(i).lane_overlap_info().start_s() -
1199 s_start;
1200 continue;
1201 }
1202 barrier_ptr = GetBarrierGateById(overlap_ptr->overlap().object(i).id());
1203 if (barrier_ptr == nullptr || lane_overlap_offset_s < 0.0) {
1204 break;
1205 }
1206 if (lane_overlap_offset_s < barrier_min_dist) {
1207 barrier_min_dist = lane_overlap_offset_s;
1208 min_dist_barrier_ptr.clear();
1209 min_dist_barrier_ptr.push_back(barrier_ptr);
1210 } else if (lane_overlap_offset_s < (barrier_min_dist + 0.1) &&
1211 lane_overlap_offset_s > (barrier_min_dist - 0.1)) {
1212 min_dist_barrier_ptr.push_back(barrier_ptr);
1213 }
1214 }
1215 }
1216 if (!min_dist_barrier_ptr.empty() && unused_distance >= barrier_min_dist) {
1217 *barrier_gates = min_dist_barrier_ptr;
1218 break;
1219 }
1220 unused_distance = unused_distance - (lane_ptr->total_length() - s_start);
1221 if (unused_distance <= 0) {
1222 break;
1223 }
1224 LaneInfoConstPtr tmp_lane_ptr = nullptr;
1225 for (const auto& successor_lane_id : lane_ptr->lane().successor_id()) {
1226 tmp_lane_ptr = GetLaneById(successor_lane_id);
1227 if (tmp_lane_ptr->lane().turn() == apollo::hdmap::Lane::NO_TURN) {
1228 break;
1229 }
1230 }
1231 lane_ptr = tmp_lane_ptr;
1232 s_start = 0;
1233 }
1234 return 0;
1235}
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.cc1424 行定义.

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

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

◆ GetJunctionById()

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

在文件 hdmap_impl.cc185 行定义.

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

◆ 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.cc180 行定义.

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

◆ 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.cc1284 行定义.

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

66 {
67 if (!map_.has_header()) {
68 return false;
69 }
70 *map_header = map_.header();
71 return true;
72}
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.cc582 行定义.

586 {
587 return GetNearestLaneWithDistance({point.x(), point.y()}, distance,
588 nearest_lane, nearest_s, nearest_l);
589}
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.cc230 行定义.

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

◆ GetParkingSpaceById()

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

在文件 hdmap_impl.cc240 行定义.

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

◆ 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.cc245 行定义.

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

◆ 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.cc554 行定义.

556 {
557 return GetPNCJunctions({point.x(), point.y()}, distance, pnc_junctions);
558}
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.cc235 行定义.

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

◆ 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.cc874 行定义.

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

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

◆ GetSignalById()

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

在文件 hdmap_impl.cc195 行定义.

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

◆ 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.cc225 行定义.

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

◆ 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.cc1237 行定义.

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

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

◆ GetStopSignById()

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

在文件 hdmap_impl.cc210 行定义.

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

◆ 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.cc215 行定义.

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

◆ 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.cc51 行定义.

51 {
52 Clear();
53 // TODO(All) seems map_ can be changed to a local variable of this
54 // function, but test will fail if I do so. if so.
55 if (absl::EndsWith(map_filename, ".xml")) {
56 if (!adapter::OpendriveAdapter::LoadData(map_filename, &map_)) {
57 return -1;
58 }
59 } else if (!cyber::common::GetProtoFromFile(map_filename, &map_)) {
60 return -1;
61 }
62
63 return LoadMapFromProto(map_);
64}
int LoadMapFromProto(const Map &map_proto)
load map from a protobuf message
Definition hdmap_impl.cc:74
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.cc74 行定义.

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

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