mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-22 06:22:06 +08:00
controlsd: reset axes in joystick mode if message is old (#30409)
Reset joystick if it wasnt received after 0.2 sec
This commit is contained in:
@@ -619,11 +619,18 @@ class Controls:
|
||||
else:
|
||||
lac_log = log.ControlsState.LateralDebugState.new_message()
|
||||
if self.sm.rcv_frame['testJoystick'] > 0:
|
||||
# reset joystick if it hasn't been received in a while
|
||||
should_reset_joystick = (self.sm.frame - self.sm.rcv_frame['testJoystick'])*DT_CTRL > 0.2
|
||||
if not should_reset_joystick:
|
||||
joystick_axes = self.sm['testJoystick'].axes
|
||||
else:
|
||||
joystick_axes = [0.0, 0.0]
|
||||
|
||||
if CC.longActive:
|
||||
actuators.accel = 4.0*clip(self.sm['testJoystick'].axes[0], -1, 1)
|
||||
actuators.accel = 4.0*clip(joystick_axes[0], -1, 1)
|
||||
|
||||
if CC.latActive:
|
||||
steer = clip(self.sm['testJoystick'].axes[1], -1, 1)
|
||||
steer = clip(joystick_axes[1], -1, 1)
|
||||
# max angle is 45 for angle-based cars, max curvature is 0.02
|
||||
actuators.steer, actuators.steeringAngleDeg, actuators.curvature = steer, steer * 45., steer * -0.02
|
||||
|
||||
|
||||
Reference in New Issue
Block a user