Apollo 10.0
自动驾驶开放平台
lane_aggregating_evaluator.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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
22#pragma once
23
24#include <string>
25#include <vector>
26
27#include "torch/script.h"
28#include "torch/torch.h"
29
32
37namespace apollo {
38namespace prediction {
39
41 public:
46
50 virtual ~LaneAggregatingEvaluator() = default;
51
57 bool Evaluate(Obstacle* obstacle_ptr,
58 ObstaclesContainer* obstacles_container) override;
59
63 std::string GetName() override { return "LANE_AGGREGATING_EVALUATOR"; }
64
65 private:
71 bool ExtractObstacleFeatures(const Obstacle* obstacle_ptr,
72 std::vector<double>* feature_values);
73
79 bool ExtractStaticEnvFeatures(
80 const Obstacle* obstacle_ptr, const LaneGraph* lane_graph_ptr,
81 std::vector<std::vector<double>>* feature_values,
82 std::vector<int>* lane_sequence_idx_to_remove);
83
84 torch::Tensor AggregateLaneEncodings(
85 const std::vector<torch::Tensor>& lane_encoding_list);
86
87 torch::Tensor LaneEncodingMaxPooling(
88 const std::vector<torch::Tensor>& lane_encoding_list);
89
90 torch::Tensor LaneEncodingAvgPooling(
91 const std::vector<torch::Tensor>& lane_encoding_list);
92
93 std::vector<double> StableSoftmax(
94 const std::vector<double>& prediction_scores);
95
96 void LoadModel();
97
98 private:
99 torch::jit::script::Module torch_obstacle_encoding_;
100 torch::jit::script::Module torch_lane_encoding_;
101 torch::jit::script::Module torch_prediction_layer_;
102 torch::Device device_;
103
104 static const size_t OBSTACLE_FEATURE_SIZE = 20 * 9;
105 static const size_t SINGLE_LANE_FEATURE_SIZE = 4;
106 static const size_t LANE_POINTS_SIZE = 100; // 50m
107 static const size_t BACKWARD_LANE_POINTS_SIZE = 50; // 25m
108
109 static const size_t OBSTACLE_ENCODING_SIZE = 128;
110 static const size_t SINGLE_LANE_ENCODING_SIZE = 128;
111 static const size_t AGGREGATED_ENCODING_SIZE = 256;
112};
113
114} // namespace prediction
115} // namespace apollo
virtual ~LaneAggregatingEvaluator()=default
Destructor
std::string GetName() override
Get the name of evaluator.
bool Evaluate(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container) override
Override Evaluate
Prediction obstacle.
Definition obstacle.h:52
class register implement
Definition arena_queue.h:37
Obstacles container
Define the data container base class