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

Collect sensor data from LaserScan

asked 2017-04-21 03:51:56 -0500

Turtle gravatar image

updated 2017-04-21 04:52:32 -0500

I am using a robot in simulator with a laser sensor (sensor_msgs/LaserScan). I'd like to collect all sensor data that the robot scans, is there any way to do that in rospy?

edit retag flag offensive close merge delete


why don't u just use rosbag record ... if you want to some real-time calculation on the Laser data I recommend to switch to C++

mohsen1989m gravatar image mohsen1989m  ( 2017-04-21 05:19:54 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-04-21 05:03:48 -0500

updated 2017-04-21 05:06:07 -0500

rospy has a logger, use it

topic = 'sensor_msgs/LaserScan/topic'
 rospy.loginfo("I will publish to the topic %s", topic)

and some latter in the callback:

def callback(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s",

if you maybe need to collect the data to later use it / reproduce it for analytics purposes then a Rosbag is the way to go :)

import rosbag
from std_msgs.msg import Int32, String

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

    str = String() = 'foo'

    i = Int32() = 42

    bag.write('chatter', str)
    bag.write('numbers', i)
edit flag offensive delete link more



Thanks! :)

Turtle gravatar image Turtle  ( 2017-04-21 05:51:07 -0500 )edit

Question Tools

1 follower


Asked: 2017-04-21 03:51:56 -0500

Seen: 656 times

Last updated: Apr 21 '17