Apollo 11.0
自动驾驶开放平台
apollo::planning::ObstacleContainer类 参考
apollo::planning::ObstacleContainer 的协作图:

Public 成员函数

 ObstacleContainer ()=default
 
bool VPresentationObstacle (const double *ROI_distance_approach_parking_boundary)
 
bool HPresentationObstacle ()
 
bool ObsHRep (const size_t obstacles_num, const Eigen::MatrixXi &obstacles_edges_num, const std::vector< std::vector< Vec2d > > &obstacles_vertices_vec, Eigen::MatrixXd *A_all, Eigen::MatrixXd *b_all)
 
void AddObstacle (const double *ROI_distance_approach_parking_boundary)
 
const std::vector< std::vector< Vec2d > > & GetObstacleVec () const
 
const Eigen::MatrixXd & GetAMatrix () const
 
const Eigen::MatrixXd & GetbMatrix () const
 
size_t GetObstaclesNum () const
 
const Eigen::MatrixXi & GetObstaclesEdgesNum () const
 

详细描述

在文件 distance_approach_problem_wrapper.cc 第 34 行定义.

构造及析构函数说明

◆ ObstacleContainer()

apollo::planning::ObstacleContainer::ObstacleContainer ( )
default

成员函数说明

◆ AddObstacle()

void apollo::planning::ObstacleContainer::AddObstacle ( const double *  ROI_distance_approach_parking_boundary)
inline

在文件 distance_approach_problem_wrapper.cc 第 143 行定义.

143 {
144 // the obstacles are hard coded into vertice sets of 3, 2, 3, 2
145 if (!(VPresentationObstacle(ROI_distance_approach_parking_boundary) && HPresentationObstacle())) {
146 AINFO << "obstacle presentation fails";
147 }
148 }
bool VPresentationObstacle(const double *ROI_distance_approach_parking_boundary)
#define AINFO
Definition log.h:42

◆ GetAMatrix()

const Eigen::MatrixXd & apollo::planning::ObstacleContainer::GetAMatrix ( ) const
inline

在文件 distance_approach_problem_wrapper.cc 第 153 行定义.

153 {
154 return obstacles_A_;
155 }

◆ GetbMatrix()

const Eigen::MatrixXd & apollo::planning::ObstacleContainer::GetbMatrix ( ) const
inline

在文件 distance_approach_problem_wrapper.cc 第 156 行定义.

156 {
157 return obstacles_b_;
158 }

◆ GetObstaclesEdgesNum()

const Eigen::MatrixXi & apollo::planning::ObstacleContainer::GetObstaclesEdgesNum ( ) const
inline

在文件 distance_approach_problem_wrapper.cc 第 162 行定义.

162 {
163 return obstacles_edges_num_;
164 }

◆ GetObstaclesNum()

size_t apollo::planning::ObstacleContainer::GetObstaclesNum ( ) const
inline

在文件 distance_approach_problem_wrapper.cc 第 159 行定义.

159 {
160 return obstacles_num_;
161 }

◆ GetObstacleVec()

const std::vector< std::vector< Vec2d > > & apollo::planning::ObstacleContainer::GetObstacleVec ( ) const
inline

在文件 distance_approach_problem_wrapper.cc 第 150 行定义.

150 {
151 return obstacles_vertices_vec_;
152 }

◆ HPresentationObstacle()

bool apollo::planning::ObstacleContainer::HPresentationObstacle ( )
inline

在文件 distance_approach_problem_wrapper.cc 第 57 行定义.

57 {
58 obstacles_A_ = Eigen::MatrixXd::Zero(obstacles_edges_num_.sum(), 2);
59 obstacles_b_ = Eigen::MatrixXd::Zero(obstacles_edges_num_.sum(), 1);
60 // vertices using H-representation
61 if (!ObsHRep(obstacles_num_, obstacles_edges_num_, obstacles_vertices_vec_, &obstacles_A_, &obstacles_b_)) {
62 AINFO << "Fail to present obstacle in hyperplane";
63 return false;
64 }
65 return true;
66 }
bool ObsHRep(const size_t obstacles_num, const Eigen::MatrixXi &obstacles_edges_num, const std::vector< std::vector< Vec2d > > &obstacles_vertices_vec, Eigen::MatrixXd *A_all, Eigen::MatrixXd *b_all)

◆ ObsHRep()

bool apollo::planning::ObstacleContainer::ObsHRep ( const size_t  obstacles_num,
const Eigen::MatrixXi &  obstacles_edges_num,
const std::vector< std::vector< Vec2d > > &  obstacles_vertices_vec,
Eigen::MatrixXd *  A_all,
Eigen::MatrixXd *  b_all 
)
inline

在文件 distance_approach_problem_wrapper.cc 第 68 行定义.

73 {
74 if (obstacles_num != obstacles_vertices_vec.size()) {
75 AINFO << "obstacles_num != obstacles_vertices_vec.size()";
76 return false;
77 }
78
79 A_all->resize(obstacles_edges_num.sum(), 2);
80 b_all->resize(obstacles_edges_num.sum(), 1);
81
82 int counter = 0;
83 double kEpsilon = 1.0e-5;
84 // start building H representation
85 for (size_t i = 0; i < obstacles_num; ++i) {
86 size_t current_vertice_num = obstacles_edges_num(i, 0);
87 Eigen::MatrixXd A_i(current_vertice_num, 2);
88 Eigen::MatrixXd b_i(current_vertice_num, 1);
89
90 // take two subsequent vertices, and computer hyperplane
91 for (size_t j = 0; j < current_vertice_num; ++j) {
92 Vec2d v1 = obstacles_vertices_vec[i][j];
93 Vec2d v2 = obstacles_vertices_vec[i][j + 1];
94
95 Eigen::MatrixXd A_tmp(2, 1), b_tmp(1, 1), ab(2, 1);
96 // find hyperplane passing through v1 and v2
97 if (std::abs(v1.x() - v2.x()) < kEpsilon) {
98 if (v2.y() < v1.y()) {
99 A_tmp << 1, 0;
100 b_tmp << v1.x();
101 } else {
102 A_tmp << -1, 0;
103 b_tmp << -v1.x();
104 }
105 } else if (std::abs(v1.y() - v2.y()) < kEpsilon) {
106 if (v1.x() < v2.x()) {
107 A_tmp << 0, 1;
108 b_tmp << v1.y();
109 } else {
110 A_tmp << 0, -1;
111 b_tmp << -v1.y();
112 }
113 } else {
114 Eigen::MatrixXd tmp1(2, 2);
115 tmp1 << v1.x(), 1, v2.x(), 1;
116 Eigen::MatrixXd tmp2(2, 1);
117 tmp2 << v1.y(), v2.y();
118 ab = tmp1.inverse() * tmp2;
119 double a = ab(0, 0);
120 double b = ab(1, 0);
121
122 if (v1.x() < v2.x()) {
123 A_tmp << -a, 1;
124 b_tmp << b;
125 } else {
126 A_tmp << a, -1;
127 b_tmp << -b;
128 }
129 }
130
131 // store vertices
132 A_i.block(j, 0, 1, 2) = A_tmp.transpose();
133 b_i.block(j, 0, 1, 1) = b_tmp;
134 }
135
136 A_all->block(counter, 0, A_i.rows(), 2) = A_i;
137 b_all->block(counter, 0, b_i.rows(), 1) = b_i;
138 counter += static_cast<int>(current_vertice_num);
139 }
140 return true;
141 }

◆ VPresentationObstacle()

bool apollo::planning::ObstacleContainer::VPresentationObstacle ( const double *  ROI_distance_approach_parking_boundary)
inline

在文件 distance_approach_problem_wrapper.cc 第 38 行定义.

38 {
39 obstacles_num_ = 4;
40 obstacles_edges_num_.resize(4, 1);
41 obstacles_edges_num_ << 2, 1, 2, 1;
42 size_t index = 0;
43 for (size_t i = 0; i < obstacles_num_; i++) {
44 std::vector<Vec2d> vertices_cw;
45 for (int j = 0; j < obstacles_edges_num_(i, 0) + 1; j++) {
46 Vec2d vertice
47 = Vec2d(ROI_distance_approach_parking_boundary[index],
48 ROI_distance_approach_parking_boundary[index + 1]);
49 index += 2;
50 vertices_cw.emplace_back(vertice);
51 }
52 obstacles_vertices_vec_.emplace_back(vertices_cw);
53 }
54 return true;
55 }

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