Skip to content

Commit

Permalink
Refactor car parsing logic in generate.py to include opendbc cars ref…
Browse files Browse the repository at this point in the history
…actor
  • Loading branch information
nelsonjchen authored Oct 4, 2024
1 parent 33e8f58 commit d59a2ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class CAR:
for root, dirs, files in os.walk("comma_openpilot/selfdrive/car/"):
values_py_paths += [os.path.join(root, f) for f in files if f == "values.py"]

for root, dirs, files in os.walk("comma_openpilot/opendbc/car/"):
values_py_paths += [os.path.join(root, f) for f in files if f == "values.py"]

for path in values_py_paths:
logging.info("Parsing %s", path)
Expand All @@ -77,6 +79,9 @@ class CAR:
if isinstance(c, ast.Assign):
if isinstance(c.value, ast.Str):
cars.append(c.value.s)
elif isinstance(c.targets[0], ast.Name):
# opendbc has most of the cars refactor
cars.append(c.targets[0].id)
# Sometimes it's an object initializer,
# If so, use the first argument
elif isinstance(c.value, ast.Call):
Expand Down

0 comments on commit d59a2ba

Please sign in to comment.