prediction_map.h 5.0 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
  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,
77 78
      std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>* lanes,
      bool on_lane = true);
79 80 81 82 83 84 85 86 87

  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 已提交
88 89 90

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}  // namespace prediction
}  // namespace apollo

154
#endif  // MODULES_PREDICTION_COMMON_PREDICTION_MAP_H_