Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
8404e099
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,发现更多精彩内容 >>
提交
8404e099
编写于
9月 25, 2018
作者:
M
michael4338
提交者:
Liangliang Zhang
9月 25, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove event_collector since not being used
上级
c0cfdd59
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
2 addition
and
245 deletion
+2
-245
modules/data/conf/event_collector_adapter.conf
modules/data/conf/event_collector_adapter.conf
+0
-16
modules/data/tools/BUILD
modules/data/tools/BUILD
+0
-13
modules/data/tools/README.md
modules/data/tools/README.md
+0
-24
modules/data/tools/event_collector_main.cc
modules/data/tools/event_collector_main.cc
+0
-184
scripts/record_bag.py
scripts/record_bag.py
+2
-8
未找到文件。
modules/data/conf/event_collector_adapter.conf
已删除
100644 → 0
浏览文件 @
c0cfdd59
config
{
type
:
CHASSIS
mode
:
RECEIVE_ONLY
message_history_limit
:
1
}
config
{
type
:
MONITOR
mode
:
RECEIVE_ONLY
message_history_limit
:
1
}
config
{
type
:
DRIVE_EVENT
mode
:
RECEIVE_ONLY
message_history_limit
:
1
}
is_ros
:
true
modules/data/tools/BUILD
已删除
100644 → 0
浏览文件 @
c0cfdd59
load
(
"//tools:cpplint.bzl"
,
"cpplint"
)
package
(
default_visibility
=
[
"//visibility:public"
])
cc_binary
(
name
=
"event_collector_main"
,
srcs
=
[
"event_collector_main.cc"
],
deps
=
[
"//modules/common/util"
,
],
)
cpplint
()
modules/data/tools/README.md
已删除
100644 → 0
浏览文件 @
c0cfdd59
# Data Tools
## Event Collector
Collect events which we are interested in, including
*drive events*
and
*disengagements*
.
### Usage
It will generate
`events.txt`
in current directory, with row format:
```
text
<timestamp> <type> <description if any>
```
On termination with SIGINT, it will also generate
`events_related_bags.txt`
in
current directory, with row format:
```
text
/path/to/bag <event timestamp offset>
```
Note that the offset may be larger than the bag end time, which means the event
is actually in the next bag.
modules/data/tools/event_collector_main.cc
已删除
100644 → 0
浏览文件 @
c0cfdd59
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include <fstream>
#include <string>
#include <vector>
#include "gflags/gflags.h"
#include "ros/include/ros/ros.h"
#include "ros/include/rosbag/bag.h"
#include "ros/include/rosbag/view.h"
#include "modules/common/adapters/adapter_manager.h"
#include "cybertron/common/log.h"
#include "modules/common/util/file.h"
#include "modules/common/util/string_util.h"
DEFINE_string
(
adapter_config_filename
,
"/apollo/modules/data/conf/event_collector_adapter.conf"
,
"Path for adapter configuration."
);
DEFINE_string
(
events_filename
,
"events.txt"
,
"File to save event list."
);
DEFINE_string
(
events_related_bags_filename
,
"events_related_bags.txt"
,
"File to save events related bags list."
);
DEFINE_double
(
event_time_backtrack_seconds
,
20
,
"Backtrack from the event time to consider bags as related."
);
namespace
apollo
{
namespace
data
{
namespace
{
using
apollo
::
common
::
adapter
::
AdapterManager
;
using
apollo
::
canbus
::
Chassis
;
void
OnSigInt
(
int32_t
signal_num
)
{
// only response for ctrl + c
if
(
signal_num
!=
SIGINT
)
{
return
;
}
AINFO
<<
"EventCollector got signal: "
<<
signal_num
;
// Only stop once.
static
bool
is_stopping
=
false
;
if
(
!
is_stopping
)
{
is_stopping
=
true
;
ros
::
shutdown
();
}
}
class
EventCollector
{
public:
void
Init
(
int32_t
argc
,
char
**
argv
)
{
signal
(
SIGINT
,
OnSigInt
);
ros
::
init
(
argc
,
argv
,
"EventCollector"
);
AdapterManager
::
Init
(
FLAGS_adapter_config_filename
);
}
void
Start
()
{
AdapterManager
::
AddDriveEventCallback
(
&
EventCollector
::
OnDriveEvent
,
this
);
AdapterManager
::
AddChassisCallback
(
&
EventCollector
::
OnChassis
,
this
);
AdapterManager
::
AddMonitorCallback
(
&
EventCollector
::
OnMonitorMessage
,
this
);
AINFO
<<
"Start spining..."
;
ros
::
spin
();
}
void
Stop
()
{
// Save events_related_bags.
std
::
ofstream
fout
(
FLAGS_events_related_bags_filename
);
if
(
!
fout
)
{
AERROR
<<
"Failed to write "
<<
FLAGS_events_related_bags_filename
;
return
;
}
AINFO
<<
"Saving info to "
<<
FLAGS_events_related_bags_filename
<<
"..."
;
fout
<<
std
::
fixed
<<
std
::
setprecision
(
1
);
sort
(
events_
.
begin
(),
events_
.
end
());
for
(
const
std
::
string
&
bag_filename
:
apollo
::
common
::
util
::
ListSubPaths
(
"./"
,
DT_REG
))
{
if
(
!
apollo
::
common
::
util
::
EndWith
(
bag_filename
,
".bag"
))
{
continue
;
}
rosbag
::
Bag
bag
(
bag_filename
);
rosbag
::
View
view
(
bag
);
const
double
begin_time
=
view
.
getBeginTime
().
toSec
();
const
double
end_time
=
view
.
getEndTime
().
toSec
()
+
FLAGS_event_time_backtrack_seconds
;
bool
started_line
=
false
;
const
std
::
tuple
<
double
,
std
::
string
>
key
(
begin_time
,
""
);
for
(
auto
iter
=
std
::
lower_bound
(
events_
.
begin
(),
events_
.
end
(),
key
);
iter
!=
events_
.
end
()
&&
std
::
get
<
0
>
(
*
iter
)
<
end_time
;
++
iter
)
{
// event_time = std::get<0>(*iter)
// event_message = std::get<1>(*iter)
if
(
!
started_line
)
{
started_line
=
true
;
fout
<<
bag_filename
<<
"
\n
"
;
}
fout
<<
" Offset = "
<<
std
::
get
<
0
>
(
*
iter
)
-
begin_time
<<
", "
<<
std
::
get
<
1
>
(
*
iter
)
<<
"
\n
"
;
}
}
}
private:
// Event time and message.
std
::
vector
<
std
::
tuple
<
double
,
std
::
string
>>
events_
;
Chassis
::
DrivingMode
last_driving_mode_
;
void
OnDriveEvent
(
const
apollo
::
common
::
DriveEvent
&
event
)
{
// The header time is the real event time.
SaveEvent
(
event
.
header
().
timestamp_sec
(),
"DriveEvent"
,
event
.
event
());
}
void
OnChassis
(
const
Chassis
&
chassis
)
{
// Save event when driving_mode changes from COMPLETE_AUTO_DRIVE to
// EMERGENCY_MODE which is taken as a disengagement.
if
(
last_driving_mode_
==
Chassis
::
COMPLETE_AUTO_DRIVE
&&
chassis
.
driving_mode
()
==
Chassis
::
EMERGENCY_MODE
)
{
SaveEvent
(
chassis
.
header
().
timestamp_sec
(),
"Disengagement"
);
}
last_driving_mode_
=
chassis
.
driving_mode
();
}
void
OnMonitorMessage
(
const
apollo
::
common
::
monitor
::
MonitorMessage
&
monitor_msg
)
{
using
apollo
::
common
::
monitor
::
MonitorMessageItem
;
// Save all ERROR and FATAL monitor logs.
const
double
time_sec
=
monitor_msg
.
header
().
timestamp_sec
();
for
(
const
auto
&
item
:
monitor_msg
.
item
())
{
if
(
item
.
log_level
()
==
MonitorMessageItem
::
ERROR
||
item
.
log_level
()
==
MonitorMessageItem
::
FATAL
)
{
SaveEvent
(
time_sec
,
"MonitorErrorLog"
,
item
.
msg
());
}
}
}
void
SaveEvent
(
const
double
timestamp_sec
,
const
std
::
string
&
type
,
const
std
::
string
&
description
=
""
)
{
const
auto
msg
=
apollo
::
common
::
util
::
StrCat
(
timestamp_sec
,
" ["
,
type
,
"] "
,
description
);
AINFO
<<
"SaveEvent: "
<<
msg
;
events_
.
emplace_back
(
timestamp_sec
,
msg
);
// Append new event and flush.
std
::
ofstream
fout
(
FLAGS_events_filename
,
std
::
ofstream
::
app
);
if
(
fout
)
{
fout
<<
msg
<<
std
::
endl
;
}
else
{
AERROR
<<
"Failed to write to "
<<
FLAGS_events_filename
;
}
}
};
}
// namespace
}
// namespace data
}
// namespace apollo
int
main
(
int32_t
argc
,
char
**
argv
)
{
google
::
InitGoogleLogging
(
argv
[
0
]);
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
apollo
::
data
::
EventCollector
event_collector
;
event_collector
.
Init
(
argc
,
argv
);
event_collector
.
Start
();
event_collector
.
Stop
();
return
0
;
}
scripts/record_bag.py
浏览文件 @
8404e099
...
...
@@ -160,8 +160,6 @@ class DiskManager(object):
class
Recorder
(
object
):
"""Data recorder."""
kEventCollector
=
'modules/data/tools/event_collector_main'
def
__init__
(
self
,
args
):
self
.
args
=
args
...
...
@@ -191,8 +189,6 @@ class Recorder(object):
def
stop
(
self
):
"""Stop recording."""
shell_cmd
(
'kill -TERM $(pgrep -f "cyber_recorder record" | grep -v pgrep)'
)
shell_cmd
(
'kill -INT $(pgrep -f "{}" | grep -v pgrep)'
.
format
(
Recorder
.
kEventCollector
))
def
record_task
(
self
,
disk
,
topics
):
"""Record tasks into the <disk>/data/bag/<task_id> directory."""
...
...
@@ -208,10 +204,8 @@ class Recorder(object):
cd "{}"
source /apollo/scripts/apollo_base.sh
source /apollo/framework/install/setup.bash
nohup cyber_recorder record {} >{} 2>&1 &
nohup ${{APOLLO_BIN_PREFIX}}/{} >/dev/null 2>&1 &
'''
.
format
(
task_dir
,
topics_str
,
log_file
,
Recorder
.
kEventCollector
)
nohup cyber_recorder record -c {} >{} 2>&1 &
'''
.
format
(
task_dir
,
topics_str
,
log_file
)
shell_cmd
(
cmd
)
@
staticmethod
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录