Apollo  6.0
Open source self driving car software
base_matcher.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 <string>
19 #include <utility>
20 #include <vector>
21 
22 #include "gtest/gtest_prod.h"
23 
24 #include "cyber/common/macros.h"
29 
30 namespace apollo {
31 namespace perception {
32 namespace radar {
33 typedef std::pair<size_t, size_t> TrackObjectPair;
34 
37 };
38 
39 class BaseMatcher {
40  public:
41  BaseMatcher() : name_("BaseMatcher") {}
42  virtual ~BaseMatcher() {}
43  virtual bool Init() { return true; }
44  // @brief match radar objects to tracks
45  // @params[IN] radar_tracks: global tracks
46  // @params[IN] radar_frame: current radar frame
47  // @params[IN] options: matcher options for future use
48  // @params[OUT] assignments: matched pair of tracks and measurements
49  // @params[OUT] unassigned_tracks: unmatched tracks
50  // @params[OUT] unassigned_objects: unmatched objects
51  // @return nothing
52  virtual bool Match(const std::vector<RadarTrackPtr> &radar_tracks,
53  const base::Frame &radar_frame,
54  const TrackObjectMatcherOptions &options,
55  std::vector<TrackObjectPair> *assignments,
56  std::vector<size_t> *unassigned_tracks,
57  std::vector<size_t> *unassigned_objects) {
58  return true;
59  }
60  virtual void IDMatch(const std::vector<RadarTrackPtr> &radar_tracks,
61  const base::Frame &radar_frame,
62  std::vector<TrackObjectPair> *assignments,
63  std::vector<size_t> *unassigned_tracks,
64  std::vector<size_t> *unassigned_objects);
65  static void SetMaxMatchDistance(double dist);
66  static double GetMaxMatchDistance();
67  static void SetBoundMatchDistance(double dist);
68  static double GetBoundMatchDistance();
69  virtual std::string Name() { return name_; }
70 
71  protected:
72  std::string name_;
73  static double s_max_match_distance_;
74  static double s_bound_match_distance_;
75  virtual bool RefinedTrack(const base::ObjectPtr &track_object,
76  double track_timestamp,
77  const base::ObjectPtr &radar_object,
78  double radar_timestamp);
79  FRIEND_TEST(BaseMatcherTest, base_matcher_test);
80 
81  private:
83 };
84 
86 #define PERCEPTION_REGISTER_MATCHER(name) \
87  PERCEPTION_REGISTER_CLASS(BaseMatcher, name)
88 
89 } // namespace radar
90 } // namespace perception
91 } // namespace apollo
Definition: frame.h:32
std::pair< size_t, size_t > TrackObjectPair
Definition: base_matcher.h:33
std::string name_
Definition: base_matcher.h:72
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
static double s_bound_match_distance_
Definition: base_matcher.h:74
PERCEPTION_REGISTER_REGISTERER(BaseDetector)
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition: macros.h:48
BaseMatcher()
Definition: base_matcher.h:41
Eigen::Vector3d Vector3d
Definition: frame_transform.h:27
static double s_max_match_distance_
Definition: base_matcher.h:73
virtual ~BaseMatcher()
Definition: base_matcher.h:42
Definition: base_matcher.h:39
virtual std::string Name()
Definition: base_matcher.h:69
virtual bool Match(const std::vector< RadarTrackPtr > &radar_tracks, const base::Frame &radar_frame, const TrackObjectMatcherOptions &options, std::vector< TrackObjectPair > *assignments, std::vector< size_t > *unassigned_tracks, std::vector< size_t > *unassigned_objects)
Definition: base_matcher.h:52
Eigen::Vector3d * ref_point
Definition: base_matcher.h:36
virtual bool Init()
Definition: base_matcher.h:43
std::shared_ptr< Object > ObjectPtr
Definition: object.h:123