Apollo 10.0
自动驾驶开放平台
mrf_tracker.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 *****************************************************************************/
17
18#include "cyber/common/file.h"
20#include "modules/perception/radar4d_detection/lib/tracker/multi_radar_fusion/proto/mrf_config.pb.h"
21
22namespace apollo {
23namespace perception {
24namespace radar4d {
25
27 std::string config_file = "mrf_tracker.pb.txt";
28 if (!options.config_file.empty()) {
29 config_file = options.config_file;
30 }
31 config_file = GetConfigFile(options.config_path, config_file);
32 MrfTrackerConfig config;
33 ACHECK(cyber::common::GetProtoFromFile(config_file, &config));
34
35 for (int i = 0; i < config.filter_name_size(); ++i) {
36 const auto& name = config.filter_name(i);
37 MrfBaseFilter* filter = MrfBaseFilterRegisterer::GetInstanceByName(name);
38 ACHECK(filter);
39 MrfFilterInitOptions filter_init_options;
40 filter_init_options.config_path = options.config_path;
41 ACHECK(filter->Init(filter_init_options));
42 filters_.push_back(filter);
43 AINFO << "MrfTracker add filter: " << filter->Name();
44 }
45
46 return true;
47}
48
50 TrackedObjectPtr new_object) {
51 new_track_data->Reset(new_object, GetNextTrackId());
52 new_track_data->is_current_state_predicted_ = false;
53}
54
56 TrackedObjectPtr new_object) {
57 // 1. state filter and store belief in new_object
58 for (auto& filter : filters_) {
59 filter->UpdateWithObject(filter_options_, track_data, new_object);
60 }
61 // 2. push new_obect to track_data
62 track_data->PushTrackedObjectToTrack(new_object);
63 track_data->is_current_state_predicted_ = false;
64}
65
67 MrfTrackDataPtr track_data) {
68 for (auto& filter : filters_) {
69 filter->UpdateWithoutObject(filter_options_, timestamp, track_data);
70 }
71 track_data->is_current_state_predicted_ = true;
72}
73
74} // namespace radar4d
75} // namespace perception
76} // namespace apollo
virtual std::string Name() const =0
Get class name
virtual bool Init(const MrfFilterInitOptions &options=MrfFilterInitOptions())=0
Init mrf fitler
void UpdateTrackDataWithoutObject(double timestamp, MrfTrackDataPtr track_data)
Update track data without object
std::vector< MrfBaseFilter * > filters_
bool Init(const MrfTrackerInitOptions options=MrfTrackerInitOptions())
Init mrf tracker
void InitializeTrack(MrfTrackDataPtr new_track_data, TrackedObjectPtr new_object)
Initialize new track data and push new object to cache
void UpdateTrackDataWithObject(MrfTrackDataPtr track_data, TrackedObjectPtr new_object)
Update track data with object
int GetNextTrackId()
Get next track id
Definition mrf_tracker.h:94
#define ACHECK(cond)
Definition log.h:80
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
std::shared_ptr< MrfTrackData > MrfTrackDataPtr
std::shared_ptr< TrackedObject > TrackedObjectPtr
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
Definition util.cc:80
class register implement
Definition arena_queue.h:37