Apollo 11.0
自动驾驶开放平台
base_matcher.cc
浏览该文件的文档.
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 *****************************************************************************/
17
18#include <numeric>
19
20namespace apollo {
21namespace perception {
22namespace radar {
23
26
30
32
36
38
39void BaseMatcher::IDMatch(const std::vector<RadarTrackPtr> &radar_tracks,
40 const base::Frame &radar_frame,
41 std::vector<TrackObjectPair> *assignments,
42 std::vector<size_t> *unassigned_tracks,
43 std::vector<size_t> *unassigned_objects) {
44 size_t num_track = radar_tracks.size();
45 const auto &objects = radar_frame.objects;
46 double object_timestamp = radar_frame.timestamp;
47 size_t num_obj = objects.size();
48 if (num_track == 0 || num_obj == 0) {
49 unassigned_tracks->resize(num_track);
50 unassigned_objects->resize(num_obj);
51 std::iota(unassigned_tracks->begin(), unassigned_tracks->end(), 0);
52 std::iota(unassigned_objects->begin(), unassigned_objects->end(), 0);
53 return;
54 }
55 std::vector<bool> track_used(num_track, false);
56 std::vector<bool> object_used(num_obj, false);
57 for (size_t i = 0; i < num_track; ++i) {
58 const auto &track_object = radar_tracks[i]->GetObsRadar();
59 double track_timestamp = radar_tracks[i]->GetTimestamp();
60 if (track_object.get() == nullptr) {
61 AERROR << "track_object is not available";
62 continue;
63 }
64 int track_object_track_id = track_object->track_id;
65 for (size_t j = 0; j < num_obj; ++j) {
66 int object_track_id = objects[j]->track_id;
67 if (track_object_track_id == object_track_id &&
68 RefinedTrack(track_object, track_timestamp, objects[j],
69 object_timestamp)) {
70 assignments->push_back(std::pair<size_t, size_t>(i, j));
71 track_used[i] = true;
72 object_used[j] = true;
73 }
74 }
75 }
76 for (size_t i = 0; i < track_used.size(); ++i) {
77 if (!track_used[i]) {
78 unassigned_tracks->push_back(i);
79 }
80 }
81 for (size_t i = 0; i < object_used.size(); ++i) {
82 if (!object_used[i]) {
83 unassigned_objects->push_back(i);
84 }
85 }
86}
87
89 double track_timestamp,
90 const base::ObjectPtr &radar_object,
91 double radar_timestamp) {
92 // This function is supposed to return true in the base class.
93 // Specific actions can be overrided in derived classes.
94 return true;
95}
96
97} // namespace radar
98} // namespace perception
99} // namespace apollo
virtual void IDMatch(const std::vector< RadarTrackPtr > &radar_tracks, const base::Frame &radar_frame, std::vector< TrackObjectPair > *assignments, std::vector< size_t > *unassigned_tracks, std::vector< size_t > *unassigned_objects)
Target association by id.
static void SetBoundMatchDistance(double dist)
Set the Bound Match Distance
static double GetBoundMatchDistance()
Get the Bound Match Distance
static double GetMaxMatchDistance()
Get the Max Match Distance
virtual bool RefinedTrack(const base::ObjectPtr &track_object, double track_timestamp, const base::ObjectPtr &radar_object, double radar_timestamp)
After the IDMatch, then track targets based on their features.
static void SetMaxMatchDistance(double dist)
Set the Max Match Distance
#define AERROR
Definition log.h:44
std::shared_ptr< Object > ObjectPtr
Definition object.h:127
class register implement
Definition arena_queue.h:37
std::vector< std::shared_ptr< Object > > objects
Definition frame.h:48