提交 a8ac0646 编写于 作者: J Jiangtao Hu 提交者: Liangliang Zhang

scripts: make replay works for current working dir. add replay sequence script.

上级 e7d6fd0a
......@@ -25,8 +25,7 @@ import rospy
from std_msgs.msg import String
from google.protobuf import text_format
import common.proto_utils as proto_utils
import common.message_manager as message_manager
def generate_message(filename, pb_type):
f_handle = file(filename, 'r')
......@@ -40,22 +39,28 @@ def seq_publisher(seq_num, period):
"""publisher"""
rospy.init_node('replay_node', anonymous=True)
messages = {}
for topic, msg_type in proto_utils.topic_pb_dict.iteritems():
for msg in message_manager.topic_pb_list:
topic = msg.topic()
name = msg.name()
msg_type = msg.msg_type()
messages[topic] = {}
filename = str(seq_num) + "_" + topic + ".pb.txt"
filename = str(seq_num) + "_" + name + ".pb.txt"
print "trying to load pb file:", filename
messages[topic]["publisher"] = rospy.Publisher(
topic, msg_type, queue_size=1)
pb_msg = msg_type()
if not proto_utils.get_pb_from_file(filename, pb_msg):
pb_msg = msg.parse_file(filename)
if not pb_msg:
print topic, " pb is none"
# continue
messages[topic]["value"] = pb_msg
rate = rospy.Rate(int(1.0 / period)) # 10hz
while not rospy.is_shutdown():
for topic, module_features in messages:
if module_features["value"] is not None:
module_features["publisher"].publish(module_features["value"])
for topic in messages:
if messages[topic]["value"] is not None:
print "publish: ", topic
messages[topic]["publisher"].publish(
messages[topic]["value"])
rate.sleep()
......
......@@ -16,11 +16,6 @@
# limitations under the License.
###############################################################################
# e.g. replay.sh 1_chassis.pb.txt
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${DIR}/.."
source "${DIR}/apollo_base.sh"
python modules/tools/replay/replay_file.py $@
python /apollo/modules/tools/replay/replay_file.py $@
#!/usr/bin/env bash
###############################################################################
# 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.
###############################################################################
# e.g. replay_seq.sh 11
python /apollo/modules/tools/replay/replay_sequence.py $@
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册