-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cars: introduce "platformconfig" to be a configuration for all relevant car information #31542
Conversation
Why not use CarInfo? |
I feel like a "car" is different from a "platform", a platform can support multiple different cars |
And CarInfo is already very dense with documentation stuff, I feel like putting the openpilot configuration in there makes it way too big |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the abstraction and iterative approach. After merging this, we can do a bigger one, like Toyota, and see if we want to adjust the abstraction before touching too many other files.
selfdrive/car/body/values.py
Outdated
CAR_INFO = {p.platform_str: p.car_info for p in CAR} | ||
DBC = {p.platform_str: p.dbc_dict for p in CAR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe handle this in get_interface_attr
?
I think we want to maintain a separate struct for docs, but perhaps we rename it to be more specific? |
selfdrive/car/body/values.py
Outdated
class CAR(Platforms): | ||
BODY = ( | ||
"COMMA BODY", | ||
CarInfo("comma body", package="All"), | ||
dbc_dict('comma_body', None), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes this is what I sort of meant since you need multiple CarInfo's per platform. I would just make it a list or tuple by definition so there's no dynamic type checking on the CarInfo part anymore eh, that's really separate from this
class Platforms(str, ReprEnum): | ||
config: PlatformConfig | ||
|
||
def __new__(cls, platform_config: PlatformConfig): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this bit of hackery allows CAR
within values.py
to still be a StrEnum
for backwards compatibility, until we fully move everything to the new PlatformConfig
. CAR.BODY.config
will be the PlatformConfig
for example, the fingerprints file and everything that references it currently depends on the fact the CAR.BODY is a string
FINGERPRINTS = {
CAR.BODY: [{
513: 8, 516: 8, 514: 3, 515: 4
}],
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows this PR's fingerprint to be small and we can make these changes in small batches, while maintaining the interface that we want
CAR_INFO = CAR.create_carinfo_map() | ||
DBC = CAR.create_dbc_map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we entirely skip these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBC is imported directly from values.py in a few places, was trying to make this a minimal PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the plan is to remove these once everything is moved over I'm assuming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the plan is to remove these once everything is moved over I'm assuming
yes, everything should directly reference the PlatformConfig when we are done
CarInfos = Union[CarInfo, List[CarInfo]] | ||
|
||
@dataclass(order=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two lines
DbcDict = Dict[str, str] | ||
|
||
def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None, body_dbc=None) -> DbcDict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two lines
CAR_INFO = CAR.create_carinfo_map() | ||
DBC = CAR.create_dbc_map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the plan is to remove these once everything is moved over I'm assuming
No description provided.