Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
4b9370a8
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,发现更多精彩内容 >>
提交
4b9370a8
编写于
3月 20, 2019
作者:
F
freeHackOfJeff
提交者:
Xiangquan Xiao
3月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tools: fix deprecated file() with open()
上级
7baf08cf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
21 deletion
+12
-21
modules/tools/plot_trace/plot_planning_result.py
modules/tools/plot_trace/plot_planning_result.py
+8
-12
modules/tools/plot_trace/plot_trace.py
modules/tools/plot_trace/plot_trace.py
+3
-8
modules/tools/rosbag/extract_trajectory.py
modules/tools/rosbag/extract_trajectory.py
+1
-1
未找到文件。
modules/tools/plot_trace/plot_planning_result.py
浏览文件 @
4b9370a8
...
@@ -32,14 +32,12 @@ from modules.planning.proto import planning_pb2
...
@@ -32,14 +32,12 @@ from modules.planning.proto import planning_pb2
g_args
=
None
g_args
=
None
def
get_3d_trajectory
(
planning_pb
):
def
get_3d_trajectory
(
planning_pb
):
x
=
[
p
.
path_point
.
x
for
p
in
planning_pb
.
trajectory_point
]
x
=
[
p
.
path_point
.
x
for
p
in
planning_pb
.
trajectory_point
]
y
=
[
p
.
path_point
.
y
for
p
in
planning_pb
.
trajectory_point
]
y
=
[
p
.
path_point
.
y
for
p
in
planning_pb
.
trajectory_point
]
z
=
[
p
.
v
for
p
in
planning_pb
.
trajectory_point
]
z
=
[
p
.
v
for
p
in
planning_pb
.
trajectory_point
]
return
(
x
,
y
,
z
)
return
(
x
,
y
,
z
)
def
get_debug_paths
(
planning_pb
):
def
get_debug_paths
(
planning_pb
):
if
not
planning_pb
.
HasField
(
"debug"
):
if
not
planning_pb
.
HasField
(
"debug"
):
return
None
return
None
...
@@ -52,12 +50,11 @@ def get_debug_paths(planning_pb):
...
@@ -52,12 +50,11 @@ def get_debug_paths(planning_pb):
results
.
append
((
path
.
name
,
(
x
,
y
)))
results
.
append
((
path
.
name
,
(
x
,
y
)))
return
results
return
results
def
plot_planning
(
ax
,
planning_file
):
def
plot_planning
(
ax
,
planning_file
):
try
:
try
:
fhandle
=
file
(
planning_file
,
'r'
)
with
open
(
planning_file
,
'r'
)
as
fp
:
except
:
except
OSError
:
print
"Failed to open file %s"
%
(
planning_file
)
print
(
'Failed to open file %s'
%
(
planning_file
)
)
return
return
planning_pb
=
planning_pb2
.
ADCTrajectory
()
planning_pb
=
planning_pb2
.
ADCTrajectory
()
text_format
.
Merge
(
fhandle
.
read
(),
planning_pb
)
text_format
.
Merge
(
fhandle
.
read
(),
planning_pb
)
...
@@ -73,22 +70,21 @@ def plot_planning(ax, planning_file):
...
@@ -73,22 +70,21 @@ def plot_planning(ax, planning_file):
ax
.
plot
(
path
[
0
],
path
[
1
],
label
=
"%s:%s"
%
(
name
,
planning_file
))
ax
.
plot
(
path
[
0
],
path
[
1
],
label
=
"%s:%s"
%
(
name
,
planning_file
))
ax
.
legend
()
ax
.
legend
()
def
press_key
(
event
):
def
press_key
(
event
):
if
event
.
key
==
'c'
:
if
event
.
key
==
'c'
:
files
=
g_args
.
planning_files
files
=
g_args
.
planning_files
if
len
(
files
)
!=
2
:
if
len
(
files
)
!=
2
:
print
"Need more than two files"
print
(
'Need more than two files.'
)
return
return
command
=
[
"cp"
]
command
=
[
"cp"
]
for
f
in
files
:
for
f
in
files
:
command
.
append
(
f
)
command
.
append
(
f
)
if
call
(
command
)
==
0
:
if
call
(
command
)
==
0
:
print
"command success: %s"
%
" "
.
join
(
command
)
print
(
'command success: %s'
%
" "
.
join
(
command
)
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
else
:
else
:
print
"Failed to run command: %s "
%
" "
.
join
(
command
)
print
(
'Failed to run command: %s '
%
" "
.
join
(
command
)
)
sys
.
exit
(
1
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
argparse
import
argparse
...
@@ -123,6 +119,6 @@ if __name__ == '__main__':
...
@@ -123,6 +119,6 @@ if __name__ == '__main__':
if
g_args
.
figure
:
if
g_args
.
figure
:
plt
.
savefig
(
g_args
.
figure
)
plt
.
savefig
(
g_args
.
figure
)
print
(
"picture saved to %s"
%
g_args
.
figure
)
print
(
'picture saved to %s'
%
g_args
.
figure
)
else
:
else
:
plt
.
show
()
plt
.
show
()
modules/tools/plot_trace/plot_trace.py
浏览文件 @
4b9370a8
...
@@ -33,7 +33,6 @@ CHASSIS_TOPIC = "/apollo/canbus/chassis"
...
@@ -33,7 +33,6 @@ CHASSIS_TOPIC = "/apollo/canbus/chassis"
LOCALIZATION_TOPIC
=
"/apollo/localization/pose"
LOCALIZATION_TOPIC
=
"/apollo/localization/pose"
IS_AUTO_MODE
=
False
IS_AUTO_MODE
=
False
def
chassis_callback
(
chassis_data
):
def
chassis_callback
(
chassis_data
):
global
IS_AUTO_MODE
global
IS_AUTO_MODE
if
chassis_data
.
driving_mode
==
chassis_pb2
.
Chassis
.
COMPLETE_AUTO_DRIVE
:
if
chassis_data
.
driving_mode
==
chassis_pb2
.
Chassis
.
COMPLETE_AUTO_DRIVE
:
...
@@ -52,7 +51,6 @@ def localization_callback(localization_data):
...
@@ -52,7 +51,6 @@ def localization_callback(localization_data):
GPS_X
.
append
(
localization_data
.
pose
.
position
.
x
)
GPS_X
.
append
(
localization_data
.
pose
.
position
.
x
)
GPS_Y
.
append
(
localization_data
.
pose
.
position
.
y
)
GPS_Y
.
append
(
localization_data
.
pose
.
position
.
y
)
def
setup_listener
(
node
):
def
setup_listener
(
node
):
node
.
create_reader
(
CHASSIS_TOPIC
,
chassis_pb2
.
Chassis
,
chassis_callback
)
node
.
create_reader
(
CHASSIS_TOPIC
,
chassis_pb2
.
Chassis
,
chassis_callback
)
node
.
create_reader
(
LOCALIZATION_TOPIC
,
node
.
create_reader
(
LOCALIZATION_TOPIC
,
...
@@ -61,7 +59,6 @@ def setup_listener(node):
...
@@ -61,7 +59,6 @@ def setup_listener(node):
while
not
cyber
.
is_shutdown
():
while
not
cyber
.
is_shutdown
():
time
.
sleep
(
0.002
)
time
.
sleep
(
0.002
)
def
update
(
frame_number
):
def
update
(
frame_number
):
global
GPS_X
global
GPS_X
global
GPS_Y
global
GPS_Y
...
@@ -69,7 +66,6 @@ def update(frame_number):
...
@@ -69,7 +66,6 @@ def update(frame_number):
min_len
=
min
(
len
(
GPS_X
),
len
(
GPS_Y
))
-
1
min_len
=
min
(
len
(
GPS_X
),
len
(
GPS_Y
))
-
1
GPS_LINE
.
set_data
(
GPS_X
[
-
min_len
:],
GPS_Y
[
-
min_len
:])
GPS_LINE
.
set_data
(
GPS_X
[
-
min_len
:],
GPS_Y
[
-
min_len
:])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
argparse
import
argparse
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
...
@@ -92,10 +88,9 @@ if __name__ == '__main__':
...
@@ -92,10 +88,9 @@ if __name__ == '__main__':
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
handle
=
file
(
args
.
trace
,
'r'
)
with
open
(
args
.
trace
,
'r'
)
as
fp
:
trace_data
=
np
.
genfromtxt
(
handle
,
delimiter
=
','
,
names
=
True
)
trace_data
=
np
.
genfromtxt
(
handle
,
delimiter
=
','
,
names
=
True
)
ax
.
plot
(
trace_data
[
'x'
],
trace_data
[
'y'
],
'b-'
,
alpha
=
0.5
,
linewidth
=
1
)
ax
.
plot
(
trace_data
[
'x'
],
trace_data
[
'y'
],
'b-'
,
alpha
=
0.5
,
linewidth
=
1
)
handle
.
close
()
cyber
.
init
()
cyber
.
init
()
node
=
cyber
.
Node
(
"plot_trace"
)
node
=
cyber
.
Node
(
"plot_trace"
)
...
...
modules/tools/rosbag/extract_trajectory.py
浏览文件 @
4b9370a8
...
@@ -62,7 +62,7 @@ def extract_record(in_record, output):
...
@@ -62,7 +62,7 @@ def extract_record(in_record, output):
print
(
"Finished extracting from record {}"
.
format
(
in_record
))
print
(
"Finished extracting from record {}"
.
format
(
in_record
))
def
main
(
args
):
def
main
(
args
):
out
=
file
(
args
.
output
,
'w'
)
if
args
.
output
or
sys
.
stdout
out
=
open
(
args
.
output
,
'w'
)
if
args
.
output
or
sys
.
stdout
for
record_file
in
args
.
in_record
:
for
record_file
in
args
.
in_record
:
extract_record
(
record_file
,
out
)
extract_record
(
record_file
,
out
)
out
.
close
()
out
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录