I want to start a ROS node and record all topics which are being published by the node. I plan to do this via a bash script.
The problem is when I first start the node and record a bag file, after the processing the bag file is generated but it is empty. I get this error message:
No messages to play on specified topics. Exciting.
My script so far:
#!/bin/bash
# launching my ros node:
roslaunch test test.launch
# [TODO] wait short period of time (until topics are available)
# record all topics via rosbag
rosbag record -a
# [TODO] kill ros node after specific amount of time/close bagfile
I think this is because when I start to record directly after starting the node there are no topics there.
Maybe someone has an idea how to do this. Any help would be much appreciated.
Your issue is because you're starting the ROS node as a foreground process which means the bash script won't execute the second command until the first one finishes; this means your record never actually starts. Instead start the node as a background process via:
As a side note to your comment, it doesn't matter if anything is publishing when the record starts.
rosbag record
will wait for theroscore
to start and then record messages relative to theroscore
clock time being published. e.g. if the core is started at the same time asrosbag
and 10 seconds pass before a message is published the playback will publish the first message 10 seconds after start.