0

I am recording data from a range scanner with "sick_scan_xd" on ROS Melodic using the following command:

rosbag record -o nav310_ws/bagFiles/session --split --duration=1 --max-splits 1 /cloud

where nav310_ws/bagFiles is the folder where the latest bag file is temporarily stored.

I was wondering how to save every recorded bag files, or copy each bag file to another folder, e.g., allBags.

I tried the following command just after the first one, but it did not do anything.

cp -a nav310_ws/bagFiles/. nav310_ws/allBags/

My complete recording code is given below:

#!/bin/bash

rm -f nav310_ws/bagFiles/*

while true; do  # Runs on a loop until stopped with CTRL+C
        rosbag record -o nav310_ws/bagFiles/session --split --duration=1 --max-splits 1 /cloud
done

Thank you for any suggestion you could provide.

AEW
  • 113
  • 4

1 Answers1

1

rosbag record will always save every recorded bag file to disk, until you stop it. You should specify the output dir in the rosbag command. Or, if you're copying multiple files after recording you should use the * operator in your cp command, not .. For example: cp nav310_ws/bagFiles/* nav310_ws/allBags/.

Edit: The reason you're seeing only one bag file is because you're using the --max-splits arg and setting it to 1. Bags will only split one time and the last bag file will be overwritten. You should up this parameter to fit your needs; or better yet, remove it.

BTables
  • 4,413
  • 2
  • 11
  • 30
  • Thanks, @BTables, for your answer. I believe that the output directory is specified, after `-o`, as `nav310_ws/bagFiles/`. An recorded bag file—which starts with `session`—is saved in this folder, then replaced with a new incoming bag file. I would like to keep all acquired bag files there, or in a separate folder, e.g., `nav310_ws/allBags/`. I have edited my question to show the complete recording `.sh` code. – AEW Jul 08 '23 at 02:08
  • 1
    @AEW sorry, I misread part of your question. I've edited my answer to include the last bit of what you're looking for. – BTables Jul 08 '23 at 04:00