Apollo  v5.5.0
Open source self driving car software
mlf_tracker.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 <vector>
20 
24 
25 namespace apollo {
26 namespace perception {
27 namespace lidar {
28 
30 
31 struct MlfTrackOptions {};
32 
33 class MlfTracker {
34  public:
35  MlfTracker() = default;
37  for (auto& filter : filters_) {
38  delete filter;
39  }
40  }
41 
42  bool Init(const MlfTrackerInitOptions options = MlfTrackerInitOptions());
43 
44  // @brief: initialize new track data and push new object to cache
45  // @params [in/out]: new track data
46  // @params [in/out]: new object
47  void InitializeTrack(MlfTrackDataPtr new_track_data,
48  TrackedObjectPtr new_object);
49 
50  // @brief: update track data with object
51  // @params [in/out]: history track data
52  // @params [in/out]: new object
53  void UpdateTrackDataWithObject(MlfTrackDataPtr track_data,
54  TrackedObjectPtr new_object);
55 
56  // @brief: update track data without object
57  // @params [in]: timestamp
58  // @params [in/out]: history track data
59  void UpdateTrackDataWithoutObject(double timestamp,
60  MlfTrackDataPtr track_data);
61 
62  std::string Name() const { return "MlfTracker"; }
63 
64  protected:
65  // @brief: get next track id
66  // @return: track id
68  if (global_track_id_counter_ == INT_MAX) {
69  global_track_id_counter_ = 0;
70  }
71  return global_track_id_counter_++;
72  }
73 
74  protected:
75  // a single whole state filter or separate state filters
76  std::vector<MlfBaseFilter*> filters_;
77  // global track id
78  int global_track_id_counter_ = 0;
79  // filter option
81 }; // class MlfTracker
82 
83 } // namespace lidar
84 } // namespace perception
85 } // namespace apollo
Definition: mlf_base_filter.h:31
std::string Name() const
Definition: mlf_tracker.h:62
Definition: blob.h:72
MlfFilterOptions filter_options_
Definition: mlf_tracker.h:80
~MlfTracker()
Definition: mlf_tracker.h:36
int GetNextTrackId()
Definition: mlf_tracker.h:67
Definition: mlf_tracker.h:31
Definition: mlf_tracker.h:33
std::shared_ptr< MlfTrackData > MlfTrackDataPtr
Definition: mlf_track_data.h:110
std::vector< MlfBaseFilter * > filters_
Definition: mlf_tracker.h:76
std::shared_ptr< TrackedObject > TrackedObjectPtr
Definition: tracked_object.h:152