Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
479f3bca
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,发现更多精彩内容 >>
提交
479f3bca
编写于
12月 10, 2018
作者:
Y
Yajia Zhang
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prediction: code refactor for feature extractor
上级
148066e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
79 deletion
+62
-79
modules/prediction/common/prediction_gflags.cc
modules/prediction/common/prediction_gflags.cc
+8
-0
modules/prediction/common/prediction_gflags.h
modules/prediction/common/prediction_gflags.h
+4
-0
modules/prediction/scenario/feature_extractor/feature_extractor.cc
...rediction/scenario/feature_extractor/feature_extractor.cc
+50
-68
modules/prediction/scenario/feature_extractor/feature_extractor.h
...prediction/scenario/feature_extractor/feature_extractor.h
+0
-11
未找到文件。
modules/prediction/common/prediction_gflags.cc
浏览文件 @
479f3bca
...
...
@@ -241,3 +241,11 @@ DEFINE_bool(use_bell_curve_for_cost_function, false,
DEFINE_int32
(
road_graph_max_search_horizon
,
20
,
"Maximal search depth for buiding road graph"
);
DEFINE_double
(
lane_distance_threshold
,
3.0
,
"The threshold for distance to ego/neighbor lane "
"in feature extraction"
);
DEFINE_double
(
lane_angle_difference_threshold
,
M_PI
*
0.25
,
"The threshold for distance to ego/neighbor lane "
"in feature extraction"
);
modules/prediction/common/prediction_gflags.h
浏览文件 @
479f3bca
...
...
@@ -145,3 +145,7 @@ DECLARE_double(cost_function_sigma);
DECLARE_bool
(
use_bell_curve_for_cost_function
);
DECLARE_int32
(
road_graph_max_search_horizon
);
// scenario feature extraction
DECLARE_double
(
lane_distance_threshold
);
DECLARE_double
(
lane_angle_difference_threshold
);
modules/prediction/scenario/feature_extractor/feature_extractor.cc
浏览文件 @
479f3bca
...
...
@@ -23,56 +23,66 @@
#include "modules/map/hdmap/hdmap_util.h"
#include "modules/prediction/common/prediction_gflags.h"
using
apollo
::
common
::
adapter
::
AdapterConfig
;
using
apollo
::
common
::
math
::
Vec2d
;
using
apollo
::
planning
::
ADCTrajectory
;
using
apollo
::
hdmap
::
HDMapUtil
;
using
apollo
::
hdmap
::
LaneInfo
;
using
apollo
::
hdmap
::
JunctionInfo
;
using
apollo
::
hdmap
::
OverlapInfo
;
using
apollo
::
perception
::
PerceptionObstacle
;
using
LaneInfoPtr
=
std
::
shared_ptr
<
const
LaneInfo
>
;
using
JunctionInfoPtr
=
std
::
shared_ptr
<
const
JunctionInfo
>
;
namespace
apollo
{
namespace
prediction
{
using
common
::
adapter
::
AdapterConfig
;
using
common
::
math
::
Vec2d
;
using
planning
::
ADCTrajectory
;
using
hdmap
::
HDMapUtil
;
using
hdmap
::
LaneInfo
;
using
hdmap
::
JunctionInfo
;
using
hdmap
::
OverlapInfo
;
using
perception
::
PerceptionObstacle
;
using
LaneInfoPtr
=
std
::
shared_ptr
<
const
LaneInfo
>
;
using
JunctionInfoPtr
=
std
::
shared_ptr
<
const
JunctionInfo
>
;
EnvironmentFeatures
FeatureExtractor
::
ExtractEnvironmentFeatures
()
{
EnvironmentFeatures
environment_features
;
auto
pos
e_container
=
auto
ego_stat
e_container
=
ContainerManager
::
Instance
()
->
GetContainer
<
PoseContainer
>
(
AdapterConfig
::
LOCALIZATION
);
if
(
pose_container
==
nullptr
)
{
AERROR
<<
"Null pose container found."
;
if
(
ego_state_container
==
nullptr
||
ego_state_container
->
ToPerceptionObstacle
()
==
nullptr
)
{
AERROR
<<
"Null ego state container found or "
"the container pointer is nullptr"
;
return
environment_features
;
}
ExtractEgoVehicleFeatures
(
&
environment_features
);
const
PerceptionObstacle
*
ptr_ego_pose
=
pose_container
->
ToPerceptionObstacle
();
if
(
ptr_ego_pose
==
nullptr
)
{
AERROR
<<
"Null pose pointer, skip extracting environment features."
;
auto
ptr_ego_state
=
ego_state_container
->
ToPerceptionObstacle
();
if
(
!
ptr_ego_state
->
has_position
()
||
!
ptr_ego_state
->
position
().
has_x
()
||
!
ptr_ego_state
->
position
().
has_y
()
||
!
ptr_ego_state
->
has_theta
()
||
!
ptr_ego_state
->
has_velocity
()
||
!
ptr_ego_state
->
velocity
().
has_x
()
||
!
ptr_ego_state
->
velocity
().
has_y
())
{
AERROR
<<
"Incomplete ego pose information."
;
return
environment_features
;
}
if
(
!
ptr_ego_pose
->
position
().
has_x
()
||
!
ptr_ego_pose
->
position
().
has_y
())
{
AERROR
<<
"Fail to get ego vehicle position"
;
if
(
std
::
isnan
(
ptr_ego_state
->
position
().
x
())
||
std
::
isnan
(
ptr_ego_state
->
position
().
y
())
||
std
::
isnan
(
ptr_ego_state
->
theta
())
||
std
::
isnan
(
ptr_ego_state
->
velocity
().
x
())
||
std
::
isnan
(
ptr_ego_state
->
velocity
().
y
()))
{
AERROR
<<
"nan found in ego state"
;
return
environment_features
;
}
// TODO(all): check the coordinate frame.
if
(
!
ptr_ego_pose
->
has_theta
())
{
AERROR
<<
"Fail to get ego vehicle heading"
;
return
environment_features
;
}
auto
ptr_ego_lane
=
GetEgoLane
(
ptr_ego_pose
->
position
(),
ptr_ego_pose
->
theta
());
Vec2d
ego_position
(
ptr_ego_state
->
position
().
x
(),
ptr_ego_state
->
position
().
y
());
Vec2d
ego_velocity
(
ptr_ego_state
->
velocity
().
x
(),
ptr_ego_state
->
velocity
().
y
());
environment_features
.
set_ego_speed
(
ego_velocity
.
Length
());
environment_features
.
set_ego_heading
(
ptr_ego_state
->
theta
());
Vec2d
ego_position
(
ptr_ego_pose
->
position
().
x
(),
ptr_ego_
pose
->
position
().
y
());
auto
ptr_ego_lane
=
GetEgoLane
(
ptr_ego_state
->
position
(),
ptr_ego_
state
->
theta
());
ExtractEgoLaneFeatures
(
&
environment_features
,
ptr_ego_lane
,
ego_position
);
...
...
@@ -82,31 +92,9 @@ EnvironmentFeatures FeatureExtractor::ExtractEnvironmentFeatures() {
ExtractFrontJunctionFeatures
(
&
environment_features
);
ExtractObstacleFeatures
(
&
environment_features
);
// TODO(all): add other features
return
environment_features
;
}
void
FeatureExtractor
::
ExtractEgoVehicleFeatures
(
EnvironmentFeatures
*
ptr_environment_features
)
{
auto
pose_container
=
ContainerManager
::
Instance
()
->
GetContainer
<
PoseContainer
>
(
AdapterConfig
::
LOCALIZATION
);
const
PerceptionObstacle
*
pose_ptr
=
pose_container
->
ToPerceptionObstacle
();
if
(
pose_ptr
==
nullptr
)
{
AERROR
<<
"Null pose pointer"
;
return
;
}
// TODO(all): change this to ego_speed and ego_heading
double
pose_speed
=
std
::
hypot
(
pose_ptr
->
velocity
().
x
(),
pose_ptr
->
velocity
().
y
());
ptr_environment_features
->
set_ego_speed
(
pose_speed
);
ptr_environment_features
->
set_ego_heading
(
pose_ptr
->
theta
());
// TODO(all): add acceleration if needed
}
void
FeatureExtractor
::
ExtractEgoLaneFeatures
(
EnvironmentFeatures
*
ptr_environment_features
,
const
LaneInfoPtr
&
ptr_ego_lane
,
...
...
@@ -150,11 +138,9 @@ void FeatureExtractor::ExtractNeighborLaneFeatures(
return
;
}
// TODO(all): make this a gflag
double
threshold
=
3.0
;
auto
ptr_left_neighbor_lane
=
PredictionMap
::
GetLeftNeighborLane
(
ptr_ego_lane
,
{
ego_position
.
x
(),
ego_position
.
y
()},
threshold
);
ptr_ego_lane
,
{
ego_position
.
x
(),
ego_position
.
y
()},
FLAGS_lane_distance_threshold
);
if
(
ptr_left_neighbor_lane
!=
nullptr
)
{
double
left_neighbor_lane_s
=
0.0
;
...
...
@@ -166,7 +152,9 @@ void FeatureExtractor::ExtractNeighborLaneFeatures(
}
auto
ptr_right_neighbor_lane
=
PredictionMap
::
GetRightNeighborLane
(
ptr_ego_lane
,
{
ego_position
.
x
(),
ego_position
.
y
()},
threshold
);
ptr_ego_lane
,
{
ego_position
.
x
(),
ego_position
.
y
()},
FLAGS_lane_distance_threshold
);
if
(
ptr_right_neighbor_lane
!=
nullptr
)
{
double
right_neighbor_lane_s
=
0.0
;
double
right_neighbor_lane_l
=
0.0
;
...
...
@@ -208,22 +196,16 @@ void FeatureExtractor::ExtractFrontJunctionFeatures(
}
}
void
FeatureExtractor
::
ExtractObstacleFeatures
(
EnvironmentFeatures
*
ptr_environment_features
)
{
}
LaneInfoPtr
FeatureExtractor
::
GetEgoLane
(
const
common
::
Point3D
&
position
,
const
double
heading
)
{
// TODO(all): move to gflags
apollo
::
common
::
PointENU
position_enu
;
common
::
PointENU
position_enu
;
position_enu
.
set_x
(
position
.
x
());
position_enu
.
set_y
(
position
.
y
());
position_enu
.
set_z
(
position
.
z
());
double
angle_diff_threshold
=
M_PI
*
0.25
;
double
radius
=
3.0
;
return
PredictionMap
::
GetMostLikelyCurrentLane
(
position_enu
,
radius
,
heading
,
angle_diff_threshold
);
return
PredictionMap
::
GetMostLikelyCurrentLane
(
position_enu
,
FLAGS_lane_distance_threshold
,
heading
,
FLAGS_lane_angle_difference_threshold
);
}
}
// namespace prediction
...
...
modules/prediction/scenario/feature_extractor/feature_extractor.h
浏览文件 @
479f3bca
...
...
@@ -41,11 +41,6 @@ class FeatureExtractor {
*/
FeatureExtractor
()
=
delete
;
/**
* @brief Destructor
*/
virtual
~
FeatureExtractor
()
=
delete
;
/**
* @brief Extract features for scenario analysis
* @return Scenario features
...
...
@@ -55,9 +50,6 @@ class FeatureExtractor {
FRIEND_TEST
(
FeatureExtractorTest
,
junction
);
private:
static
void
ExtractEgoVehicleFeatures
(
EnvironmentFeatures
*
ptr_environment_features
);
static
void
ExtractEgoLaneFeatures
(
EnvironmentFeatures
*
ptr_environment_features
,
const
std
::
shared_ptr
<
const
hdmap
::
LaneInfo
>&
ptr_ego_lane
,
...
...
@@ -71,9 +63,6 @@ class FeatureExtractor {
static
void
ExtractFrontJunctionFeatures
(
EnvironmentFeatures
*
ptr_environment_features
);
static
void
ExtractObstacleFeatures
(
EnvironmentFeatures
*
ptr_environment_features
);
static
std
::
shared_ptr
<
const
hdmap
::
LaneInfo
>
GetEgoLane
(
const
common
::
Point3D
&
position
,
const
double
heading
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录