ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

(python) how to save ranges of laser scan related to each time stamp?!

asked 2022-08-11 08:05:16 -0500

Delbina gravatar image

updated 2022-08-11 08:06:09 -0500


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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-08-11 08:58:34 -0500

ljaniec gravatar image

updated 2022-08-11 12:33:08 -0500

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
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-08-11 08:05:16 -0500

Seen: 92 times

Last updated: Aug 11 '22