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

using rosbag in callback

$
0
0
For my project I am interested in many frames of reference contained in a list called frame_list, each with Pose messages published to their own topic e.g. '*frame*_transform'. I am trying to subscribe to all of these topics and use rosbag to save the Poses as they are published. The code below creates the .bag file, but does not write any data into it even though messages are being published to the topics. Is this a good way to achieve what I want? Can anybody spot where I am going wrong? Thanks. #!/usr/bin/env python import roslib import rospy import rosbag from geometry_msgs.msg import Pose def callback(data, args): bag = rosbag.Bag('data.bag', 'w') bag.write(str(args), data) if __name__ == '__main__': if rospy.has_param('init_complete'): #check if initialisation is complete rospy.init_node('rosbag_writer') #initiate node frame_list = rospy.get_param('frame_list') #import list of frames from rosparam for frame in frame_list: rospy.Subscriber(str(frame) + '_transform', Pose, callback, frame) #check for frame transforms rospy.spin()

Viewing all articles
Browse latest Browse all 475

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>