axelbr / racecar_gym

A gym environment for a miniature racecar using the pybullet physics engine.
MIT License
164 stars 26 forks source link

bugfix: raycasting was ignoring walls closer than `min_range` #8

Closed luigiberducci closed 2 years ago

luigiberducci commented 2 years ago

Fix issue of lidar rays propagated beyond the walls.

Problem: the raycasting is computed starting from a point at distance min_distance in the sensor coordinate system. When the car collides with a wall, the distance between the sensor and the wall is lower than min_distance but the ray was erroneously propagated from a point at min_distance, which is beyond the wall.

Solution: the raycasting starts at distance 0. The min_distance of the sensor reading is simply applied after the raycasting, through a clipping operation.