Apollo  6.0
Open source self driving car software
dst_type_fusion.h
Go to the documentation of this file.
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 
25 
26 namespace apollo {
27 namespace perception {
28 namespace fusion {
29 
30 struct DstMaps {
31  // dst hypothesis types
32  enum {
33  PEDESTRIAN = (1 << 0),
34  BICYCLE = (1 << 1),
35  VEHICLE = (1 << 2),
36  OTHERS_MOVABLE = (1 << 3),
37  OTHERS_UNMOVABLE = (1 << 4)
38  };
39  enum {
42  };
43 
44  std::vector<uint64_t> fod_subsets_ = {
47  std::vector<std::string> subset_names_ = {
48  "PEDESTRIAN", "BICYCLE", "VEHICLE", "OTHERS_MOVABLE",
49  "OTHERS_UNMOVABLE", "OTHERS", "UNKNOWN"};
50  std::unordered_map<size_t, uint64_t> typ_to_hyp_map_ = {
51  {static_cast<size_t>(base::ObjectType::PEDESTRIAN), PEDESTRIAN},
52  {static_cast<size_t>(base::ObjectType::BICYCLE), BICYCLE},
53  {static_cast<size_t>(base::ObjectType::VEHICLE), VEHICLE},
54  {static_cast<size_t>(base::ObjectType::UNKNOWN_MOVABLE), OTHERS_MOVABLE},
55  {static_cast<size_t>(base::ObjectType::UNKNOWN_UNMOVABLE),
57  {static_cast<size_t>(base::ObjectType::UNKNOWN), OTHERS},
58  };
59  std::map<uint64_t, size_t> hyp_to_typ_map_ = {
60  {PEDESTRIAN, static_cast<size_t>(base::ObjectType::PEDESTRIAN)},
61  {BICYCLE, static_cast<size_t>(base::ObjectType::BICYCLE)},
62  {VEHICLE, static_cast<size_t>(base::ObjectType::VEHICLE)},
63  {OTHERS_MOVABLE, static_cast<size_t>(base::ObjectType::UNKNOWN_MOVABLE)},
65  static_cast<size_t>(base::ObjectType::UNKNOWN_UNMOVABLE)},
66  {OTHERS, static_cast<size_t>(base::ObjectType::UNKNOWN)},
67  {UNKNOWN, static_cast<size_t>(base::ObjectType::UNKNOWN)}};
68 };
69 
71  std::map<std::string, double> camera_max_valid_dist_ = {
72  {"camera_smartereye", 110},
73  {"camera_front_obstacle", 110},
74  {"front_6mm", 110},
75  {"camera_front_narrow", 150},
76  };
77  std::map<std::string, double> sensor_reliability_ = {
78  {"velodyne16", 0.5}, {"velodyne64", 0.5}, {"velodyne_64", 0.5},
79  {"velodyne128", 0.5}, {"camera_smartereye", 0.95},
80  {"front_6mm", 0.95}, {"camera_front_obstacle", 0.95},
81  {"camera_front_narrow", 0.5},
82  };
83  std::map<std::string, double> sensor_reliability_for_unknown_ = {
84  {"velodyne16", 0.5}, {"velodyne64", 0.5}, {"velodyne_64", 0.5},
85  {"velodyne128", 0.5}, {"camera_smartereye", 0.2},
86  {"front_6mm", 0.2}, {"camera_front_obstacle", 0.2},
87  {"camera_front_narrow", 0.2},
88  };
89 };
90 
91 class DstTypeFusion : public BaseTypeFusion {
92  public:
93  explicit DstTypeFusion(TrackPtr track);
95 
96  // @brief: init dst application and options_
97  static bool Init();
98 
99  // @brief: update track state with measurement
100  // @param [in]: measurement
101  // @param [in]: target_timestamp
102  void UpdateWithMeasurement(const SensorObjectPtr measurement,
103  double target_timestamp) override;
104 
105  void UpdateWithoutMeasurement(const std::string &sensor_id,
106  double measurement_timestamp,
107  double target_timestamp,
108  double min_match_dist) override;
109 
110  std::string Name() const;
111 
112  private:
113  bool TypToHyp(size_t object_type, uint64_t *hypothesis_type) const;
114  bool HypToTyp(uint64_t hypothesis_type, size_t *object_type) const;
115  Dst TypeProbsToDst(const std::vector<float> &type_probs);
116  double GetReliability(const std::string &sensor_id) const;
117  double GetReliabilityForUnKnown(const std::string &sensor_id,
118  double measurement_timestamp) const;
119 
120  // Update state
121  void UpdateTypeState();
122 
123  private:
124  Dst fused_dst_;
125 
126  private:
127  static std::string name_;
128  // static const char name_[];
129  static DstMaps dst_maps_;
130  static DstTypeFusionOptions options_;
131 };
132 
133 } // namespace fusion
134 } // namespace perception
135 } // namespace apollo
Definition: dst_type_fusion.h:70
Definition: dst_type_fusion.h:40
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: dst_type_fusion.h:35
std::shared_ptr< SensorObject > SensorObjectPtr
Definition: sensor_object.h:68
Definition: base_type_fusion.h:29
std::vector< std::string > subset_names_
Definition: dst_type_fusion.h:47
std::map< uint64_t, size_t > hyp_to_typ_map_
Definition: dst_type_fusion.h:59
std::shared_ptr< Track > TrackPtr
Definition: track.h:160
Definition: dst_evidence.h:91
Definition: dst_type_fusion.h:30
bool Init(const char *binary_name)
std::unordered_map< size_t, uint64_t > typ_to_hyp_map_
Definition: dst_type_fusion.h:50
~DstTypeFusion()
Definition: dst_type_fusion.h:94
Definition: dst_type_fusion.h:41
Definition: dst_type_fusion.h:91
Definition: dst_type_fusion.h:33
Definition: dst_type_fusion.h:34
std::vector< uint64_t > fod_subsets_
Definition: dst_type_fusion.h:44