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

namespace apollo {
namespace prediction {

class PredictionMap {
 public:
36
  static Eigen::Vector2d PositionOnLane(
37 38 39
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info,
      const double s);

40
  static double HeadingOnLane(
41 42 43
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info,
      const double s);

44
  static double LaneTotalWidth(
45 46 47 48 49 50 51 52 53
      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);

54
  static void GetProjection(
55 56 57 58 59
      const Eigen::Vector2d& position,
      std::shared_ptr<const apollo::hdmap::LaneInfo> lane_info_ptr,
      double* s,
      double* l);

60
  static bool ProjectionFromLane(
61 62 63 64 65 66 67 68
      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,
69 70
      std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>* lanes,
      bool on_lane = true);
71

72
  static double PathHeading(
73 74 75 76 77 78 79
      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 已提交
80 81 82

  void NearbyLanesByCurrentLanes(
      const Eigen::Vector2d& point,
83 84
      double heading,
      double radius,
85 86 87
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes,
      std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>*
          nearby_lanes);
K
kechxu 已提交
88

89
  static bool IsLeftNeighborLane(
90 91
      std::shared_ptr<const apollo::hdmap::LaneInfo> left_lane,
      std::shared_ptr<const apollo::hdmap::LaneInfo> curr_lane);
K
kechxu 已提交
92

93
  static bool IsLeftNeighborLane(
94 95
      std::shared_ptr<const apollo::hdmap::LaneInfo> left_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
96

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

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

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

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

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

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

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

125
  static bool IsIdenticalLane(
126 127
      std::shared_ptr<const apollo::hdmap::LaneInfo> other_lane,
      const std::vector<std::shared_ptr<const apollo::hdmap::LaneInfo>>& lanes);
K
kechxu 已提交
128 129 130 131 132

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

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

133
  template <class MapInfo>
134
  static std::string id_string(std::shared_ptr<const MapInfo> info) {
K
kechxu 已提交
135 136
    return info->id().id();
  }
K
kechxu 已提交
137

K
kechxu 已提交
138
 private:
139 140 141
  bool LoadMap();

  std::unique_ptr<apollo::hdmap::HDMap> hdmap_ = nullptr;
K
kechxu 已提交
142 143 144 145 146 147
  DECLARE_SINGLETON(PredictionMap);
};

}  // namespace prediction
}  // namespace apollo

148
#endif  // MODULES_PREDICTION_COMMON_PREDICTION_MAP_H_