Apollo 11.0
自动驾驶开放平台
pbf_tracker.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 "modules/perception/multi_sensor_fusion/proto/pbf_tracker_config.pb.h"
19
20#include "cyber/common/file.h"
27
28namespace apollo {
29namespace perception {
30namespace fusion {
31
33
34std::string PbfTracker::s_type_fusion_method_ = "DstTypeFusion"; // NOLINT
35std::string PbfTracker::s_existence_fusion_method_ = // NOLINT
36 "DstExistenceFusion";
37std::string PbfTracker::s_motion_fusion_method_ = // NOLINT
38 "KalmanMotionFusion";
39std::string PbfTracker::s_shape_fusion_method_ = "PbfShapeFusion"; // NOLINT
40
42 std::string config_file =
43 GetConfigFile(options.config_path, options.config_file);
44
45 PbfTrackerConfig params;
46 if (!cyber::common::GetProtoFromFile(config_file, &params)) {
47 AERROR << "Read config failed: " << config_file;
48 return false;
49 }
50
51 AINFO << "Load PbfTrackerConfig: " << params.DebugString();
52
57
58 TypeFusionInitOptions type_fusion_init_options;
59 auto type_fusion_param = params.type_fusion_param();
60 type_fusion_init_options.config_path = type_fusion_param.config_path();
61 type_fusion_init_options.config_file = type_fusion_param.config_file();
62 DstTypeFusion::Init(type_fusion_init_options);
63
64 ExistenceFusionInitOptions existence_fusion_init_options;
65 auto existence_fusion_param = params.existence_fusion_param();
66 existence_fusion_init_options.config_path =
67 existence_fusion_param.config_path();
68 existence_fusion_init_options.config_file =
69 existence_fusion_param.config_file();
70 DstExistenceFusion::Init(existence_fusion_init_options);
71
72 return true;
73}
74
76 if (s_type_fusion_method_ == "DstTypeFusion") {
78 } else {
79 AERROR << "Unknown type fusion : " << s_type_fusion_method_;
80 return false;
81 }
82
83 if (s_motion_fusion_method_ == "KalmanMotionFusion") {
85 } else {
86 AERROR << "Unknown motion fusion : " << s_motion_fusion_method_;
87 return false;
88 }
89
90 if (s_existence_fusion_method_ == "DstExistenceFusion") {
92 } else {
93 AERROR << "Unknown existence fusion : " << s_existence_fusion_method_;
94 return false;
95 }
96
97 if (s_shape_fusion_method_ == "PbfShapeFusion") {
99 } else {
100 AERROR << "Unknown shape fusion : " << s_shape_fusion_method_;
101 return false;
102 }
103
104 return true;
105}
106
107bool PbfTracker::Init(TrackPtr track, SensorObjectPtr measurement) {
108 track_ = track;
109 if (!InitMethods()) {
110 return false;
111 }
112 motion_fusion_->Init();
113 return true;
114}
115
117 const SensorObjectPtr measurement,
118 double target_timestamp) {
119 std::string sensor_id = measurement->GetSensorId();
120 ADEBUG << "fusion_updating..." << track_->GetTrackId() << " with "
121 << sensor_id << "..." << measurement->GetBaseObject()->track_id << "@"
122 << FORMAT_TIMESTAMP(measurement->GetTimestamp());
123 existence_fusion_->UpdateWithMeasurement(measurement, target_timestamp,
124 options.match_distance);
125 motion_fusion_->UpdateWithMeasurement(measurement, target_timestamp);
126 shape_fusion_->UpdateWithMeasurement(measurement, target_timestamp);
127 type_fusion_->UpdateWithMeasurement(measurement, target_timestamp);
128 track_->UpdateWithSensorObject(measurement);
129}
130
132 const std::string& sensor_id,
133 double measurement_timestamp,
134 double target_timestamp) {
135 existence_fusion_->UpdateWithoutMeasurement(sensor_id, measurement_timestamp,
136 target_timestamp,
137 options.match_distance);
138 motion_fusion_->UpdateWithoutMeasurement(sensor_id, measurement_timestamp,
139 target_timestamp);
140 shape_fusion_->UpdateWithoutMeasurement(sensor_id, measurement_timestamp,
141 target_timestamp);
142 type_fusion_->UpdateWithoutMeasurement(sensor_id, measurement_timestamp,
143 target_timestamp,
144 options.match_distance);
145 track_->UpdateWithoutSensorObject(sensor_id, measurement_timestamp);
146}
147
148} // namespace fusion
149} // namespace perception
150} // namespace apollo
static bool Init(const ExistenceFusionInitOptions &options)
add dst application
static bool Init(const TypeFusionInitOptions &options)
std::unique_ptr< BaseTypeFusion > type_fusion_
Definition pbf_tracker.h:99
void UpdateWithMeasurement(const TrackerOptions &options, const SensorObjectPtr measurement, double target_timestamp) override
Update with measurement
static std::string s_existence_fusion_method_
Definition pbf_tracker.h:97
static std::string s_shape_fusion_method_
Definition pbf_tracker.h:96
std::unique_ptr< BaseExistenceFusion > existence_fusion_
bool Init(TrackPtr track, SensorObjectPtr measurement) override
Init
std::unique_ptr< BaseMotionFusion > motion_fusion_
static bool InitParams(const TrackerInitOptions &options)
Init params
bool InitMethods()
Init fusion methods
void UpdateWithoutMeasurement(const TrackerOptions &options, const std::string &sensor_id, double measurement_timestamp, double target_timestamp) override
Update without measurement
static std::string s_motion_fusion_method_
Definition pbf_tracker.h:95
std::unique_ptr< BaseShapeFusion > shape_fusion_
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
#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::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
Definition file.cc:179
std::shared_ptr< SensorObject > SensorObjectPtr
std::shared_ptr< Track > TrackPtr
Definition track.h:397
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
Some string util functions.
#define FORMAT_TIMESTAMP(timestamp)
Definition string_util.h:29
optional perception::PluginParam shape_fusion_param
optional perception::PluginParam motion_fusion_param
optional perception::PluginParam existence_fusion_param
optional perception::PluginParam type_fusion_param