How to play rosbag file from node
Long story short, I am trying to play a bag file from a node and mimic the same functionality of the following:
rosbag play -l recorded1.bag
Before I dive in to the rosbag API, I thought I'd ask the question if there was a simpler way than using the API, which I am not completely familiar with.
If the API was the way, I was thinking something like this:
import rosbag
bag = rosbag.Bag('test.bag')
% Loop
for topic, msg, t in bag.read_messages(topics=['chatter', 'numbers']):
%Publish Messages
Am I on the right track?
Cheers
curiosity: Why would you want to implement that yourself? You can start rosbag like this also as node via launch file...
I am doing a research study and I need to be able to play a random bag file of Kinect data when a button is pressed in another node. The button will be used many times and I need to avoid any terminal commands. Am I able to launch a launch file from within a node?
Yes the rosbag API seems to be the straight forward solution in this case I think. YOU could call into the rosbag via system command, but you would have to open the rosbag after every button press, so I think the application would be very slow and unresponsive...
Thanks for the help Wolf