Rosanswers logo


I have a python problem. I want to save the output of msg.ranges in a csv file. actually i want to have a csv file that in the first column time stamp are saved, and in the second column ranges. i run a bag file. so for each timestamp i will have its realted ranges.

rosmsg show sensor_msgs/LaserScan 
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
float32 angle_min
float32 angle_max
float32 angle_increment
float32 time_increment
float32 scan_time
float32 range_min
float32 range_max
float32[] ranges
float32[] intensities

would you please guide me?

Originally posted by Delbina on ROS Answers with karma: 109 on 2022-08-11

Post score: 0


1 Answer 1


Rosanswers logo

You will have to downgrade it to Kinetic, but overall scripts should be usable:


A GUI tool to convert topics from a single rosbag file or multiple rosbag files at once to csv files

Don't use GUI, but the scripts inside - overall, you can install a virtual machine with ROS Noetic and use it directly here with your bags.

In these answers here you have other options to use:

  • rostopic echo -b file.bag -p /topic

where flags:

-b - display messages in a bag file.

-p display messages in a matlab/octave-friendly plotting format.

  • rosbag play mybag.bag and then rostopic echo /foo > output.txt + modify it with e.g. Python pandas library

Originally posted by ljaniec with karma: 3064 on 2022-08-11

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.