Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
10bac81c
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,发现更多精彩内容 >>
提交
10bac81c
编写于
8月 31, 2020
作者:
U
unacao
提交者:
Xiangquan Xiao
8月 31, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dreamview: publish audio event in backend
上级
4feba190
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
99 addition
and
0 deletion
+99
-0
modules/common/adapters/adapter_gflags.cc
modules/common/adapters/adapter_gflags.cc
+2
-0
modules/common/adapters/adapter_gflags.h
modules/common/adapters/adapter_gflags.h
+1
-0
modules/dreamview/backend/hmi/BUILD
modules/dreamview/backend/hmi/BUILD
+2
-0
modules/dreamview/backend/hmi/hmi.cc
modules/dreamview/backend/hmi/hmi.cc
+28
-0
modules/dreamview/backend/hmi/hmi_worker.cc
modules/dreamview/backend/hmi/hmi_worker.cc
+43
-0
modules/dreamview/backend/hmi/hmi_worker.h
modules/dreamview/backend/hmi/hmi_worker.h
+11
-0
modules/dreamview/backend/simulation_world/BUILD
modules/dreamview/backend/simulation_world/BUILD
+1
-0
modules/dreamview/backend/simulation_world/simulation_world_service.cc
...view/backend/simulation_world/simulation_world_service.cc
+8
-0
modules/dreamview/backend/simulation_world/simulation_world_service.h
...mview/backend/simulation_world/simulation_world_service.h
+3
-0
未找到文件。
modules/common/adapters/adapter_gflags.cc
浏览文件 @
10bac81c
...
...
@@ -210,6 +210,8 @@ DEFINE_string(v2x_trafficlight_topic, "/apollo/v2x/traffic_light",
"v2x trafficlight topic name"
);
DEFINE_string
(
storytelling_topic
,
"/apollo/storytelling"
,
"Storytelling topic."
);
DEFINE_string
(
audio_event_topic
,
"/apollo/audio_event"
,
"Audio event topic."
);
DEFINE_string
(
guardian_topic
,
"/apollo/guardian"
,
"Guardian topic."
);
DEFINE_string
(
gnss_raw_data_topic
,
"/apollo/sensor/gnss/raw_data"
,
...
...
modules/common/adapters/adapter_gflags.h
浏览文件 @
10bac81c
...
...
@@ -109,6 +109,7 @@ DECLARE_string(gnss_raw_data_topic);
DECLARE_string
(
stream_status_topic
);
DECLARE_string
(
heading_topic
);
DECLARE_string
(
rtcm_data_topic
);
DECLARE_string
(
audio_event_topic
);
// Guardian topic
DECLARE_string
(
guardian_topic
);
...
...
modules/dreamview/backend/hmi/BUILD
浏览文件 @
10bac81c
...
...
@@ -67,6 +67,7 @@ cc_library(
":vehicle_manager"
,
"//cyber"
,
"//cyber/proto:dag_conf_cc_proto"
,
"//modules/audio/proto:audio_event_cc_proto"
,
"//modules/common/adapters:adapter_gflags"
,
"//modules/common/configs:config_gflags"
,
"//modules/common/kv_db"
,
...
...
@@ -78,6 +79,7 @@ cc_library(
"//modules/dreamview/proto:hmi_config_cc_proto"
,
"//modules/dreamview/proto:hmi_mode_cc_proto"
,
"//modules/dreamview/proto:hmi_status_cc_proto"
,
"//modules/localization/proto:localization_cc_proto"
,
"//modules/monitor/proto:system_status_cc_proto"
,
"@boost"
,
"@com_google_absl//absl/strings"
,
...
...
modules/dreamview/backend/hmi/hmi.cc
浏览文件 @
10bac81c
...
...
@@ -116,6 +116,34 @@ void HMI::RegisterMessageHandlers() {
}
});
// HMI client asks for adding new AudioEvent.
websocket_
->
RegisterMessageHandler
(
"SubmitAudioEvent"
,
[
this
](
const
Json
&
json
,
WebSocketHandler
::
Connection
*
conn
)
{
// json should contain event_time_ms, obstacle_id, audio_type,
// moving_result, audio_direction and is_siren_on.
uint64_t
event_time_ms
;
int
obstacle_id
;
int
audio_type
;
int
moving_result
;
int
audio_direction
;
bool
is_siren_on
;
if
(
JsonUtil
::
GetNumber
(
json
,
"event_time_ms"
,
&
event_time_ms
)
&&
JsonUtil
::
GetNumber
(
json
,
"obstacle_id"
,
&
obstacle_id
)
&&
JsonUtil
::
GetNumber
(
json
,
"audio_type"
,
&
audio_type
)
&&
JsonUtil
::
GetNumber
(
json
,
"moving_result"
,
&
moving_result
)
&&
JsonUtil
::
GetNumber
(
json
,
"audio_direction"
,
&
audio_direction
)
&&
JsonUtil
::
GetBoolean
(
json
,
"is_siren_on"
,
&
is_siren_on
))
{
hmi_worker_
->
SubmitAudioEvent
(
event_time_ms
,
obstacle_id
,
audio_type
,
moving_result
,
audio_direction
,
is_siren_on
);
monitor_log_buffer_
.
INFO
(
"Audio event added."
);
}
else
{
AERROR
<<
"Truncated SubmitAudioEvent request."
;
monitor_log_buffer_
.
WARN
(
"Failed to submit an audio event."
);
}
});
// HMI client asks for adding new DriveEvent.
websocket_
->
RegisterMessageHandler
(
"SubmitDriveEvent"
,
...
...
modules/dreamview/backend/hmi/hmi_worker.cc
浏览文件 @
10bac81c
...
...
@@ -52,6 +52,7 @@ namespace apollo {
namespace
dreamview
{
namespace
{
using
apollo
::
audio
::
AudioEvent
;
using
apollo
::
canbus
::
Chassis
;
using
apollo
::
common
::
DriveEvent
;
using
apollo
::
common
::
KVDB
;
...
...
@@ -59,6 +60,7 @@ using apollo::control::DrivingAction;
using
apollo
::
cyber
::
Clock
;
using
apollo
::
cyber
::
Node
;
using
apollo
::
cyber
::
proto
::
DagConfig
;
using
apollo
::
localization
::
LocalizationEstimate
;
using
apollo
::
monitor
::
ComponentStatus
;
using
apollo
::
monitor
::
SystemStatus
;
using
google
::
protobuf
::
Map
;
...
...
@@ -275,6 +277,8 @@ void HMIWorker::InitStatus() {
void
HMIWorker
::
InitReadersAndWriters
()
{
status_writer_
=
node_
->
CreateWriter
<
HMIStatus
>
(
FLAGS_hmi_status_topic
);
pad_writer_
=
node_
->
CreateWriter
<
control
::
PadMessage
>
(
FLAGS_pad_topic
);
audio_event_writer_
=
node_
->
CreateWriter
<
AudioEvent
>
(
FLAGS_audio_event_topic
);
drive_event_writer_
=
node_
->
CreateWriter
<
DriveEvent
>
(
FLAGS_drive_event_topic
);
...
...
@@ -319,6 +323,8 @@ void HMIWorker::InitReadersAndWriters() {
}
});
localization_reader_
=
node_
->
CreateReader
<
LocalizationEstimate
>
(
FLAGS_localization_topic
);
// Received Chassis, trigger action if there is high beam signal.
chassis_reader_
=
node_
->
CreateReader
<
Chassis
>
(
FLAGS_chassis_topic
,
[
this
](
const
std
::
shared_ptr
<
Chassis
>&
chassis
)
{
...
...
@@ -381,6 +387,43 @@ bool HMIWorker::Trigger(const HMIAction action, const std::string& value) {
return
true
;
}
void
HMIWorker
::
SubmitAudioEvent
(
const
uint64_t
event_time_ms
,
const
int
obstacle_id
,
const
int
audio_type
,
const
int
moving_result
,
const
int
audio_direction
,
const
bool
is_siren_on
)
{
std
::
shared_ptr
<
AudioEvent
>
audio_event
=
std
::
make_shared
<
AudioEvent
>
();
apollo
::
common
::
util
::
FillHeader
(
"HMI"
,
audio_event
.
get
());
// Here we reuse the header time field as the event occurring time.
// A better solution might be adding an event time field to DriveEvent proto
// to make it clear.
audio_event
->
mutable_header
()
->
set_timestamp_sec
(
static_cast
<
double
>
(
event_time_ms
)
/
1000.0
);
audio_event
->
set_id
(
obstacle_id
);
audio_event
->
set_audio_type
(
static_cast
<
apollo
::
audio
::
AudioType
>
(
audio_type
));
audio_event
->
set_moving_result
(
static_cast
<
apollo
::
audio
::
MovingResult
>
(
moving_result
));
audio_event
->
set_audio_direction
(
static_cast
<
apollo
::
audio
::
AudioDirection
>
(
audio_direction
));
audio_event
->
set_siren_is_on
(
is_siren_on
);
// Read the current localization pose
localization_reader_
->
Observe
();
if
(
localization_reader_
->
Empty
())
{
AERROR
<<
"Failed to get localization associated with the audio event: "
<<
audio_event
->
DebugString
()
<<
"
\n
Localization reader is empty!"
;
return
;
}
const
std
::
shared_ptr
<
LocalizationEstimate
>
localization
=
localization_reader_
->
GetLatestObserved
();
audio_event
->
mutable_pose
()
->
CopyFrom
(
localization
->
pose
());
AINFO
<<
"AudioEvent: "
<<
audio_event
->
DebugString
();
audio_event_writer_
->
Write
(
audio_event
);
}
void
HMIWorker
::
SubmitDriveEvent
(
const
uint64_t
event_time_ms
,
const
std
::
string
&
event_msg
,
const
std
::
vector
<
std
::
string
>&
event_types
,
...
...
modules/dreamview/backend/hmi/hmi_worker.h
浏览文件 @
10bac81c
...
...
@@ -26,12 +26,14 @@
#include "cyber/cyber.h"
#include "cyber/time/time.h"
#include "modules/audio/proto/audio_event.pb.h"
#include "modules/canbus/proto/chassis.pb.h"
#include "modules/common/proto/drive_event.pb.h"
#include "modules/control/proto/pad_msg.pb.h"
#include "modules/dreamview/proto/hmi_config.pb.h"
#include "modules/dreamview/proto/hmi_mode.pb.h"
#include "modules/dreamview/proto/hmi_status.pb.h"
#include "modules/localization/proto/localization.pb.h"
/**
* @namespace apollo::dreamview
...
...
@@ -61,6 +63,11 @@ class HMIWorker {
status_update_handlers_
.
push_back
(
handler
);
}
// Submit an AudioEvent
void
SubmitAudioEvent
(
const
uint64_t
event_time_ms
,
const
int
obstacle_id
,
const
int
audio_type
,
const
int
moving_result
,
const
int
audio_direction
,
const
bool
is_siren_on
);
// Submit a DriveEvent.
void
SubmitDriveEvent
(
const
uint64_t
event_time_ms
,
const
std
::
string
&
event_msg
,
...
...
@@ -113,8 +120,12 @@ class HMIWorker {
// Cyber members.
std
::
shared_ptr
<
apollo
::
cyber
::
Node
>
node_
;
std
::
shared_ptr
<
cyber
::
Reader
<
apollo
::
canbus
::
Chassis
>>
chassis_reader_
;
std
::
shared_ptr
<
cyber
::
Reader
<
apollo
::
localization
::
LocalizationEstimate
>>
localization_reader_
;
std
::
shared_ptr
<
cyber
::
Writer
<
HMIStatus
>>
status_writer_
;
std
::
shared_ptr
<
cyber
::
Writer
<
apollo
::
control
::
PadMessage
>>
pad_writer_
;
std
::
shared_ptr
<
cyber
::
Writer
<
apollo
::
audio
::
AudioEvent
>>
audio_event_writer_
;
std
::
shared_ptr
<
cyber
::
Writer
<
apollo
::
common
::
DriveEvent
>>
drive_event_writer_
;
};
...
...
modules/dreamview/backend/simulation_world/BUILD
浏览文件 @
10bac81c
...
...
@@ -10,6 +10,7 @@ cc_library(
copts
=
[
'-DMODULE_NAME=
\\
"dreamview
\\
"'
],
deps
=
[
"//cyber"
,
"//modules/audio/proto:audio_event_cc_proto"
,
"//modules/canbus/proto:chassis_cc_proto"
,
"//modules/common/adapters:adapter_gflags"
,
"//modules/common/configs:vehicle_config_helper"
,
...
...
modules/dreamview/backend/simulation_world/simulation_world_service.cc
浏览文件 @
10bac81c
...
...
@@ -38,6 +38,7 @@
namespace
apollo
{
namespace
dreamview
{
using
apollo
::
audio
::
AudioEvent
;
using
apollo
::
canbus
::
Chassis
;
using
apollo
::
common
::
DriveEvent
;
using
apollo
::
common
::
PathPoint
;
...
...
@@ -281,6 +282,13 @@ void SimulationWorldService::InitReaders() {
relative_map_reader_
=
node_
->
CreateReader
<
MapMsg
>
(
FLAGS_relative_map_topic
);
storytelling_reader_
=
node_
->
CreateReader
<
Stories
>
(
FLAGS_storytelling_topic
);
audio_event_reader_
=
node_
->
CreateReader
<
AudioEvent
>
(
FLAGS_audio_event_topic
,
[
this
](
const
std
::
shared_ptr
<
AudioEvent
>
&
audio_event
)
{
this
->
PublishMonitorMessage
(
MonitorMessageItem
::
WARN
,
apollo
::
audio
::
AudioType_Name
(
audio_event
->
audio_type
()));
});
drive_event_reader_
=
node_
->
CreateReader
<
DriveEvent
>
(
FLAGS_drive_event_topic
,
[
this
](
const
std
::
shared_ptr
<
DriveEvent
>
&
drive_event
)
{
...
...
modules/dreamview/backend/simulation_world/simulation_world_service.h
浏览文件 @
10bac81c
...
...
@@ -35,6 +35,7 @@
#include "gtest/gtest_prod.h"
#include "nlohmann/json.hpp"
#include "modules/audio/proto/audio_event.pb.h"
#include "modules/common/monitor_log/monitor_log_buffer.h"
#include "modules/common/proto/drive_event.pb.h"
#include "modules/common/proto/pnc_point.pb.h"
...
...
@@ -367,6 +368,8 @@ class SimulationWorldService {
navigation_reader_
;
std
::
shared_ptr
<
cyber
::
Reader
<
apollo
::
relative_map
::
MapMsg
>>
relative_map_reader_
;
std
::
shared_ptr
<
cyber
::
Reader
<
apollo
::
audio
::
AudioEvent
>>
audio_event_reader_
;
std
::
shared_ptr
<
cyber
::
Reader
<
apollo
::
common
::
DriveEvent
>>
drive_event_reader_
;
std
::
shared_ptr
<
cyber
::
Reader
<
apollo
::
common
::
monitor
::
MonitorMessage
>>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录