Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
cde91b67
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cde91b67
编写于
8月 28, 2017
作者:
Z
Zhang Liangliang
提交者:
Dong Li
8月 28, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Planning: rewrite get index function in StBoundary
上级
9e713aab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
24 deletion
+54
-24
modules/planning/common/speed/st_boundary.cc
modules/planning/common/speed/st_boundary.cc
+52
-22
modules/planning/tasks/speed_optimizer.cc
modules/planning/tasks/speed_optimizer.cc
+2
-2
未找到文件。
modules/planning/common/speed/st_boundary.cc
浏览文件 @
cde91b67
...
...
@@ -32,10 +32,26 @@ using Vec2d = common::math::Vec2d;
namespace
{
uint32_t
GetIndex
(
const
std
::
vector
<
STPoint
>&
points
,
const
double
t
)
{
auto
comp
=
[](
const
double
t
,
const
STPoint
&
p
)
{
return
t
<
p
.
t
();
};
auto
first_gt
=
std
::
upper_bound
(
points
.
begin
(),
points
.
end
(),
t
,
comp
);
return
std
::
distance
(
points
.
begin
(),
first_gt
)
-
1
;
bool
GetIndexRange
(
const
std
::
vector
<
STPoint
>&
points
,
const
double
t
,
size_t
*
left
,
size_t
*
right
)
{
CHECK_NOTNULL
(
left
);
CHECK_NOTNULL
(
right
);
if
(
t
<
points
.
front
().
t
()
||
t
>
points
.
back
().
t
())
{
AERROR
<<
"t is out of range. t = "
<<
t
;
return
false
;
}
auto
comp
=
[](
const
STPoint
&
p
,
const
double
t
)
{
return
p
.
t
()
<
t
;
};
auto
first_ge
=
std
::
lower_bound
(
points
.
begin
(),
points
.
end
(),
t
,
comp
);
size_t
index
=
std
::
distance
(
points
.
begin
(),
first_ge
);
if
(
index
==
0
)
{
*
left
=
*
right
=
0
;
}
else
if
(
first_ge
==
points
.
end
())
{
*
left
=
*
right
=
points
.
size
()
-
1
;
}
else
{
*
left
=
index
-
1
;
*
right
=
index
;
}
return
true
;
}
}
...
...
@@ -117,11 +133,16 @@ bool StBoundary::IsPointInBoundary(const STPoint& st_point) const {
if
(
st_point
.
t
()
<=
min_t_
||
st_point
.
t
()
>=
max_t_
)
{
return
false
;
}
auto
index
=
GetIndex
(
lower_points_
,
st_point
.
t
());
size_t
left
=
0
;
size_t
right
=
0
;
if
(
!
GetIndexRange
(
lower_points_
,
st_point
.
t
(),
&
left
,
&
right
))
{
AERROR
<<
"fait to get index range."
;
return
false
;
}
const
double
check_upper
=
common
::
math
::
CrossProd
(
st_point
,
upper_points_
[
index
],
upper_points_
[
index
+
1
]);
st_point
,
upper_points_
[
left
],
upper_points_
[
right
]);
const
double
check_lower
=
common
::
math
::
CrossProd
(
st_point
,
lower_points_
[
index
],
lower_points_
[
index
+
1
]);
st_point
,
lower_points_
[
left
],
lower_points_
[
right
]);
return
(
check_upper
*
check_lower
<
0
);
}
...
...
@@ -211,17 +232,21 @@ bool StBoundary::GetUnblockSRange(const double curr_time, double* s_upper,
return
true
;
}
auto
index
=
GetIndex
(
lower_points_
,
curr_time
);
const
double
r
=
(
curr_time
-
upper_points_
[
index
].
t
())
/
(
upper_points_
.
at
(
index
+
1
).
t
()
-
upper_points_
.
at
(
index
).
t
());
size_t
left
=
0
;
size_t
right
=
0
;
if
(
!
GetIndexRange
(
lower_points_
,
curr_time
,
&
left
,
&
right
))
{
AERROR
<<
"Fail to get index range."
;
return
false
;
}
const
double
r
=
(
curr_time
-
upper_points_
[
left
].
t
())
/
(
upper_points_
.
at
(
right
).
t
()
-
upper_points_
.
at
(
left
).
t
());
double
upper_cross_s
=
upper_points_
[
index
].
s
()
+
r
*
(
upper_points_
[
index
+
1
].
s
()
-
upper_points_
[
index
].
s
());
upper_points_
[
left
].
s
()
+
r
*
(
upper_points_
[
right
].
s
()
-
upper_points_
[
left
].
s
());
double
lower_cross_s
=
lower_points_
[
index
].
s
()
+
r
*
(
lower_points_
[
index
+
1
].
s
()
-
lower_points_
[
index
].
s
());
lower_points_
[
left
].
s
()
+
r
*
(
lower_points_
[
right
].
s
()
-
lower_points_
[
left
].
s
());
if
(
boundary_type_
==
BoundaryType
::
STOP
||
boundary_type_
==
BoundaryType
::
YIELD
||
...
...
@@ -245,14 +270,19 @@ bool StBoundary::GetBoundarySRange(const double curr_time, double* s_upper,
return
false
;
}
auto
index
=
GetIndex
(
lower_points_
,
curr_time
);
const
double
r
=
(
curr_time
-
upper_points_
[
index
].
t
())
/
(
upper_points_
[
index
+
1
].
t
()
-
upper_points_
[
index
].
t
());
size_t
left
=
0
;
size_t
right
=
0
;
if
(
!
GetIndexRange
(
lower_points_
,
curr_time
,
&
left
,
&
right
))
{
AERROR
<<
"Fail to get index range."
;
return
false
;
}
const
double
r
=
(
curr_time
-
upper_points_
[
left
].
t
())
/
(
upper_points_
[
right
].
t
()
-
upper_points_
[
left
].
t
());
*
s_upper
=
upper_points_
[
index
].
s
()
+
r
*
(
upper_points_
[
index
+
1
].
s
()
-
upper_points_
[
index
].
s
());
*
s_lower
=
lower_points_
[
index
].
s
()
+
r
*
(
lower_points_
[
index
+
1
].
s
()
-
lower_points_
[
index
].
s
());
*
s_upper
=
upper_points_
[
left
].
s
()
+
r
*
(
upper_points_
[
right
].
s
()
-
upper_points_
[
left
].
s
());
*
s_lower
=
lower_points_
[
left
].
s
()
+
r
*
(
lower_points_
[
right
].
s
()
-
lower_points_
[
left
].
s
());
*
s_upper
=
std
::
fmin
(
*
s_upper
,
s_high_limit_
);
*
s_lower
=
std
::
fmax
(
*
s_lower
,
0.0
);
...
...
modules/planning/tasks/speed_optimizer.cc
浏览文件 @
cde91b67
...
...
@@ -92,8 +92,8 @@ void SpeedOptimizer::RecordSTGraphDebug(
for
(
const
auto
&
point
:
boundary
.
lower_points
())
{
auto
point_debug
=
boundary_debug
->
add_point
();
point_debug
->
set_t
(
point
.
x
());
point_debug
->
set_s
(
point
.
y
());
point_debug
->
set_t
(
point
.
t
());
point_debug
->
set_s
(
point
.
s
());
}
for
(
size_t
i
=
0
;
i
<
boundary
.
upper_points
().
size
();
++
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录