Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
fa332414
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,发现更多精彩内容 >>
提交
fa332414
编写于
12月 25, 2017
作者:
L
Liangliang Zhang
提交者:
Dong Li
12月 25, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Planning: added cost calculation for poly st graph. (#2064)
上级
e458f734
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
29 deletion
+72
-29
modules/planning/tasks/path_optimizer.cc
modules/planning/tasks/path_optimizer.cc
+1
-1
modules/planning/tasks/poly_st_speed/poly_st_graph.cc
modules/planning/tasks/poly_st_speed/poly_st_graph.cc
+15
-20
modules/planning/tasks/poly_st_speed/poly_st_graph.h
modules/planning/tasks/poly_st_speed/poly_st_graph.h
+2
-1
modules/planning/tasks/poly_st_speed/speed_profile_cost.cc
modules/planning/tasks/poly_st_speed/speed_profile_cost.cc
+45
-5
modules/planning/tasks/poly_st_speed/speed_profile_cost.h
modules/planning/tasks/poly_st_speed/speed_profile_cost.h
+9
-2
未找到文件。
modules/planning/tasks/path_optimizer.cc
浏览文件 @
fa332414
...
...
@@ -15,7 +15,7 @@
*****************************************************************************/
/**
* @file
path_optimizer.cpp
* @file
**/
#include "modules/planning/tasks/path_optimizer.h"
...
...
modules/planning/tasks/poly_st_speed/poly_st_graph.cc
浏览文件 @
fa332414
...
...
@@ -21,9 +21,7 @@
#include "modules/planning/tasks/poly_st_speed/poly_st_graph.h"
#include <algorithm>
#include <unordered_map>
#include "modules/common/proto/error_code.pb.h"
#include "modules/common/proto/pnc_point.pb.h"
#include "modules/planning/proto/planning_internal.pb.h"
...
...
@@ -54,20 +52,23 @@ bool PolyStGraph::FindStTunnel(
SpeedData
*
const
speed_data
)
{
CHECK_NOTNULL
(
speed_data
);
// set init point
init_point_
=
init_point
;
std
::
vector
<
PolyStGraphNode
>
min_cost_path
;
if
(
!
GenerateMinCostSpeedProfile
(
obstacles
,
&
min_cost_path
))
{
AERROR
<<
"Fail to generate graph!"
;
// sample end points
std
::
vector
<
std
::
vector
<
STPoint
>>
points
;
if
(
!
SampleStPoints
(
&
points
))
{
AERROR
<<
"Fail to sample st points."
;
return
false
;
}
std
::
vector
<
PolyStGraphNode
>
min_cost_speed_profil
e
;
if
(
!
GenerateMinCostSpeedProfile
(
obstacles
,
&
min_cost_speed_profil
e
))
{
PolyStGraphNode
min_cost_nod
e
;
if
(
!
GenerateMinCostSpeedProfile
(
points
,
obstacles
,
&
min_cost_nod
e
))
{
AERROR
<<
"Fail to search min cost speed profile."
;
return
false
;
}
constexpr
double
delta_t
=
0.1
;
// output resolution, in seconds
const
auto
curve
=
min_cost_
speed_profile
.
back
()
.
speed_profile
;
const
auto
curve
=
min_cost_
node
.
speed_profile
;
for
(
double
t
=
0.0
;
t
<
planning_time_
;
t
+=
delta_t
)
{
const
double
s
=
curve
.
Evaluate
(
0
,
t
);
const
double
v
=
curve
.
Evaluate
(
1
,
t
);
...
...
@@ -79,19 +80,13 @@ bool PolyStGraph::FindStTunnel(
}
bool
PolyStGraph
::
GenerateMinCostSpeedProfile
(
const
std
::
vector
<
std
::
vector
<
STPoint
>>
&
points
,
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles
,
std
::
vector
<
PolyStGraphNode
>
*
min_cost_speed_profile
)
{
CHECK
(
min_cost_speed_profile
!=
nullptr
);
std
::
vector
<
std
::
vector
<
STPoint
>>
points
;
if
(
!
SampleStPoints
(
&
points
))
{
AERROR
<<
"Fail to sample st points."
;
return
false
;
}
PolyStGraphNode
*
const
min_cost_node
)
{
CHECK_NOTNULL
(
min_cost_node
);
PolyStGraphNode
start_node
=
{
STPoint
(
0.0
,
0.0
),
init_point_
.
v
(),
init_point_
.
a
()};
min_cost_speed_profile
->
resize
(
2
);
min_cost_speed_profile
->
front
()
=
start_node
;
SpeedProfileCost
cost
(
config_
,
obstacles
);
SpeedProfileCost
cost
(
config_
,
obstacles
,
speed_limit_
);
double
min_cost
=
std
::
numeric_limits
<
double
>::
max
();
for
(
const
auto
&
level
:
points
)
{
for
(
const
auto
&
st_point
:
level
)
{
...
...
@@ -103,9 +98,9 @@ bool PolyStGraph::GenerateMinCostSpeedProfile(
node
.
speed_profile
=
QuinticPolynomialCurve1d
(
0.0
,
start_node
.
speed
,
start_node
.
accel
,
node
.
st_point
.
s
(),
node
.
speed
,
node
.
accel
,
node
.
st_point
.
t
());
const
double
c
=
cost
.
Calculate
(
node
.
speed_profile
);
const
double
c
=
cost
.
Calculate
(
node
.
speed_profile
,
st_point
.
t
()
);
if
(
c
<
min_cost
)
{
min_cost_speed_profile
->
back
()
=
node
;
*
min_cost_node
=
node
;
min_cost
=
c
;
}
}
...
...
modules/planning/tasks/poly_st_speed/poly_st_graph.h
浏览文件 @
fa332414
...
...
@@ -71,8 +71,9 @@ class PolyStGraph {
};
bool
GenerateMinCostSpeedProfile
(
const
std
::
vector
<
std
::
vector
<
STPoint
>>
&
points
,
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles
,
std
::
vector
<
PolyStGraphNode
>
*
min_cost_path
);
PolyStGraphNode
*
const
min_cost_node
);
bool
SampleStPoints
(
std
::
vector
<
std
::
vector
<
STPoint
>>
*
const
points
);
...
...
modules/planning/tasks/poly_st_speed/speed_profile_cost.cc
浏览文件 @
fa332414
...
...
@@ -20,19 +20,59 @@
#include "modules/planning/tasks/poly_st_speed/speed_profile_cost.h"
#include <limits>
namespace
apollo
{
namespace
planning
{
namespace
{
constexpr
auto
kInfCost
=
std
::
numeric_limits
<
double
>::
infinity
();
}
using
apollo
::
common
::
TrajectoryPoint
;
SpeedProfileCost
::
SpeedProfileCost
(
const
PolyStSpeedConfig
&
config
,
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles
)
:
config_
(
config
),
obstacles_
(
obstacles
)
{}
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles
,
const
SpeedLimit
&
speed_limit
)
:
config_
(
config
),
obstacles_
(
obstacles
),
speed_limit_
(
speed_limit
)
{}
double
SpeedProfileCost
::
Calculate
(
const
QuinticPolynomialCurve1d
&
curve
,
const
double
end_time
)
const
{
double
cost
=
0.0
;
constexpr
double
kDeltaT
=
0.5
;
for
(
double
t
=
kDeltaT
;
t
<=
end_time
;
t
=
std
::
fmin
(
end_time
,
t
+
end_time
))
{
cost
+=
CalculatePointCost
(
curve
,
t
);
}
return
cost
;
}
double
SpeedProfileCost
::
CalculatePointCost
(
const
QuinticPolynomialCurve1d
&
curve
,
const
double
t
)
const
{
const
double
s
=
curve
.
Evaluate
(
0
,
t
);
const
double
v
=
curve
.
Evaluate
(
1
,
t
);
const
double
a
=
curve
.
Evaluate
(
2
,
t
);
const
double
da
=
curve
.
Evaluate
(
3
,
t
);
double
SpeedProfileCost
::
Calculate
(
const
QuinticPolynomialCurve1d
&
curve
)
const
{
return
0.0
;
const
double
speed_limit
=
speed_limit_
.
GetSpeedLimitByS
(
s
);
if
(
v
>
speed_limit
*
1.05
)
{
return
kInfCost
;
}
if
(
a
>
1.5
||
a
<
-
4.5
)
{
return
kInfCost
;
}
for
(
const
auto
*
obstacle
:
obstacles_
)
{
auto
boundary
=
obstacle
->
st_boundary
();
if
(
boundary
.
IsPointInBoundary
(
STPoint
(
s
,
t
)))
{
return
kInfCost
;
}
}
double
cost
=
0.0
;
constexpr
double
kSpeedCost
=
1.0
;
cost
+=
kSpeedCost
*
std
::
pow
((
v
-
speed_limit
),
2
);
constexpr
double
kJerkCost
=
1.0
;
cost
+=
kJerkCost
*
std
::
pow
(
da
,
2
);
return
cost
;
}
}
// namespace planning
...
...
modules/planning/tasks/poly_st_speed/speed_profile_cost.h
浏览文件 @
fa332414
...
...
@@ -27,6 +27,7 @@
#include "modules/planning/common/obstacle.h"
#include "modules/planning/common/path_decision.h"
#include "modules/planning/common/speed_limit.h"
#include "modules/planning/math/curve1d/quintic_polynomial_curve1d.h"
namespace
apollo
{
...
...
@@ -35,13 +36,19 @@ namespace planning {
class
SpeedProfileCost
{
public:
explicit
SpeedProfileCost
(
const
PolyStSpeedConfig
&
config
,
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles
);
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles
,
const
SpeedLimit
&
speed_limit
);
double
Calculate
(
const
QuinticPolynomialCurve1d
&
curve
)
const
;
double
Calculate
(
const
QuinticPolynomialCurve1d
&
curve
,
const
double
end_time
)
const
;
private:
double
CalculatePointCost
(
const
QuinticPolynomialCurve1d
&
curve
,
const
double
t
)
const
;
const
PolyStSpeedConfig
config_
;
const
std
::
vector
<
const
PathObstacle
*>
&
obstacles_
;
const
SpeedLimit
&
speed_limit_
;
};
}
// namespace planning
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录