Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 475

how to play bag files from c++ or python class

$
0
0
At the moment I'm reading bag files and publishing back the results: bag = rosbag.Bag('2017-09-04-16-11-56.bag') rospy.init_node('talker', anonymous=True) rate = rospy.Rate(0.5) # Not sure what this should be set to pub = rospy.Publisher('cmd_vel', Twist, queue_size=10) for topic, msg, t in bag.read_messages(topics=['cmd_vel']): pub.publish(msg) rate.sleep() But this is not the same as playing back the data since **it does not take into account the time difference between each message.** In this answer (https://answers.ros.org/question/144646/how-to-play-rosbag-file-from-node/) the poster included their solution which as far as I can tell, just publishes all the messages to a topic. So now the only thing I can think of is to go look through the source code of the player.cpp and see how they are publishing rosbag messages at the same rate at which they were recorded (https://github.com/ros/ros_comm/blob/indigo-devel/tools/rosbag/src/player.cpp) Is there a better way?

Viewing all articles
Browse latest Browse all 475

Trending Articles