prediction_map.h 4.9 KB
Newer Older
K
kechxu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

17 18
#ifndef MODULES_PREDICTION_COMMON_PREDICTION_MAP_H_
#define MODULES_PREDICTION_COMMON_PREDICTION_MAP_H_
K
kechxu 已提交
19 20

#include <memory>
K
kechxu 已提交
21
#include <string>
K
kechxu 已提交
22
#include <vector>
K
kechxu 已提交
23

K
kechxu 已提交
24 25
#include "Eigen/Dense"

K
kechxu 已提交
26
#include "modules/common/macro.h"
K
kechxu 已提交
27
#include "modules/map/hdmap/hdmap_common.h"
28
#include "modules/map/hdmap/hdmap_impl.h"
K
kechxu 已提交
29
#include "modules/map/pnc_map/path.h"
K
kechxu 已提交
30 31 32 33 34 35 36 37

namespace apollo {
namespace prediction {

class PredictionMap {
 public:
  ~PredictionMap();

K
kechxu 已提交
38 39 40 41
  void LoadMap();

  void Clear();

K
kechxu 已提交
42 43
  apollo::hdmap::Id id(const std::string& str_id);

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
  Eigen::Vector2d PositionOnLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info,
      const double s);

  double HeadingOnLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info,
      const double s);

  double LaneTotalWidth(
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info_ptr,
      const double s);

  std::shared_ptr<const apollo::hdmap::LaneInfo> LaneById(
      const apollo::hdmap::Id& id);

  std::shared_ptr<const apollo::hdmap::LaneInfo> LaneById(
      const std::string& str_id);

  void GetProjection(
      const Eigen::Vector2d& position,
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info_ptr,
      double* s,
      double* l);

  bool ProjectionFromLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info_ptr,
      double s, apollo::hdmap::MapPathPoint* path_point);

  void OnLane(
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>&
          prev_lanes,
      const Eigen::Vector2d& point, const double heading,
      const double radius,
      std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>* lanes);

  double PathHeading(
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info_ptr,
      const apollo::common::PointENU& point);

  int SmoothPointFromLane(
      const apollo::hdmap::Id& id, const double s,
      const double l, Eigen::Vector2d* point,
      double* heading);
K
kechxu 已提交
87 88 89

  void NearbyLanesByCurrentLanes(
      const Eigen::Vector2d& point,
90 91 92
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes,
      std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>*
          nearby_lanes);
K
kechxu 已提交
93

94 95 96
  bool IsLeftNeighborLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> left_lane,
      std::shared_ptr<const apollo::hdmap::LaneInfo> curr_lane);
K
kechxu 已提交
97 98

  bool IsLeftNeighborLane(
99 100
      std::shared_ptr<const apollo::hdmap::LaneInfo> left_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
101

102 103 104
  bool IsRightNeighborLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> right_lane,
      std::shared_ptr<const apollo::hdmap::LaneInfo> curr_lane);
K
kechxu 已提交
105 106

  bool IsRightNeighborLane(
107 108
      std::shared_ptr<const apollo::hdmap::LaneInfo> right_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
109

110 111 112
  bool IsSuccessorLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> succ_lane,
      std::shared_ptr<const apollo::hdmap::LaneInfo> curr_lane);
K
kechxu 已提交
113 114

  bool IsSuccessorLane(
115 116
      std::shared_ptr<const apollo::hdmap::LaneInfo> succ_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
117

118 119 120
  bool IsPredecessorLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> pred_lane,
      std::shared_ptr<const apollo::hdmap::LaneInfo> curr_lane);
K
kechxu 已提交
121 122

  bool IsPredecessorLane(
123 124
      std::shared_ptr<const apollo::hdmap::LaneInfo> pred_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
125

126 127 128
  bool IsIdenticalLane(
      std::shared_ptr<const apollo::hdmap::LaneInfo> other_lane,
      std::shared_ptr<const apollo::hdmap::LaneInfo> curr_lane);
K
kechxu 已提交
129 130

  bool IsIdenticalLane(
131 132
      std::shared_ptr<const apollo::hdmap::LaneInfo> other_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
133 134 135 136 137

  int LaneTurnType(const apollo::hdmap::Id& id);

  int LaneTurnType(const std::string& lane_id);

138
  template <class MapInfo>
139
  std::string id_string(std::shared_ptr<const MapInfo> info) {
K
kechxu 已提交
140 141
    return info->id().id();
  }
K
kechxu 已提交
142

K
kechxu 已提交
143
 private:
S
siyangy 已提交
144
  std::unique_ptr<apollo::hdmap::HDMap> hdmap_;
K
kechxu 已提交
145 146 147 148 149 150
  DECLARE_SINGLETON(PredictionMap);
};

}  // namespace prediction
}  // namespace apollo

151
#endif  // MODULES_PREDICTION_COMMON_PREDICTION_MAP_H_