Apollo 11.0
自动驾驶开放平台
dst_type_fusion.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#pragma once
17
18#include <map>
19#include <string>
20#include <unordered_map>
21#include <vector>
22
23#include "cyber/common/macros.h"
26
27namespace apollo {
28namespace perception {
29namespace fusion {
30
31struct DstMaps {
32 // dst hypothesis types
33 enum {
34 PEDESTRIAN = (1 << 0),
35 BICYCLE = (1 << 1),
36 VEHICLE = (1 << 2),
37 OTHERS_MOVABLE = (1 << 3),
38 OTHERS_UNMOVABLE = (1 << 4)
39 };
40 enum {
43 };
44
48 std::vector<std::string> subset_names_ = {
49 "PEDESTRIAN", "BICYCLE", "VEHICLE", "OTHERS_MOVABLE",
50 "OTHERS_UNMOVABLE", "OTHERS", "UNKNOWN"};
51 std::unordered_map<size_t, uint64_t> typ_to_hyp_map_ = {
52 {static_cast<size_t>(base::ObjectType::PEDESTRIAN), PEDESTRIAN},
53 {static_cast<size_t>(base::ObjectType::BICYCLE), BICYCLE},
54 {static_cast<size_t>(base::ObjectType::VEHICLE), VEHICLE},
56 {static_cast<size_t>(base::ObjectType::UNKNOWN_UNMOVABLE),
58 {static_cast<size_t>(base::ObjectType::UNKNOWN), OTHERS},
59 };
60 std::map<uint64_t, size_t> hyp_to_typ_map_ = {
61 {PEDESTRIAN, static_cast<size_t>(base::ObjectType::PEDESTRIAN)},
62 {BICYCLE, static_cast<size_t>(base::ObjectType::BICYCLE)},
63 {VEHICLE, static_cast<size_t>(base::ObjectType::VEHICLE)},
66 static_cast<size_t>(base::ObjectType::UNKNOWN_UNMOVABLE)},
67 {OTHERS, static_cast<size_t>(base::ObjectType::UNKNOWN)},
68 {UNKNOWN, static_cast<size_t>(base::ObjectType::UNKNOWN)}};
69};
70
72 std::map<std::string, double> camera_max_valid_dist = {
73 {"camera_smartereye", 110}, {"camera_front_obstacle", 110},
74 {"front_6mm", 110}, {"camera_front_narrow", 150},
75 {"camera_rear", 60}, {"camera_front", 110}
76 };
77 std::map<std::string, double> sensor_reliability = {
78 {"velodyne16", 0.5},
79 {"velodyne64", 0.5},
80 {"velodyne_64", 0.5},
81 {"velodyne128", 0.5},
82 {"camera_smartereye", 0.95},
83 {"front_6mm", 0.95},
84 {"camera_front_obstacle", 0.95},
85 {"camera_front_narrow", 0.5},
86 {"camera_rear", 0.95},
87 {"camera_front", 0.95}
88 };
89 std::map<std::string, double> sensor_reliability_for_unknown = {
90 {"velodyne16", 0.5},
91 {"velodyne64", 0.5},
92 {"velodyne_64", 0.5},
93 {"velodyne128", 0.5},
94 {"camera_smartereye", 0.2},
95 {"front_6mm", 0.2},
96 {"camera_front_obstacle", 0.2},
97 {"camera_front_narrow", 0.2},
98 {"camera_rear", 0.2},
99 {"camera_front", 0.2}
100 };
101};
102
104 public:
105 explicit DstTypeFusion(TrackPtr track);
106 ~DstTypeFusion() = default;
107
108 // @brief: init dst application and options_
109 static bool Init(const TypeFusionInitOptions& options);
110
111 // @brief: update track state with measurement
112 // @param [in]: measurement
113 // @param [in]: target_timestamp
114 void UpdateWithMeasurement(const SensorObjectPtr measurement,
115 double target_timestamp) override;
116
125 void UpdateWithoutMeasurement(const std::string &sensor_id,
126 double measurement_timestamp,
127 double target_timestamp,
128 double min_match_dist) override;
129
130 std::string Name() const;
131
132 private:
141 bool TypToHyp(size_t object_type, uint64_t *hypothesis_type) const;
142
151 bool HypToTyp(uint64_t hypothesis_type, size_t *object_type) const;
152
159 Dst TypeProbsToDst(const std::vector<float> &type_probs);
160
167 double GetReliability(const std::string &sensor_id) const;
168
176 double GetReliabilityForUnKnown(const std::string &sensor_id,
177 double measurement_timestamp) const;
178
180 void UpdateTypeState();
181
182 private:
183 Dst fused_dst_;
184
185 private:
186 static std::string name_;
187 static DstMaps dst_maps_;
188 static DstTypeFusionOptions options_;
189
191};
192
193} // namespace fusion
194} // namespace perception
195} // namespace apollo
void UpdateWithoutMeasurement(const std::string &sensor_id, double measurement_timestamp, double target_timestamp, double min_match_dist) override
update track state without measurement
void UpdateWithMeasurement(const SensorObjectPtr measurement, double target_timestamp) override
update track type state with measurement
static bool Init(const TypeFusionInitOptions &options)
std::string Name() const
The name of BaseTypeFusion
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::shared_ptr< SensorObject > SensorObjectPtr
std::shared_ptr< Track > TrackPtr
Definition track.h:397
class register implement
Definition arena_queue.h:37
std::map< uint64_t, size_t > hyp_to_typ_map_
std::vector< std::string > subset_names_
std::unordered_map< size_t, uint64_t > typ_to_hyp_map_
std::vector< uint64_t > fod_subsets_
std::map< std::string, double > sensor_reliability_for_unknown
std::map< std::string, double > camera_max_valid_dist
std::map< std::string, double > sensor_reliability