  
      # MPC can plan to turn the wheel and turn back before t_delay. This means
      # in high delay cases some corrections never even get commanded. So just use
      # 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
 
</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     # 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)
 </s> add     self.desired_curvature = next_curvature
    self.desired_curvature_rate = next_curvature_rate </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       # Check if we deviated from the path
      left_deviation = actuators.steer > 0 and lat_plan.dPathPoints[0] < -0.1
      right_deviation = actuators.steer < 0 and lat_plan.dPathPoints[0] > 0.1
 </s> add  </s> remove     steering_angle = CS.steeringAngleDeg

 </s> add 
    curvature_diff_from_psi = psi / (max(v_ego, 1e-1) * delay) - current_curvature
    next_curvature = current_curvature + 2 * curvature_diff_from_psi
  
      # MPC can plan to turn the wheel and turn back before t_delay. This means
      # in high delay cases some corrections never even get commanded. So just use
      # 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
    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
keep keep keep keep 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