mlp_evaluator.h 3.0 KB
Newer Older
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_EVALUATOR_VEHICLE_MLP_EVALUATOR_H_
#define MODULES_PREDICTION_EVALUATOR_VEHICLE_MLP_EVALUATOR_H_
19

20
#include <memory>
21 22 23
#include <string>
#include <unordered_map>
#include <vector>
24 25

#include "modules/prediction/container/obstacles/obstacle.h"
26
#include "modules/prediction/evaluator/evaluator.h"
27
#include "modules/prediction/proto/fnn_vehicle_model.pb.h"
28
#include "modules/prediction/proto/lane_graph.pb.h"
29 30 31 32

namespace apollo {
namespace prediction {

33
class MLPEvaluator : public Evaluator {
34
 public:
35 36 37
  /**
   * @brief Constructor
   */
38
  MLPEvaluator();
39

40 41 42
  /**
   * @brief Destructor
   */
S
siyangy 已提交
43
  virtual ~MLPEvaluator() = default;
44

45 46 47 48 49 50 51 52 53 54 55
  /**
   * @brief Override Evaluate
   * @param Obstacle pointer
   */
  void Evaluate(Obstacle* obstacle_ptr) override;

  /**
   * @brief Extract feature vector
   * @param Obstacle pointer
   *        Lane Sequence pointer
   */
56 57
  void ExtractFeatureValues(Obstacle* obstacle_ptr,
                            LaneSequence* lane_sequence_ptr);
58

K
kechxu 已提交
59 60
  const std::vector<double>& feature_values() const;

61 62 63
  /**
   * @brief Clear obstacle feature map
   */
64
  void Clear();
K
kechxu 已提交
65 66

 private:
67 68 69 70 71
  /**
   * @brief Set obstacle feature vector
   * @param Obstacle pointer
   *        Feature container in a vector for receiving the feature values
   */
72
  void SetObstacleFeatureValues(Obstacle* obstacle_ptr,
K
kechxu 已提交
73 74
                                std::vector<double>* feature_values);

75 76 77 78 79 80
  /**
   * @brief Set lane feature vector
   * @param Obstacle pointer
   *        Lane sequence pointer
   *        Feature container in a vector for receiving the feature values
   */
81 82 83
  void SetLaneFeatureValues(Obstacle* obstacle_ptr,
                            LaneSequence* lane_sequence_ptr,
                            std::vector<double>* feature_values);
K
kechxu 已提交
84

85 86 87 88
  /**
   * @brief Load mode file
   * @param Model file name
   */
89 90
  void LoadModel(const std::string& model_file);

91 92 93
  /**
   * @brief Compute probability
   */
94 95
  double ComputeProbability();

K
kechxu 已提交
96 97 98 99
 private:
  std::unordered_map<int, std::vector<double>> obstacle_feature_values_map_;
  static const size_t OBSTACLE_FEATURE_SIZE = 18;
  static const size_t LANE_FEATURE_SIZE = 20;
100 101

  std::unique_ptr<FnnVehicleModel> model_ptr_;
102 103 104 105 106
};

}  // namespace prediction
}  // namespace apollo

107
#endif  // MODULES_PREDICTION_EVALUATOR_VEHICLE_MLP_EVALUATOR_H_