Apollo 10.0
自动驾驶开放平台
apollo::prediction::PredictionMap类 参考

#include <prediction_map.h>

apollo::prediction::PredictionMap 的协作图:

静态 Public 成员函数

static bool Ready ()
 Check if map is ready
 
static Eigen::Vector2d PositionOnLane (const std::shared_ptr< const hdmap::LaneInfo > lane_info, const double s)
 Get the position of a point on a specific distance along a lane.
 
static double HeadingOnLane (const std::shared_ptr< const hdmap::LaneInfo > lane_info, const double s)
 Get the heading of a point on a specific distance along a lane.
 
static double CurvatureOnLane (const std::string &lane_id, const double s)
 Get the curvature of a point on a specific distance along a lane.
 
static double LaneTotalWidth (const std::shared_ptr< const hdmap::LaneInfo > lane_info, const double s)
 Get the width on a specified distance on a lane.
 
static std::shared_ptr< const hdmap::LaneInfoLaneById (const std::string &id)
 Get a shared pointer to a lane by lane ID.
 
static std::shared_ptr< const hdmap::JunctionInfoJunctionById (const std::string &id)
 Get a shared pointer to a junction by junction ID.
 
static std::shared_ptr< const hdmap::OverlapInfoOverlapById (const std::string &id)
 Get a shared pointer to an overlap by overlap ID.
 
static bool GetProjection (const Eigen::Vector2d &position, const std::shared_ptr< const hdmap::LaneInfo > lane_info, double *s, double *l)
 Get the frenet coordinates (s, l) on a lane by a position.
 
static bool HasNearbyLane (const double x, const double y, const double radius)
 If there is a lane in the range with radius
 
static bool ProjectionFromLane (std::shared_ptr< const hdmap::LaneInfo > lane_info, const double s, hdmap::MapPathPoint *path_point)
 Get the nearest path point to a longitudinal coordinate on a lane.
 
static bool IsVirtualLane (const std::string &lane_id)
 Determine if a lane is a virtual lane.
 
static bool OnVirtualLane (const Eigen::Vector2d &position, const double radius)
 Determine if a point is on a virtual lane.
 
static void OnLane (const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &prev_lanes, const Eigen::Vector2d &point, const double heading, const double radius, const bool on_lane, const int max_num_lane, const double max_lane_angle_diff, std::vector< std::shared_ptr< const hdmap::LaneInfo > > *lanes)
 Get the connected lanes from some specified lanes.
 
static std::shared_ptr< const apollo::hdmap::LaneInfoGetMostLikelyCurrentLane (const common::PointENU &position, const double radius, const double heading, const double angle_diff_threshold)
 Get the lane that the position is on with minimal angle diff
 
static bool IsProjectionApproximateWithinLane (const Eigen::Vector2d &ego_position, const std::string &lane_id)
 Check whether the projection of ego vehicle is on the target lane.
 
static bool NearJunction (const Eigen::Vector2d &point, const double radius)
 Check if there are any junctions within the range centered at a certain point with a radius.
 
static bool IsPointInJunction (const double x, const double y, const std::shared_ptr< const hdmap::JunctionInfo > junction_info_ptr)
 Check if a point with coord x and y is in the junction.
 
static bool InJunction (const Eigen::Vector2d &point, const double radius)
 Check if the obstacle is in a junction.
 
static bool IsLaneInJunction (const std::shared_ptr< const hdmap::LaneInfo > lane_info, const std::string &junction_id)
 Check if a lane is in a junction
 
static std::vector< std::shared_ptr< const apollo::hdmap::JunctionInfo > > GetJunctions (const Eigen::Vector2d &point, const double radius)
 Get a list of junctions given a point and a search radius
 
static std::vector< std::shared_ptr< const apollo::hdmap::PNCJunctionInfo > > GetPNCJunctions (const Eigen::Vector2d &point, const double radius)
 Get a list of junctions given a point and a search radius
 
static double PathHeading (std::shared_ptr< const hdmap::LaneInfo > lane_info, const common::PointENU &point)
 Get the lane heading on a point.
 
static bool SmoothPointFromLane (const std::string &id, const double s, const double l, Eigen::Vector2d *point, double *heading)
 Get the smooth point on a lane by a longitudinal coordinate.
 
static void NearbyLanesByCurrentLanes (const Eigen::Vector2d &point, const double heading, const double radius, const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lanes, const int max_num_lane, std::vector< std::shared_ptr< const hdmap::LaneInfo > > *nearby_lanes)
 Get nearby lanes by a position and current lanes.
 
static std::shared_ptr< const hdmap::LaneInfoGetLeftNeighborLane (const std::shared_ptr< const hdmap::LaneInfo > &ptr_ego_lane, const Eigen::Vector2d &ego_position, const double threshold)
 
static std::shared_ptr< const hdmap::LaneInfoGetRightNeighborLane (const std::shared_ptr< const hdmap::LaneInfo > &ptr_ego_lane, const Eigen::Vector2d &ego_position, const double threshold)
 
static std::vector< std::string > NearbyLaneIds (const Eigen::Vector2d &point, const double radius)
 Get nearby lanes by a position.
 
static bool IsLeftNeighborLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
 Check if a lane is a left neighbor of another lane.
 
static bool IsLeftNeighborLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lanes)
 Check if the target lane is a left neighbor of one of some lanes.
 
static bool IsRightNeighborLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
 Check if a lane is a right neighbor of another lane.
 
static bool IsRightNeighborLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lanes)
 Check if the target lane is a right neighbor of one of some lanes.
 
static bool IsSuccessorLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
 Check if the target lane is a successor of another lane.
 
static bool IsSuccessorLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lanes)
 Check if the target lane is a successor of one of some lanes.
 
static bool IsPredecessorLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
 Check if the target lane is a predecessor of another lane.
 
static bool IsPredecessorLane (std::shared_ptr< const hdmap::LaneInfo > target_lane, const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lanes)
 Check if the target lane is a predecessor of one of some lanes.
 
static bool IsIdenticalLane (std::shared_ptr< const hdmap::LaneInfo > other_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
 Check if two lanes are identical.
 
static bool IsIdenticalLane (std::shared_ptr< const hdmap::LaneInfo > other_lane, const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lanes)
 Check if a lane is identical to one of some lanes.
 
static int LaneTurnType (const std::string &lane_id)
 Get lane turn type.
 
static std::vector< std::shared_ptr< const hdmap::LaneInfo > > GetNearbyLanes (const common::PointENU &position, const double nearby_radius)
 Get all nearby lanes within certain radius given a position
 
static std::shared_ptr< const hdmap::LaneInfoLaneWithSmallestAverageCurvature (const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &lane_infos)
 Get the pointer to the lane with the smallest average curvature
 
static double AverageCurvature (const std::string &lane_id, const size_t sample_size)
 Get the average curvature along a lane with the ID lane_id
 

详细描述

在文件 prediction_map.h28 行定义.

成员函数说明

◆ AverageCurvature()

double apollo::prediction::PredictionMap::AverageCurvature ( const std::string &  lane_id,
const size_t  sample_size 
)
static

Get the average curvature along a lane with the ID lane_id

参数
TheID of the lane
Thesize of samples alone the lane to compute the average curvature
返回
The average curvature

在文件 prediction_map.cc697 行定义.

698 {
699 CHECK_GT(sample_size, 0U);
700 std::shared_ptr<const hdmap::LaneInfo> lane_info_ptr =
702 if (lane_info_ptr == nullptr) {
703 return 0.0;
704 }
705 double lane_length = lane_info_ptr->total_length();
706 double s_gap = lane_length / static_cast<double>(sample_size);
707 double curvature_sum = 0.0;
708 for (size_t i = 0; i < sample_size; ++i) {
709 double s = s_gap * static_cast<double>(i);
710 curvature_sum += std::abs(PredictionMap::CurvatureOnLane(lane_id, s));
711 }
712 return curvature_sum / static_cast<double>(sample_size);
713}
static double CurvatureOnLane(const std::string &lane_id, const double s)
Get the curvature of a point on a specific distance along a lane.
static std::shared_ptr< const hdmap::LaneInfo > LaneById(const std::string &id)
Get a shared pointer to a lane by lane ID.

◆ CurvatureOnLane()

double apollo::prediction::PredictionMap::CurvatureOnLane ( const std::string &  lane_id,
const double  s 
)
static

Get the curvature of a point on a specific distance along a lane.

参数
lane_iidThe id of the lane to get a curvature.
sThe distance along the lane.
返回
The curvature of the point.

在文件 prediction_map.cc51 行定义.

52 {
53 std::shared_ptr<const hdmap::LaneInfo> lane_info = LaneById(lane_id);
54 if (lane_info == nullptr) {
55 AERROR << "Null lane_info ptr found";
56 return 0.0;
57 }
58 return lane_info->Curvature(s);
59}
#define AERROR
Definition log.h:44

◆ GetJunctions()

std::vector< std::shared_ptr< const JunctionInfo > > apollo::prediction::PredictionMap::GetJunctions ( const Eigen::Vector2d &  point,
const double  radius 
)
static

Get a list of junctions given a point and a search radius

参数
Point
Searchradius
返回
A list of junctions

在文件 prediction_map.cc287 行定义.

288 {
289 common::PointENU hdmap_point;
290 hdmap_point.set_x(point.x());
291 hdmap_point.set_y(point.y());
292 std::vector<std::shared_ptr<const JunctionInfo>> junctions;
293 HDMapUtil::BaseMap().GetJunctions(hdmap_point, radius, &junctions);
294 return junctions;
295}
static const HDMap & BaseMap()
int GetJunctions(const apollo::common::PointENU &point, double distance, std::vector< JunctionInfoConstPtr > *junctions) const
get all junctions in certain range
Definition hdmap.cc:95

◆ GetLeftNeighborLane()

std::shared_ptr< const LaneInfo > apollo::prediction::PredictionMap::GetLeftNeighborLane ( const std::shared_ptr< const hdmap::LaneInfo > &  ptr_ego_lane,
const Eigen::Vector2d &  ego_position,
const double  threshold 
)
static

在文件 prediction_map.cc437 行定义.

439 {
440 std::vector<std::string> neighbor_ids;
441 for (const auto& lane_id :
442 ptr_ego_lane->lane().left_neighbor_forward_lane_id()) {
443 neighbor_ids.push_back(lane_id.id());
444 }
445
446 return GetNeighborLane(ptr_ego_lane, ego_position, neighbor_ids, threshold);
447}

◆ GetMostLikelyCurrentLane()

std::shared_ptr< const LaneInfo > apollo::prediction::PredictionMap::GetMostLikelyCurrentLane ( const common::PointENU position,
const double  radius,
const double  heading,
const double  angle_diff_threshold 
)
static

Get the lane that the position is on with minimal angle diff

参数
positionthe position of an obstacle
radiusThe searching radius
headingThe specified heading
angle_diff_thresholdThreshold of angle diff
返回
A pointer to a lane info

在文件 prediction_map.cc209 行定义.

211 {
212 std::vector<std::shared_ptr<const LaneInfo>> candidate_lanes;
213 if (HDMapUtil::BaseMap().GetLanesWithHeading(position, radius, heading,
214 angle_diff_threshold,
215 &candidate_lanes) != 0) {
216 return nullptr;
217 }
218 double min_angle_diff = 2.0 * M_PI;
219 std::shared_ptr<const LaneInfo> curr_lane_ptr = nullptr;
220 for (auto candidate_lane : candidate_lanes) {
221 if (!candidate_lane->IsOnLane({position.x(), position.y()})) {
222 continue;
223 }
224 double distance = 0.0;
225 common::PointENU nearest_point = candidate_lane->GetNearestPoint(
226 {position.x(), position.y()}, &distance);
227 double nearest_point_heading = PathHeading(candidate_lane, nearest_point);
228 double angle_diff =
229 std::fabs(common::math::AngleDiff(heading, nearest_point_heading));
230 if (angle_diff < min_angle_diff) {
231 min_angle_diff = angle_diff;
232 curr_lane_ptr = candidate_lane;
233 }
234 }
235 return curr_lane_ptr;
236}
static double PathHeading(std::shared_ptr< const hdmap::LaneInfo > lane_info, const common::PointENU &point)
Get the lane heading on a point.
double AngleDiff(const double from, const double to)
Calculate the difference between angle from and to
Definition math_utils.cc:61

◆ GetNearbyLanes()

std::vector< std::shared_ptr< const LaneInfo > > apollo::prediction::PredictionMap::GetNearbyLanes ( const common::PointENU position,
const double  nearby_radius 
)
static

Get all nearby lanes within certain radius given a position

参数
positionPosition in ENU frame
nearyby_radiusSearch radius around the given position
返回
All nearby lanes within the radius

在文件 prediction_map.cc660 行定义.

661 {
662 ACHECK(position.has_x() && position.has_y() && position.has_z());
663 ACHECK(nearby_radius > 0.0);
664
665 std::vector<std::shared_ptr<const LaneInfo>> nearby_lanes;
666
667 HDMapUtil::BaseMap().GetLanes(position, nearby_radius, &nearby_lanes);
668 return nearby_lanes;
669}
int GetLanes(const apollo::common::PointENU &point, double distance, std::vector< LaneInfoConstPtr > *lanes) const
get all lanes in certain range
Definition hdmap.cc:90
#define ACHECK(cond)
Definition log.h:80

◆ GetPNCJunctions()

std::vector< std::shared_ptr< const PNCJunctionInfo > > apollo::prediction::PredictionMap::GetPNCJunctions ( const Eigen::Vector2d &  point,
const double  radius 
)
static

Get a list of junctions given a point and a search radius

参数
Point
Searchradius
返回
A list of junctions

在文件 prediction_map.cc298 行定义.

299 {
300 common::PointENU hdmap_point;
301 hdmap_point.set_x(point.x());
302 hdmap_point.set_y(point.y());
303 std::vector<std::shared_ptr<const PNCJunctionInfo>> junctions;
304 HDMapUtil::BaseMap().GetPNCJunctions(hdmap_point, radius, &junctions);
305 return junctions;
306}
int GetPNCJunctions(const apollo::common::PointENU &point, double distance, std::vector< PNCJunctionInfoConstPtr > *pnc_junctions) const
get all pnc junctions in certain range
Definition hdmap.cc:155

◆ GetProjection()

bool apollo::prediction::PredictionMap::GetProjection ( const Eigen::Vector2d &  position,
const std::shared_ptr< const hdmap::LaneInfo lane_info,
double *  s,
double *  l 
)
static

Get the frenet coordinates (s, l) on a lane by a position.

参数
positionThe position to get its frenet coordinates.
lane_infoThe lane on which to get the frenet coordinates.
sThe longitudinal coordinate of the position.
lThe lateral coordinate of the position.

在文件 prediction_map.cc84 行定义.

86 {
87 if (lane_info == nullptr) {
88 return false;
89 }
90 return lane_info->GetProjection({pos.x(), pos.y()}, s, l);
91}

◆ GetRightNeighborLane()

std::shared_ptr< const LaneInfo > apollo::prediction::PredictionMap::GetRightNeighborLane ( const std::shared_ptr< const hdmap::LaneInfo > &  ptr_ego_lane,
const Eigen::Vector2d &  ego_position,
const double  threshold 
)
static

在文件 prediction_map.cc449 行定义.

451 {
452 std::vector<std::string> neighbor_ids;
453 for (const auto& lane_id :
454 ptr_ego_lane->lane().right_neighbor_forward_lane_id()) {
455 neighbor_ids.push_back(lane_id.id());
456 }
457
458 return GetNeighborLane(ptr_ego_lane, ego_position, neighbor_ids, threshold);
459}

◆ HasNearbyLane()

bool apollo::prediction::PredictionMap::HasNearbyLane ( const double  x,
const double  y,
const double  radius 
)
static

If there is a lane in the range with radius

参数
xx-axis coordinate
yy-axis coordinate
radiusrange radius
返回
If there is a lane in the range with radius

在文件 prediction_map.cc93 行定义.

94 {
95 common::PointENU point_enu;
96 point_enu.set_x(x);
97 point_enu.set_y(y);
98 std::vector<std::shared_ptr<const LaneInfo>> lanes;
99 HDMapUtil::BaseMap().GetLanes(point_enu, radius, &lanes);
100 return (!lanes.empty());
101}

◆ HeadingOnLane()

double apollo::prediction::PredictionMap::HeadingOnLane ( const std::shared_ptr< const hdmap::LaneInfo lane_info,
const double  s 
)
static

Get the heading of a point on a specific distance along a lane.

参数
lane_infoThe lane to get a heading.
sThe distance along the lane.
返回
The heading of the point.

在文件 prediction_map.cc46 行定义.

47 {
48 return lane_info->Heading(s);
49}

◆ InJunction()

bool apollo::prediction::PredictionMap::InJunction ( const Eigen::Vector2d &  point,
const double  radius 
)
static

Check if the obstacle is in a junction.

参数
pointposition
radiusthe radius to search candidate junctions
返回
If the obstacle is in a junction.

在文件 prediction_map.cc308 行定义.

309 {
310 auto junction_infos = GetJunctions(point, radius);
311 if (junction_infos.empty()) {
312 return false;
313 }
314 for (const auto junction_info : junction_infos) {
315 if (junction_info == nullptr || !junction_info->junction().has_polygon()) {
316 continue;
317 }
318 std::vector<Vec2d> vertices;
319 for (const auto& point : junction_info->junction().polygon().point()) {
320 vertices.emplace_back(point.x(), point.y());
321 }
322 if (vertices.size() < 3) {
323 continue;
324 }
325 Polygon2d junction_polygon{vertices};
326 if (junction_polygon.IsPointIn({point.x(), point.y()})) {
327 return true;
328 }
329 }
330 return false;
331}
static std::vector< std::shared_ptr< const apollo::hdmap::JunctionInfo > > GetJunctions(const Eigen::Vector2d &point, const double radius)
Get a list of junctions given a point and a search radius

◆ IsIdenticalLane() [1/2]

static bool apollo::prediction::PredictionMap::IsIdenticalLane ( std::shared_ptr< const hdmap::LaneInfo other_lane,
const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lanes 
)
static

Check if a lane is identical to one of some lanes.

参数
other_laneThe other lane.
lanesThe lanes.
返回
If other_lane is identical to one of lanes.

◆ IsIdenticalLane() [2/2]

static bool apollo::prediction::PredictionMap::IsIdenticalLane ( std::shared_ptr< const hdmap::LaneInfo other_lane,
std::shared_ptr< const hdmap::LaneInfo curr_lane 
)
static

Check if two lanes are identical.

参数
other_laneThe other lane.
curr_laneThe current lane.
返回
If other_lane is identical to curr_lane.

◆ IsLaneInJunction()

bool apollo::prediction::PredictionMap::IsLaneInJunction ( const std::shared_ptr< const hdmap::LaneInfo lane_info,
const std::string &  junction_id 
)
static

Check if a lane is in a junction

参数
lane
junctionid
返回
If the lane is in the junction

在文件 prediction_map.cc333 行定义.

335 {
336 if (lane_info == nullptr) {
337 return false;
338 }
339
340 // first, check whether the lane is virtual
341 if (!PredictionMap::IsVirtualLane(lane_info->lane().id().id())) {
342 return false;
343 }
344
345 // second, use junction from lane
346 if (lane_info->lane().has_junction_id() &&
347 lane_info->lane().junction_id().id() == junction_id) {
348 return true;
349 }
350
351 // third, use junction from road
352 auto ptr_road_info = HDMapUtil::BaseMap().GetRoadById(lane_info->road_id());
353 if (ptr_road_info->has_junction_id() &&
354 ptr_road_info->junction_id().id() == junction_id) {
355 return true;
356 }
357
358 return false;
359}
RoadInfoConstPtr GetRoadById(const Id &id) const
Definition hdmap.cc:78
static bool IsVirtualLane(const std::string &lane_id)
Determine if a lane is a virtual lane.

◆ IsLeftNeighborLane() [1/2]

static bool apollo::prediction::PredictionMap::IsLeftNeighborLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lanes 
)
static

Check if the target lane is a left neighbor of one of some lanes.

参数
target_laneThe lane to check if it is a left neighbor.
lanesThe current lanes.
返回
If left_lane is a left neighbor of one of lanes.

◆ IsLeftNeighborLane() [2/2]

static bool apollo::prediction::PredictionMap::IsLeftNeighborLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
std::shared_ptr< const hdmap::LaneInfo curr_lane 
)
static

Check if a lane is a left neighbor of another lane.

参数
target_laneThe lane to check if it is a left neighbor.
curr_laneThe current lane.
返回
If left_lane is a left neighbor of curr_lane.

◆ IsPointInJunction()

bool apollo::prediction::PredictionMap::IsPointInJunction ( const double  x,
const double  y,
const std::shared_ptr< const hdmap::JunctionInfo junction_info_ptr 
)
static

Check if a point with coord x and y is in the junction.

参数
Xaxis coordinate.
Yaxis coordinate.
Apointer to junction info.
返回
If the point is in the junction.

在文件 prediction_map.cc277 行定义.

279 {
280 if (junction_info_ptr == nullptr) {
281 return false;
282 }
283 const Polygon2d& polygon = junction_info_ptr->polygon();
284 return polygon.IsPointIn({x, y});
285}

◆ IsPredecessorLane() [1/2]

static bool apollo::prediction::PredictionMap::IsPredecessorLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lanes 
)
static

Check if the target lane is a predecessor of one of some lanes.

参数
target_laneThe lane to check if it is a predecessor.
lanesThe current lanes.
返回
If pred_lane is a predecessor of one of lanes.

◆ IsPredecessorLane() [2/2]

static bool apollo::prediction::PredictionMap::IsPredecessorLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
std::shared_ptr< const hdmap::LaneInfo curr_lane 
)
static

Check if the target lane is a predecessor of another lane.

参数
target_laneThe lane to check if it is a predecessor.
curr_laneThe current lane.
返回
If pred_lane is a predecessor of curr_lane.

◆ IsProjectionApproximateWithinLane()

bool apollo::prediction::PredictionMap::IsProjectionApproximateWithinLane ( const Eigen::Vector2d &  ego_position,
const std::string &  lane_id 
)
static

Check whether the projection of ego vehicle is on the target lane.

Note: the direction of the lane is approximated by the terminal points.

参数
ego_positionThe position of the ego vehicle
lane_idThe target lane to project
返回
true if the projection of ego vehicle is within the lane range; false otherwise.

在文件 prediction_map.cc238 行定义.

239 {
240 auto ptr_lane = LaneById(lane_id);
241 const auto& lane_points = ptr_lane->points();
242 if (lane_points.size() < 2) {
243 return false;
244 }
245
246 const auto& start_point = lane_points.front();
247 const auto& end_point = lane_points.back();
248
249 auto lane_vec = end_point - start_point;
250
251 auto approx_lane_length = lane_vec.Length();
252 if (approx_lane_length < 1.0e-3) {
253 return false;
254 }
255
256 auto dist_vec =
257 common::math::Vec2d(ego_position.x(), ego_position.y()) - start_point;
258
259 auto projection_length = dist_vec.InnerProd(lane_vec) / approx_lane_length;
260
261 if (projection_length < 0.0 || projection_length > approx_lane_length) {
262 return false;
263 }
264 return true;
265}

◆ IsRightNeighborLane() [1/2]

static bool apollo::prediction::PredictionMap::IsRightNeighborLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lanes 
)
static

Check if the target lane is a right neighbor of one of some lanes.

参数
target_laneThe lane to check if it is a right neighbor.
lanesThe current lanes.
返回
If right_lane is a right neighbor of one of lanes.

◆ IsRightNeighborLane() [2/2]

static bool apollo::prediction::PredictionMap::IsRightNeighborLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
std::shared_ptr< const hdmap::LaneInfo curr_lane 
)
static

Check if a lane is a right neighbor of another lane.

参数
target_laneThe lane to check if it is a right neighbor.
curr_laneThe current lane.
返回
If right_lane is a right neighbor of curr_lane.

◆ IsSuccessorLane() [1/2]

static bool apollo::prediction::PredictionMap::IsSuccessorLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lanes 
)
static

Check if the target lane is a successor of one of some lanes.

参数
target_laneThe lane to check if it is a successor.
lanesThe current lanes.
返回
If succ_lane is a successor of one of lanes.

◆ IsSuccessorLane() [2/2]

static bool apollo::prediction::PredictionMap::IsSuccessorLane ( std::shared_ptr< const hdmap::LaneInfo target_lane,
std::shared_ptr< const hdmap::LaneInfo curr_lane 
)
static

Check if the target lane is a successor of another lane.

参数
target_laneThe lane to check if it is a successor.
curr_laneThe current lane.
返回
If succ_lane is a successor of curr_lane.

◆ IsVirtualLane()

bool apollo::prediction::PredictionMap::IsVirtualLane ( const std::string &  lane_id)
static

Determine if a lane is a virtual lane.

参数
Thelane ID of the lane.
返回
If the lane is a virtual lane.

在文件 prediction_map.cc117 行定义.

117 {
118 std::shared_ptr<const LaneInfo> lane_info =
120 if (lane_info == nullptr) {
121 return false;
122 }
123 const hdmap::Lane& lane = lane_info->lane();
124 bool left_virtual = lane.has_left_boundary() &&
125 lane.left_boundary().has_virtual_() &&
126 lane.left_boundary().virtual_();
127 bool right_virtual = lane.has_right_boundary() &&
128 lane.right_boundary().has_virtual_() &&
129 lane.right_boundary().virtual_();
130 return left_virtual && right_virtual;
131}
LaneInfoConstPtr GetLaneById(const Id &id) const
Definition hdmap.cc:34
apollo::hdmap::Id MakeMapId(const std::string &id)
create a Map ID given a string.
Definition hdmap_util.h:85

◆ JunctionById()

std::shared_ptr< const JunctionInfo > apollo::prediction::PredictionMap::JunctionById ( const std::string &  id)
static

Get a shared pointer to a junction by junction ID.

参数
idThe ID of the target junction ID in the form of string.
返回
A shared pointer to the junction with the input junction ID.

在文件 prediction_map.cc74 行定义.

75 {
77}
JunctionInfoConstPtr GetJunctionById(const Id &id) const
Definition hdmap.cc:38

◆ LaneById()

std::shared_ptr< const LaneInfo > apollo::prediction::PredictionMap::LaneById ( const std::string &  id)
static

Get a shared pointer to a lane by lane ID.

参数
idThe ID of the target lane ID in the form of string.
返回
A shared pointer to the lane with the input lane ID.

在文件 prediction_map.cc69 行定义.

70 {
72}

◆ LaneTotalWidth()

double apollo::prediction::PredictionMap::LaneTotalWidth ( const std::shared_ptr< const hdmap::LaneInfo lane_info,
const double  s 
)
static

Get the width on a specified distance on a lane.

参数
lane_infoThe lane to get the width.
sThe distance along the lane.
返回
The width on the distance s.

在文件 prediction_map.cc61 行定义.

62 {
63 double left = 0.0;
64 double right = 0.0;
65 lane_info->GetWidth(s, &left, &right);
66 return left + right;
67}

◆ LaneTurnType()

int apollo::prediction::PredictionMap::LaneTurnType ( const std::string &  lane_id)
static

Get lane turn type.

参数
lane_idThe lane ID.
返回
Integer corresponding to the lane turn type.

在文件 prediction_map.cc652 行定义.

652 {
653 std::shared_ptr<const LaneInfo> lane = LaneById(lane_id);
654 if (lane != nullptr) {
655 return static_cast<int>(lane->lane().turn());
656 }
657 return 1;
658}

◆ LaneWithSmallestAverageCurvature()

std::shared_ptr< const LaneInfo > apollo::prediction::PredictionMap::LaneWithSmallestAverageCurvature ( const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lane_infos)
static

Get the pointer to the lane with the smallest average curvature

参数
Thevector of lane infos
返回
The pointer to the lane with the smallest average curvature

在文件 prediction_map.cc671 行定义.

672 {
673 ACHECK(!lane_infos.empty());
674 size_t sample_size = FLAGS_sample_size_for_average_lane_curvature;
675 std::shared_ptr<const hdmap::LaneInfo> selected_lane_info = lane_infos[0];
676 if (selected_lane_info == nullptr) {
677 AERROR << "Lane Vector first element: selected_lane_info is nullptr.";
678 return nullptr;
679 }
680 double smallest_curvature =
681 AverageCurvature(selected_lane_info->id().id(), sample_size);
682 for (size_t i = 1; i < lane_infos.size(); ++i) {
683 std::shared_ptr<const hdmap::LaneInfo> lane_info = lane_infos[i];
684 if (lane_info == nullptr) {
685 AWARN << "Lane vector element: one lane_info is nullptr.";
686 continue;
687 }
688 double curvature = AverageCurvature(lane_info->id().id(), sample_size);
689 if (curvature < smallest_curvature) {
690 smallest_curvature = curvature;
691 selected_lane_info = lane_info;
692 }
693 }
694 return selected_lane_info;
695}
static double AverageCurvature(const std::string &lane_id, const size_t sample_size)
Get the average curvature along a lane with the ID lane_id
#define AWARN
Definition log.h:43

◆ NearbyLaneIds()

std::vector< std::string > apollo::prediction::PredictionMap::NearbyLaneIds ( const Eigen::Vector2d &  point,
const double  radius 
)
static

Get nearby lanes by a position.

参数
pointThe position to search its nearby lanes.
radiusThe searching radius.
返回
A vector of nearby lane IDs.

在文件 prediction_map.cc491 行定义.

492 {
493 std::vector<std::string> lane_ids;
494 std::vector<std::shared_ptr<const LaneInfo>> lanes;
495 common::PointENU hdmap_point;
496 hdmap_point.set_x(point[0]);
497 hdmap_point.set_y(point[1]);
498 HDMapUtil::BaseMap().GetLanes(hdmap_point, radius, &lanes);
499 for (const auto& lane : lanes) {
500 lane_ids.push_back(lane->id().id());
501 }
502 return lane_ids;
503}

◆ NearbyLanesByCurrentLanes()

void apollo::prediction::PredictionMap::NearbyLanesByCurrentLanes ( const Eigen::Vector2d &  point,
const double  heading,
const double  radius,
const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  lanes,
const int  max_num_lane,
std::vector< std::shared_ptr< const hdmap::LaneInfo > > *  nearby_lanes 
)
static

Get nearby lanes by a position and current lanes.

参数
pointThe position to search its nearby lanes.
headingThe heading of an obstacle.
radiusThe searching radius.
lanesThe current lanes.
nearby_lanesThe searched nearby lanes.

在文件 prediction_map.cc386 行定义.

390 {
391 if (lanes.empty()) {
392 std::vector<std::shared_ptr<const LaneInfo>> prev_lanes;
393 OnLane(prev_lanes, point, heading, radius, false, max_num_lane,
394 FLAGS_max_lane_angle_diff, nearby_lanes);
395 } else {
396 std::unordered_set<std::string> lane_ids;
397 for (auto& lane_ptr : lanes) {
398 if (lane_ptr == nullptr) {
399 continue;
400 }
401 for (auto& lane_id : lane_ptr->lane().left_neighbor_forward_lane_id()) {
402 const std::string& id = lane_id.id();
403 if (lane_ids.find(id) != lane_ids.end()) {
404 continue;
405 }
406 std::shared_ptr<const LaneInfo> nearby_lane = LaneById(id);
407 double s = -1.0;
408 double l = 0.0;
409 GetProjection(point, nearby_lane, &s, &l);
410 if (s < 0.0 || s >= nearby_lane->total_length() ||
411 std::fabs(l) > radius) {
412 continue;
413 }
414 lane_ids.insert(id);
415 nearby_lanes->push_back(nearby_lane);
416 }
417 for (auto& lane_id : lane_ptr->lane().right_neighbor_forward_lane_id()) {
418 const std::string& id = lane_id.id();
419 if (lane_ids.find(id) != lane_ids.end()) {
420 continue;
421 }
422 std::shared_ptr<const LaneInfo> nearby_lane = LaneById(id);
423 double s = -1.0;
424 double l = 0.0;
425 GetProjection(point, nearby_lane, &s, &l);
426 if (s < 0.0 || s >= nearby_lane->total_length() ||
427 std::fabs(l) > radius) {
428 continue;
429 }
430 lane_ids.insert(id);
431 nearby_lanes->push_back(nearby_lane);
432 }
433 }
434 }
435}
static void OnLane(const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &prev_lanes, const Eigen::Vector2d &point, const double heading, const double radius, const bool on_lane, const int max_num_lane, const double max_lane_angle_diff, std::vector< std::shared_ptr< const hdmap::LaneInfo > > *lanes)
Get the connected lanes from some specified lanes.
static bool GetProjection(const Eigen::Vector2d &position, const std::shared_ptr< const hdmap::LaneInfo > lane_info, double *s, double *l)
Get the frenet coordinates (s, l) on a lane by a position.

◆ NearJunction()

bool apollo::prediction::PredictionMap::NearJunction ( const Eigen::Vector2d &  point,
const double  radius 
)
static

Check if there are any junctions within the range centered at a certain point with a radius.

参数
pointThe position.
radiusThe radius to search junctions.
返回
If any junctions exist.

在文件 prediction_map.cc267 行定义.

268 {
269 common::PointENU hdmap_point;
270 hdmap_point.set_x(point.x());
271 hdmap_point.set_y(point.y());
272 std::vector<std::shared_ptr<const JunctionInfo>> junctions;
273 HDMapUtil::BaseMap().GetJunctions(hdmap_point, radius, &junctions);
274 return junctions.size() > 0;
275}

◆ OnLane()

void apollo::prediction::PredictionMap::OnLane ( const std::vector< std::shared_ptr< const hdmap::LaneInfo > > &  prev_lanes,
const Eigen::Vector2d &  point,
const double  heading,
const double  radius,
const bool  on_lane,
const int  max_num_lane,
const double  max_lane_angle_diff,
std::vector< std::shared_ptr< const hdmap::LaneInfo > > *  lanes 
)
static

Get the connected lanes from some specified lanes.

参数
prev_lanesThe lanes from which to search their connected lanes.
headingThe specified heading.
radiusThe searching radius.
on_laneIf the position is on lane.
lanesThe searched lanes.

在文件 prediction_map.cc148 行定义.

153 {
154 std::vector<std::shared_ptr<const LaneInfo>> candidate_lanes;
155
156 common::PointENU hdmap_point;
157 hdmap_point.set_x(point.x());
158 hdmap_point.set_y(point.y());
159 if (HDMapUtil::BaseMap().GetLanesWithHeading(hdmap_point, radius, heading,
160 max_lane_angle_diff,
161 &candidate_lanes) != 0) {
162 return;
163 }
164
165 std::vector<std::pair<std::shared_ptr<const LaneInfo>, double>> lane_pairs;
166 for (const auto& candidate_lane : candidate_lanes) {
167 if (candidate_lane == nullptr) {
168 continue;
169 }
170 if (on_lane && !candidate_lane->IsOnLane({point.x(), point.y()})) {
171 continue;
172 }
173 if (!FLAGS_use_navigation_mode &&
174 !IsIdenticalLane(candidate_lane, prev_lanes) &&
175 !IsSuccessorLane(candidate_lane, prev_lanes) &&
176 !IsLeftNeighborLane(candidate_lane, prev_lanes) &&
177 !IsRightNeighborLane(candidate_lane, prev_lanes)) {
178 continue;
179 }
180 double distance = 0.0;
181 common::PointENU nearest_point =
182 candidate_lane->GetNearestPoint({point.x(), point.y()}, &distance);
183 double nearest_point_heading = PathHeading(candidate_lane, nearest_point);
184 double diff =
185 std::fabs(common::math::AngleDiff(heading, nearest_point_heading));
186 if (diff <= max_lane_angle_diff) {
187 lane_pairs.emplace_back(candidate_lane, diff);
188 }
189 }
190 if (lane_pairs.empty()) {
191 return;
192 }
193 std::sort(lane_pairs.begin(), lane_pairs.end(),
194 [](const std::pair<std::shared_ptr<const LaneInfo>, double>& p1,
195 const std::pair<std::shared_ptr<const LaneInfo>, double>& p2) {
196 return p1.second < p2.second;
197 });
198
199 int count = 0;
200 for (const auto& lane_pair : lane_pairs) {
201 lanes->push_back(lane_pair.first);
202 ++count;
203 if (count >= max_num_lane) {
204 break;
205 }
206 }
207}
static bool IsSuccessorLane(std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
Check if the target lane is a successor of another lane.
static bool IsIdenticalLane(std::shared_ptr< const hdmap::LaneInfo > other_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
Check if two lanes are identical.
static bool IsRightNeighborLane(std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
Check if a lane is a right neighbor of another lane.
static bool IsLeftNeighborLane(std::shared_ptr< const hdmap::LaneInfo > target_lane, std::shared_ptr< const hdmap::LaneInfo > curr_lane)
Check if a lane is a left neighbor of another lane.

◆ OnVirtualLane()

bool apollo::prediction::PredictionMap::OnVirtualLane ( const Eigen::Vector2d &  position,
const double  radius 
)
static

Determine if a point is on a virtual lane.

参数
Thepoint coordinate.
返回
If the point is on a virtual lane.

在文件 prediction_map.cc133 行定义.

134 {
135 std::vector<std::shared_ptr<const LaneInfo>> lanes;
136 common::PointENU hdmap_point;
137 hdmap_point.set_x(point[0]);
138 hdmap_point.set_y(point[1]);
139 HDMapUtil::BaseMap().GetLanes(hdmap_point, radius, &lanes);
140 for (const auto& lane : lanes) {
141 if (IsVirtualLane(lane->id().id())) {
142 return true;
143 }
144 }
145 return false;
146}

◆ OverlapById()

std::shared_ptr< const OverlapInfo > apollo::prediction::PredictionMap::OverlapById ( const std::string &  id)
static

Get a shared pointer to an overlap by overlap ID.

参数
idThe ID of the target overlap ID in the form of string.
返回
A shared pointer to the overlap with the input overlap ID.

在文件 prediction_map.cc79 行定义.

80 {
82}
OverlapInfoConstPtr GetOverlapById(const Id &id) const
Definition hdmap.cc:74

◆ PathHeading()

double apollo::prediction::PredictionMap::PathHeading ( std::shared_ptr< const hdmap::LaneInfo lane_info,
const common::PointENU point 
)
static

Get the lane heading on a point.

参数
lane_infoThe target lane.
pointThe point to get the heading.
返回
The heading of the input point on the input lane.

在文件 prediction_map.cc361 行定义.

362 {
363 double s = 0.0;
364 double l = 0.0;
365 if (lane_info->GetProjection({point.x(), point.y()}, &s, &l)) {
366 return HeadingOnLane(lane_info, s);
367 } else {
368 return M_PI;
369 }
370}
static double HeadingOnLane(const std::shared_ptr< const hdmap::LaneInfo > lane_info, const double s)
Get the heading of a point on a specific distance along a lane.

◆ PositionOnLane()

Eigen::Vector2d apollo::prediction::PredictionMap::PositionOnLane ( const std::shared_ptr< const hdmap::LaneInfo lane_info,
const double  s 
)
static

Get the position of a point on a specific distance along a lane.

参数
lane_infoThe lane to get a position.
sThe distance along the lane.
返回
The position with coordinates.

在文件 prediction_map.cc40 行定义.

41 {
42 common::PointENU point = lane_info->GetSmoothPoint(s);
43 return {point.x(), point.y()};
44}

◆ ProjectionFromLane()

bool apollo::prediction::PredictionMap::ProjectionFromLane ( std::shared_ptr< const hdmap::LaneInfo lane_info,
const double  s,
hdmap::MapPathPoint path_point 
)
static

Get the nearest path point to a longitudinal coordinate on a lane.

参数
lane_infoThe lane on which to get the projected point.
sThe longitudinal coordinate.
path_pointThe nearest path point.
Ifthe process is successful.

在文件 prediction_map.cc103 行定义.

105 {
106 if (lane_info == nullptr) {
107 return false;
108 }
109 const common::PointENU point = lane_info->GetSmoothPoint(s);
110 const double heading = HeadingOnLane(lane_info, s);
111 path_point->set_x(point.x());
112 path_point->set_y(point.y());
113 path_point->set_heading(heading);
114 return true;
115}

◆ Ready()

bool apollo::prediction::PredictionMap::Ready ( )
static

Check if map is ready

返回
True if map is ready

在文件 prediction_map.cc38 行定义.

38{ return HDMapUtil::BaseMapPtr() != nullptr; }
static const HDMap * BaseMapPtr()

◆ SmoothPointFromLane()

bool apollo::prediction::PredictionMap::SmoothPointFromLane ( const std::string &  id,
const double  s,
const double  l,
Eigen::Vector2d *  point,
double *  heading 
)
static

Get the smooth point on a lane by a longitudinal coordinate.

参数
idThe lane ID.
sThe longitudinal coordinate along the lane.
lThe lateral coordinate of the position.
pointThe point corresponding to the s,l-value coordinate.
headingThe lane heading on the point.
返回
If the process is successful.

在文件 prediction_map.cc372 行定义.

374 {
375 if (point == nullptr || heading == nullptr) {
376 return false;
377 }
378 std::shared_ptr<const LaneInfo> lane = LaneById(id);
379 common::PointENU hdmap_point = lane->GetSmoothPoint(s);
380 *heading = PathHeading(lane, hdmap_point);
381 point->x() = hdmap_point.x() - std::sin(*heading) * l;
382 point->y() = hdmap_point.y() + std::cos(*heading) * l;
383 return true;
384}

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