26using common::math::Box2d;
27using common::math::Vec2d;
30 const Box2d& bounding_box,
31 const std::vector<std::vector<common::math::LineSegment2d>> obstacles_linesegments_vec) {
32 for (
const auto& obstacle_linesegments : obstacles_linesegments_vec) {
35 ADEBUG <<
"collision start at x: " << linesegment.start().x();
36 ADEBUG <<
"collision start at y: " << linesegment.start().y();
37 ADEBUG <<
"collision end at x: " << linesegment.end().x();
38 ADEBUG <<
"collision end at y: " << linesegment.end().y();
47 const std::vector<std::vector<common::math::LineSegment2d>> obstacles_linesegments_vec,
48 const std::vector<std::pair<double, double>>& result,
49 std::vector<std::vector<Vec2d>>& box_vec) {
51 double shift_distance = vehicle_param.
length() / 2.0 - vehicle_param.back_edge_to_center();
52 double init_length = vehicle_param.length();
53 double init_width = vehicle_param.width();
57 for (
int i = 0; i < result.size() - 1; i++) {
58 double x = result[i].first;
59 double y = result[i].second;
60 double x_next = result[i + 1].first;
61 double y_next = result[i + 1].second;
62 double heading = std::atan2(y_next - y, x_next - x);
63 AINFO <<
"init pos: " << x <<
" " << y;
66 Box2d box({x, y}, heading, init_length, init_width);
67 for (
int j = 1; j < 10; j++) {
70 box =
Box2d({x, y}, heading, init_length + j * 0.2, init_width + j * 0.2);
73 box_vec.push_back(corners);
78 ADEBUG <<
"corners 1: " << corners[0].x() <<
" " << corners[0].y();
79 ADEBUG <<
"corners 2: " << corners[1].x() <<
" " << corners[1].y();
80 ADEBUG <<
"corners 3: " << corners[2].x() <<
" " << corners[2].y();
81 ADEBUG <<
"corners 4: " << corners[3].x() <<
" " << corners[3].y();
87 const Vec2d& translate_origin,
91 *x -= translate_origin.
x();
92 *y -= translate_origin.
y();
94 *x = (*x) * std::cos(-rotate_angle) - (*y) * std::sin(-rotate_angle);
95 *y = tmp_x * std::sin(-rotate_angle) + (*y) * std::cos(-rotate_angle);
101 const Vec2d& translate_origin,
106 *x = (*x) * std::cos(rotate_angle) - (*y) * std::sin(rotate_angle);
107 *y = tmp_x * std::sin(rotate_angle) + (*y) * std::cos(rotate_angle);
108 *x += translate_origin.
x();
109 *y += translate_origin.
y();
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
Rectangular (undirected) bounding box in 2-D.
void GetAllCorners(std::vector< Vec2d > *const corners) const
Getter of the corners of the box
bool HasOverlap(const LineSegment2d &line_segment) const
Determines whether this box overlaps a given line segment
Implements a class of 2-dimensional vectors.
double y() const
Getter for y component
double x() const
Getter for x component
static void PathPointNormalizing(double rotate_angle, const common::math::Vec2d &translate_origin, double *x, double *y, double *phi)
static bool BoxOverlapObstacles(const common::math::Box2d &bounding_box, const std::vector< std::vector< common::math::LineSegment2d > > obstacles_linesegments_vec)
check if box collision with obstacles
static void PathPointDeNormalizing(double rotate_angle, const common::math::Vec2d &translate_origin, double *x, double *y, double *phi)
static void GeneratePointBox(const std::vector< std::vector< common::math::LineSegment2d > > obstacles_linesegments_vec, const std::vector< std::pair< double, double > > &result, std::vector< std::vector< common::math::Vec2d > > &box_vec)
check if box collision with obstacles
Planning module main class.
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
optional VehicleParam vehicle_param