Robotics StackExchange | Archived questions

rosbag play folder with bags using roslauch

Hello, how can I use rosbag play in a roslauch file, in order to play a folder that contains all bags. Folder should be and argument to roslauch, e.g:

roslaunch playdata.launch bagfolder:=some_folder

and bag_folder is used inside .launch.

So, in command line this would be just: rosbag play some_folder/*.

Thanks!

Asked by tanasis on 2018-05-09 08:15:58 UTC

Comments

Answers

I'm assuming you want to play each bag file in the folder sequentially one after another, not all of them in parallel.

I don't think this is a feature of the rosbag node, you could potentially do this using a bash script. However playing multiple ROS bag files one after another using separate rosbag play commands will cause some problems with the discontinuity of the time stamps.

It would be possible to write your own node using the rosbag Code API to playback a list of bag files in the way that you want. This way you could adjust the timestamps so they were continuous as multiple bags were played back.

Asked by PeteBlackerThe3rd on 2018-05-09 08:44:50 UTC

Comments

Thanks for the input! Basically concurrently, yes. And rosbag play folder/* seems to be doing this fine. So in that sense I think the rosbag node, can pay all those bags. Currently I am writing a bash script as you also suggested, but I wanted to see if there is a roslauch way. :)

Asked by tanasis on 2018-05-09 08:49:38 UTC

can you share this bash script?

Asked by Petros ADLATUS on 2022-03-23 08:06:27 UTC

It has been a while... I tried to find it but no luck, sorry. Basically if I remember the idea is to put the rosbag play folder/*.bag in a bash script. This you can then call from a .lauch file like this.

Asked by tanasis on 2022-03-23 10:22:32 UTC

I have a question, do you use folder/*.bag to enumerate every single bag file that is in the folder or is there a way to read a folder without enumerating every file?

Asked by Petros ADLATUS on 2022-03-24 05:26:31 UTC

as far as I know, there is not. You need to specify .bag files to the rosbag play command.

Asked by tanasis on 2022-03-24 06:21:05 UTC

thank you Σωτήρα μου :D it works with the listing of each file, but the process does not end afterwards. do you know what the problem could be.

LAUNCH FILE i used:

<node pkg ="rosbag" type="play" name="bag_files_playback" output="screen"

args="/home/pkatsoulakos/catkin_ws/src/launch/rosbags/Besprechungsraum/_2022-03-23-08-37-50_0.bag /home/pkatsoulakos/catkin_ws/src/launch/rosbags/Besprechungsraum/_2022-03-23-08-39-07_2.bag"/>

TERMINAL MESSAGE:

[bag_files_playback-2] process has finished cleanly log file: /home/pkatsoulakos/.ros/log/d083b67e-ab69-11ec-a365-031947a8d74f/bag_files_playback-2*.log

Asked by Petros ADLATUS on 2022-03-24 07:08:39 UTC

haha tpt! What you are trying to do should work. Just pasting it again for you to compare:

<launch>
  <node pkg="rosbag" type="play" name="player" output="screen" args="--clock <full_path_file1>.bag <full_path_file2>.bag etc"/>
</launch>

Asked by tanasis on 2022-03-25 06:58:22 UTC

thank you this works for me!

Asked by Petros ADLATUS on 2022-03-25 07:20:51 UTC