Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clamp differential drive throttle and steering #983

Merged
merged 1 commit into from
Jan 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions donkeycar/parts/actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,13 @@ def run(self, throttle:float, steering:float) -> Tuple[float, float]:
where 1 is full forward and -1 is full backwards.
"""
if throttle > 1 or throttle < -1:
raise ValueError( "throttle must be between 1(forward) and -1(reverse)")
logger.warn( f"throttle is {throttle}, but it must be between 1(forward) and -1(reverse)")
if steering > 1 or steering < -1:
raise ValueError( "steering must be between 1(right) and -1(left)")
logger.warn( f"steering is {steering}, but it must be between 1(right) and -1(left)")

from donkeycar.utils import clamp
throttle = clamp(throttle, -1, 1)
steering = clamp(steering, -1, 1)

left_motor_speed = throttle
right_motor_speed = throttle
Expand Down