ROS2 Basics in 5 days (Python): Syntax to get laser scan angle with minimum distance

Hi, how do I obtain the angle of the laser scan with the minimum distance?

I currently get the minimum distance measured by the laser scan with this:

self.laser_near_wall = min(msg.ranges[0:359])

How do I obtain the angle for the minimum distance?

You can obtain the distance by looking at the index of that minimum distance reading. The front of the robot corresponds to the middle of the scan message, so you can divide the number of readings by 360 degrees

But when I run the program and log the minimum value, the value I get is only the distance.

What is the syntax to get the corresponding index/angle of this distance?

Hi - I think you are asking a question about python and how to get the key of the minimum value.

If that is the question, you can find an answer here python - Get the key corresponding to the minimum value within a dictionary - Stack Overflow

Thank you. I think it’s a list. I’ll try to have a look. Thanks for the help. Appreciate it.

Oops [Kite](Get minimum index of list)

min_index =msg.ranges.index(min_value)