Apollo 10.0
自动驾驶开放平台
junction_mlp_evaluator.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 <string>
20#include <vector>
21
22#include "torch/script.h"
23#include "torch/torch.h"
24
27
28namespace apollo {
29namespace prediction {
30
32 public:
37
41 virtual ~JunctionMLPEvaluator() = default;
42
46 void Clear();
47
53 bool Evaluate(Obstacle* obstacle_ptr,
54 ObstaclesContainer* obstacles_container) override;
55
62 void ExtractFeatureValues(Obstacle* obstacle_ptr,
63 ObstaclesContainer* obstacles_container,
64 std::vector<double>* feature_values);
65
69 std::string GetName() override { return "JUNCTION_MLP_EVALUATOR"; }
70
71 private:
77 void SetObstacleFeatureValues(Obstacle* obstacle_ptr,
78 std::vector<double>* const feature_values);
79
86 void SetEgoVehicleFeatureValues(Obstacle* obstacle_ptr,
87 ObstaclesContainer* obstacles_container,
88 std::vector<double>* const feature_values);
89
95 void SetJunctionFeatureValues(Obstacle* obstacle_ptr,
96 std::vector<double>* const feature_values);
97
101 void LoadModel();
102
103 private:
104 // obstacle feature with 4 basic features and 5 frames of history position
105 static const size_t OBSTACLE_FEATURE_SIZE = 4 + 2 * 5;
106 // ego vehicle feature of position and velocity
107 static const size_t EGO_VEHICLE_FEATURE_SIZE = 4;
108 // junction feature on 12 fan area 8 dim each
109 static const size_t JUNCTION_FEATURE_SIZE = 12 * 8;
110
111 torch::jit::script::Module torch_model_;
112 torch::Device device_;
113};
114
115} // namespace prediction
116} // namespace apollo
bool Evaluate(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container) override
Override Evaluate
std::string GetName() override
Get the name of evaluator.
void ExtractFeatureValues(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container, std::vector< double > *feature_values)
Extract feature vector
virtual ~JunctionMLPEvaluator()=default
Destructor
Prediction obstacle.
Definition obstacle.h:52
class register implement
Definition arena_queue.h:37
Obstacles container
Define the data container base class