ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Assign a parameter to rosbag record

asked 2021-08-17 08:58:40 -0600

Kansai gravatar image

updated 2021-08-17 09:54:41 -0600

I am a bit confused by the answer to a related question

I have the following launch file

    <launch> 
<node type="generate_message.py" name="generator" pkg="my_package" />

    <node name="rosbag" type="record" pkg="rosbag"  args="-o $(find my_package)/bags/default_ /the_topic">
</node>
    </launch>

please focus on the rosbag part. This launch file works well to start. It records a bag with the name default_ then the date and time in the bags folder of my workspace (a folder that I suppose have to exist???)

What I want to achieve is:

  1. To enter the output folder path and name as a parameter (or argument?? I am confused about the difference)
  2. That this output folder path may include non-existent folders and if that is the case to generate those folders (is this possible?)
  3. That the default would be the one written above

So I am trying something like

<launch>

<arg name = "output_folder" default="-$(find my_package)/bags/default_" />
<node name="rosbag" type="record" pkg="rosbag" 
  arg="-O $(arg name) /the=topic>
</node>

</launch>

Obviously it is not working that well. I suppose with this

  1. I can enter the parameter as output_folder:="/the/path/to/the/bag.bag" and it will generate this bag but by default it will generate default_.bag not with the date

  2. I don't know what would happen if the output folder path includes non existent folders

Can somebody lend me a hand to get this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-17 11:26:03 -0600

tfoote gravatar image

For 1) you have a name mismatch. Your parameter is named output_folder but you're loading the argument named name you should use $(arg output_folder) You also have a typo in the topic /the=topic

And the lack of date stamp is due to you using -O which sets the NAME, where you should be using -o which sets the PREFIXhttp://wiki.ros.org/rosbag/Commandlin...

2) I don't know offhand. I'd suggest a quick test, and please comment back here for other's knowledge or open a PR in the documentation would be even better.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-08-17 08:58:40 -0600

Seen: 321 times

Last updated: Aug 17 '21