Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
0f180510
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,发现更多精彩内容 >>
提交
0f180510
编写于
8月 03, 2017
作者:
S
siyangy
提交者:
Jiangtao Hu
8月 03, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow setting multiple callbacks
上级
6ba6e887
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
27 addition
and
26 deletion
+27
-26
modules/canbus/canbus.cc
modules/canbus/canbus.cc
+1
-1
modules/canbus/tools/teleop.cc
modules/canbus/tools/teleop.cc
+1
-1
modules/common/adapters/adapter.h
modules/common/adapters/adapter.h
+9
-8
modules/common/adapters/adapter_manager.h
modules/common/adapters/adapter_manager.h
+4
-4
modules/control/control.cc
modules/control/control.cc
+2
-2
modules/control/tools/terminal.cc
modules/control/tools/terminal.cc
+1
-1
modules/dreamview/backend/sim_control/sim_control.cc
modules/dreamview/backend/sim_control/sim_control.cc
+2
-2
modules/dreamview/backend/simulation_world/simulation_world_service.cc
...view/backend/simulation_world/simulation_world_service.cc
+1
-1
modules/perception/perception.cc
modules/perception/perception.cc
+1
-1
modules/prediction/prediction.cc
modules/prediction/prediction.cc
+1
-1
modules/routing/routing.cc
modules/routing/routing.cc
+4
-4
未找到文件。
modules/canbus/canbus.cc
浏览文件 @
0f180510
...
...
@@ -130,7 +130,7 @@ Status Canbus::Start() {
const
double
duration
=
1.0
/
FLAGS_chassis_freq
;
timer_
=
AdapterManager
::
CreateTimer
(
ros
::
Duration
(
duration
),
&
Canbus
::
OnTimer
,
this
);
AdapterManager
::
Set
ControlCommandCallback
(
&
Canbus
::
OnControlCommand
,
this
);
AdapterManager
::
Add
ControlCommandCallback
(
&
Canbus
::
OnControlCommand
,
this
);
// last step: publish monitor messages
apollo
::
common
::
monitor
::
MonitorBuffer
buffer
(
&
monitor_
);
...
...
modules/canbus/tools/teleop.cc
浏览文件 @
0f180510
...
...
@@ -335,7 +335,7 @@ class Teleop {
return
-
1
;
}
is_running_
=
true
;
AdapterManager
::
Set
ChassisCallback
(
&
Teleop
::
OnChassis
,
this
);
AdapterManager
::
Add
ChassisCallback
(
&
Teleop
::
OnChassis
,
this
);
keyboard_thread_
.
reset
(
new
std
::
thread
([
this
]
{
KeyboardLoopThreadFunc
();
}));
if
(
keyboard_thread_
==
nullptr
)
{
...
...
modules/common/adapters/adapter.h
浏览文件 @
0f180510
...
...
@@ -145,7 +145,7 @@ class Adapter {
*/
void
OnReceive
(
const
D
&
message
)
{
EnqueueData
(
message
);
FireCallback
(
message
);
FireCallback
s
(
message
);
}
/**
...
...
@@ -228,8 +228,8 @@ class Adapter {
* message hits the adapter.
* @param callback the callback with signature void(const D &).
*/
void
Set
Callback
(
Callback
callback
)
{
receive_callback
_
=
callback
;
void
Add
Callback
(
Callback
callback
)
{
receive_callback
s_
.
push_back
(
callback
)
;
}
/**
...
...
@@ -346,12 +346,13 @@ class Adapter {
}
/**
* @brief proactively invokes the callback with the specified data.
* @brief proactively invokes the callbacks one by one registered with the
* specified data.
* @param data the specified data.
*/
void
FireCallback
(
const
D
&
data
)
{
if
(
receive_callback_
!=
nullptr
)
{
receive_callback_
(
data
);
void
FireCallback
s
(
const
D
&
data
)
{
for
(
const
auto
&
callback
:
receive_callbacks_
)
{
callback
(
data
);
}
}
...
...
@@ -391,7 +392,7 @@ class Adapter {
std
::
list
<
std
::
shared_ptr
<
D
>>
observed_queue_
;
/// User defined function when receiving a message
Callback
receive_callback_
=
nullptr
;
std
::
vector
<
Callback
>
receive_callbacks_
;
/// The mutex guarding data_queue_ and observed_queue_
mutable
std
::
mutex
mutex_
;
...
...
modules/common/adapters/adapter_manager.h
浏览文件 @
0f180510
...
...
@@ -77,15 +77,15 @@ namespace adapter {
"Data type must be the same with adapter's type!"); \
instance()->name##_->FillHeader(module_name, data); \
} \
static void
Set
##name##Callback(name##Adapter::Callback callback) { \
static void
Add
##name##Callback(name##Adapter::Callback callback) { \
CHECK(instance()->name##_) \
<< "Initialize adapter before setting callback"; \
instance()->name##_->
Set
Callback(callback); \
instance()->name##_->
Add
Callback(callback); \
} \
template <class T> \
static void
Set
##name##Callback( \
static void
Add
##name##Callback( \
void (T::*fp)(const name##Adapter::DataType &data), T *obj) { \
Set
##name##Callback(std::bind(fp, obj, std::placeholders::_1)); \
Add
##name##Callback(std::bind(fp, obj, std::placeholders::_1)); \
} \
\
private: \
...
...
modules/control/control.cc
浏览文件 @
0f180510
...
...
@@ -86,8 +86,8 @@ Status Control::Init() {
CHECK
(
AdapterManager
::
GetControlCommand
())
<<
"ControlCommand publisher is not initialized."
;
AdapterManager
::
Set
PadCallback
(
&
Control
::
OnPad
,
this
);
AdapterManager
::
Set
MonitorCallback
(
&
Control
::
OnMonitor
,
this
);
AdapterManager
::
Add
PadCallback
(
&
Control
::
OnPad
,
this
);
AdapterManager
::
Add
MonitorCallback
(
&
Control
::
OnMonitor
,
this
);
return
Status
::
OK
();
}
...
...
modules/control/tools/terminal.cc
浏览文件 @
0f180510
...
...
@@ -157,7 +157,7 @@ int main(int argc, char **argv) {
}
AdapterManager
::
Init
(
config
);
AdapterManager
::
Set
ChassisCallback
(
on_chassis
);
AdapterManager
::
Add
ChassisCallback
(
on_chassis
);
help
();
std
::
thread
terminal_thread
(
terminal_thread_func
);
...
...
modules/dreamview/backend/sim_control/sim_control.cc
浏览文件 @
0f180510
...
...
@@ -80,8 +80,8 @@ void SimControl::SetStartPoint(const RoutingResponse& routing) {
void
SimControl
::
Start
()
{
if
(
initial_start_
)
{
// Setup planning and routing result data callback.
AdapterManager
::
Set
PlanningCallback
(
&
SimControl
::
OnPlanning
,
this
);
AdapterManager
::
Set
RoutingResponseCallback
(
&
SimControl
::
SetStartPoint
,
this
);
AdapterManager
::
Add
PlanningCallback
(
&
SimControl
::
OnPlanning
,
this
);
AdapterManager
::
Add
RoutingResponseCallback
(
&
SimControl
::
SetStartPoint
,
this
);
// Start timer to publish localiztion and chassis messages.
sim_control_timer_
=
AdapterManager
::
CreateTimer
(
...
...
modules/dreamview/backend/simulation_world/simulation_world_service.cc
浏览文件 @
0f180510
...
...
@@ -601,7 +601,7 @@ void SimulationWorldService::UpdateSimulationWorld(
void
SimulationWorldService
::
RegisterMonitorCallback
()
{
if
(
CheckAdapterInitialized
(
"Monitor"
,
AdapterManager
::
GetMonitor
()))
{
AdapterManager
::
Set
MonitorCallback
(
AdapterManager
::
Add
MonitorCallback
(
&
SimulationWorldService
::
UpdateSimulationWorld
,
this
);
}
}
...
...
modules/perception/perception.cc
浏览文件 @
0f180510
...
...
@@ -44,7 +44,7 @@ Status Perception::Init() {
}
CHECK
(
AdapterManager
::
GetPointCloud
())
<<
"PointCloud is not initialized."
;
AdapterManager
::
Set
PointCloudCallback
(
&
Perception
::
OnPointCloud
,
this
);
AdapterManager
::
Add
PointCloudCallback
(
&
Perception
::
OnPointCloud
,
this
);
return
Status
::
OK
();
}
...
...
modules/prediction/prediction.cc
浏览文件 @
0f180510
...
...
@@ -73,7 +73,7 @@ Status Prediction::Init() {
CHECK
(
AdapterManager
::
GetPerceptionObstacles
())
<<
"Perception is not ready."
;
// Set perception obstacle callback function
AdapterManager
::
Set
PerceptionObstaclesCallback
(
&
Prediction
::
OnPerception
,
AdapterManager
::
Add
PerceptionObstaclesCallback
(
&
Prediction
::
OnPerception
,
this
);
return
Status
::
OK
();
}
...
...
modules/routing/routing.cc
浏览文件 @
0f180510
...
...
@@ -28,9 +28,9 @@ using apollo::common::ErrorCode;
std
::
string
Routing
::
Name
()
const
{
return
FLAGS_node_name
;
}
Routing
::
Routing
()
:
Routing
::
Routing
()
:
monitor_
(
apollo
::
common
::
monitor
::
MonitorMessageItem
::
ROUTING
)
{
std
::
string
graph_path
=
FLAGS_graph_dir
+
"/"
+
FLAGS_graph_file_name
;
AINFO
<<
"Use routing topology graph path: "
<<
graph_path
.
c_str
();
_navigator_ptr
.
reset
(
new
Navigator
(
graph_path
));
...
...
@@ -40,8 +40,8 @@ apollo::common::Status Routing::Init() {
std
::
string
graph_path
=
FLAGS_graph_dir
+
"/"
+
FLAGS_graph_file_name
;
AdapterManager
::
Init
(
FLAGS_adapter_config_path
);
AdapterManager
::
Set
MonitorCallback
(
&
Routing
::
OnMonitor
,
this
);
AdapterManager
::
Set
RoutingRequestCallback
(
&
Routing
::
OnRouting_Request
,
this
);
AdapterManager
::
Add
MonitorCallback
(
&
Routing
::
OnMonitor
,
this
);
AdapterManager
::
Add
RoutingRequestCallback
(
&
Routing
::
OnRouting_Request
,
this
);
return
apollo
::
common
::
Status
::
OK
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录