Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
6001cff5
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,发现更多精彩内容 >>
提交
6001cff5
编写于
9月 13, 2018
作者:
K
kechxu
提交者:
Yajia Zhang
9月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prediction: refactor callback functions according to cybertron
上级
9db10404
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
32 deletion
+43
-32
modules/prediction/prediction_component.cc
modules/prediction/prediction_component.cc
+32
-24
modules/prediction/prediction_component.h
modules/prediction/prediction_component.h
+11
-8
未找到文件。
modules/prediction/prediction_component.cc
浏览文件 @
6001cff5
...
...
@@ -54,6 +54,7 @@ using apollo::common::util::Glob;
using
apollo
::
localization
::
LocalizationEstimate
;
using
apollo
::
perception
::
PerceptionObstacle
;
using
apollo
::
perception
::
PerceptionObstacles
;
using
apollo
::
planning
::
ADCTrajectory
;
std
::
string
PredictionComponent
::
Name
()
const
{
return
FLAGS_prediction_module_name
;
...
...
@@ -122,16 +123,29 @@ bool PredictionComponent::Init() {
EvaluatorManager
::
Instance
()
->
Init
(
prediction_conf_
);
PredictorManager
::
Instance
()
->
Init
(
prediction_conf_
);
// TODO(all) move channel names to conf
localization_reader_
=
node_
->
CreateReader
<
LocalizationEstimate
>
(
"/apollo/localization"
,
[
this
](
const
std
::
shared_ptr
<
LocalizationEstimate
>&
localization
)
{
ADEBUG
<<
"Received localization data: run localization callback."
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
OnLocalization
(
*
localization
);
});
planning_reader_
=
node_
->
CreateReader
<
ADCTrajectory
>
(
"/apollo/planning"
,
[
this
](
const
std
::
shared_ptr
<
ADCTrajectory
>&
adc_trajectory
)
{
ADEBUG
<<
"Received planning data: run planning callback."
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
OnPlanning
(
*
adc_trajectory
);
});
// CHECK(AdapterManager::GetLocalization())
// << "Localization is not registered.";
// CHECK(AdapterManager::GetPerceptionObstacles())
// << "Perception is not registered.";
/* TODO(kechxu) recover callbacks according to cybertron
// Set localization callback function
AdapterManager::AddLocalizationCallback(&Prediction::OnLocalization, this);
// Set planning callback function
AdapterManager::AddPlanningCallback(&Prediction::OnPlanning, this);
// Set perception obstacle callback function
AdapterManager::AddPerceptionObstaclesCallback(&Prediction::RunOnce, this);
*/
...
...
@@ -170,13 +184,6 @@ bool PredictionComponent::Init() {
return
true
;
}
bool
PredictionComponent
::
Proc
(
const
std
::
shared_ptr
<
perception
::
PerceptionObstacles
>&
perception_obstacles
)
{
// TODO(all) implement
return
true
;
}
Status
PredictionComponent
::
Start
()
{
return
Status
::
OK
();
}
void
PredictionComponent
::
Stop
()
{
...
...
@@ -209,8 +216,8 @@ void PredictionComponent::OnPlanning(
<<
"]."
;
}
void
PredictionComponent
::
RunOnce
(
const
PerceptionObstacles
&
perception_obstacles
)
{
bool
PredictionComponent
::
Proc
(
const
std
::
shared_ptr
<
PerceptionObstacles
>
&
perception_obstacles
)
{
if
(
FLAGS_prediction_test_mode
&&
FLAGS_prediction_test_duration
>
0.0
&&
(
Clock
::
NowInSeconds
()
-
start_time_
>
FLAGS_prediction_test_duration
))
{
AINFO
<<
"Prediction finished running in test mode"
;
...
...
@@ -222,7 +229,7 @@ void PredictionComponent::RunOnce(
// AdapterManager::Observe();
if
(
FLAGS_use_navigation_mode
&&
!
PredictionMap
::
Ready
())
{
AERROR
<<
"Relative map is empty."
;
return
;
return
false
;
}
double
start_timestamp
=
Clock
::
NowInSeconds
();
...
...
@@ -232,10 +239,10 @@ void PredictionComponent::RunOnce(
ContainerManager
::
Instance
()
->
GetContainer
(
AdapterConfig
::
PERCEPTION_OBSTACLES
));
CHECK_NOTNULL
(
obstacles_container
);
obstacles_container
->
Insert
(
perception_obstacles
);
obstacles_container
->
Insert
(
*
perception_obstacles
);
ADEBUG
<<
"Received a perception message ["
<<
perception_obstacles
.
ShortDebugString
()
<<
"]."
;
<<
perception_obstacles
->
ShortDebugString
()
<<
"]."
;
// Update ADC status
PoseContainer
*
pose_container
=
dynamic_cast
<
PoseContainer
*>
(
...
...
@@ -258,26 +265,26 @@ void PredictionComponent::RunOnce(
}
// Make evaluations
EvaluatorManager
::
Instance
()
->
Run
(
perception_obstacles
);
EvaluatorManager
::
Instance
()
->
Run
(
*
perception_obstacles
);
// No prediction for offline mode
// No prediction
trajectories
for offline mode
if
(
FLAGS_prediction_offline_mode
)
{
return
;
return
true
;
}
// Make predictions
PredictorManager
::
Instance
()
->
Run
(
perception_obstacles
);
PredictorManager
::
Instance
()
->
Run
(
*
perception_obstacles
);
auto
prediction_obstacles
=
PredictorManager
::
Instance
()
->
prediction_obstacles
();
prediction_obstacles
.
set_start_timestamp
(
start_timestamp
);
prediction_obstacles
.
set_end_timestamp
(
Clock
::
NowInSeconds
());
prediction_obstacles
.
mutable_header
()
->
set_lidar_timestamp
(
perception_obstacles
.
header
().
lidar_timestamp
());
perception_obstacles
->
header
().
lidar_timestamp
());
prediction_obstacles
.
mutable_header
()
->
set_camera_timestamp
(
perception_obstacles
.
header
().
camera_timestamp
());
perception_obstacles
->
header
().
camera_timestamp
());
prediction_obstacles
.
mutable_header
()
->
set_radar_timestamp
(
perception_obstacles
.
header
().
radar_timestamp
());
perception_obstacles
->
header
().
radar_timestamp
());
if
(
FLAGS_prediction_test_mode
)
{
for
(
auto
const
&
prediction_obstacle
:
...
...
@@ -287,7 +294,7 @@ void PredictionComponent::RunOnce(
if
(
!
ValidationChecker
::
ValidTrajectoryPoint
(
trajectory_point
))
{
AERROR
<<
"Invalid trajectory point ["
<<
trajectory_point
.
ShortDebugString
()
<<
"]"
;
return
;
return
false
;
}
}
}
...
...
@@ -295,6 +302,7 @@ void PredictionComponent::RunOnce(
}
// TODO(all) accord to cybertron
// Publish(&prediction_obstacles);
return
true
;
}
Status
PredictionComponent
::
OnError
(
const
std
::
string
&
error_msg
)
{
...
...
modules/prediction/prediction_component.h
浏览文件 @
6001cff5
...
...
@@ -21,9 +21,10 @@
#ifndef MODULES_PREDICTION_PREDICTION_COMPONENT_H_
#define MODULES_PREDICTION_PREDICTION_COMPONENT_H_
#include <memory>
#include <string>
#include <vector>
#include <memory>
#include <mutex>
#include "cybertron/component/component.h"
#include "modules/common/status/status.h"
...
...
@@ -61,6 +62,10 @@ class PredictionComponent :
*/
bool
Init
()
override
;
/**
* @brief Data callback upon receiving a perception obstacle message.
* @param perception_obstacles received message.
*/
bool
Proc
(
const
std
::
shared_ptr
<
perception
::
PerceptionObstacles
>&
perception_obstacles
)
override
;
...
...
@@ -75,13 +80,6 @@ class PredictionComponent :
*/
void
Stop
();
/**
* @brief Data callback upon receiving a perception obstacle message.
* @param perception_obstacles received message.
*/
void
RunOnce
(
const
perception
::
PerceptionObstacles
&
perception_obstacles
);
private:
common
::
Status
OnError
(
const
std
::
string
&
error_msg
);
...
...
@@ -101,6 +99,11 @@ class PredictionComponent :
PredictionConf
prediction_conf_
;
common
::
adapter
::
AdapterManagerConfig
adapter_conf_
;
std
::
shared_ptr
<
Reader
<
localization
::
LocalizationEstimate
>>
localization_reader_
;
std
::
shared_ptr
<
Reader
<
planning
::
ADCTrajectory
>>
planning_reader_
;
std
::
mutex
mutex_
;
};
CYBERTRON_REGISTER_COMPONENT
(
PredictionComponent
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录