Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify bags base directory #1595

Open
tonynajjar opened this issue Mar 25, 2024 · 8 comments
Open

Specify bags base directory #1595

tonynajjar opened this issue Mar 25, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@tonynajjar
Copy link

Description

Currently in record.py, the arg --output allows to specify the full directory of the bag. It would be nice if we could specify the "base directory" only such that the bag folder is still automatically generated with the timestamp but all bags are contained in a configurable directory other than the current directory where the command is run

@tonynajjar tonynajjar added the enhancement New feature or request label Mar 25, 2024
@tonynajjar tonynajjar changed the title Specify bags directory Specify bags base directory Mar 25, 2024
@fujitatomoya
Copy link
Contributor

i think sounds reasonable, --output-dir or environmental variable would be useful.

@MichaelOrlov
Copy link
Contributor

@tonynajjar I am sorry. I didn't get your proposal. Could you please clarify/elaborate?

@tonynajjar
Copy link
Author

tonynajjar commented Mar 26, 2024

Sure. Currently we can specify the --output which is base directory + bag folder. If we don't specify it then base dir = current dir and bag folder is autogenerated to be unique (with a timestamp).

I'd like to specify only the base dir as an argument, to keep both benefits of specifying a directory for my bags and have unique aurogenerated names. I hope it's clearer

@MichaelOrlov
Copy link
Contributor

You basically want the autogenerated name of the bag_folder when specifying a base path where it should be?

Make sense to consider changing the current behaviour for the --output flag?
What would be the pros and cons?

I am not a fan of having two very similar options like --output and --output-dir. It will cause a lot of confusion and questions. Why and what is the difference?

@tonynajjar
Copy link
Author

Make sense to consider changing the current behaviour for the --output flag? What would be the pros and cons?

The biggest con is probably that it's breaking for current users. Besides, I think it makes sense to want to specify these 2 things separately: where you want to save your bags and what you want the name of your bag to be

@MichaelOrlov
Copy link
Contributor

@tonynajjar In this case, to avoid confusion in parameter names, I would suggest adding a new parameter like --autogen-name instead of the --output-dir.
i.e., one would use ros2 bag record --output path/to/bag/folder --autogen-name if needed to autogenerate the folder name inside the specified base folder path in the --output argument.

@b-adkins
Copy link

I don't think it's a stretch to say that robotics projects want ros bag to launch automatically as part of their stack bringup, aka in a launch file. The problem with launch files and the ros2 bag interface is how they can be run from a working directory anywhere. So your logs will be scattered all over the place.

I also didn't want to have to write my own name generators. But to change the directory, you are required to.

Here's my workaround:

  1. Use the -o flag
  2. Copy paste the filename-generating python code into the launch.py file, from ros2bag/verb/record.py:293
bag_dirname = datetime.datetime.now().strftime('rosbag2_%Y_%m_%d-%H_%M_%S')
  1. Do some path stuff:
ExecuteProcess(
        cmd=['ros2', 'bag', 'record', '-a', '-o', 'os.path.join("my_bag_root", bag_dirname)']
...

(If you're not using launch.py, then I guess you can be sad? Or wrap it in a shell script?)

@emersonknapp
Copy link
Collaborator

emersonknapp commented Aug 27, 2024

I'm not sure I see that it's necessary for rosbag2 to support this behavior. You can easily set the cwd for the recording process that you launch, no matter your invoking enironment, no?

  1. When running from shell: pushd $MY_BASE_DIR && ros2 bag record ...
  2. In a launchfile:
ExecuteProcess(
  cmd=['ros2', 'bag', 'record', ...],
  cwd=my_base_dir,  
),

Or have I missed something about this request that changing cwd doesn't address?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants