Apollo 10.0
自动驾驶开放平台
vectornet_evaluator.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2021 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 <utility>
21#include <vector>
22
23#include "torch/extension.h"
24#include "torch/script.h"
27
28namespace apollo {
29namespace prediction {
30
32 public:
37
41 virtual ~VectornetEvaluator() = default;
42
46 void Clear();
47
60 ObstaclesContainer* obstacles_container,
61 torch::Tensor* ptr_target_obs_pos,
62 torch::Tensor* ptr_target_obs_pos_step,
63 torch::Tensor* ptr_vector_mask,
64 torch::Tensor* ptr_obstacle_data,
65 torch::Tensor* ptr_all_obs_p_id);
66
75 bool VectornetProcessMapData(FeatureVector *map_feature,
76 PidVector *map_p_id,
77 const int obs_num,
78 torch::Tensor* ptr_map_data,
79 torch::Tensor* ptr_all_map_p_id,
80 torch::Tensor* ptr_vector_mask);
81
87 bool Evaluate(Obstacle* obstacle_ptr,
88 ObstaclesContainer* obstacles_container) override;
89
96 Obstacle* obstacle_ptr, ObstaclesContainer* obstacles_container,
97 std::vector<std::pair<double, double>>* curr_pos_history,
98 std::vector<std::pair<double, double>>* all_obs_length,
99 std::vector<std::vector<std::pair<double, double>>>* all_obs_pos_history,
100 torch::Tensor* vector_mask);
101
105 std::string GetName() override { return "VECTORNET_EVALUATOR"; }
106
107 private:
111 void LoadModel();
112
113 private:
114 torch::jit::script::Module torch_vehicle_model_;
115 at::Tensor torch_default_output_tensor_;
116 torch::Device device_;
117 VectorNet vector_net_;
118};
119
120} // namespace prediction
121} // namespace apollo
Prediction obstacle.
Definition obstacle.h:52
virtual ~VectornetEvaluator()=default
Destructor
void Clear()
Clear obstacle feature map
bool VectornetProcessMapData(FeatureVector *map_feature, PidVector *map_p_id, const int obs_num, torch::Tensor *ptr_map_data, torch::Tensor *ptr_all_map_p_id, torch::Tensor *ptr_vector_mask)
Process map data to vector
bool Evaluate(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container) override
Override Evaluate
bool ExtractObstaclesHistory(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container, std::vector< std::pair< double, double > > *curr_pos_history, std::vector< std::pair< double, double > > *all_obs_length, std::vector< std::vector< std::pair< double, double > > > *all_obs_pos_history, torch::Tensor *vector_mask)
Extract all obstacles history
bool VectornetProcessObstaclePosition(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container, torch::Tensor *ptr_target_obs_pos, torch::Tensor *ptr_target_obs_pos_step, torch::Tensor *ptr_vector_mask, torch::Tensor *ptr_obstacle_data, torch::Tensor *ptr_all_obs_p_id)
Process obstacle position to vector
std::string GetName() override
Get the name of evaluator.
std::vector< std::vector< double > > PidVector
Definition vector_net.h:34
std::vector< std::vector< std::vector< double > > > FeatureVector
Definition vector_net.h:33
class register implement
Definition arena_queue.h:37
Define the data container base class