Ask Your Question
0

Bag file recorded from ROS node

asked 2020-05-09 15:12:12 -0500

Shamuquito gravatar image

Hello. I have a simple question about if its possible to record topics from within a rosnode. The goal is to autonomously have a robot collecting data for a period of time given specific locations of the environment.

My node looks like this so far but the file seems not to be created:

#!/usr/bin/python
import rospy
import rosbag
from std_msgs.msg import Int32, String

rospy.init_node("bagtest")
rate = rospy.Rate(2) 

bag = rosbag.Bag('test13.bag','w')

#Set up message from String
s = String()
s.data = 'foo'
#Set up message from Int32
i = Int32()
i.data = 42

bag.write('chatter', s)
bag.write('numbers', i)

bag.close()


while not rospy.is_shutdown():

print("this is my first node")
rate.sleep()

The launch file looks like this:

<launch>
<node pkg="data_acquisition_package" type="testbag.py" name="bagtest" output="screen"></node>
</launch>

If this is not supposed to work, is there any other example of how to start recording topics given specific situations in the environment ?

Thank you in advance !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-05-09 19:09:54 -0500

Shamuquito gravatar image

Actually files are stored properly. My mistake. They are located in /home/.ros

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-09 15:09:13 -0500

Seen: 61 times

Last updated: May 09 '20