Apollo 11.0
自动驾驶开放平台
pbf_shape_fusion.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
18namespace apollo {
19namespace perception {
20namespace fusion {
21
22bool PbfShapeFusion::s_use_camera_3d_ = true;
23float PbfShapeFusion::s_camera_radar_time_diff_th_ = 0.3f;
24
25bool PbfShapeFusion::Init() { return true; }
26
28 double target_timestamp) {
29 SensorObjectConstPtr latest_lidar = track_ref_->GetLatestLidarObject();
30 SensorObjectConstPtr latest_radar = track_ref_->GetLatestRadarObject();
31 SensorObjectConstPtr latest_camera = track_ref_->GetLatestCameraObject();
32 if (IsLidar(measurement)) {
33 UpdateState(measurement);
34 } else if (IsRadar(measurement)) {
35 if (latest_lidar == nullptr) {
36 if (latest_camera != nullptr) {
37 if (std::fabs(measurement->GetTimestamp() -
38 latest_camera->GetTimestamp()) <
39 s_camera_radar_time_diff_th_) {
40 UpdateShape(latest_camera);
41 UpdateCenter(measurement);
42 } else {
43 // nothing to do
44 }
45 } else {
46 UpdateState(measurement);
47 }
48 } else {
49 // nothing to do
50 }
51 } else if (IsCamera(measurement) && s_use_camera_3d_) {
52 if (latest_lidar == nullptr) {
53 UpdateState(measurement);
54 } else {
55 // nothing to do
56 }
57 } else {
58 // nothing to do;
59 }
60}
61void PbfShapeFusion::UpdateWithoutMeasurement(const std::string& sensor_id,
62 double measurement_timestamp,
63 double target_timestamp) {}
64
65std::string PbfShapeFusion::Name() const { return "PbfShapeFusion"; }
66
67void PbfShapeFusion::UpdateState(const SensorObjectConstPtr& measurement) {
68 UpdateShape(measurement);
69 UpdateCenter(measurement);
70}
71
72void PbfShapeFusion::UpdateShape(const SensorObjectConstPtr& measurement) {
73 base::ObjectPtr dst_obj = track_ref_->GetFusedObject()->GetBaseObject();
74 base::ObjectConstPtr src_obj = measurement->GetBaseObject();
75
76 dst_obj->size = src_obj->size;
77 dst_obj->direction = src_obj->direction;
78 dst_obj->theta = src_obj->theta;
79 dst_obj->polygon = src_obj->polygon;
80}
81
82void PbfShapeFusion::UpdateCenter(const SensorObjectConstPtr& measurement) {
83 base::ObjectPtr dst_obj = track_ref_->GetFusedObject()->GetBaseObject();
84 base::ObjectConstPtr src_obj = measurement->GetBaseObject();
85
86 dst_obj->center = src_obj->center;
87 dst_obj->anchor_point = src_obj->anchor_point;
88}
89
90} // namespace fusion
91} // namespace perception
92} // namespace apollo
void UpdateWithoutMeasurement(const std::string &sensor_id, double measurement_timestamp, double target_timestamp) override
Update without measurement
std::string Name() const override
The name of BaseShapeFusion
void UpdateWithMeasurement(const SensorObjectPtr measurement, double target_timestamp) override
Update with measurement
std::shared_ptr< const Object > ObjectConstPtr
Definition object.h:128
std::shared_ptr< Object > ObjectPtr
Definition object.h:127
std::shared_ptr< const SensorObject > SensorObjectConstPtr
std::shared_ptr< SensorObject > SensorObjectPtr
bool IsCamera(const SensorObjectConstPtr &obj)
bool IsLidar(const SensorObjectConstPtr &obj)
bool IsRadar(const SensorObjectConstPtr &obj)
class register implement
Definition arena_queue.h:37