    def update_alpha(self, rc):
      self.alpha = self.dt / (rc + self.dt)
  
    def update(self, x):
      self.x = (1. - self.alpha) * self.x + self.alpha * x
      return self.x
 
</s> remove   def __init__(self, x0, rc, dt):
 </s> add   def __init__(self, x0, rc, dt, initialized=True): </s> remove     self.angle_offset = 0.
 </s> add     self.angle_offset = FirstOrderFilter(None, 60.0, DT_CTRL, initialized=False) </s> remove     if abs(cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"]) > 1e-3:
 </s> add     if abs(torque_sensor_angle_deg) > 1e-3:
    if self.initialized:
      self.x = (1. - self.alpha) * self.x + self.alpha * x
    else:
      self.initialized = True
      self.x = x
    def update_alpha(self, rc):
      self.alpha = self.dt / (rc + self.dt)
  
    def update(self, x):
    if self.initialized:
      self.x = (1. - self.alpha) * self.x + self.alpha * x
    else:
      self.initialized = True
      self.x = x
      return self.x
keep keep keep keep replace keep
 Continuously update offset between TSS2 angle sensors (#21943)

* Continuously update offset between TSS2 angle sensors

* add comment

* less lines

* only when initialized

* init to None

* update ref 
common/filter_simple.py