duckietown / gym-duckietown

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

Weirdness around Bezier control points? #227

Open pmirallesr opened 4 years ago

pmirallesr commented 4 years ago

When digging into the simulator's reward function, I got curious about the control points for curve right and curve left. I went to their hard-coded definition in the code, which is the following:

elif kind == 'curve_left':
            pts = np.array([
                [
                    [-0.20, 0, -0.50],
                    [-0.20, 0, 0.00],
                    [0.00, 0, 0.20],
                    [0.50, 0, 0.20],
                ],
                [
                    [0.50, 0, -0.20],
                    [0.30, 0, -0.20],
                    [0.20, 0, -0.30],
                    [0.20, 0, -0.50],
                ]
            ]) * self.road_tile_size

        elif kind == 'curve_right':
            pts = np.array([
                [
                    [-0.20, 0, -0.50],
                    [-0.20, 0, -0.20],
                    [-0.30, 0, -0.20],
                    [-0.50, 0, -0.20],
                ],

                [
                    [-0.50, 0, 0.20],
                    [-0.30, 0, 0.20],
                    [0.30, 0, 0.00],
                    [0.20, 0, -0.50],
                ]
            ]) * self.road_tile_size

I think the control points for curve right may be badly defined? I would expect it to be symetrical with respect to the x=0 axis to curve_left, but that is not the case. When drawing the points on a grid, I obtain a strange, incorrect-looking pattern as well.

It seems to me that, to be symmetric with respect to curve_left, point 2/8 in curve right should be [-0.20, 0, -0.30], point 6/8 should be [0, 0, 0.20], and point 7/8 should be [0.20, 0, 0] ?

Which brings me into a question I have. These points do not touch the limits of the tiles. Do the bezier curves defined by these points then extend past them to the limits of the tile?

I'm a bit lost in the code, so I could have got it all wrong. And I see now that the curves look ok in manual_control with --draw-curves on. So this seems like a misunderstanding on my side. Can someone help me understand this?