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
Originally posted by TFinleyosu on ROS Answers with karma: 385 on 2014-03-26
Post score: 4
Original comments
Comment by Wolf on 2014-03-26:
curiosity: Why would you want to implement that yourself? You can start rosbag like this also as node via launch file...
Comment by TFinleyosu on 2014-03-26:
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?
Comment by Wolf on 2014-03-26:
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...
Comment by TFinleyosu on 2014-03-27:
Thanks for the help Wolf