controlsd: no mutable carParams (#32381)

* no as builder

* fix car int test

* more
pull/32899/head
Shane Smiskol 11 months ago committed by GitHub
parent 3e41b1b287
commit c95b58401a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      selfdrive/car/tests/test_car_interfaces.py
  2. 3
      selfdrive/controls/controlsd.py
  3. 2
      selfdrive/controls/lib/latcontrol_torque.py
  4. 2
      selfdrive/controls/lib/tests/test_latcontrol.py

@ -62,6 +62,7 @@ class TestCarInterfaces:
car_params = CarInterface.get_params(car_name, args['fingerprints'], args['car_fw'], car_params = CarInterface.get_params(car_name, args['fingerprints'], args['car_fw'],
experimental_long=args['experimental_long'], docs=False) experimental_long=args['experimental_long'], docs=False)
car_params = car_params.as_reader()
car_interface = CarInterface(car_params, CarController, CarState) car_interface = CarInterface(car_params, CarController, CarState)
assert car_params assert car_params
assert car_interface assert car_interface

@ -65,8 +65,7 @@ class Controls:
if CI is None: if CI is None:
cloudlog.info("controlsd is waiting for CarParams") cloudlog.info("controlsd is waiting for CarParams")
with car.CarParams.from_bytes(self.params.get("CarParams", block=True)) as msg: with car.CarParams.from_bytes(self.params.get("CarParams", block=True)) as msg:
# TODO: this shouldn't need to be a builder self.CP = msg
self.CP = msg.as_builder()
cloudlog.info("controlsd got CarParams") cloudlog.info("controlsd got CarParams")
# Uses car interface helper functions, altering state won't be considered by card for actuation # Uses car interface helper functions, altering state won't be considered by card for actuation

@ -25,7 +25,7 @@ LOW_SPEED_Y = [15, 13, 10, 5]
class LatControlTorque(LatControl): class LatControlTorque(LatControl):
def __init__(self, CP, CI): def __init__(self, CP, CI):
super().__init__(CP, CI) super().__init__(CP, CI)
self.torque_params = CP.lateralTuning.torque self.torque_params = CP.lateralTuning.torque.as_builder()
self.pid = PIDController(self.torque_params.kp, self.torque_params.ki, self.pid = PIDController(self.torque_params.kp, self.torque_params.ki,
k_f=self.torque_params.kf, pos_limit=self.steer_max, neg_limit=-self.steer_max) k_f=self.torque_params.kf, pos_limit=self.steer_max, neg_limit=-self.steer_max)
self.torque_from_lateral_accel = CI.torque_from_lateral_accel() self.torque_from_lateral_accel = CI.torque_from_lateral_accel()

@ -21,7 +21,7 @@ class TestLatControl:
CI = CarInterface(CP, CarController, CarState) CI = CarInterface(CP, CarController, CarState)
VM = VehicleModel(CP) VM = VehicleModel(CP)
controller = controller(CP, CI) controller = controller(CP.as_reader(), CI)
CS = car.CarState.new_message() CS = car.CarState.new_message()
CS.vEgo = 30 CS.vEgo = 30

Loading…
Cancel
Save