jamcar23 / openpilot

Flexpilot is a fork of openpilot focused on flexibility, live tuning, and other experimental features.
MIT License
3 stars 2 forks source link

OpParams as a standalone process #105

Open jamcar23 opened 3 years ago

jamcar23 commented 3 years ago

The purpose of this issue is to outline the ideas, goals, and challenges of rewriting opparams to be its own dedicated process.

Goals

Challenges

Implementation Ideas

jamcar23 commented 3 years ago

After speaking with some other members of the community I've decided that captn proto serialization is probably the easiest problem as there are multiple solutions. The easiest being to convert the code for the value / param into a string, serialize it into a hashmap, and then use runtime code generation to convert it back into python on the other side. There are other options like having opparamsd write the evaluated value into param text file (kinda like how Params works already) but either way, it's relatively easy to solve.

The bigger challenges are going to be 2 & 3 above, specifically: how will params be grouped together and how will opparams know how to evaluate them?

For challenge 2 I think some combination of 2.2 & 2.3 will work best, starting with 2.3 (param group class). Specifically:

  • Perhaps Params could use a lambda / function to handle evaluation on a per param basis?
  • Maybe there should be specific param class for the different types of param groups?
    • e.g. a MultiBpParam which handles evaluating the params
      • if we do this the param group class should be able to declare all need params to make the feature work (e.g. breakpoints will always need BP and V params.)

For challenge 3, 3.2 is still the best / only option I've thought of. I'm not sure if this will be the best approach, it would be a good idea to revisit this after solving challenge 2.

  • Perhaps there is a fallback prop for the param group with a string in the format of [message].[field] which then gets converted to the submaster equivalent string and then uses the same runtime code generation as opEdit to turn it into python?
    • e.g. carParams.steerActuatorDelay string becomes sm["carParams"].steerActuatorDelay string where sm is an existing SubMaster instance inside of opparamsd once the code is generated

Roadmap challenge 2: