Better steering for manual control (#1957)

This commit is contained in:
bernat 2019-08-01 11:36:34 +02:00 committed by GitHub
parent f83cea732e
commit 70e67b8dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
## Latest
* Better steering in manual control
* Added Doxygen documentation online with automatic updates through Jenkins pipeline

View File

@ -337,9 +337,15 @@ class KeyboardControl(object):
self._control.throttle = 1.0 if keys[K_UP] or keys[K_w] else 0.0
steer_increment = 5e-4 * milliseconds
if keys[K_LEFT] or keys[K_a]:
self._steer_cache -= steer_increment
if self._steer_cache > 0:
self._steer_cache = 0
else:
self._steer_cache -= steer_increment
elif keys[K_RIGHT] or keys[K_d]:
self._steer_cache += steer_increment
if self._steer_cache < 0:
self._steer_cache = 0
else:
self._steer_cache += steer_increment
else:
self._steer_cache = 0.0
self._steer_cache = min(0.7, max(-0.7, self._steer_cache))