Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
dff81292
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,发现更多精彩内容 >>
提交
dff81292
编写于
8月 01, 2017
作者:
Z
Zhang Liangliang
提交者:
Jiangtao Hu
8月 01, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use t_knots_ in qp_spline_st_graph
上级
35f829e0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
69 deletion
+65
-69
modules/planning/optimizer/qp_spline_st_speed/qp_spline_st_graph.cc
...anning/optimizer/qp_spline_st_speed/qp_spline_st_graph.cc
+55
-59
modules/planning/optimizer/qp_spline_st_speed/qp_spline_st_graph.h
...lanning/optimizer/qp_spline_st_speed/qp_spline_st_graph.h
+9
-9
modules/planning/optimizer/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc
...imizer/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc
+1
-1
未找到文件。
modules/planning/optimizer/qp_spline_st_speed/qp_spline_st_graph.cc
浏览文件 @
dff81292
...
...
@@ -36,29 +36,29 @@ using apollo::common::VehicleParam;
QpSplineStGraph
::
QpSplineStGraph
(
const
QpSplineStSpeedConfig
&
qp_spline_st_speed_config
,
const
apollo
::
common
::
VehicleParam
&
veh_param
)
:
_qp_spline_st_speed_config
(
qp_spline_st_speed_config
),
:
qp_spline_st_speed_config_
(
qp_spline_st_speed_config
),
time_resolution_
(
_qp_spline_st_speed_config
.
total_time
()
/
_qp_spline_st_speed_config
.
number_of_discrete_graph_t
())
{}
qp_spline_st_speed_config_
.
total_time
()
/
qp_spline_st_speed_config_
.
number_of_discrete_graph_t
())
{}
void
QpSplineStGraph
::
Init
()
{
double
curr_t
=
0.0
;
for
(
uint32_t
i
=
0
;
i
<=
_qp_spline_st_speed_config
.
number_of_discrete_graph_t
();
++
i
)
{
i
<=
qp_spline_st_speed_config_
.
number_of_discrete_graph_t
();
++
i
)
{
t_knots_
.
push_back
(
curr_t
);
curr_t
+=
time_resolution_
;
}
_spline_generator
.
reset
(
new
Spline1dGenerator
(
t_knots_
,
_qp_spline_st_speed_config
.
spline_order
()));
spline_generator_
.
reset
(
new
Spline1dGenerator
(
t_knots_
,
qp_spline_st_speed_config_
.
spline_order
()));
}
Status
QpSplineStGraph
::
s
earch
(
const
StGraphData
&
st_graph_data
,
Status
QpSplineStGraph
::
S
earch
(
const
StGraphData
&
st_graph_data
,
const
PathData
&
path_data
,
SpeedData
*
const
speed_data
)
{
_init_point
=
st_graph_data
.
init_point
();
init_point_
=
st_graph_data
.
init_point
();
if
(
st_graph_data
.
path_data_length
()
<
_qp_spline_st_speed_config
.
total_path_length
())
{
_qp_spline_st_speed_config
.
set_total_path_length
(
qp_spline_st_speed_config_
.
total_path_length
())
{
qp_spline_st_speed_config_
.
set_total_path_length
(
st_graph_data
.
path_data_length
());
}
...
...
@@ -68,19 +68,19 @@ Status QpSplineStGraph::search(const StGraphData& st_graph_data,
// initialize time resolution and
Init
();
if
(
!
apply_c
onstraint
(
st_graph_data
.
obs_boundary
()).
ok
())
{
if
(
!
ApplyC
onstraint
(
st_graph_data
.
obs_boundary
()).
ok
())
{
const
std
::
string
msg
=
"Apply constraint failed!"
;
AERROR
<<
msg
;
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
}
if
(
!
apply_k
ernel
(
st_graph_data
.
speed_limit
()).
ok
())
{
if
(
!
ApplyK
ernel
(
st_graph_data
.
speed_limit
()).
ok
())
{
const
std
::
string
msg
=
"Apply kernel failed!"
;
AERROR
<<
msg
;
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
}
if
(
!
s
olve
().
ok
())
{
if
(
!
S
olve
().
ok
())
{
const
std
::
string
msg
=
"Solve qp problem failed!"
;
AERROR
<<
msg
;
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
...
...
@@ -88,11 +88,11 @@ Status QpSplineStGraph::search(const StGraphData& st_graph_data,
// extract output
speed_data
->
Clear
();
const
Spline1d
&
spline
=
_spline_generator
->
spline
();
const
Spline1d
&
spline
=
spline_generator_
->
spline
();
double
time_resolution
=
_qp_spline_st_speed_config
.
output_time_resolution
();
double
time_resolution
=
qp_spline_st_speed_config_
.
output_time_resolution
();
double
time
=
0.0
;
while
(
time
<
_qp_spline_st_speed_config
.
total_time
()
+
time_resolution
)
{
while
(
time
<
qp_spline_st_speed_config_
.
total_time
()
+
time_resolution
)
{
double
s
=
spline
(
time
);
double
v
=
spline
.
derivative
(
time
);
double
a
=
spline
.
second_order_derivative
(
time
);
...
...
@@ -104,10 +104,10 @@ Status QpSplineStGraph::search(const StGraphData& st_graph_data,
return
Status
::
OK
();
}
Status
QpSplineStGraph
::
apply_c
onstraint
(
Status
QpSplineStGraph
::
ApplyC
onstraint
(
const
std
::
vector
<
StGraphBoundary
>&
boundaries
)
{
Spline1dConstraint
*
constraint
=
_spline_generator
->
mutable_spline_constraint
();
spline_generator_
->
mutable_spline_constraint
();
// position, velocity, acceleration
if
(
!
constraint
->
add_point_fx_constraint
(
0.0
,
0.0
))
{
...
...
@@ -116,14 +116,14 @@ Status QpSplineStGraph::apply_constraint(
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
}
if
(
!
constraint
->
add_point_derivative_constraint
(
0.0
,
_init_point
.
v
()))
{
if
(
!
constraint
->
add_point_derivative_constraint
(
0.0
,
init_point_
.
v
()))
{
const
std
::
string
msg
=
"add st start point velocity constraint failed!"
;
AERROR
<<
msg
;
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
}
if
(
!
constraint
->
add_point_second_derivative_constraint
(
0.0
,
_init_point
.
a
()))
{
init_point_
.
a
()))
{
const
std
::
string
msg
=
"add st start point acceleration constraint failed!"
;
AERROR
<<
msg
;
...
...
@@ -131,7 +131,7 @@ Status QpSplineStGraph::apply_constraint(
}
if
(
!
constraint
->
add_point_second_derivative_constraint
(
_spline_generator
->
spline
().
x_knots
().
back
(),
0.0
))
{
spline_generator_
->
spline
().
x_knots
().
back
(),
0.0
))
{
const
std
::
string
msg
=
"add st end point acceleration constraint failed!"
;
AERROR
<<
msg
;
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
...
...
@@ -152,26 +152,19 @@ Status QpSplineStGraph::apply_constraint(
}
// boundary constraint
double
evaluated_resolution
=
_qp_spline_st_speed_config
.
total_time
()
/
_qp_spline_st_speed_config
.
number_of_evaluated_graph_t
();
std
::
vector
<
double
>
evaluated_knots
;
std
::
vector
<
double
>
s_upper_bound
;
std
::
vector
<
double
>
s_lower_bound
;
for
(
uint32_t
i
=
1
;
i
<=
_qp_spline_st_speed_config
.
number_of_evaluated_graph_t
();
++
i
)
{
evaluated_knots
.
push_back
(
i
*
evaluated_resolution
);
for
(
const
double
curr_t
:
t_knots_
)
{
double
lower_s
=
0.0
;
double
upper_s
=
0.0
;
get_s_constraints_by_time
(
boundaries
,
evaluated_knots
.
back
()
,
_qp_spline_st_speed_config
.
total_path_length
(),
&
upper_s
,
&
lower_s
);
GetSConstraintByTime
(
boundaries
,
curr_t
,
qp_spline_st_speed_config_
.
total_path_length
(),
&
upper_s
,
&
lower_s
);
s_upper_bound
.
push_back
(
upper_s
);
s_lower_bound
.
push_back
(
lower_s
);
}
if
(
!
constraint
->
add_fx_boundary
(
evaluated_knots
,
s_lower_bound
,
s_upper_bound
))
{
if
(
!
constraint
->
add_fx_boundary
(
t_knots_
,
s_lower_bound
,
s_upper_bound
))
{
const
std
::
string
msg
=
"Fail to apply obstacle constraint"
;
AERROR
<<
msg
;
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
...
...
@@ -181,47 +174,43 @@ Status QpSplineStGraph::apply_constraint(
return
Status
::
OK
();
}
Status
QpSplineStGraph
::
apply_k
ernel
(
const
SpeedLimit
&
speed_limit
)
{
Spline1dKernel
*
spline_kernel
=
_spline_generator
->
mutable_spline_kernel
();
Status
QpSplineStGraph
::
ApplyK
ernel
(
const
SpeedLimit
&
speed_limit
)
{
Spline1dKernel
*
spline_kernel
=
spline_generator_
->
mutable_spline_kernel
();
if
(
_qp_spline_st_speed_config
.
speed_kernel_weight
()
>
0
)
{
if
(
qp_spline_st_speed_config_
.
speed_kernel_weight
()
>
0
)
{
spline_kernel
->
add_derivative_kernel_matrix
(
_qp_spline_st_speed_config
.
speed_kernel_weight
());
qp_spline_st_speed_config_
.
speed_kernel_weight
());
}
if
(
_qp_spline_st_speed_config
.
accel_kernel_weight
()
>
0
)
{
if
(
qp_spline_st_speed_config_
.
accel_kernel_weight
()
>
0
)
{
spline_kernel
->
add_second_order_derivative_matrix
(
_qp_spline_st_speed_config
.
accel_kernel_weight
());
qp_spline_st_speed_config_
.
accel_kernel_weight
());
}
if
(
_qp_spline_st_speed_config
.
jerk_kernel_weight
()
>
0
)
{
if
(
qp_spline_st_speed_config_
.
jerk_kernel_weight
()
>
0
)
{
spline_kernel
->
add_third_order_derivative_matrix
(
_qp_spline_st_speed_config
.
jerk_kernel_weight
());
qp_spline_st_speed_config_
.
jerk_kernel_weight
());
}
// TODO(all): add reference speed profile for different main decision
std
::
vector
<
double
>
t_knots
;
std
::
vector
<
double
>
s_vec
;
if
(
speed_limit
.
speed_limits
().
size
()
==
0
)
{
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
"QpSplineStGraph::apply_kernel"
);
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
"Fail to apply_kernel due to empty speed limits."
);
}
double
dist_ref
=
0.0
;
double
curr_knot
=
0.0
;
for
(
uint32_t
i
=
0
;
i
<=
_qp_spline_st_speed_config
.
number_of_discrete_graph_t
();
++
i
)
{
t_knots
.
push_back
(
curr_knot
);
i
<=
qp_spline_st_speed_config_
.
number_of_discrete_graph_t
();
++
i
)
{
s_vec
.
push_back
(
dist_ref
);
dist_ref
+=
time_resolution_
*
speed_limit
.
get_speed_limit
(
dist_ref
);
curr_knot
+=
time_resolution_
;
}
// TODO: change reference line kernel to configurable version
spline_kernel
->
add_reference_line_kernel_matrix
(
t_knots
,
s_vec
,
1
);
spline_kernel
->
add_reference_line_kernel_matrix
(
t_knots
_
,
s_vec
,
1
);
return
Status
::
OK
();
}
Status
QpSplineStGraph
::
s
olve
()
{
return
_spline_generator
->
solve
()
Status
QpSplineStGraph
::
S
olve
()
{
return
spline_generator_
->
solve
()
?
Status
::
OK
()
:
Status
(
ErrorCode
::
PLANNING_ERROR
,
"QpSplineStGraph::solve"
);
}
...
...
@@ -237,20 +226,27 @@ Status QpSplineStGraph::AddFollowReferenceLineKernel(
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
msg
);
}
// TODO: (Liangliang) implement this dummy function.
auto
*
spline_kernel
=
_spline_generator
->
mutable_spline_kernel
();
const
std
::
vector
<
double
>
t_coord
;
const
std
::
vector
<
double
>
ref_s
;
spline_kernel
->
add_reference_line_kernel_matrix
(
t_coord
,
ref_s
,
1.0
);
auto
*
spline_kernel
=
spline_generator_
->
mutable_spline_kernel
();
std
::
vector
<
double
>
ref_s
;
for
(
const
double
curr_t
:
t_knots_
)
{
double
s_upper
=
0.0
;
double
s_lower
=
0.0
;
if
(
follow_boundary
.
get_s_boundary_position
(
curr_t
,
&
s_upper
,
&
s_lower
))
{
ref_s
.
push_back
(
s_upper
-
follow_boundary
.
characteristic_length
());
}
ref_s
.
push_back
(
s_upper
);
}
spline_kernel
->
add_reference_line_kernel_matrix
(
t_knots_
,
ref_s
,
1.0
);
return
Status
::
OK
();
}
Status
QpSplineStGraph
::
get_s_constraints_by_t
ime
(
Status
QpSplineStGraph
::
GetSConstraintByT
ime
(
const
std
::
vector
<
StGraphBoundary
>&
boundaries
,
const
double
time
,
const
double
total_path_s
,
double
*
const
s_upper_bound
,
double
*
const
s_lower_bound
)
const
{
*
s_upper_bound
=
std
::
min
(
total_path_s
,
time
*
_qp_spline_st_speed_config
.
max_speed
());
std
::
min
(
total_path_s
,
time
*
qp_spline_st_speed_config_
.
max_speed
());
for
(
const
StGraphBoundary
&
boundary
:
boundaries
)
{
double
s_upper
=
0.0
;
...
...
modules/planning/optimizer/qp_spline_st_speed/qp_spline_st_graph.h
浏览文件 @
dff81292
...
...
@@ -45,43 +45,43 @@ class QpSplineStGraph {
QpSplineStGraph
(
const
QpSplineStSpeedConfig
&
qp_config
,
const
apollo
::
common
::
VehicleParam
&
veh_param
);
common
::
Status
s
earch
(
const
StGraphData
&
st_graph_data
,
common
::
Status
S
earch
(
const
StGraphData
&
st_graph_data
,
const
PathData
&
path_data
,
SpeedData
*
const
speed_data
);
private:
void
Init
();
// apply st graph constraint
common
::
Status
apply_c
onstraint
(
common
::
Status
ApplyC
onstraint
(
const
std
::
vector
<
StGraphBoundary
>&
boundaries
);
// apply objective function
common
::
Status
apply_k
ernel
(
const
SpeedLimit
&
speed_limit
);
common
::
Status
ApplyK
ernel
(
const
SpeedLimit
&
speed_limit
);
// solve
common
::
Status
s
olve
();
common
::
Status
S
olve
();
// extract upper lower bound for constraint;
common
::
Status
get_s_constraints_by_t
ime
(
common
::
Status
GetSConstraintByT
ime
(
const
std
::
vector
<
StGraphBoundary
>&
boundaries
,
const
double
time
,
const
double
total_path_s
,
double
*
const
s_upper_bound
,
double
*
const
s_lower_bound
)
const
;
// generate reference speed profile
common
::
Status
apply_reference_speed_p
rofile
();
// common::Status ApplyReferenceSpeedP
rofile();
common
::
Status
AddFollowReferenceLineKernel
(
const
StGraphBoundary
&
follow_boundary
);
private:
// qp st configuration
QpSplineStSpeedConfig
_qp_spline_st_speed_config
;
QpSplineStSpeedConfig
qp_spline_st_speed_config_
;
// initial status
common
::
TrajectoryPoint
_init_point
;
common
::
TrajectoryPoint
init_point_
;
// solver
std
::
unique_ptr
<
Spline1dGenerator
>
_spline_generator
=
nullptr
;
std
::
unique_ptr
<
Spline1dGenerator
>
spline_generator_
=
nullptr
;
// time resolution
double
time_resolution_
=
0.0
;
...
...
modules/planning/optimizer/qp_spline_st_speed/qp_spline_st_speed_optimizer.cc
浏览文件 @
dff81292
...
...
@@ -102,7 +102,7 @@ Status QpSplineStSpeedOptimizer::Process(const PathData& path_data,
StGraphData
st_graph_data
(
boundaries
,
init_point
,
speed_limits
,
path_data
.
discretized_path
().
length
());
if
(
st_graph
.
s
earch
(
st_graph_data
,
path_data
,
speed_data
)
!=
Status
::
OK
())
{
if
(
st_graph
.
S
earch
(
st_graph_data
,
path_data
,
speed_data
)
!=
Status
::
OK
())
{
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
"Failed to search graph with dynamic programming!"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录