Nearest obstacle in Map
Let's say I have a robot in a Map. The robot it already knows the map and it knows its position (with amcl). Is there a way to extract from the information of the robot and the map the nearest obstacle in the map? To put it simple, let's see the figure below. The blue circle is the robot. I know all the map (black line). I want to know the distance and the angle of the orange dotted line that represents the closest obstacle. I should be able to know this information with the map and odometry topics. How can I do it?
Note: I'm pretty sure amcl guys did it somehow. But, it's there any simple way I can extract this info? Note 2: I want to add multiple multiple objects in the scene and I would like to put some dynamics based on this distance. And of course this objects don't have lasers. As I said before, I should be able to do it only with the position of the object and the map.
i suppose, starting at theta = 0, you can trace a ray from the robot's origin, to the map wall. continue for 360 degrees or whatever resolution you want. and when you're done, the smallest distance you saw is the closest object. you then have the distance and the angle w.r.t. the robot.
Actually what I thought to be the best solution is to get all the distances for all the points in the map, the problem is that getting all this information will take a lot of time, because you have to process the map data first. And such a common problem that should be already solved.
You can project a ray as you said, the problem is that you still need to process this map data.
AMCL already calculates the Distance Transform of the static map to speed up calculating scan match scores. see the map_update_cspace() function in map_cspace.cpp:
https://github.com/ros-planning/navig...
To get at that data, you could add a ROS service to AMCL to tell you that value given an (x,y) location.