kung-fu-panda-automotive / carla-driver

The CarND Capstone Project
8 stars 8 forks source link

Gradually stop at red light (fixes #13) #42

Closed mithi closed 7 years ago

mithi commented 7 years ago
mithi commented 7 years ago

Update: Add gradual slowdown

Example:

MIN_DISTANCE = 22.5 #: Minimum distance from away from traffic light
MAX_DISTANCE = 45.0 #: Maximum distance from the traffic light to stop
DELTA_DISTANCE = 7.5 #: Buffer distance 

Car starts to slow down from MAX_DISTANCE = 45 m to traffic light until a complete stop at 30 m STOPPED_DISTANCE = MIN_DISTANCE + DELTA_DISTANCE Car should be within 22.5 m and 30 m of traffic light. If the car is less than 22.5 m near the traffic light it ignores the status of the traffic light as it's too late and its already in the intersection area.

mithi commented 7 years ago

Hi everyone, just for reference here’s a video of gradual stopping from this code https://www.youtube.com/watch?v=zx61O8XdkMg

ljanyst commented 7 years ago

Mithi, it worke very well. Thanks! :)

Can you please remove the warning messages?

mithi commented 7 years ago

Okay sure one sec! @ljanyst

mithi commented 7 years ago

Here’s the video for 40mph https://www.youtube.com/watch?v=CM22iPj_HuE But with the following parameters

LOOKAHEAD_WPS = 150 #: Number of waypoints we will publish
STALE_TIME = 2.0 #: Time since that indicates it is relatively new data
MIN_DISTANCE = 23.0 #: Minimum distance from away from traffic light
MAX_DISTANCE = 100.0 #: Maximum distance from the traffic light to stop
DELTA_DISTANCE = 7.0 #: Buffer distance which is where the car must be completely stopped
mithi commented 7 years ago

So I tested it on speeds = 45, 40, 30, 20, 10 It seems to work quite well on my machine setup.

Just tweak

SLOW_DISTANCE = SPEED_MPH * 1.5 #: Distance amount where vehicle slows down
# NOTE: For SLOW_DISTANCE tweak coefficient as necessary
# > 1.5 for more gradual slowdown, < 1.5 for more abrupt stopping

Also depending on size of the road intersection you can tweak

MIN_DISTANCE = 22.0 #: Minimum distance from away from traffic light
DELTA_DISTANCE = 8.0 #: Buffer distance to give time to completely stop
ljanyst commented 7 years ago

It works well for me too at 10 and 40 MPH. Thank you, Mithi!

mithi commented 7 years ago

@ljanyst WOOHOO! Finally! :)