Why do you need to store it directly from stdout? There are a couple of different ways to go about this that are probably easier.
You can simply publish the (x,y,z)
data and record it with rosbag record and then export via rosbag_to_csv.
You could also just write the values to a file directly in the code instead of printing it out. Since you did not specify Python or C++ here is a quick example in Python
f = open('your_output_file.csv', 'a')
while not rospy.is_shutdown():
#Whatever ops to get data
x,y,z = get_the_data()
output_str = str(x)+','+str(y)+','+str(z)
f.write(output_str)
ROS will also automatically log output from rospy.log*()
functions. You can control where this is stored by exporting the environmental variable ROS_LOG_DIR
. Note that this may not work 100% correctly for print()
statements
Finally, if you really really need to use stdout for some reason you can always redirect the output from however you're launching the node. Ex: roslaunch your_package your_launch.launch >> some_file.txt