Apollo  6.0
Open source self driving car software
mlp_evaluator.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
25 #include "modules/prediction/proto/fnn_vehicle_model.pb.h"
26 
27 namespace apollo {
28 namespace prediction {
29 
30 class MLPEvaluator : public Evaluator {
31  public:
35  MLPEvaluator();
36 
40  virtual ~MLPEvaluator() = default;
41 
47  bool Evaluate(Obstacle* obstacle_ptr,
48  ObstaclesContainer* obstacles_container) override;
49 
55  void ExtractFeatureValues(Obstacle* obstacle_ptr,
56  LaneSequence* lane_sequence_ptr,
57  std::vector<double>* feature_values);
58 
62  std::string GetName() override { return "MLP_EVALUATOR"; }
63 
67  void Clear();
68 
69  private:
75  void SetObstacleFeatureValues(Obstacle* obstacle_ptr,
76  std::vector<double>* feature_values);
77 
84  void SetLaneFeatureValues(Obstacle* obstacle_ptr,
85  LaneSequence* lane_sequence_ptr,
86  std::vector<double>* feature_values);
87 
92  void LoadModel(const std::string& model_file);
93 
97  double ComputeProbability(const std::vector<double>& feature_values);
98 
104  void SaveOfflineFeatures(LaneSequence* sequence,
105  const std::vector<double>& feature_values);
106 
107  private:
108  static const size_t OBSTACLE_FEATURE_SIZE = 22;
109  static const size_t LANE_FEATURE_SIZE = 40;
110 
111  std::unique_ptr<FnnVehicleModel> model_ptr_;
112 };
113 
114 } // namespace prediction
115 } // namespace apollo
Definition: mlp_evaluator.h:30
Prediction obstacle.
Definition: obstacle.h:52
Definition: obstacles_container.h:39
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
virtual ~MLPEvaluator()=default
Destructor.
std::string GetName() override
Get the name of evaluator.
Definition: mlp_evaluator.h:62
void ExtractFeatureValues(Obstacle *obstacle_ptr, LaneSequence *lane_sequence_ptr, std::vector< double > *feature_values)
Extract feature vector.
void Clear()
Clear obstacle feature map.
Obstacles container.
Definition: evaluator.h:39
bool Evaluate(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container) override
Override Evaluate.
Define the data container base class.