pull/23850/head
sshane 3 years ago
parent 41236e5fb7
commit d4e47cfe94
  1. 9
      selfdrive/controls/controlsd.py

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import copy
import os import os
import math import math
from numbers import Number from numbers import Number
@ -121,6 +120,7 @@ class Controls:
put_nonblocking("CarParamsCache", cp_bytes) put_nonblocking("CarParamsCache", cp_bytes)
self.CC = car.CarControl.new_message() self.CC = car.CarControl.new_message()
self.CS = car.CarState.new_message()
self.AM = AlertManager() self.AM = AlertManager()
self.events = Events() self.events = Events()
@ -155,7 +155,6 @@ class Controls:
self.logged_comm_issue = False self.logged_comm_issue = False
self.button_timers = {ButtonEvent.Type.decelCruise: 0, ButtonEvent.Type.accelCruise: 0} self.button_timers = {ButtonEvent.Type.decelCruise: 0, ButtonEvent.Type.accelCruise: 0}
self.last_actuators = car.CarControl.Actuators.new_message() self.last_actuators = car.CarControl.Actuators.new_message()
self.CS_prev = car.CarState()
# TODO: no longer necessary, aside from process replay # TODO: no longer necessary, aside from process replay
self.sm['liveParameters'].valid = True self.sm['liveParameters'].valid = True
@ -196,8 +195,8 @@ class Controls:
return return
# Disable on rising edge of gas or brake. Also disable on brake when speed > 0 # Disable on rising edge of gas or brake. Also disable on brake when speed > 0
if (CS.gasPressed and not self.CS_prev.gasPressed) or \ if (CS.gasPressed and not self.CS.gasPressed) or \
(CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)): (CS.brakePressed and (not self.CS.brakePressed or not CS.standstill)):
self.events.add(EventName.pedalPressed) self.events.add(EventName.pedalPressed)
self.events.add_from_msg(CS.events) self.events.add_from_msg(CS.events)
@ -736,7 +735,7 @@ class Controls:
self.prof.checkpoint("Sent") self.prof.checkpoint("Sent")
self.update_button_timers(CS.buttonEvents) self.update_button_timers(CS.buttonEvents)
self.CS_prev = copy.copy(CS) self.CS = CS
def controlsd_thread(self): def controlsd_thread(self):
while True: while True:

Loading…
Cancel
Save