33 const std::vector<std::vector<Box2d>>&
34 predicted_bounding_rectangles,
35 const std::vector<Obstacle*>& static_obstacles,
int* current_index,
36 int* first_collision_index,
bool& is_collision_with_static_obstacle,
37 bool& is_collision_with_dynamic_obstacle,
const double& collilsion_time_buffer) {
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);
48 for (
int i = *current_index; i < point_size; ++i) {
49 const auto& trajectory_point = trajectory_pb.TrajectoryPointAt(i);
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);
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;
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 <<
"]";
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;
100 const std::vector<const Obstacle*>& obstacles,
101 std::vector<std::vector<common::math::Box2d>>&
102 predicted_bounding_rectangles,
103 const double& time_period,
104 const double& build_range) {
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()) {
116 Box2d box = obstacle->GetBoundingBox(point);
117 predicted_env.push_back(std::move(box));
120 predicted_bounding_rectangles.emplace_back(std::move(predicted_env));
121 relative_time += FLAGS_trajectory_time_resolution;
127 const std::vector<const Obstacle*>& obstacles,
128 std::vector<Obstacle*>& static_obstacles,
129 const double& build_range) {
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));
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)