Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
ccd92f03
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,发现更多精彩内容 >>
提交
ccd92f03
编写于
11月 08, 2018
作者:
L
luoqi06
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Planning : update open space planner interface and use internal debug proto
上级
5bb1e5d1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
30 deletion
+46
-30
modules/planning/open_space/open_space_trajectory_generator.cc
...es/planning/open_space/open_space_trajectory_generator.cc
+19
-12
modules/planning/open_space/open_space_trajectory_generator.h
...les/planning/open_space/open_space_trajectory_generator.h
+5
-2
modules/planning/planner/open_space/open_space_planner.cc
modules/planning/planner/open_space/open_space_planner.cc
+18
-13
modules/planning/planner/open_space/open_space_planner.h
modules/planning/planner/open_space/open_space_planner.h
+4
-3
未找到文件。
modules/planning/open_space/open_space_trajectory_generator.cc
浏览文件 @
ccd92f03
...
...
@@ -38,6 +38,7 @@ using apollo::common::TrajectoryPoint;
using
apollo
::
common
::
VehicleState
;
using
apollo
::
common
::
math
::
Box2d
;
using
apollo
::
common
::
math
::
Vec2d
;
using
apollo
::
planning_internal
::
Trajectories
;
Status
OpenSpaceTrajectoryGenerator
::
Init
(
const
PlannerOpenSpaceConfig
&
planner_open_space_config
)
{
...
...
@@ -212,40 +213,45 @@ apollo::common::Status OpenSpaceTrajectoryGenerator::Plan(
// Every time update, use trajectory_partition to store each ADCTrajectory
double
relative_time
=
0.0
;
double
distance_s
=
0.0
;
ADCTrajectories
trajectory_partition
;
ADCTrajectory
*
current_trajectory
=
trajectory_partition
.
add_adc_trajectory
();
Trajectories
trajectory_partition
;
gear_positions_
.
clear
();
::
apollo
::
common
::
Trajectory
*
current_trajectory
=
trajectory_partition
.
add_trajectory
();
// set initial gear position for first ADCTrajectory depending on v
// and check potential edge cases
if
(
horizon_
<
3
)
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
"Invalid trajectory length!"
);
if
(
state_result_ds
(
3
,
0
)
>
-
1e-3
&&
state_result_ds
(
3
,
1
)
>
-
1e-3
&&
state_result_ds
(
3
,
2
)
>
-
1e-3
)
{
current_trajectory
->
set_gear
(
canbus
::
Chassis
::
GEAR_DRIVE
);
gear_positions_
.
push_back
(
canbus
::
Chassis
::
GEAR_DRIVE
);
}
else
{
if
(
state_result_ds
(
3
,
0
)
<
1e-3
&&
state_result_ds
(
3
,
1
)
<
1e-3
&&
state_result_ds
(
3
,
2
)
<
1e-3
)
{
current_trajectory
->
set_gear
(
canbus
::
Chassis
::
GEAR_REVERSE
);
gear_positions_
.
push_back
(
canbus
::
Chassis
::
GEAR_REVERSE
);
}
else
{
return
Status
(
ErrorCode
::
PLANNING_ERROR
,
"Invalid trajectory start!"
);
}
}
// partition trajectory points into each trajectory
for
(
std
::
size_t
i
=
0
;
i
<
horizon_
+
1
;
i
++
)
{
// shift from GEAR_DRIVE to GEAR_REVERSE if v < 0
// then add a new trajectory with GEAR_REVERSE
if
(
state_result_ds
(
3
,
i
)
<
-
1e-3
&&
current_trajectory
->
gear
()
==
canbus
::
Chassis
::
GEAR_DRIVE
)
{
current_trajectory
=
trajectory_partition
.
add_
adc_
trajectory
();
current_trajectory
->
set_gear
(
canbus
::
Chassis
::
GEAR_REVERSE
);
gear_positions_
.
back
()
==
canbus
::
Chassis
::
GEAR_DRIVE
)
{
current_trajectory
=
trajectory_partition
.
add_trajectory
();
gear_positions_
.
push_back
(
canbus
::
Chassis
::
GEAR_REVERSE
);
distance_s
=
0.0
;
relative_time
=
0.0
;
}
// shift from GEAR_REVERSE to GEAR_DRIVE if v > 0
// then add a new trajectory with GEAR_DRIVE
if
(
state_result_ds
(
3
,
i
)
>
1e-3
&&
current_trajectory
->
gear
()
==
canbus
::
Chassis
::
GEAR_REVERSE
)
{
current_trajectory
=
trajectory_partition
.
add_
adc_
trajectory
();
current_trajectory
->
set_gear
(
canbus
::
Chassis
::
GEAR_DRIVE
);
gear_positions_
.
back
()
==
canbus
::
Chassis
::
GEAR_REVERSE
)
{
current_trajectory
=
trajectory_partition
.
add_trajectory
();
gear_positions_
.
push_back
(
canbus
::
Chassis
::
GEAR_DRIVE
);
distance_s
=
0.0
;
relative_time
=
0.0
;
}
...
...
@@ -266,7 +272,7 @@ apollo::common::Status OpenSpaceTrajectoryGenerator::Plan(
}
point
->
mutable_path_point
()
->
set_s
(
distance_s
);
int
gear_drive
=
1
;
if
(
current_trajectory
->
gear
()
==
canbus
::
Chassis
::
GEAR_REVERSE
)
if
(
gear_positions_
.
back
()
==
canbus
::
Chassis
::
GEAR_REVERSE
)
gear_drive
=
-
1
;
point
->
set_v
(
state_result_ds
(
3
,
i
)
*
gear_drive
);
...
...
@@ -282,7 +288,8 @@ apollo::common::Status OpenSpaceTrajectoryGenerator::Plan(
}
apollo
::
common
::
Status
OpenSpaceTrajectoryGenerator
::
UpdateTrajectory
(
ADCTrajectories
*
adc_trajectories
)
{
Trajectories
*
adc_trajectories
,
std
::
vector
<
canbus
::
Chassis
::
GearPosition
>*
gear_positions
)
{
adc_trajectories
->
CopyFrom
(
trajectory_partition_
);
return
Status
::
OK
();
}
...
...
modules/planning/open_space/open_space_trajectory_generator.h
浏览文件 @
ccd92f03
...
...
@@ -36,6 +36,7 @@
#include "modules/planning/open_space/hybrid_a_star.h"
#include "modules/planning/proto/planner_open_space_config.pb.h"
#include "modules/planning/proto/planning_config.pb.h"
#include "modules/planning/proto/planning_internal.pb.h"
/*
Initially inspired by "Optimization-Based Collision Avoidance" from Xiaojing
...
...
@@ -89,7 +90,8 @@ class OpenSpaceTrajectoryGenerator {
void
BuildPredictedEnvironment
(
const
std
::
vector
<
const
Obstacle
*>&
obstacles
);
apollo
::
common
::
Status
UpdateTrajectory
(
ADCTrajectories
*
trajectory_partition
);
::
apollo
::
planning_internal
::
Trajectories
*
trajectory_partition
,
std
::
vector
<::
apollo
::
canbus
::
Chassis
::
GearPosition
>*
gear_positions
);
void
Stop
();
...
...
@@ -114,7 +116,8 @@ class OpenSpaceTrajectoryGenerator {
Eigen
::
MatrixXd
ego_
;
std
::
vector
<
double
>
XYbounds_
;
ADCTrajectories
trajectory_partition_
;
::
apollo
::
planning_internal
::
Trajectories
trajectory_partition_
;
std
::
vector
<::
apollo
::
canbus
::
Chassis
::
GearPosition
>
gear_positions_
;
};
}
// namespace planning
...
...
modules/planning/planner/open_space/open_space_planner.cc
浏览文件 @
ccd92f03
...
...
@@ -92,8 +92,10 @@ apollo::common::Status OpenSpacePlanner::Plan(
// 3. Check if trajectory updated, if so, update internal
// trajectory_partition_;
if
(
trajectory_updated_
)
{
open_space_trajectory_generator_
->
UpdateTrajectory
(
&
trajectory_partition_
);
trajectory_partition_
.
Clear
();
gear_positions_
.
clear
();
open_space_trajectory_generator_
->
UpdateTrajectory
(
&
trajectory_partition_
,
&
gear_positions_
);
AINFO
<<
"Trajectory caculation updated, new results : "
<<
trajectory_partition_
.
ShortDebugString
();
}
...
...
@@ -101,7 +103,7 @@ apollo::common::Status OpenSpacePlanner::Plan(
// If the vehicle each the end point of current trajectory and stop
// Then move to the next Trajectory
current_trajectory_
=
trajectory_partition_
.
adc_
trajectory
(
current_trajectory_index_
);
trajectory_partition_
.
trajectory
(
current_trajectory_index_
);
TrajectoryPoint
end_point
=
current_trajectory_
.
trajectory_point
(
current_trajectory_
.
trajectory_point_size
()
-
1
);
...
...
@@ -115,7 +117,7 @@ apollo::common::Status OpenSpacePlanner::Plan(
std
::
abs
(
vehicle_state_
.
heading
()
-
end_point
.
path_point
().
theta
())
<
planner_open_space_config_
.
max_theta_error_to_end_point
()
&&
(
current_trajectory_index_
<
trajectory_partition_
.
adc_
trajectory_size
()
-
1
))
{
trajectory_partition_
.
trajectory_size
()
-
1
))
{
current_trajectory_index_
+=
1
;
}
...
...
@@ -123,7 +125,8 @@ apollo::common::Status OpenSpacePlanner::Plan(
// return error status
if
(
IsCollisionFreeTrajectory
(
current_trajectory_
))
{
frame
->
mutable_trajectory
()
->
CopyFrom
(
current_trajectory_
);
// Convet current trajectory to publishable_trajectory
// frame->mutable_trajectory()->CopyFrom(current_trajectory_);
return
Status
::
OK
();
}
else
{
// If collision happens, return wrong planning status and estop
...
...
@@ -156,8 +159,10 @@ apollo::common::Status OpenSpacePlanner::Plan(
// 3. If status is OK, update vehicle trajectory;
if
(
status
==
Status
::
OK
())
{
open_space_trajectory_generator_
->
UpdateTrajectory
(
&
trajectory_partition_
);
trajectory_partition_
.
Clear
();
gear_positions_
.
clear
();
open_space_trajectory_generator_
->
UpdateTrajectory
(
&
trajectory_partition_
,
&
gear_positions_
);
AINFO
<<
"Trajectory caculation updated, new results : "
<<
trajectory_partition_
.
ShortDebugString
();
}
else
{
...
...
@@ -166,7 +171,7 @@ apollo::common::Status OpenSpacePlanner::Plan(
}
current_trajectory_
=
trajectory_partition_
.
adc_
trajectory
(
current_trajectory_index_
);
trajectory_partition_
.
trajectory
(
current_trajectory_index_
);
TrajectoryPoint
end_point
=
current_trajectory_
.
trajectory_point
(
current_trajectory_
.
trajectory_point_size
()
-
1
);
...
...
@@ -180,7 +185,7 @@ apollo::common::Status OpenSpacePlanner::Plan(
std
::
abs
(
vehicle_state_
.
heading
()
-
end_point
.
path_point
().
theta
())
<
planner_open_space_config_
.
max_theta_error_to_end_point
()
&&
(
current_trajectory_index_
<
trajectory_partition_
.
adc_
trajectory_size
()
-
1
))
{
trajectory_partition_
.
trajectory_size
()
-
1
))
{
current_trajectory_index_
+=
1
;
}
...
...
@@ -221,16 +226,16 @@ void OpenSpacePlanner::Stop() {
}
bool
OpenSpacePlanner
::
IsCollisionFreeTrajectory
(
const
ADCTrajectory
&
adc_
trajectory
)
{
CHECK_LE
(
adc_
trajectory
.
trajectory_point
().
size
(),
const
apollo
::
common
::
Trajectory
&
trajectory
)
{
CHECK_LE
(
trajectory
.
trajectory_point
().
size
(),
predicted_bounding_rectangles_
.
size
());
const
auto
&
vehicle_config
=
common
::
VehicleConfigHelper
::
Instance
()
->
GetConfig
();
double
ego_length
=
vehicle_config
.
vehicle_param
().
length
();
double
ego_width
=
vehicle_config
.
vehicle_param
().
width
();
for
(
int
i
=
0
;
i
<
adc_
trajectory
.
trajectory_point
().
size
();
++
i
)
{
const
auto
&
trajectory_point
=
adc_
trajectory
.
trajectory_point
(
i
);
for
(
int
i
=
0
;
i
<
trajectory
.
trajectory_point
().
size
();
++
i
)
{
const
auto
&
trajectory_point
=
trajectory
.
trajectory_point
(
i
);
double
ego_theta
=
trajectory_point
.
path_point
().
theta
();
Box2d
ego_box
(
{
trajectory_point
.
path_point
().
x
(),
trajectory_point
.
path_point
().
y
()},
...
...
modules/planning/planner/open_space/open_space_planner.h
浏览文件 @
ccd92f03
...
...
@@ -85,7 +85,7 @@ class OpenSpacePlanner : public Planner {
void
GenerateTrajectoryThread
();
bool
IsCollisionFreeTrajectory
(
const
ADCTrajectory
&
adc_
trajectory
);
bool
IsCollisionFreeTrajectory
(
const
common
::
Trajectory
&
trajectory
);
void
BuildPredictedEnvironment
(
const
std
::
vector
<
const
Obstacle
*>&
obstacles
);
...
...
@@ -118,8 +118,9 @@ class OpenSpacePlanner : public Planner {
std
::
mutex
open_space_mutex_
;
int
current_trajectory_index_
;
ADCTrajectory
current_trajectory_
;
ADCTrajectories
trajectory_partition_
;
apollo
::
common
::
Trajectory
current_trajectory_
;
apollo
::
planning_internal
::
Trajectories
trajectory_partition_
;
std
::
vector
<::
apollo
::
canbus
::
Chassis
::
GearPosition
>
gear_positions_
;
std
::
vector
<
std
::
vector
<
common
::
math
::
Box2d
>>
predicted_bounding_rectangles_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录