Compare commits

...

6 Commits

Author SHA1 Message Date
royjr a20ad8d114 Update joystick_control.py 2026-04-01 20:09:30 -04:00
royjr 235327cdac Update joystick_control.py 2026-04-01 20:02:47 -04:00
royjr 1cbd666f32 better 2026-04-01 19:58:31 -04:00
royjr b7299785ac Update hud_renderer.py 2026-04-01 19:51:40 -04:00
royjr 4eaf27ee92 Update opendbc_repo 2026-04-01 19:49:18 -04:00
royjr e017d09fc9 Update joystickd.py 2026-04-01 19:48:46 -04:00
4 changed files with 14 additions and 6 deletions
+3 -1
View File
@@ -185,7 +185,9 @@ def modeld_lagging_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubM
def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert:
gb = sm['carControl'].actuators.accel / 4.
steer = sm['carControl'].actuators.torque
vals = f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%"
damp = sm['carControl'].actuators.dampFactor
damp_pct = round((damp - 3) / (200 - 3) * 100.) if damp > 0 else 50
vals = f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%\nDamp: {damp_pct}%"
return NormalPermanentAlert("Joystick Mode", vals)
+6 -4
View File
@@ -55,10 +55,11 @@ class Joystick:
steer_axis = 'ABS_Z'
self.flip_map = {'ABS_RY': accel_axis}
self.min_axis_value = {accel_axis: 0., steer_axis: 0.}
self.max_axis_value = {accel_axis: 255., steer_axis: 255.}
self.axes_values = {accel_axis: 0., steer_axis: 0.}
self.axes_order = [accel_axis, steer_axis]
damp_axis = 'ABS_X'
self.min_axis_value = {accel_axis: 0., steer_axis: 0., damp_axis: 0.}
self.max_axis_value = {accel_axis: 255., steer_axis: 255., damp_axis: 255.}
self.axes_values = {accel_axis: 0., steer_axis: 0., damp_axis: 0.}
self.axes_order = [accel_axis, steer_axis, damp_axis]
self.cancel = False
def update(self):
@@ -69,6 +70,7 @@ class Joystick:
return False
event = (joystick_event.code, joystick_event.state)
print(f"event: code={joystick_event.code}, state={joystick_event.state}, ev_type={joystick_event.ev_type}")
# flip left trigger to negative accel
if event[0] in self.flip_map:
+4
View File
@@ -57,6 +57,10 @@ def joystickd_thread():
actuators.torque = float(np.clip(joystick_axes[1], -1, 1))
actuators.steeringAngleDeg, actuators.curvature = actuators.torque * max_angle, actuators.torque * -max_curvature
if len(joystick_axes) > 2:
# axes[2] controls DAMP_FACTOR: [-1, 1] mapped to [3, 200]
actuators.dampFactor = float(np.interp(joystick_axes[2], [-1, 1], [3, 200]))
pm.send('carControl', cc_msg)
cs_msg = messaging.new_message('controlsState')