How to plot laser scan data into Matlab ?
Hi I have recorded a simulation and created a bag file. I'm using a python code ( http://wiki.ros.org/rosbag/Code%20API ) for reading laser scan information.
from __future__ import print_function
import rosbag
bag = rosbag.Bag('2016-06-06-12-57-11.bag')
for topic, msg, t in bag.read_messages(topics=['/base_scan']):
for i in range(msg.min.ranges, msg.max.ranges):
print("%f %f " % (msg.min.ranges, msg.max.ranges))
bag.close()
How can I read all the laser scan data by using python ?
Try running a rostopic list to see if your laser scans are published (they probably are). Then you can start by changing the '/odom/ to the laser topic.
It is published.This is my idea that doesn't work yet
Have you tried msg.min... etc?
Yes! it dosen't work ...
File "read_bagfile.py", line 5 for (msg.min.ranges[i],msg.max.ranges[i]) ^ IndentationError: expected an indented block
That's a python error. You should indent your python code properly. You can paste the full script here and I can check the indents if necessary, but try correcting them yourself first.
I have tried different things after I have searched the error where it is due to mixing
Tab
andspace
So I tried change for loop but it did not worked!I have edited my question code to full script