From 587c7b36a0ca067124a1319ad2faf272f701796c Mon Sep 17 00:00:00 2001 From: Laurent George Date: Fri, 8 Jun 2018 08:59:30 +0200 Subject: [PATCH] Remove hardcoding rosbag path --- carla_ros_bridge/Readme.md | 4 ++-- carla_ros_bridge/client.launch | 4 ++-- carla_ros_bridge/src/carla_ros_bridge/bridge_with_rosbag.py | 5 +++-- carla_ros_bridge/src/carla_ros_bridge/client.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/carla_ros_bridge/Readme.md b/carla_ros_bridge/Readme.md index b5f2e1ecc..7a69406b3 100644 --- a/carla_ros_bridge/Readme.md +++ b/carla_ros_bridge/Readme.md @@ -153,9 +153,9 @@ Example for backward : The carla_ros_bridge could also be used to record all published topics into a rosbag: - roslaunch carla_ros_bridge client_with_rviz.launch enable_rosbag:=True + roslaunch carla_ros_bridge client_with_rviz.launch rosbag_fname:=/tmp/save_session.bag -This command will create a rosbag in /tmp/output_{date}.bag +This command will create a rosbag /tmp/save_session.bag You can of course also use rosbag record to do the same, but using the ros_bridge to do the recording you have the guarentee that all the message are saved without small desynchronization that could occurs when using *rosbag record* in an other process. diff --git a/carla_ros_bridge/client.launch b/carla_ros_bridge/client.launch index 07c77f5fd..020ac907e 100644 --- a/carla_ros_bridge/client.launch +++ b/carla_ros_bridge/client.launch @@ -1,7 +1,7 @@ - + + - diff --git a/carla_ros_bridge/src/carla_ros_bridge/bridge_with_rosbag.py b/carla_ros_bridge/src/carla_ros_bridge/bridge_with_rosbag.py index b99565ebe..82ca3db52 100644 --- a/carla_ros_bridge/src/carla_ros_bridge/bridge_with_rosbag.py +++ b/carla_ros_bridge/src/carla_ros_bridge/bridge_with_rosbag.py @@ -7,6 +7,7 @@ import time from tf2_msgs.msg import TFMessage import rosbag import rospy +import os from carla_ros_bridge.bridge import CarlaRosBridge @@ -14,8 +15,8 @@ from carla_ros_bridge.bridge import CarlaRosBridge class CarlaRosBridgeWithBag(CarlaRosBridge): def __init__(self, *args, **kwargs): super(CarlaRosBridgeWithBag, self).__init__(*args, **kwargs) - timestr = time.strftime("%Y%m%d-%H%M%S") - self.bag = rosbag.Bag('/tmp/output_{}.bag'.format(timestr), mode='w') + rosbag_fname = rospy.get_param('rosbag_fname') + self.bag = rosbag.Bag(rosbag_fname, mode='w') def send_msgs(self): for publisher, msg in self.msgs_to_publish: diff --git a/carla_ros_bridge/src/carla_ros_bridge/client.py b/carla_ros_bridge/src/carla_ros_bridge/client.py index 124355b32..6f9fdea9e 100755 --- a/carla_ros_bridge/src/carla_ros_bridge/client.py +++ b/carla_ros_bridge/src/carla_ros_bridge/client.py @@ -24,7 +24,7 @@ def main(): rospy.loginfo("Connected") bridge_cls = CarlaRosBridgeWithBag if rospy.get_param( - 'enable_rosbag') else CarlaRosBridge + 'rosbag_fname', '') else CarlaRosBridge with bridge_cls(client=client, params=params) as carla_ros_bridge: rospy.on_shutdown(carla_ros_bridge.on_shutdown) carla_ros_bridge.run()