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

#include <open_space_fallback_util.h>

apollo::planning::OpenSpaceFallbackUtil 的协作图:

静态 Public 成员函数

static bool IsCollisionFreeTrajectory (const TrajGearPair &trajectory_gear_pair, const std::vector< std::vector< common::math::Box2d > > &predicted_bounding_rectangles, const std::vector< Obstacle * > &static_obstacles, int *current_index, int *first_collision_index, bool &is_collision_with_static_obstacle, bool &is_collision_with_dynamic_obstacle, const double &collilsion_time_buffer)
 
static void BuildPredictedEnvironment (const common::math::Vec2d ego_pos, const std::vector< const Obstacle * > &obstacles, std::vector< std::vector< common::math::Box2d > > &predicted_bounding_rectangles, const double &time_period, const double &build_range)
 
static void BuildStaticObstacleEnvironment (const common::math::Vec2d ego_pos, const std::vector< const Obstacle * > &obstacles, std::vector< Obstacle * > &static_obstacles, const double &build_range)
 

详细描述

在文件 open_space_fallback_util.h 第 31 行定义.

成员函数说明

◆ BuildPredictedEnvironment()

void apollo::planning::OpenSpaceFallbackUtil::BuildPredictedEnvironment ( const common::math::Vec2d  ego_pos,
const std::vector< const Obstacle * > &  obstacles,
std::vector< std::vector< common::math::Box2d > > &  predicted_bounding_rectangles,
const double &  time_period,
const double &  build_range 
)
static

在文件 open_space_fallback_util.cc 第 98 行定义.

104 {
105 predicted_bounding_rectangles.clear();
106 double relative_time = 0.0;
107 while (relative_time < time_period) {
108 std::vector<Box2d> predicted_env;
109 std::vector<Obstacle*> static_obstacles_env;
110 for (const Obstacle* obstacle : obstacles) {
111 if (!obstacle->IsVirtual() && !obstacle->IsStatic()) {
112 TrajectoryPoint point = obstacle->GetPointAtTime(relative_time);
113 if (ego_pos.DistanceTo(Vec2d(point.path_point().x(), point.path_point().y())) > build_range) {
114 continue;
115 }
116 Box2d box = obstacle->GetBoundingBox(point);
117 predicted_env.push_back(std::move(box));
118 }
119 }
120 predicted_bounding_rectangles.emplace_back(std::move(predicted_env));
121 relative_time += FLAGS_trajectory_time_resolution;
122 }
123}

◆ BuildStaticObstacleEnvironment()

void apollo::planning::OpenSpaceFallbackUtil::BuildStaticObstacleEnvironment ( const common::math::Vec2d  ego_pos,
const std::vector< const Obstacle * > &  obstacles,
std::vector< Obstacle * > &  static_obstacles,
const double &  build_range 
)
static

在文件 open_space_fallback_util.cc 第 125 行定义.

129 {
130 static_obstacles.clear();
131 for (const Obstacle* obstacle : obstacles) {
132 if (!obstacle->IsVirtual() && obstacle->IsStatic() &&
133 obstacle->Perception().width() > 0.2 &&
134 obstacle->Perception().length() > 0.2 &&
135 obstacle->PerceptionPolygon().DistanceTo(ego_pos) <= build_range) {
136 static_obstacles.push_back(const_cast<Obstacle*>(obstacle));
137 }
138 }
139}

◆ IsCollisionFreeTrajectory()

bool apollo::planning::OpenSpaceFallbackUtil::IsCollisionFreeTrajectory ( const TrajGearPair &  trajectory_gear_pair,
const std::vector< std::vector< common::math::Box2d > > &  predicted_bounding_rectangles,
const std::vector< Obstacle * > &  static_obstacles,
int *  current_index,
int *  first_collision_index,
bool &  is_collision_with_static_obstacle,
bool &  is_collision_with_dynamic_obstacle,
const double &  collilsion_time_buffer 
)
static

在文件 open_space_fallback_util.cc 第 31 行定义.

37 {
38 // prediction time resolution: FLAGS_trajectory_time_resolution
39 const auto& vehicle_config =
40 common::VehicleConfigHelper::Instance()->GetConfig();
41 double ego_length = vehicle_config.vehicle_param().length();
42 double ego_width = vehicle_config.vehicle_param().width();
43 auto trajectory_pb = trajectory_gear_pair.first;
44 const int point_size = trajectory_pb.NumOfPoints();
45 AINFO << "trajectory_pb.NumOfPoints: [" << point_size << "]";
46 *current_index = trajectory_pb.QueryLowerBoundPoint(0.0);
47
48 for (int i = *current_index; i < point_size; ++i) {
49 const auto& trajectory_point = trajectory_pb.TrajectoryPointAt(i);
50 double ego_theta = trajectory_point.path_point().theta();
51 Box2d ego_box(
52 {trajectory_point.path_point().x(), trajectory_point.path_point().y()},
53 ego_theta, ego_length, ego_width);
54 double shift_distance =
55 ego_length / 2.0 - vehicle_config.vehicle_param().back_edge_to_center();
56 Vec2d shift_vec{shift_distance * std::cos(ego_theta),
57 shift_distance * std::sin(ego_theta)};
58 ego_box.Shift(shift_vec);
59
60 // is collision with static obstacles
61 Polygon2d ego_polygon = Polygon2d(ego_box);
62 for (const Obstacle* obstacle : static_obstacles) {
63 Polygon2d obstacle_polygon = obstacle->PerceptionPolygon();
64 if (ego_polygon.HasOverlap(obstacle_polygon)) {
65 AINFO << "HasOverlapWithStaticObstacle" << obstacle->Id()
66 << "first_collision_index_of_static_obstacle: [" << i << "]";
67 *first_collision_index = i;
68 is_collision_with_static_obstacle = true;
69 return false;
70 }
71 }
72
73 // is collision with dynamic obstacles
74 int predicted_time_horizon = predicted_bounding_rectangles.size();
75 for (int j = 0; j < predicted_time_horizon; j++) {
76 for (const auto& obstacle_box : predicted_bounding_rectangles[j]) {
77 if (ego_box.HasOverlap(obstacle_box)) {
78 ADEBUG << "HasOverlap(obstacle_box) [" << i << "]";
79 // remove points in previous trajectory
80 if (std::abs(trajectory_point.relative_time() -
81 static_cast<double>(j) *
82 FLAGS_trajectory_time_resolution) <
83 collilsion_time_buffer &&
84 trajectory_point.relative_time() > 0.0) {
85 ADEBUG << "first_collision_index: [" << i << "]";
86 *first_collision_index = i;
87 is_collision_with_dynamic_obstacle = true;
88 return false;
89 }
90 }
91 }
92 }
93 }
94
95 return true;
96}
#define ADEBUG
Definition log.h:41
#define AINFO
Definition log.h:42

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