def on_gamepad_event(self, event: carb.input.GamepadEvent):
# D-pad Up for accelerating
if event.input == GamepadInput.DPAD_UP:
if event.value > 0.5: self.throttle = 1
else: self.throttle = 0
# D-pad Down for braking
elif event.input == GamepadInput.DPAD_DOWN:
if event.value > 0.5: self.brakes = 1
else: self.brakes = 0
cur_val = event.value
absval = abs(event.value)
# Ignore 0 since it signifies the movement of the stick has stopped,
# but doesn't mean it's at center...could be being held steady
if absval == 0:
return
if absval < 0.001:
cur_val = 0
# Use right stick for steering
if event.input == GamepadInput.RIGHT_STICK_RIGHT:
self.steering = cur_val
elif event.input == GamepadInput.RIGHT_STICK_LEFT:
self.steering = -1 * cur_val