Apollo 10.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) &&
147 AINFO << "obstacle presentation fails";
148 }
149 }
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 第 154 行定义.

154{ return obstacles_A_; }

◆ GetbMatrix()

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

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

155{ return obstacles_b_; }

◆ GetObstaclesEdgesNum()

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

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

157 {
158 return obstacles_edges_num_;
159 }

◆ GetObstaclesNum()

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

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

156{ return obstacles_num_; }

◆ GetObstacleVec()

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

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

151 {
152 return obstacles_vertices_vec_;
153 }

◆ HPresentationObstacle()

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

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

58 {
59 obstacles_A_ = Eigen::MatrixXd::Zero(obstacles_edges_num_.sum(), 2);
60 obstacles_b_ = Eigen::MatrixXd::Zero(obstacles_edges_num_.sum(), 1);
61 // vertices using H-representation
62 if (!ObsHRep(obstacles_num_, obstacles_edges_num_, obstacles_vertices_vec_,
63 &obstacles_A_, &obstacles_b_)) {
64 AINFO << "Fail to present obstacle in hyperplane";
65 return false;
66 }
67 return true;
68 }
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 第 70 行定义.

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 行定义.

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

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