Controls - Model Management

Manage openpilot's driving models.
This commit is contained in:
FrogAi
2024-07-31 19:09:53 -07:00
parent 2720ea9f20
commit 9dcf86fdb6
27 changed files with 711 additions and 88 deletions
+5 -2
View File
@@ -72,7 +72,10 @@ class Calibrator:
# Read saved calibration
self.params = Params()
calibration_params = self.params.get("CalibrationParams")
if self.params.check_key(self.frogpilot_toggles.part_model_param + "CalibrationParams"):
calibration_params = self.params.get(self.frogpilot_toggles.part_model_param + "CalibrationParams")
else:
calibration_params = self.params.get("CalibrationParams")
rpy_init = RPY_INIT
wide_from_device_euler = WIDE_FROM_DEVICE_EULER_INIT
height = HEIGHT_INIT
@@ -171,7 +174,7 @@ class Calibrator:
write_this_cycle = (self.idx == 0) and (self.block_idx % (INPUTS_WANTED//5) == 5)
if self.param_put and write_this_cycle:
self.params.put_nonblocking("CalibrationParams", self.get_msg(True).to_bytes())
self.params.put_nonblocking(self.frogpilot_toggles.part_model_param + "CalibrationParams", self.get_msg(True).to_bytes())
# Update FrogPilot parameters
if FrogPilotVariables.toggles_updated:
+6 -3
View File
@@ -100,7 +100,10 @@ class TorqueEstimator(ParameterEstimator):
# try to restore cached params
params = Params()
params_cache = params.get("CarParamsPrevRoute")
torque_cache = params.get("LiveTorqueParameters")
if params.check_key(self.frogpilot_toggles.part_model_param + "LiveTorqueParameters"):
torque_cache = params.get(self.frogpilot_toggles.part_model_param + "LiveTorqueParameters")
else:
torque_cache = params.get("LiveTorqueParameters")
if params_cache is not None and torque_cache is not None:
try:
with log.Event.from_bytes(torque_cache) as log_evt:
@@ -120,7 +123,7 @@ class TorqueEstimator(ParameterEstimator):
cloudlog.info("restored torque params from cache")
except Exception:
cloudlog.exception("failed to restore cached torque params")
params.remove("LiveTorqueParameters")
params.remove(self.frogpilot_toggles.part_model_param + "LiveTorqueParameters")
self.filtered_params = {}
for param in initial_params:
@@ -258,7 +261,7 @@ def main(demo=False):
# Cache points every 60 seconds while onroad
if sm.frame % 240 == 0:
msg = estimator.get_msg(valid=sm.all_checks(), with_points=True)
params.put_nonblocking("LiveTorqueParameters", msg.to_bytes())
params.put_nonblocking(frogpilot_toggles.part_model_param + "LiveTorqueParameters", msg.to_bytes())
if __name__ == "__main__":
import argparse