Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
2b5ff96a
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,发现更多精彩内容 >>
提交
2b5ff96a
编写于
9月 02, 2017
作者:
D
Dong Li
提交者:
lianglia-apollo
9月 02, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
planning: added tool to plot planning result
上级
993ca87f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
107 addition
and
14 deletion
+107
-14
modules/planning/integration_tests/planning_test_base.cc
modules/planning/integration_tests/planning_test_base.cc
+3
-0
modules/tools/plot_trace/plot_planning_result.py
modules/tools/plot_trace/plot_planning_result.py
+84
-0
modules/tools/replay/replay_file.py
modules/tools/replay/replay_file.py
+20
-14
未找到文件。
modules/planning/integration_tests/planning_test_base.cc
浏览文件 @
2b5ff96a
...
...
@@ -145,6 +145,9 @@ bool PlanningTestBase::RunPlanning(const std::string& test_case_name,
AERROR
<<
"Failed to write to file "
<<
tmp_fname
;
}
AERROR
<<
"found
\n
diff "
<<
tmp_fname
<<
" "
<<
full_golden_path
;
AERROR
<<
"visualize diff
\n
python "
"modules/tools/plot_trace/plot_planning_result.py "
<<
tmp_fname
<<
" "
<<
full_golden_path
;
return
false
;
}
}
...
...
modules/tools/plot_trace/plot_planning_result.py
0 → 100755
浏览文件 @
2b5ff96a
#!/usr/bin/env python
###############################################################################
# Copyright 2017 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.
###############################################################################
import
sys
import
matplotlib
import
matplotlib.animation
as
animation
import
matplotlib.pyplot
as
plt
from
subprocess
import
call
import
numpy
as
np
import
rosbag
import
rospy
from
std_msgs.msg
import
String
from
google.protobuf
import
text_format
from
mpl_toolkits.mplot3d
import
Axes3D
from
modules.canbus.proto
import
chassis_pb2
from
modules.localization.proto
import
localization_pb2
from
modules.planning.proto
import
planning_pb2
g_args
=
None
def
plot_planning
(
ax
,
planning_file
):
fhandle
=
file
(
planning_file
,
'r'
)
if
not
fhandle
:
print
"Failed to open file %s"
%
(
planning_file
)
planning_pb
=
planning_pb2
.
ADCTrajectory
()
text_format
.
Merge
(
fhandle
.
read
(),
planning_pb
)
x
=
[
p
.
path_point
.
x
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
]
ax
.
plot
(
x
,
y
,
z
,
label
=
planning_file
)
ax
.
legend
()
def
press_key
(
event
):
files
=
" "
.
join
(
g_args
.
planning_files
)
if
evnet
.
key
==
'f'
:
call
([
"cp"
,
files
])
if
__name__
==
'__main__'
:
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
"""A visualization tool that can plot one or multiple planning "
results, so that we can compare the differences.
Example: plot_planning_result.py result_file1.pb.txt result_file2.pb.txt"""
)
parser
.
add_argument
(
"planning_files"
,
action
=
'store'
,
nargs
=
"+"
,
help
=
"The planning results"
)
g_args
=
parser
.
parse_args
()
matplotlib
.
rcParams
[
'legend.fontsize'
]
=
10
fig
=
plt
.
figure
()
fig
.
canvas
.
mpl_connect
(
'key_press_event'
,
press_key
)
ax
=
fig
.
gca
(
projection
=
'3d'
)
ax
.
set_xlabel
(
"x"
)
ax
.
set_ylabel
(
"y"
)
ax
.
set_zlabel
(
"speed"
)
for
planning_file
in
g_args
.
planning_files
:
plot_planning
(
ax
,
planning_file
)
plt
.
show
()
modules/tools/replay/replay_file.py
浏览文件 @
2b5ff96a
...
...
@@ -33,6 +33,7 @@ from modules.planning.proto import planning_pb2
from
modules.prediction.proto
import
prediction_obstacle_pb2
from
modules.routing.proto
import
routing_pb2
def
generate_message
(
topic
,
filename
):
"""generate message from file"""
message
=
None
...
...
@@ -61,34 +62,39 @@ def topic_publisher(topic, filename, period):
"""publisher"""
rospy
.
init_node
(
'replay_node'
,
anonymous
=
True
)
pub
=
rospy
.
Publisher
(
topic
,
String
,
queue_size
=
1
)
rate
=
rospy
.
Rate
(
int
(
1.0
/
period
))
# 10hz
rate
=
rospy
.
Rate
(
int
(
1.0
/
period
))
message
=
generate_message
(
topic
,
filename
)
while
not
rospy
.
is_shutdown
():
pub
.
publish
(
str
(
message
))
rate
.
sleep
()
def
seq_publisher
(
seq_num
,
period
):
"""publisher"""
rospy
.
init_node
(
'replay_node'
,
anonymous
=
True
)
# topic_name => module_name, pb type, pb, publish_handler
topic_name_map
=
{
"/apollo/localization/pose"
:
[
"localization"
,
localization_pb2
.
LocalizationEstimate
,
None
,
None
],
"/apollo/routing_response"
:
[
"routing"
,
routing_pb2
.
RoutingResponse
,
None
,
None
],
"/apollo/perception/obstacles"
:
[
"perception"
,
perception_obstacle_pb2
.
PerceptionObstacles
,
None
,
None
],
"/apollo/prediction"
:
[
"prediction"
,
prediction_obstacle_pb2
.
PredictionObstacles
,
None
,
None
],
"/apollo/planning"
:
[
"planning"
,
planning_pb2
.
ADCTrajectory
,
None
,
None
],
"/apollo/localization/pose"
:
[
"localization"
,
localization_pb2
.
LocalizationEstimate
,
None
,
None
],
"/apollo/routing_response"
:
[
"routing"
,
routing_pb2
.
RoutingResponse
,
None
,
None
],
"/apollo/perception/obstacles"
:
[
"perception"
,
perception_obstacle_pb2
.
PerceptionObstacles
,
None
,
None
],
"/apollo/prediction"
:
[
"prediction"
,
prediction_obstacle_pb2
.
PredictionObstacles
,
None
,
None
],
"/apollo/planning"
:
[
"planning"
,
planning_pb2
.
ADCTrajectory
,
None
,
None
],
}
for
topic
,
module_features
in
topic_name_map
.
iteritems
():
filename
=
str
(
seq_num
)
+
"_"
+
module_features
[
0
]
+
".pb.txt"
print
"trying to load pb file:"
,
filename
module_features
[
3
]
=
rospy
.
Publisher
(
topic
,
module_features
[
1
],
queue_size
=
1
)
module_features
[
3
]
=
rospy
.
Publisher
(
topic
,
module_features
[
1
],
queue_size
=
1
)
module_features
[
2
]
=
generate_message
(
topic
,
filename
)
if
module_features
[
2
]
is
None
:
print
topic
,
" pb is none"
...
...
@@ -105,7 +111,7 @@ if __name__ == '__main__':
parser
=
argparse
.
ArgumentParser
(
description
=
"replay a planning result pb file"
)
parser
.
add_argument
(
"
--
filename"
,
action
=
"store"
,
type
=
str
,
help
=
"planning result files"
)
"filename"
,
action
=
"store"
,
type
=
str
,
help
=
"planning result files"
)
parser
.
add_argument
(
"--topic"
,
action
=
"store"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录