predictor_manager.h 3.2 KB
Newer Older
C
Calvin Miao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/******************************************************************************
 * 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.
 *****************************************************************************/

/**
 * @file
 * @brief Use predictor manager to manage all predictors
 */

#ifndef MODULES_PREDICTION_PREDICTOR_PREDICTOR_MANAGER_H_
#define MODULES_PREDICTION_PREDICTOR_PREDICTOR_MANAGER_H_

K
kechxu 已提交
25 26
#include <map>
#include <memory>
C
Calvin Miao 已提交
27 28 29

#include "modules/prediction/predictor/predictor.h"
#include "modules/perception/proto/perception_obstacle.pb.h"
30 31
#include "modules/prediction/proto/prediction_obstacle.pb.h"
#include "modules/prediction/proto/prediction_conf.pb.h"
C
Calvin Miao 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#include "modules/common/macro.h"

/**
 * @namespace apollo::prediction
 * @brief apollo::prediction
 */
namespace apollo {
namespace prediction {

class PredictorManager {
 public:
  /**
   * @brief Destructor
   */ 
  virtual ~PredictorManager() = default;

48 49 50 51 52 53
  /**
   * @brief Initializer
   * @param Prediction config
   */
  void Init(const PredictionConf& config);

C
Calvin Miao 已提交
54 55 56 57
  /**
   * @brief Get predictor
   * @return Pointer to the predictor
   */
58
  Predictor* GetPredictor(const ObstacleConf::PredictorType& type);
C
Calvin Miao 已提交
59

60 61 62 63
  /**
   * @brief Execute the predictor generation on perception obstacles
   * @param Perception obstacles
   */
C
Calvin Miao 已提交
64 65
  void Run(
      const ::apollo::perception::PerceptionObstacles& perception_obstacles);
C
Calvin Miao 已提交
66

67 68 69 70 71 72 73
  /**
   * @brief Get prediction obstacles
   * @return Prediction obstacles
   */
  const PredictionObstacles& prediction_obstacles();

 private:
C
Calvin Miao 已提交
74 75 76 77
  /**
   * @brief Register a predictor by type
   * @param Predictor type
   */
78 79
  void RegisterPredictor(const ObstacleConf::PredictorType& type);

C
Calvin Miao 已提交
80 81 82 83 84
  /**
   * @brief Create a predictor by type
   * @param Predictor type
   * @return A unique pointer to the predictor
   */
85 86 87
  std::unique_ptr<Predictor> CreatePredictor(
      const ObstacleConf::PredictorType& type);

C
Calvin Miao 已提交
88 89 90
  /**
   * @brief Register all predictors
   */
91 92 93
  void RegisterPredictors();

 private:
94
  std::map<ObstacleConf::PredictorType, std::unique_ptr<Predictor>> predictors_;
95

96 97 98 99 100 101 102 103 104 105 106 107
  ObstacleConf::PredictorType vehicle_on_lane_predictor_ =
      ObstacleConf::LANE_SEQUENCE_PREDICTOR;

  ObstacleConf::PredictorType vehicle_off_lane_predictor_ =
      ObstacleConf::FREE_MOVE_PREDICTOR;

  ObstacleConf::PredictorType pedestrian_predictor_ =
      ObstacleConf::REGIONAL_PREDICTOR;

  ObstacleConf::PredictorType default_predictor_ =
      ObstacleConf::FREE_MOVE_PREDICTOR;

108 109
  PredictionObstacles prediction_obstacles_;

C
Calvin Miao 已提交
110 111 112
  DECLARE_SINGLETON(PredictorManager)
};

C
Calvin Miao 已提交
113 114 115 116
}  // namespace prediction
}  // namespace apollo

#endif  // MODULES_PREDICTION_PREDICTOR_PREDICTOR_MANAGER_H_
C
Calvin Miao 已提交
117