Apollo 11.0
自动驾驶开放平台
apollo::planning::CollisionChecker类 参考

#include <collision_checker.h>

apollo::planning::CollisionChecker 的协作图:

Public 成员函数

 CollisionChecker (const std::vector< const Obstacle * > &obstacles, const double ego_vehicle_s, const double ego_vehicle_d, const std::vector< common::PathPoint > &discretized_reference_line, const ReferenceLineInfo *ptr_reference_line_info, const std::shared_ptr< PathTimeGraph > &ptr_path_time_graph)
 
bool InCollision (const DiscretizedTrajectory &discretized_trajectory)
 

静态 Public 成员函数

static bool InCollision (const std::vector< const Obstacle * > &obstacles, const DiscretizedTrajectory &ego_trajectory, const double ego_length, const double ego_width, const double ego_edge_to_center)
 

详细描述

在文件 collision_checker.h 第 35 行定义.

构造及析构函数说明

◆ CollisionChecker()

apollo::planning::CollisionChecker::CollisionChecker ( const std::vector< const Obstacle * > &  obstacles,
const double  ego_vehicle_s,
const double  ego_vehicle_d,
const std::vector< common::PathPoint > &  discretized_reference_line,
const ReferenceLineInfo *  ptr_reference_line_info,
const std::shared_ptr< PathTimeGraph > &  ptr_path_time_graph 
)

在文件 collision_checker.cc 第 42 行定义.

47 {
48 ptr_reference_line_info_ = ptr_reference_line_info;
49 ptr_path_time_graph_ = ptr_path_time_graph;
50 BuildPredictedEnvironment(obstacles, ego_vehicle_s, ego_vehicle_d,
51 discretized_reference_line);
52}

成员函数说明

◆ InCollision() [1/2]

bool apollo::planning::CollisionChecker::InCollision ( const DiscretizedTrajectory &  discretized_trajectory)

在文件 collision_checker.cc 第 86 行定义.

87 {
88 CHECK_LE(discretized_trajectory.NumOfPoints(),
89 predicted_bounding_rectangles_.size());
90 const auto& vehicle_config =
91 common::VehicleConfigHelper::Instance()->GetConfig();
92 double ego_length = vehicle_config.vehicle_param().length();
93 double ego_width = vehicle_config.vehicle_param().width();
94
95 for (size_t i = 0; i < discretized_trajectory.NumOfPoints(); ++i) {
96 const auto& trajectory_point =
97 discretized_trajectory.TrajectoryPointAt(static_cast<std::uint32_t>(i));
98 double ego_theta = trajectory_point.path_point().theta();
99 Box2d ego_box(
100 {trajectory_point.path_point().x(), trajectory_point.path_point().y()},
101 ego_theta, ego_length, ego_width);
102 double shift_distance =
103 ego_length / 2.0 - vehicle_config.vehicle_param().back_edge_to_center();
104 Vec2d shift_vec{shift_distance * std::cos(ego_theta),
105 shift_distance * std::sin(ego_theta)};
106 ego_box.Shift(shift_vec);
107
108 for (const auto& obstacle_box : predicted_bounding_rectangles_[i]) {
109 if (ego_box.HasOverlap(obstacle_box)) {
110 return true;
111 }
112 }
113 }
114 return false;
115}

◆ InCollision() [2/2]

bool apollo::planning::CollisionChecker::InCollision ( const std::vector< const Obstacle * > &  obstacles,
const DiscretizedTrajectory &  ego_trajectory,
const double  ego_length,
const double  ego_width,
const double  ego_edge_to_center 
)
static

在文件 collision_checker.cc 第 54 行定义.

57 {
58 for (size_t i = 0; i < ego_trajectory.NumOfPoints(); ++i) {
59 const auto& ego_point =
60 ego_trajectory.TrajectoryPointAt(static_cast<std::uint32_t>(i));
61 const auto relative_time = ego_point.relative_time();
62 const auto ego_theta = ego_point.path_point().theta();
63
64 Box2d ego_box({ego_point.path_point().x(), ego_point.path_point().y()},
65 ego_theta, ego_length, ego_width);
66
67 // correct the inconsistency of reference point and center point
68 // TODO(all): move the logic before constructing the ego_box
69 double shift_distance = ego_length / 2.0 - ego_back_edge_to_center;
70 Vec2d shift_vec(shift_distance * std::cos(ego_theta),
71 shift_distance * std::sin(ego_theta));
72 ego_box.Shift(shift_vec);
73
74 std::vector<Box2d> obstacle_boxes;
75 for (const auto obstacle : obstacles) {
76 auto obtacle_point = obstacle->GetPointAtTime(relative_time);
77 Box2d obstacle_box = obstacle->GetBoundingBox(obtacle_point);
78 if (ego_box.HasOverlap(obstacle_box)) {
79 return true;
80 }
81 }
82 }
83 return false;
84}

该类的文档由以下文件生成: