Apollo 11.0
自动驾驶开放平台
mlf_shape_filter.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 *****************************************************************************/
16
18
19#include "cyber/common/file.h"
22#include "modules/perception/lidar_tracking/tracker/multi_lidar_fusion/proto/multi_lidar_fusion_config.pb.h"
23
24namespace apollo {
25namespace perception {
26namespace lidar {
27
29 std::string config_file = "mlf_shape_filter.conf";
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 MlfTrackDataConstPtr& track_data,
44 TrackedObjectPtr new_object) {
45 // compute tight object polygon
46 auto& obj = new_object->object_ptr;
47 if (obj->lidar_supplement.is_clustered) {
48 hull_.GetConvexHull(obj->lidar_supplement.cloud_world, &obj->polygon);
49 } else {
50 hull_.GetConvexHullWithoutGroundAndHead(
51 obj->lidar_supplement.cloud_world,
52 static_cast<float>(bottom_points_ignore_threshold_),
53 static_cast<float>(top_points_ignore_threshold_), &obj->polygon);
54 }
55 /*
56 // simple moving average orientation filtering
57 if (track_data->age_ > 0) {
58 TrackedObjectConstPtr latest_object = track_data->GetLatestObject().second;
59 if (new_object->direction.dot(latest_object->direction) < 0) {
60 new_object->direction *= -1;
61 }
62 static const double kMovingAverage = 0.6;
63 new_object->direction =
64 latest_object->output_direction * (1 - kMovingAverage) +
65 new_object->direction * kMovingAverage;
66 new_object->direction.normalize();
67 }
68 */
69 Eigen::Vector3f local_direction = obj->direction;
70 Eigen::Vector3d local_center = obj->center;
71 Eigen::Vector3f local_size = obj->size;
72 obj->direction = new_object->output_direction.cast<float>(); // sync
73 // finally, recompute object shape
75 new_object->center = obj->center;
76 new_object->size = obj->size.cast<double>();
77 // center and size in object should not changed
78 obj->center = local_center;
79 obj->size = local_size;
80 obj->direction = local_direction;
81 new_object->output_center = new_object->center;
82 new_object->output_direction = new_object->direction;
83 new_object->output_size = new_object->size;
84}
85
87 double timestamp,
88 MlfTrackDataPtr track_data) {
89 // TODO(.)
90}
91
93
94} // namespace lidar
95} // namespace perception
96} // namespace apollo
void UpdateWithObject(const MlfFilterOptions &options, const MlfTrackDataConstPtr &track_data, TrackedObjectPtr new_object) override
Updating shape filter with object
algorithm::ConvexHull2D< base::PointDCloud, base::PolygonDType > hull_
bool Init(const MlfFilterInitOptions &options=MlfFilterInitOptions()) override
Init mlf filter
void UpdateWithoutObject(const MlfFilterOptions &options, double timestamp, MlfTrackDataPtr track_data) override
Updating shape filter without object
#define ACHECK(cond)
Definition log.h:80
#define PERCEPTION_REGISTER_MLFFILTER(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 MlfTrackData > MlfTrackDataConstPtr
std::shared_ptr< MlfTrackData > MlfTrackDataPtr
void ComputeObjectShapeFromPolygon(std::shared_ptr< Object > object, bool use_world_cloud)
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