Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Afaik this is not supported by rosbag.

You also seem to conflate roslaunch functionality (which would be the read-from-file you suggest) with what rosbag does.

If you don't want to extend rosbag's functionality (ie: contribute reading a list of topics from a file), then I believe you can achieve what you are asking for by combining roslaunch's support for args and current rosbag functionality.

args can be set from the command line, so if you have a plain text file (no need for YAML I believe) with the list of topics on a single line, we can pass its contents as the value for a roslaunch arg, which finally gets passed on to rosbag play.

You could perhaps do something like this:

<launch>
   <arg name="list_of_topics" doc="A space-separated list of topics to play, single line" />
   <node 
     pkg="rosbag" 
     name="play" 
     type="play" 
     args="--bags $(find test_package)/mybag.bag --topics=$(arg list_of_topics)" />
</launch>

You would then invoke roslaunch as follows:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(cat /path/to/topic_list.txt)"

Alternatively write a small Python script (or whichever language you prefer), which takes in a .yaml and spits out a single line of space separated topic names. You would then do something like:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(your_utility.py /path/to/topic_list.yaml)"

that should result again in list_of_topics to be set to the list of topics, which is then passed to rosbag.

Afaik this is not supported by rosbag.

You also seem to conflate roslaunch functionality (which would be the read-from-file you suggest) with what rosbag does.

If you don't want to extend rosbag's functionality (ie: contribute reading a list of topics from a file), then I believe you can achieve what you are asking for by combining roslaunch's support for args and current rosbag functionality.

args can be set from the command line, so if you have a plain text file (no need for YAML I believe) with the list of topics on a single line, we can pass its contents as the value for a roslaunch arg, which finally gets passed on to rosbag play.

You could perhaps do something like this:

<launch>
   <arg name="list_of_topics" doc="A space-separated list of topics to play, single line" />
   <node 
     pkg="rosbag" 
     name="play" 
     type="play" 
     args="--bags $(find test_package)/mybag.bag --topics=$(arg list_of_topics)" />
</launch>

You would then invoke roslaunch as follows:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(cat /path/to/topic_list.txt)"

Alternatively write a small Python script (or whichever language you prefer), which takes in a .yaml and spits out a single line of space separated topic names. You would then do something like:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(your_utility.py /path/to/topic_list.yaml)"

that should result again in list_of_topics to be set to the list of topics, which is then passed to rosbag.

Afaik this is not supported by rosbag.

You also seem to conflate roslaunch functionality (which would be the read-from-file you suggest) with what rosbag does.

If you don't want to extend rosbag's functionality (ie: contribute reading a list of topics from a file), then I believe you can achieve what you are asking for by combining roslaunch's support for args and current rosbag functionality.

args can be set from the command line, so if you have a plain text file (no need for YAML I believe) with the list of topics on a single line, we can pass its contents as the value for a roslaunch arg, which finally gets passed on to rosbag play.

You could perhaps do something like this:

<launch>
   <arg name="list_of_topics" doc="A space-separated list of topics to play, single line" />
   <node 
     pkg="rosbag" 
     name="play" 
     type="play" 
     args="--bags $(find test_package)/mybag.bag --topics=$(arg list_of_topics)" />
</launch>

You would then invoke roslaunch as follows:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(cat /path/to/topic_list.txt)"

Alternatively write a small Python script (or whichever language you prefer), which takes in a .yaml and spits out a single line of space separated topic names. You would then do something like:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(your_utility.py /path/to/topic_list.yaml)"

that should result again in list_of_topics to be set to the list of topics, which is then passed to rosbag.

Note: I've not checked whether there are extra quotes needed around the value passed to --topics. That would be something to verify.

Afaik this is not supported by rosbag.

You also seem to conflate roslaunch functionality (which would be the read-from-file you suggest) with what rosbag does.

If you don't want to extend rosbag's functionality (ie: contribute reading a list of topics from a file), then I believe you can achieve what you are asking for by combining roslaunch's support for args and current rosbag functionality.

args can be set from the command line, so if you have a plain text file (no need for YAML I believe) with the list of topics on a single line, we can pass its contents as the value for a roslaunch arg, which finally gets passed on to rosbag play.

You could perhaps do something like this:

<launch>
   <arg name="list_of_topics" doc="A space-separated list of topics to play, single line" />
   <node 
     pkg="rosbag" 
     name="play" 
     type="play" 
     args="--bags $(find test_package)/mybag.bag --topics=$(arg list_of_topics)" />
</launch>

You would then invoke roslaunch as follows:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(cat /path/to/topic_list.txt)"

Alternatively write a small Python script (or whichever language you prefer), which takes in a .yaml and spits out a single line of space separated topic names. You would then do something like:

roslaunch your_pkg rosbag_wrapper.launch list_of_topics:="$(your_utility.py /path/to/topic_list.yaml)"

that should result again in list_of_topics to be set to the list of topics, which is then passed to rosbag.

Note: I've not checked whether there are extra quotes needed around the value passed to --topics. That would be something to verify.