duckietown / gym-duckietown

Self-driving car simulator for the Duckietown universe
http://duckietown.org
Other
51 stars 19 forks source link

Check Collisions against objects only on drivable tiles #32

Closed bhairavmehta95 closed 6 years ago

bhairavmehta95 commented 6 years ago

Small PR that addresses the easier of two issues / optimizations referenced in #24

Before objects are added to the array with is checked against during collision detection, we make sure atleast one of the vertices of its OBB is on a drivable tile.

maximecb commented 6 years ago

Props for doing it with numpy 👍

The issue that I see with this approach, however, is that it is possible for an object to be, say, at the corner of multiple tiles, and to partially overlap with a drivable tile, without any of its corners being on it. To accurately solve this problem, I think you might need an OBB test.

bhairavmehta95 commented 6 years ago

Lot of edge cases w. this problem, but I think this solves it.

Now, when you run ./manual_control.py --map-name loop_obstacles and add print(len(self.objects), len(self.static_corners)) after the objects are tested / added, you will see 6 5, which is right because none of the barrier is actually on a drivable tile.

maximecb commented 6 years ago

I feel like that's a lot of code to add into the _load_map() method. Maybe you could factor out more of the generation of possible tiles and corners into a function that goes in collision.py?

maximecb commented 6 years ago

Also:

bhairavmehta95 commented 6 years ago

When I checked the 6,3 and what objects were being added, it's only the signs on udem1 which are all (slightly) on drivable tiles, and you can actually run into them.

Fixed draw-bbox, and I tried to move as much code as I could out of that function, but because it uses some class methods I kept some code there. Let me know if this is okay.

Edit: wait, let me just move it into a different class method.