Apollo  6.0
Open source self driving car software
prediction_map.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
24 
25 namespace apollo {
26 namespace prediction {
27 
29  public:
34  static bool Ready();
35 
43  const std::shared_ptr<const hdmap::LaneInfo> lane_info, const double s);
44 
51  static double HeadingOnLane(
52  const std::shared_ptr<const hdmap::LaneInfo> lane_info, const double s);
53 
60  static double CurvatureOnLane(const std::string& lane_id, const double s);
61 
68  static double LaneTotalWidth(
69  const std::shared_ptr<const hdmap::LaneInfo> lane_info, const double s);
70 
76  static std::shared_ptr<const hdmap::LaneInfo> LaneById(const std::string& id);
77 
83  static std::shared_ptr<const hdmap::JunctionInfo> JunctionById(
84  const std::string& id);
85 
91  static std::shared_ptr<const hdmap::OverlapInfo> OverlapById(
92  const std::string& id);
93 
101  static bool GetProjection(
102  const Eigen::Vector2d& position,
103  const std::shared_ptr<const hdmap::LaneInfo> lane_info, double* s,
104  double* l);
105 
113  static bool HasNearbyLane(const double x, const double y,
114  const double radius);
115 
123  static bool ProjectionFromLane(
124  std::shared_ptr<const hdmap::LaneInfo> lane_info, const double s,
125  hdmap::MapPathPoint* path_point);
126 
132  static bool IsVirtualLane(const std::string& lane_id);
133 
139  static bool OnVirtualLane(const Eigen::Vector2d& position,
140  const double radius);
141 
150  static void OnLane(
151  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& prev_lanes,
152  const Eigen::Vector2d& point, const double heading, const double radius,
153  const bool on_lane, const int max_num_lane,
154  const double max_lane_angle_diff,
155  std::vector<std::shared_ptr<const hdmap::LaneInfo>>* lanes);
156 
165  static std::shared_ptr<const apollo::hdmap::LaneInfo>
166  GetMostLikelyCurrentLane(const common::PointENU& position,
167  const double radius, const double heading,
168  const double angle_diff_threshold);
169 
180  const Eigen::Vector2d& ego_position, const std::string& lane_id);
181 
189  static bool NearJunction(const Eigen::Vector2d& point, const double radius);
190 
198  static bool IsPointInJunction(
199  const double x, const double y,
200  const std::shared_ptr<const hdmap::JunctionInfo> junction_info_ptr);
201 
208  static bool InJunction(const Eigen::Vector2d& point, const double radius);
209 
216  static bool IsLaneInJunction(
217  const std::shared_ptr<const hdmap::LaneInfo> lane_info,
218  const std::string& junction_id);
219 
226  static std::vector<std::shared_ptr<const apollo::hdmap::JunctionInfo>>
227  GetJunctions(const Eigen::Vector2d& point, const double radius);
228 
235  static std::vector<std::shared_ptr<const apollo::hdmap::PNCJunctionInfo>>
236  GetPNCJunctions(const Eigen::Vector2d& point, const double radius);
237 
244  static double PathHeading(std::shared_ptr<const hdmap::LaneInfo> lane_info,
245  const common::PointENU& point);
246 
256  static bool SmoothPointFromLane(const std::string& id, const double s,
257  const double l, Eigen::Vector2d* point,
258  double* heading);
259 
268  static void NearbyLanesByCurrentLanes(
269  const Eigen::Vector2d& point, const double heading, const double radius,
270  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lanes,
271  const int max_num_lane,
272  std::vector<std::shared_ptr<const hdmap::LaneInfo>>* nearby_lanes);
273 
274  static std::shared_ptr<const hdmap::LaneInfo> GetLeftNeighborLane(
275  const std::shared_ptr<const hdmap::LaneInfo>& ptr_ego_lane,
276  const Eigen::Vector2d& ego_position, const double threshold);
277 
278  static std::shared_ptr<const hdmap::LaneInfo> GetRightNeighborLane(
279  const std::shared_ptr<const hdmap::LaneInfo>& ptr_ego_lane,
280  const Eigen::Vector2d& ego_position, const double threshold);
281 
288  static std::vector<std::string> NearbyLaneIds(const Eigen::Vector2d& point,
289  const double radius);
290 
297  static bool IsLeftNeighborLane(
298  std::shared_ptr<const hdmap::LaneInfo> target_lane,
299  std::shared_ptr<const hdmap::LaneInfo> curr_lane);
300 
307  static bool IsLeftNeighborLane(
308  std::shared_ptr<const hdmap::LaneInfo> target_lane,
309  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lanes);
310 
317  static bool IsRightNeighborLane(
318  std::shared_ptr<const hdmap::LaneInfo> target_lane,
319  std::shared_ptr<const hdmap::LaneInfo> curr_lane);
320 
327  static bool IsRightNeighborLane(
328  std::shared_ptr<const hdmap::LaneInfo> target_lane,
329  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lanes);
330 
337  static bool IsSuccessorLane(
338  std::shared_ptr<const hdmap::LaneInfo> target_lane,
339  std::shared_ptr<const hdmap::LaneInfo> curr_lane);
340 
347  static bool IsSuccessorLane(
348  std::shared_ptr<const hdmap::LaneInfo> target_lane,
349  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lanes);
350 
357  static bool IsPredecessorLane(
358  std::shared_ptr<const hdmap::LaneInfo> target_lane,
359  std::shared_ptr<const hdmap::LaneInfo> curr_lane);
360 
367  static bool IsPredecessorLane(
368  std::shared_ptr<const hdmap::LaneInfo> target_lane,
369  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lanes);
370 
377  static bool IsIdenticalLane(std::shared_ptr<const hdmap::LaneInfo> other_lane,
378  std::shared_ptr<const hdmap::LaneInfo> curr_lane);
379 
386  static bool IsIdenticalLane(
387  std::shared_ptr<const hdmap::LaneInfo> other_lane,
388  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lanes);
389 
395  static int LaneTurnType(const std::string& lane_id);
396 
403  static std::vector<std::shared_ptr<const hdmap::LaneInfo>> GetNearbyLanes(
404  const common::PointENU& position, const double nearby_radius);
405 
411  static std::shared_ptr<const hdmap::LaneInfo>
413  const std::vector<std::shared_ptr<const hdmap::LaneInfo>>& lane_infos);
414 
421  static double AverageCurvature(const std::string& lane_id,
422  const size_t sample_size);
423 
424  private:
425  static std::shared_ptr<const hdmap::LaneInfo> GetNeighborLane(
426  const std::shared_ptr<const hdmap::LaneInfo>& ptr_ego_lane,
427  const Eigen::Vector2d& ego_position,
428  const std::vector<std::string>& neighbor_lane_ids,
429  const double threshold);
430 
431  PredictionMap() = delete;
432 };
433 
434 } // namespace prediction
435 } // namespace apollo
static bool Ready()
Check if map is ready.
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 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 bool IsVirtualLane(const std::string &lane_id)
Determine if a lane is a virtual lane.
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
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 bool IsProjectionApproximateWithinLane(const Eigen::Vector2d &ego_position, const std::string &lane_id)
Check whether the projection of ego vehicle is on the target lane. Note: the direction of the lane is...
Eigen::Vector2d Vector2d
Definition: base_map_fwd.h:36
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 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 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 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 PathHeading(std::shared_ptr< const hdmap::LaneInfo > lane_info, const common::PointENU &point)
Get the lane heading on a point.
Definition: prediction_map.h:28
static std::shared_ptr< const hdmap::LaneInfo > GetLeftNeighborLane(const std::shared_ptr< const hdmap::LaneInfo > &ptr_ego_lane, const Eigen::Vector2d &ego_position, const double threshold)
static std::shared_ptr< const hdmap::OverlapInfo > OverlapById(const std::string &id)
Get a shared pointer to an overlap by overlap ID.
Definition: path.h:103
static std::shared_ptr< const apollo::hdmap::LaneInfo > GetMostLikelyCurrentLane(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 double CurvatureOnLane(const std::string &lane_id, const double s)
Get the curvature of a point on a specific distance along a lane.
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 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 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 std::shared_ptr< const hdmap::LaneInfo > LaneWithSmallestAverageCurvature(const std::vector< std::shared_ptr< const hdmap::LaneInfo >> &lane_infos)
Get the pointer to the lane with the smallest average curvature.
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 HasNearbyLane(const double x, const double y, const double radius)
If there is a lane in the range with radius.
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 bool OnVirtualLane(const Eigen::Vector2d &position, const double radius)
Determine if a point is on a virtual lane.
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 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 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 std::shared_ptr< const hdmap::JunctionInfo > JunctionById(const std::string &id)
Get a shared pointer to a junction by junction ID.
static bool InJunction(const Eigen::Vector2d &point, const double radius)
Check if the obstacle is in a junction.
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.
static std::vector< std::string > NearbyLaneIds(const Eigen::Vector2d &point, const double radius)
Get nearby lanes by a position.
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 hdmap::LaneInfo > LaneById(const std::string &id)
Get a shared pointer to a lane by lane ID.
Image< uchar > * threshold(Image< T > *src, int t)
Definition: imutil.h:63
static std::shared_ptr< const hdmap::LaneInfo > GetRightNeighborLane(const std::shared_ptr< const hdmap::LaneInfo > &ptr_ego_lane, const Eigen::Vector2d &ego_position, const double threshold)
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 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 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.