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

#include <open_space_trajectory_optimizer_util.h>

apollo::planning::OpenSpaceTrajectoryOptimizerUtil 的协作图:

静态 Public 成员函数

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 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
 
static void PathPointNormalizing (double rotate_angle, const common::math::Vec2d &translate_origin, double *x, double *y, double *phi)
 
static void PathPointDeNormalizing (double rotate_angle, const common::math::Vec2d &translate_origin, double *x, double *y, double *phi)
 

详细描述

在文件 open_space_trajectory_optimizer_util.h 第 40 行定义.

成员函数说明

◆ BoxOverlapObstacles()

bool apollo::planning::OpenSpaceTrajectoryOptimizerUtil::BoxOverlapObstacles ( const common::math::Box2d &  bounding_box,
const std::vector< std::vector< common::math::LineSegment2d > >  obstacles_linesegments_vec 
)
static

check if box collision with obstacles

在文件 open_space_trajectory_optimizer_util.cc 第 29 行定义.

31 {
32 for (const auto& obstacle_linesegments : obstacles_linesegments_vec) {
33 for (const common::math::LineSegment2d& linesegment : obstacle_linesegments) {
34 if (bounding_box.HasOverlap(linesegment)) {
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();
39 return true;
40 }
41 }
42 }
43 return false;
44}
#define ADEBUG
Definition log.h:41

◆ GeneratePointBox()

void apollo::planning::OpenSpaceTrajectoryOptimizerUtil::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 
)
static

check if box collision with obstacles

在文件 open_space_trajectory_optimizer_util.cc 第 46 行定义.

49 {
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();
54 double rate = 1.0;
55
56 box_vec.clear();
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;
64 // ego_box.Shift(shift_vec);
65 // x += shift_distance;
66 Box2d box({x, y}, heading, init_length, init_width);
67 for (int j = 1; j < 10; j++) {
68 if (OpenSpaceTrajectoryOptimizerUtil::BoxOverlapObstacles(box, obstacles_linesegments_vec))
69 break;
70 box = Box2d({x, y}, heading, init_length + j * 0.2, init_width + j * 0.2);
71 }
72 auto corners = box.GetAllCorners();
73 box_vec.push_back(corners);
74 // 3-----------2
75 // | |
76 // | |
77 // 4-----------1
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();
82 }
83}
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
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
#define AINFO
Definition log.h:42
optional VehicleParam vehicle_param

◆ PathPointDeNormalizing()

void apollo::planning::OpenSpaceTrajectoryOptimizerUtil::PathPointDeNormalizing ( double  rotate_angle,
const common::math::Vec2d &  translate_origin,
double *  x,
double *  y,
double *  phi 
)
static

在文件 open_space_trajectory_optimizer_util.cc 第 99 行定义.

104 {
105 double tmp_x = *x;
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();
110 *phi = common::math::NormalizeAngle(*phi + rotate_angle);
111}
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
Definition math_utils.cc:53

◆ PathPointNormalizing()

void apollo::planning::OpenSpaceTrajectoryOptimizerUtil::PathPointNormalizing ( double  rotate_angle,
const common::math::Vec2d &  translate_origin,
double *  x,
double *  y,
double *  phi 
)
static

在文件 open_space_trajectory_optimizer_util.cc 第 85 行定义.

90 {
91 *x -= translate_origin.x();
92 *y -= translate_origin.y();
93 double tmp_x = *x;
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);
96 *phi = common::math::NormalizeAngle(*phi - rotate_angle);
97}

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