Apollo 11.0
自动驾驶开放平台
fusion.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
22
23#include <vector>
24
26
31namespace apollo {
32namespace third_party_perception {
33namespace fusion {
34
38
40 const PerceptionObstacle& obstacle) {
41 std::vector<Vec2d> result;
42 for (const auto& vertex : obstacle.polygon_point()) {
43 result.emplace_back(vertex.x(), vertex.y());
44 }
45 return result;
46}
47
48bool HasOverlap(const PerceptionObstacle& obstacle_1,
49 const PerceptionObstacle& obstacle_2) {
54 return polygon_1.HasOverlap(polygon_2);
55}
56
57bool HasOverlap(const PerceptionObstacle& obstacle,
58 const PerceptionObstacles& obstacles) {
59 for (const auto& current_obstacle : obstacles.perception_obstacle()) {
60 if (HasOverlap(obstacle, current_obstacle)) {
61 return true;
62 }
63 }
64 return false;
65}
66
68 const PerceptionObstacles& radar_obstacles) {
69 PerceptionObstacles eye_obstacles_fusion = eye_obstacles;
70 PerceptionObstacles radar_obstacles_fusion = radar_obstacles;
71
72 for (auto& eye_obstacle :
73 *(eye_obstacles_fusion.mutable_perception_obstacle())) {
74 for (auto& radar_obstacle :
75 *(radar_obstacles_fusion.mutable_perception_obstacle())) {
76 if (HasOverlap(eye_obstacle, radar_obstacle)) {
77 eye_obstacle.set_confidence(0.99);
78 eye_obstacle.mutable_velocity()->CopyFrom(radar_obstacle.velocity());
79 }
80 }
81 }
82
83 // mobileye_obstacles_fusion.MergeFrom(radar_obstacles_fusion);
84 return eye_obstacles_fusion;
85}
86
87} // namespace fusion
88} // namespace third_party_perception
89} // namespace apollo
The class of polygon in 2-D.
Definition polygon2d.h:42
bool HasOverlap(const LineSegment2d &line_segment) const
Check if a line segment has overlap with this polygon.
Definition polygon2d.cc:377
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
PerceptionObstacles EyeRadarFusion(const PerceptionObstacles &eye_obstacles, const PerceptionObstacles &radar_obstacles)
Definition fusion.cc:67
bool HasOverlap(const PerceptionObstacle &obstacle_1, const PerceptionObstacle &obstacle_2)
Definition fusion.cc:48
std::vector< Vec2d > PerceptionObstacleToVectorVec2d(const PerceptionObstacle &obstacle)
Definition fusion.cc:39
class register implement
Definition arena_queue.h:37
Define the Polygon2d class.
repeated apollo::common::Point3D polygon_point