Skip to content

Commit 7acd8a2

Browse files
committed
Restore Crazy Robotaxi arcade controls
1 parent bb51c49 commit 7acd8a2

3 files changed

Lines changed: 46 additions & 3 deletions

File tree

apps/crazy_robotaxi/crazy_robotaxi/dynamics.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class TaxiVehicleConfig(VehicleConfig):
2323
max_steer_rad: float = 0.69
2424
"""Full-lock steering angle for tight arcade turns."""
2525

26+
steer_rate_rad_per_s: float = 2.415
27+
"""Reach full lock in the original keyboard control's 1 / 3.5 seconds."""
28+
29+
steer_return_rate_rad_per_s: float = 3.45
30+
"""Return from full lock in the original keyboard control's 1 / 5 seconds."""
31+
2632
max_accel_mps2: float = 10.0
2733
reverse_accel_mps2: float = 10.0
2834
max_brake_mps2: float = 14.0

apps/crazy_robotaxi/crazy_robotaxi/session.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,23 @@ def _restart_requested(events: UserInputEvents) -> bool:
641641

642642

643643
def _taxi_driver_command(command: DriverCommand) -> DriverCommand:
644-
"""Restore Crazy Robotaxi's keyboard handbrake over shared drive input."""
645-
if not command.manual_control or command.steer_is_direct or command.brake <= 0.0:
644+
"""Apply Taxi's arcade pedal policy to shared non-direct drive commands."""
645+
if command.steer_is_direct:
646646
return command
647-
return replace(command, throttle=0.0, stop=False, handbrake=True)
647+
if command.brake > 0.0:
648+
return replace(
649+
command,
650+
throttle=0.0,
651+
brake=0.0,
652+
stop=False,
653+
handbrake=True,
654+
manual_control=True,
655+
)
656+
if command.reverse:
657+
command = replace(
658+
command,
659+
throttle=0.0,
660+
brake=command.throttle,
661+
reverse=False,
662+
)
663+
return replace(command, manual_control=True)

apps/crazy_robotaxi/tests/test_application.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
CrazyRobotaxiApplication,
1818
_fit_bev_renderer_to_ui,
1919
)
20+
from crazy_robotaxi.dynamics import TaxiVehicleConfig
2021
from crazy_robotaxi.game_selection import GameSelection
2122
from crazy_robotaxi.physics import TaxiPhysicsWorld
2223
from crazy_robotaxi.rules import TaxiGameSnapshot
@@ -406,6 +407,26 @@ def test_taxi_space_key_restores_handbrake_over_shared_input_mapping() -> None:
406407
assert not command.stop
407408

408409

410+
def test_taxi_keyboard_restores_arcade_brake_reverse() -> None:
411+
driver_input = DriverInput(pressed_keys={"a", "s"})
412+
vehicle = TaxiVehicleConfig()
413+
414+
command = _taxi_driver_command(driver_input.command())
415+
416+
assert vehicle.steer_rate_rad_per_s == pytest.approx(
417+
3.5 * vehicle.max_steer_rad
418+
)
419+
assert vehicle.steer_return_rate_rad_per_s == pytest.approx(
420+
5.0 * vehicle.max_steer_rad
421+
)
422+
assert command.steer == 1.0
423+
assert not command.steer_is_direct
424+
assert command.manual_control
425+
assert command.throttle == 0.0
426+
assert command.brake == 1.0
427+
assert not command.reverse
428+
429+
409430
def test_leaderboard_does_not_finish_the_v2_model_loop() -> None:
410431
snapshot = TaxiGameSnapshot(
411432
phase="seeking_pickup",

0 commit comments

Comments
 (0)