Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
f5f3efb7
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,体验更适合开发者的 AI 搜索 >>
提交
f5f3efb7
编写于
12月 31, 2017
作者:
Z
Zhang Liangliang
提交者:
Jiangtao Hu
12月 31, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Planning: (1) fixed a bug in dp_st_graph. (2) used array instead of map in dp_st_cost.
上级
03a24eea
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
46 deletion
+60
-46
modules/planning/tasks/dp_st_speed/dp_st_cost.cc
modules/planning/tasks/dp_st_speed/dp_st_cost.cc
+24
-13
modules/planning/tasks/dp_st_speed/dp_st_cost.h
modules/planning/tasks/dp_st_speed/dp_st_cost.h
+3
-4
modules/planning/tasks/dp_st_speed/dp_st_graph.cc
modules/planning/tasks/dp_st_speed/dp_st_graph.cc
+33
-29
未找到文件。
modules/planning/tasks/dp_st_speed/dp_st_cost.cc
浏览文件 @
f5f3efb7
...
@@ -36,9 +36,10 @@ DpStCost::DpStCost(const DpStSpeedConfig& config,
...
@@ -36,9 +36,10 @@ DpStCost::DpStCost(const DpStSpeedConfig& config,
:
config_
(
config
),
:
config_
(
config
),
obstacles_
(
obstacles
),
obstacles_
(
obstacles
),
init_point_
(
init_point
),
init_point_
(
init_point
),
unit_s_
(
config_
.
total_path_length
()
/
config_
.
matrix_dimension_s
()),
unit_t_
(
config_
.
total_time
()
/
config_
.
matrix_dimension_t
())
{
unit_t_
(
config_
.
total_time
()
/
config_
.
matrix_dimension_t
()),
accel_cost_
.
fill
(
-
1.0
);
unit_v_
(
unit_s_
/
unit_t_
)
{}
jerk_cost_
.
fill
(
-
1.0
);
}
double
DpStCost
::
GetObstacleCost
(
const
StGraphPoint
&
st_graph_point
)
{
double
DpStCost
::
GetObstacleCost
(
const
StGraphPoint
&
st_graph_point
)
{
const
double
s
=
st_graph_point
.
point
().
s
();
const
double
s
=
st_graph_point
.
point
().
s
();
...
@@ -123,9 +124,14 @@ double DpStCost::GetSpeedCost(const STPoint& first, const STPoint& second,
...
@@ -123,9 +124,14 @@ double DpStCost::GetSpeedCost(const STPoint& first, const STPoint& second,
double
DpStCost
::
GetAccelCost
(
const
double
accel
)
{
double
DpStCost
::
GetAccelCost
(
const
double
accel
)
{
double
cost
=
0.0
;
double
cost
=
0.0
;
constexpr
double
kEpsilon
=
0.1
;
constexpr
double
kEpsilon
=
0.1
;
const
int
accel_key
=
static_cast
<
int
>
(
accel
/
kEpsilon
+
0.5
);
constexpr
int
kShift
=
100
;
auto
p_val
=
accel_cost_map_
.
find
(
accel_key
);
const
int
accel_key
=
static_cast
<
int
>
(
accel
/
kEpsilon
+
0.5
)
+
kShift
;
if
(
p_val
==
accel_cost_map_
.
end
())
{
DCHECK_LT
(
accel_key
,
accel_cost_
.
size
());
if
(
accel_key
<
0
||
accel_key
>=
accel_cost_
.
size
())
{
return
kInf
;
}
if
(
accel_cost_
.
at
(
accel_key
)
<
0.0
)
{
const
double
accel_sq
=
accel
*
accel
;
const
double
accel_sq
=
accel
*
accel
;
double
max_acc
=
config_
.
max_acceleration
();
double
max_acc
=
config_
.
max_acceleration
();
double
max_dec
=
config_
.
max_deceleration
();
double
max_dec
=
config_
.
max_deceleration
();
...
@@ -141,9 +147,9 @@ double DpStCost::GetAccelCost(const double accel) {
...
@@ -141,9 +147,9 @@ double DpStCost::GetAccelCost(const double accel) {
(
1
+
std
::
exp
(
1.0
*
(
accel
-
max_dec
)))
+
(
1
+
std
::
exp
(
1.0
*
(
accel
-
max_dec
)))
+
accel_sq
*
accel_penalty
*
accel_penalty
/
accel_sq
*
accel_penalty
*
accel_penalty
/
(
1
+
std
::
exp
(
-
1.0
*
(
accel
-
max_acc
)));
(
1
+
std
::
exp
(
-
1.0
*
(
accel
-
max_acc
)));
accel_cost_
map_
[
accel_key
]
=
cost
;
accel_cost_
.
at
(
accel_key
)
=
cost
;
}
else
{
}
else
{
cost
=
p_val
->
second
;
cost
=
accel_cost_
.
at
(
accel_key
)
;
}
}
return
cost
*
unit_t_
;
return
cost
*
unit_t_
;
}
}
...
@@ -166,18 +172,23 @@ double DpStCost::GetAccelCostByTwoPoints(const double pre_speed,
...
@@ -166,18 +172,23 @@ double DpStCost::GetAccelCostByTwoPoints(const double pre_speed,
double
DpStCost
::
JerkCost
(
const
double
jerk
)
{
double
DpStCost
::
JerkCost
(
const
double
jerk
)
{
double
cost
=
0.0
;
double
cost
=
0.0
;
constexpr
double
kEpsilon
=
0.1
;
constexpr
double
kEpsilon
=
0.1
;
const
int
jerk_key
=
static_cast
<
int
>
(
jerk
/
kEpsilon
+
0.5
);
constexpr
int
kShift
=
200
;
auto
p_val
=
jerk_cost_map_
.
find
(
jerk_key
);
const
int
jerk_key
=
static_cast
<
int
>
(
jerk
/
kEpsilon
+
0.5
)
+
kShift
;
if
(
p_val
==
jerk_cost_map_
.
end
())
{
DCHECK_LT
(
jerk_key
,
jerk_cost_
.
size
());
if
(
jerk_key
<
0
||
jerk_key
>=
jerk_cost_
.
size
())
{
return
kInf
;
}
if
(
jerk_cost_
.
at
(
jerk_key
)
<
0.0
)
{
double
jerk_sq
=
jerk
*
jerk
;
double
jerk_sq
=
jerk
*
jerk
;
if
(
jerk
>
0
)
{
if
(
jerk
>
0
)
{
cost
=
config_
.
positive_jerk_coeff
()
*
jerk_sq
*
unit_t_
;
cost
=
config_
.
positive_jerk_coeff
()
*
jerk_sq
*
unit_t_
;
}
else
{
}
else
{
cost
=
config_
.
negative_jerk_coeff
()
*
jerk_sq
*
unit_t_
;
cost
=
config_
.
negative_jerk_coeff
()
*
jerk_sq
*
unit_t_
;
}
}
jerk_cost_
map_
[
jerk_key
]
=
cost
;
jerk_cost_
.
at
(
jerk_key
)
=
cost
;
}
else
{
}
else
{
cost
=
p_val
->
second
;
cost
=
jerk_cost_
.
at
(
jerk_key
)
;
}
}
// TODO(All): normalize to unit_t_
// TODO(All): normalize to unit_t_
...
...
modules/planning/tasks/dp_st_speed/dp_st_cost.h
浏览文件 @
f5f3efb7
...
@@ -74,14 +74,13 @@ class DpStCost {
...
@@ -74,14 +74,13 @@ class DpStCost {
const
DpStSpeedConfig
&
config_
;
const
DpStSpeedConfig
&
config_
;
const
std
::
vector
<
const
PathObstacle
*>&
obstacles_
;
const
std
::
vector
<
const
PathObstacle
*>&
obstacles_
;
const
common
::
TrajectoryPoint
&
init_point_
;
const
common
::
TrajectoryPoint
&
init_point_
;
double
unit_s_
=
0.0
;
double
unit_t_
=
0.0
;
double
unit_t_
=
0.0
;
double
unit_v_
=
0.0
;
std
::
unordered_map
<
std
::
string
,
std
::
pair
<
double
,
double
>>
std
::
unordered_map
<
std
::
string
,
std
::
pair
<
double
,
double
>>
boundary_range_map_
;
boundary_range_map_
;
std
::
unordered_map
<
int
,
double
>
accel_cost_map
_
;
std
::
array
<
double
,
200
>
accel_cost
_
;
std
::
unordered_map
<
int
,
double
>
jerk_cost_map
_
;
std
::
array
<
double
,
400
>
jerk_cost
_
;
};
};
}
// namespace planning
}
// namespace planning
...
...
modules/planning/tasks/dp_st_speed/dp_st_graph.cc
浏览文件 @
f5f3efb7
...
@@ -40,6 +40,7 @@ using apollo::common::math::Vec2d;
...
@@ -40,6 +40,7 @@ using apollo::common::math::Vec2d;
using
apollo
::
common
::
VehicleParam
;
using
apollo
::
common
::
VehicleParam
;
namespace
{
namespace
{
constexpr
double
kInf
=
std
::
numeric_limits
<
double
>::
infinity
();
bool
CheckOverlapOnDpStGraph
(
const
std
::
vector
<
const
StBoundary
*>&
boundaries
,
bool
CheckOverlapOnDpStGraph
(
const
std
::
vector
<
const
StBoundary
*>&
boundaries
,
const
StGraphPoint
&
p1
,
const
StGraphPoint
&
p2
)
{
const
StGraphPoint
&
p1
,
const
StGraphPoint
&
p2
)
{
...
@@ -232,6 +233,12 @@ void DpStGraph::CalculateCostAt(const uint32_t c, const uint32_t r) {
...
@@ -232,6 +233,12 @@ void DpStGraph::CalculateCostAt(const uint32_t c, const uint32_t r) {
double
speed_limit
=
double
speed_limit
=
st_graph_data_
.
speed_limit
().
GetSpeedLimitByS
(
unit_s_
*
r
);
st_graph_data_
.
speed_limit
().
GetSpeedLimitByS
(
unit_s_
*
r
);
if
(
c
==
1
)
{
if
(
c
==
1
)
{
const
double
acc
=
(
r
*
unit_s_
/
unit_t_
-
init_point_
.
v
())
/
unit_t_
;
if
(
acc
<
dp_st_speed_config_
.
max_deceleration
()
||
acc
>
dp_st_speed_config_
.
max_acceleration
())
{
return
;
}
if
(
CheckOverlapOnDpStGraph
(
st_graph_data_
.
st_boundaries
(),
cost_cr
,
if
(
CheckOverlapOnDpStGraph
(
st_graph_data_
.
st_boundaries
(),
cost_cr
,
cost_init
))
{
cost_init
))
{
return
;
return
;
...
@@ -252,6 +259,13 @@ void DpStGraph::CalculateCostAt(const uint32_t c, const uint32_t r) {
...
@@ -252,6 +259,13 @@ void DpStGraph::CalculateCostAt(const uint32_t c, const uint32_t r) {
if
(
c
==
2
)
{
if
(
c
==
2
)
{
for
(
uint32_t
r_pre
=
r_low
;
r_pre
<=
r
;
++
r_pre
)
{
for
(
uint32_t
r_pre
=
r_low
;
r_pre
<=
r
;
++
r_pre
)
{
const
double
acc
=
(
static_cast
<
int
>
(
r
-
2
*
r_pre
))
*
unit_s_
/
(
unit_t_
*
unit_t_
);
if
(
acc
<
dp_st_speed_config_
.
max_deceleration
()
||
acc
>
dp_st_speed_config_
.
max_acceleration
())
{
continue
;
}
if
(
CheckOverlapOnDpStGraph
(
st_graph_data_
.
st_boundaries
(),
cost_cr
,
if
(
CheckOverlapOnDpStGraph
(
st_graph_data_
.
st_boundaries
(),
cost_cr
,
pre_col
[
r_pre
]))
{
pre_col
[
r_pre
]))
{
continue
;
continue
;
...
@@ -282,41 +296,31 @@ void DpStGraph::CalculateCostAt(const uint32_t c, const uint32_t r) {
...
@@ -282,41 +296,31 @@ void DpStGraph::CalculateCostAt(const uint32_t c, const uint32_t r) {
curr_a
<
vehicle_param_
.
max_deceleration
())
{
curr_a
<
vehicle_param_
.
max_deceleration
())
{
continue
;
continue
;
}
}
uint32_t
lower_bound
=
0
;
uint32_t
upper_bound
=
0
;
if
(
!
CalculateFeasibleAccelRange
(
static_cast
<
double
>
(
r_pre
),
static_cast
<
double
>
(
r
),
&
lower_bound
,
&
upper_bound
))
{
continue
;
}
if
(
CheckOverlapOnDpStGraph
(
st_graph_data_
.
st_boundaries
(),
cost_cr
,
if
(
CheckOverlapOnDpStGraph
(
st_graph_data_
.
st_boundaries
(),
cost_cr
,
pre_col
[
r_pre
]))
{
pre_col
[
r_pre
]))
{
continue
;
continue
;
}
}
for
(
uint32_t
r_prepre
=
lower_bound
;
r_prepre
<=
upper_bound
;
++
r_prepre
)
{
uint32_t
r_prepre
=
pre_col
[
r_pre
].
pre_point
()
->
index_s
();
const
StGraphPoint
&
prepre_graph_point
=
cost_table_
[
c
-
2
][
r_prepre
];
const
StGraphPoint
&
prepre_graph_point
=
cost_table_
[
c
-
2
][
r_prepre
];
if
(
std
::
isinf
(
prepre_graph_point
.
total_cost
()))
{
if
(
std
::
isinf
(
prepre_graph_point
.
total_cost
()))
{
continue
;
continue
;
}
}
if
(
!
prepre_graph_point
.
pre_point
())
{
continue
;
}
const
STPoint
&
triple_pre_point
=
prepre_graph_point
.
pre_point
()
->
point
();
const
STPoint
&
prepre_point
=
prepre_graph_point
.
point
();
const
STPoint
&
pre_point
=
pre_col
[
r_pre
].
point
();
const
STPoint
&
curr_point
=
cost_cr
.
point
();
double
cost
=
cost_cr
.
obstacle_cost
()
+
pre_col
[
r_pre
].
total_cost
()
+
CalculateEdgeCost
(
triple_pre_point
,
prepre_point
,
pre_point
,
curr_point
,
speed_limit
);
if
(
cost
<
cost_cr
.
total_cost
())
{
if
(
!
prepre_graph_point
.
pre_point
())
{
cost_cr
.
SetTotalCost
(
cost
);
continue
;
cost_cr
.
SetPrePoint
(
pre_col
[
r_pre
]);
}
}
const
STPoint
&
triple_pre_point
=
prepre_graph_point
.
pre_point
()
->
point
();
const
STPoint
&
prepre_point
=
prepre_graph_point
.
point
();
const
STPoint
&
pre_point
=
pre_col
[
r_pre
].
point
();
const
STPoint
&
curr_point
=
cost_cr
.
point
();
double
cost
=
cost_cr
.
obstacle_cost
()
+
pre_col
[
r_pre
].
total_cost
()
+
CalculateEdgeCost
(
triple_pre_point
,
prepre_point
,
pre_point
,
curr_point
,
speed_limit
);
if
(
cost
<
cost_cr
.
total_cost
())
{
cost_cr
.
SetTotalCost
(
cost
);
cost_cr
.
SetPrePoint
(
pre_col
[
r_pre
]);
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录