-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
86 lines (73 loc) · 3.45 KB
/
Copy pathsettings.py
File metadata and controls
86 lines (73 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Settings for the JoystickController extension (Xbox-style gamepad).
Usage: select **JoystickController** in the Control dropdown, then run
simulation or press Step. Input is read inside ``control()`` each tick.
Axis mapping (Xbox controller via pygame; triggers are analog axes, not buttons):
| Control | Xbox input | Default axis | Output |
|------------------|------------------|--------------|---------------------------------------------|
| Steer left/right | Left stick X | 0 | ``steer``, scaled to ``ego_max_steering`` |
| Accelerate | Right trigger RT | 4 | ``acceleration``, normalized from rest to full press |
| Brake | Left trigger LT | 5 | added to acceleration, same normalization |
Trigger rest positions are auto-calibrated at init (release triggers when
starting). Devices differ: some axes rest at 0, others at -1.
Not mapped: face buttons (A/B/X/Y), bumpers (LB/RB), D-pad, right stick.
Axis indices can differ per device; adjust ``steer_axis``, ``accel_axis``,
``brake_axis`` in the extension config if needed.
Deadzones: ``deadzone`` for steer stick; ``accel_deadzone`` and ``brake_deadzone``
for normalized trigger input (0..1 after rest calibration).
Steering gain scales down with ``ego.velocity`` when ``steer_speed_scale`` is enabled:
full stick authority at or below ``steer_full_gain_below`` m/s, reduced toward
``steer_min_gain`` at ``ego_max_velocity``.
"""
from pydantic import Field
from avlite.c60_apps.c64_settings_schema import SettingsSchema
class PluginSettingsSchema(SettingsSchema):
device_index: int = Field(
default=0,
description="pygame joystick index (0 = first connected gamepad).",
)
deadzone: float = Field(
default=0.02,
description="Steer-axis deadzone; stick values below this are treated as zero.",
)
accel_deadzone: float = Field(
default=0.02,
description="Throttle deadzone on normalized 0..1 input (after rest calibration).",
)
brake_deadzone: float = Field(
default=0.02,
description="Brake deadzone on normalized 0..1 input (after rest calibration).",
)
steer_axis: int = Field(
default=0,
description="Axis for steering (Xbox: left stick X).",
)
accel_axis: int = Field(
default=4,
description="Axis for throttle (Xbox: right trigger RT; pygame range -1..1).",
)
brake_axis: int = Field(
default=5,
description="Axis for brake (Xbox: left trigger LT; pygame range -1..1).",
)
steer_invert: bool = Field(
default=True,
description="If true, push stick right steers right (negates axis before scaling).",
)
steer_speed_scale: bool = Field(
default=True,
description="Reduce max steer as ego velocity increases (less sensitive at high speed).",
)
steer_full_gain_below: float = Field(
default=3.0,
description="Velocity (m/s) at or below which steering uses full stick gain (1.0).",
)
steer_min_gain: float = Field(
default=0.25,
description="Minimum steer fraction at ego_max_velocity (0..1).",
)
fail_if_missing: bool = Field(
default=False,
description="Raise at init if pygame is missing or no gamepad at device_index.",
)
# Settings singleton; filepath is assigned by the plugin loader from the directory name.
PluginSettings = PluginSettingsSchema()