      # psi to calculate a simple linearization of desired curvature
      curvature_diff_from_psi = psi/(max(v_ego, 1e-1) * delay) - current_curvature
      next_curvature = current_curvature + 2*curvature_diff_from_psi
  
      # reset to current steer angle if not active or overriding
      if active:
        curvature_desired = next_curvature
        desired_curvature_rate = next_curvature_rate
      else:
        curvature_desired = measured_curvature
        desired_curvature_rate = 0.0
  
      # negative sign, controls uses different convention
      self.desired_steering_wheel_angle_deg = -float(math.degrees(curvature_desired * VM.sR)/curvature_factor) + steering_wheel_angle_offset_deg
      self.desired_steering_wheel_angle_rate_deg = -float(math.degrees(desired_curvature_rate * VM.sR)/curvature_factor)
  
      #  Check for infeasable MPC solution
      mpc_nans = any(math.isnan(x) for x in self.mpc_solution.curvature)
      t = sec_since_boot()
      if mpc_nans:
 
</s> remove     curvature_diff_from_psi = psi/(max(v_ego, 1e-1) * delay) - current_curvature
    next_curvature = current_curvature + 2*curvature_diff_from_psi
 </s> add     curvature_diff_from_psi = psi / (max(v_ego, 1e-1) * delay) - current_curvature
    next_curvature = current_curvature + 2 * curvature_diff_from_psi </s> remove     psi = interp(delay, self.t_idxs[:MPC_N+1], self.mpc_solution.psi)
 </s> add     psi = interp(delay, self.t_idxs[:MPC_N + 1], self.mpc_solution.psi) </s> remove     self.cur_state.curvature = interp(DT_MDL, self.t_idxs[:MPC_N+1], self.mpc_solution.curvature)
 </s> add     self.cur_state.curvature = interp(DT_MDL, self.t_idxs[:MPC_N + 1], self.mpc_solution.curvature) </s> remove     steering_wheel_angle_offset_deg = sm['liveParameters'].angleOffsetDeg
    steering_wheel_angle_deg = sm['carState'].steeringAngleDeg

    # Update vehicle model
    x = max(sm['liveParameters'].stiffnessFactor, 0.1)
    sr = max(sm['liveParameters'].steerRatio, 0.1)
    VM.update_params(x, sr)
    curvature_factor = VM.curvature_factor(v_ego)
    measured_curvature = -curvature_factor * math.radians(steering_wheel_angle_deg - steering_wheel_angle_offset_deg) / VM.sR

 </s> add     measured_curvature = sm['controlsState'].curvature </s> remove         error = self.angle_steers_des - angle_steers_k
 </s> add         error = desired_angle - angle_steers_k
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
      # psi to calculate a simple linearization of desired curvature
      curvature_diff_from_psi = psi/(max(v_ego, 1e-1) * delay) - current_curvature
      next_curvature = current_curvature + 2*curvature_diff_from_psi
  
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
    self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate
  
      #  Check for infeasable MPC solution
      mpc_nans = any(math.isnan(x) for x in self.mpc_solution.curvature)
      t = sec_since_boot()
      if mpc_nans:
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 LateralPlanner should only compute curvature (#20289)

* get curvature from planner

* no need to check active

* remove that

* remove self

* liveParams not needed

* cast

* fix test bug

* fixes

* fix ui.py

* fix radians

* update refs

* update refs

* bump cereal

* bump cereal

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> 
selfdrive/controls/lib/lateral_planner.py