Apollo 10.0
自动驾驶开放平台
mrf_shape_filter.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 *****************************************************************************/
16
18
19#include "cyber/common/file.h"
22#include "modules/perception/radar4d_detection/lib/tracker/multi_radar_fusion/proto/mrf_config.pb.h"
23
24namespace apollo {
25namespace perception {
26namespace radar4d {
27
29 std::string config_file = "mrf_shape_filter.pb.txt";
30 if (!options.config_file.empty()) {
31 config_file = options.config_file;
32 }
33 config_file = GetConfigFile(options.config_path, config_file);
35 ACHECK(cyber::common::GetProtoFromFile(config_file, &config));
36
39 return true;
40}
41
43 const MrfTrackDataConstPtr& track_data,
44 TrackedObjectPtr new_object) {
45 // compute tight object polygon
46 auto& obj = new_object->object_ptr;
47 hull_.GetConvexHull(obj->radar4d_supplement.cloud_world, &obj->polygon);
48
49 // simple moving average orientation filtering
50 if (track_data->age_ > 0) {
51 TrackedObjectConstPtr latest_object = track_data->GetLatestObject().second;
52 if (new_object->direction.dot(latest_object->direction) < 0) {
53 new_object->direction *= -1;
54 }
55 static const double kMovingAverage = 0.6;
56 new_object->direction =
57 latest_object->output_direction * (1 - kMovingAverage) +
58 new_object->direction * kMovingAverage;
59 new_object->direction.normalize();
60 }
61 Eigen::Vector3f local_direction = obj->direction;
62 Eigen::Vector3d local_center = obj->center;
63 Eigen::Vector3f local_size = obj->size;
64 obj->direction = new_object->direction.cast<float>(); // sync
65 // finally, recompute object shape
67 new_object->center = obj->center;
68 new_object->size = obj->size.cast<double>();
69 // center and size in object should not changed
70 obj->center = local_center;
71 obj->size = local_size;
72 obj->direction = local_direction;
73 new_object->output_center = new_object->center;
74 new_object->output_direction = new_object->direction;
75 new_object->output_size = new_object->size;
76}
77
79 double timestamp,
80 MrfTrackDataPtr track_data) {
81 // TODO(.)
82}
83
85
86} // namespace radar4d
87} // namespace perception
88} // namespace apollo
void UpdateWithoutObject(const MrfFilterOptions &options, double timestamp, MrfTrackDataPtr track_data) override
Updating shape filter without object
algorithm::ConvexHull2D< base::RadarPointDCloud, base::PolygonDType > hull_
bool Init(const MrfFilterInitOptions &options=MrfFilterInitOptions()) override
Init mrf filter
void UpdateWithObject(const MrfFilterOptions &options, const MrfTrackDataConstPtr &track_data, TrackedObjectPtr new_object) override
Updating shape filter with object
#define ACHECK(cond)
Definition log.h:80
#define PERCEPTION_REGISTER_MRFFILTER(name)
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< const TrackedObject > TrackedObjectConstPtr
std::shared_ptr< MrfTrackData > MrfTrackDataPtr
std::shared_ptr< TrackedObject > TrackedObjectPtr
std::shared_ptr< const MrfTrackData > MrfTrackDataConstPtr
void ComputeObjectShapeFromPolygon(std::shared_ptr< Object > object, bool use_world_cloud)
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