mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-19 16:52:06 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a20ad8d114 | |||
| 235327cdac | |||
| 1cbd666f32 | |||
| b7299785ac | |||
| 4eaf27ee92 | |||
| e017d09fc9 |
+1
-1
Submodule opendbc_repo updated: e9e4ce66e6...824beb0ffb
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user