Need help in LaserScan range

def laser_callback(msg):

front = msg.ranges[90]
right = msg.ranges[45]
left = msg.ranges[135]
back = msg.ranges[0]

print("Laser range ", msg.ranges[45])

min_value = min(msg.ranges)  # find minimum value
min_index = msg.range.index(min_value)  # get location
print("min_value, min_index ", min_value, min_index)

i am getting error on line 26:
File “/home/user/catkin_ws/src/sm_pkg/scripts/”, line 26, in laser_callback
min_index = msg.range.index(min_value) # get location
AttributeError: ‘LaserScan’ object has no attribute ‘range’


hi @misbahsuhail123 , this looks like a typo. Did you try replacing “range” by “ranges”? that is for line min_index=msg.ranges.index(min_value).

Give it a try and revert.

thanks it working now.

1 Like

Great! @misbahsuhail123 please mark the issue resolved.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.