JdeRobot / RoboticsAcademy

Learn Robotics with JdeRobot
https://jderobot.github.io/RoboticsAcademy
GNU General Public License v3.0
317 stars 223 forks source link

[Monte Carlo Laser Loc] bugs in poseToMap #2834

Closed franmore-urjc closed 1 week ago

franmore-urjc commented 1 week ago

The method poseToMap from the Monte Carlo Laser Localization exercise returns floating numbers, which are not valid map coordinates. One would expect to receive the indices of the map cell corresponding to the given pose.

Moreover, the methods poseToMap and mapToPose are not symmetrical: If one creates a cell in map coordinates, converts it to a pose, and then converts it back to map coordinates, the values are different. You can see an example in this image:

Screenshot from 2024-11-04 17-09-59

From the code related to this functions, I see that the offset applied when doing the transformation is not the same in both directions:

    def poseToMap(self, x_prime, y_prime, yaw_prime):
        x = 101.1 * ( 4.2 + y_prime)
        y = 101.1  * ( 5.7 - x_prime)
        yaw = yaw_prime + math.pi/2
        return [x, y, yaw]

    def mapToPose(self, map_x, map_y, map_yaw):
        x = (map_y - 576.27) / -101.1
        y = (map_x - 425.25) /  101.1
        yaw = map_yaw - math.pi/2
        return [x, y, yaw]

I don't know where do these numbers come from, so I don't know which one is the correct offset. Could you please fix this?

javizqh commented 1 week ago

Thanks for noticing, the error was that 425.25 was the for the old map. Now it is 424.62 (4.2 * 101.1).