Skip to content
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

Sync 20240831 #25

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5c16f7e
define project (#1073)
sshane Aug 1, 2024
1e9f853
fix ruff warnings
adeebshihadeh Aug 2, 2024
f4d077b
CANPacker: msg type is tuple (#1077)
sshane Aug 7, 2024
132b1a6
Bump pre-commit hooks, more coverage (similar to openpilot) (#1078)
sshane Aug 17, 2024
9a53f08
move selfdrive/car to opendbc (#1049)
sshane Aug 17, 2024
0a9727a
one minute ci (#1080)
adeebshihadeh Aug 17, 2024
3537404
no docker (#1081)
adeebshihadeh Aug 17, 2024
17e21fe
CI: auto PR review (#1082)
adeebshihadeh Aug 17, 2024
357e43f
simple README (#1083)
adeebshihadeh Aug 17, 2024
74e042d
Remove Static Library from Build Script (#1084)
deanlee Aug 18, 2024
d377af6
pyyaml is unused
adeebshihadeh Aug 18, 2024
5ed7a83
more robust libdbc linking
adeebshihadeh Aug 18, 2024
8866aa7
this was getting installed from panda
adeebshihadeh Aug 18, 2024
dc4de1a
rename car label
sshane Aug 19, 2024
ff1c8b4
add opendbc/can/ to LIBPATH
adeebshihadeh Aug 19, 2024
fa1d7e7
fixup auto labeler (#1089)
sshane Aug 20, 2024
3229aa2
add test_lateral_limits.py
sshane Aug 20, 2024
7d6f7cb
add banned apis
sshane Aug 20, 2024
c02e83d
speedup CI (#1179)
sshane Aug 21, 2024
06c51c1
add test_car_interfaces.py (#1178)
sshane Aug 21, 2024
f6f0674
tests: some speed optimizations (#1181)
sshane Aug 21, 2024
81fcc40
openpilot isn't required for a car port PR (#1183)
adeebshihadeh Aug 27, 2024
46790af
CI should use the defaults
adeebshihadeh Aug 27, 2024
8e20376
GM: implement allow throttle/brakes (#1185)
sshane Aug 27, 2024
7009381
Revert "GM: implement allow throttle/brakes" (#1187)
sshane Aug 27, 2024
c9650ff
Toyota: add misc adas/toggle signal definitions (#1076)
cydia2020 Aug 27, 2024
3a8a864
Toyota: add a VSC message (#1190)
sshane Aug 27, 2024
aa1d21b
ignore uv.lock for now
adeebshihadeh Aug 29, 2024
6cb7851
car: default now_nanos value
adeebshihadeh Aug 29, 2024
c0aa729
new optional syntax
adeebshihadeh Aug 29, 2024
a1b95d7
Honda: distance bars always cycle 1, 2, 3 (#1201)
sshane Aug 29, 2024
cbad7f0
simple joystick example (#1200)
adeebshihadeh Aug 29, 2024
f2fa755
longitudinal profile runner (#1197)
adeebshihadeh Aug 30, 2024
c928f6b
longitudinal maneuvers: add gas/brake step responses (#1207)
adeebshihadeh Aug 30, 2024
f99bb69
longitudinal maneuvers: proper ratekeeping
adeebshihadeh Aug 31, 2024
732bf8f
longitudinal maneuvers fixups (#1209)
adeebshihadeh Aug 31, 2024
227908e
GM: Car Port for XT4 2023 (#1177)
garrettpall Aug 31, 2024
26dfa1d
ci: Bot comment only for first timers (#1213)
AlexandreSato Aug 31, 2024
b4d39b9
Toyota: more ACC-related definitions (#1215)
adeebshihadeh Aug 31, 2024
2dac06d
Merge remote-tracking branch 'comma/master' into sync-20240831
rav4kumar Aug 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
CI / testing:
- changed-files:
- any-glob-to-any-file: '.github/**'

car:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/**'

can:
- changed-files:
- any-glob-to-any-file: 'opendbc/can/**'

DBC signals:
- changed-files:
- any-glob-to-any-file: 'opendbc/dbc/**'


body:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/body/**'

chrysler:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/chrysler/**'

ford:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/ford/**'

gm:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/gm/**'

honda:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/honda/**'

hyundai:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/hyundai/**'

mazda:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/mazda/**'

nissan:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/nissan/**'

subaru:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/subaru/**'

tesla:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/tesla/**'

toyota:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/toyota/**'

volkswagen:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/volkswagen/**'

fingerprint:
- changed-files:
- any-glob-to-any-file: 'opendbc/car/*/fingerprints.py'
49 changes: 49 additions & 0 deletions .github/workflows/auto_pr_review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "PR review"
on:
pull_request_target:
types: [opened, reopened, synchronize, edited, edited]

jobs:
labeler:
name: review
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Label PRs
- uses: actions/labeler@v5.0.0
with:
dot: true
configuration-path: .github/labeler.yaml

# Check PR target branch
- name: check branch
uses: Vankka/pr-target-branch-action@def32ec9d93514138d6ac0132ee62e120a72aed5
if: github.repository == 'commaai/opendbc'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target: /^(?!master$).*/
exclude: /commaai:.*/
change-to: ${{ github.base_ref }}
already-exists-action: close_this
already-exists-comment: "Your PR should be made against the `master` branch"

# Welcome comment
- name: "First timers PR"
uses: actions/first-interaction@v1
if: github.event.pull_request.head.repo.full_name != 'commaai/opendbc'
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: |
<!-- _(run_id **${{ github.run_id }}**)_ -->
Thanks for contributing to opendbc! In order for us to review your PR as quickly as possible, check the following:
* Convert your PR to a draft unless it's ready to review
* Read the [contributing docs](https://github.com/commaai/openpilot/blob/master/docs/CONTRIBUTING.md)
* Before marking as "ready for review", ensure:
* the goal is clearly stated in the description
* all the tests are passing
* include a route or your device' dongle ID if relevant
62 changes: 33 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
name: tests

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:

env:
RUN: docker run -e PYTHONWARNINGS="error,default::DeprecationWarning" --shm-size 1G --rm opendbc /bin/bash -c
BUILD: docker buildx build --pull --load --cache-to type=inline --cache-from type=registry,ref=ghcr.io/commaai/opendbc:latest -t opendbc -f Dockerfile .
PYTHONWARNINGS: error
# TODO: enable this
#env:
# PYTHONWARNINGS: error,default::DeprecationWarning

jobs:
unit-tests:
name: unit tests
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 1
#strategy:
# fail-fast: false
# matrix:
# run: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: eval "$BUILD"
- name: Unit tests
run: ${{ env.RUN }} "pytest -n logical --durations=0"
- name: setup python
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
# TODO: remove setuptools once https://github.com/cython/cython/issues/5751 is fixed
uv pip install -e .[testing,docs] setuptools
- run: uv run scons -j$(nproc)
- run: uv run pytest .

static-analysis:
name: static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: eval "$BUILD"
- name: pre-commit
# TODO: a package pre-commit installs has a warning, remove the unset once that's fixed
run: ${{ env.RUN }} "git init && git add -A && unset PYTHONWARNINGS && pre-commit run --all"

docker-push:
name: docker push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/opendbc'
runs-on: ubuntu-24.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: eval "$BUILD"
- name: Push to dockerhub
- run: sudo apt install --no-install-recommends -y cppcheck
- name: setup python
run: |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
docker tag opendbc ghcr.io/commaai/opendbc:latest
docker push ghcr.io/commaai/opendbc:latest
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install -e . pre-commit
- name: cache pre-commit environments
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pre-commit-
- run: uv run pre-commit run --all
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build/
.mypy_cache/
*.pyc
*.os
Expand All @@ -7,6 +8,10 @@
.*.swp
.DS_Store
.sconsign.dblite
.hypothesis
*.egg-info/
*.html
uv.lock

opendbc/can/*.so
opendbc/can/*.a
Expand Down
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ repos:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
exclude: '\.dbc$'
args:
- --check-hidden
- --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.11.1
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.5.7
hooks:
- id: ruff
- repo: https://github.com/MarcoGorelli/cython-lint
Expand Down
47 changes: 0 additions & 47 deletions Dockerfile

This file was deleted.

77 changes: 28 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,28 @@
## DBC file basics

A DBC file encodes, in a humanly readable way, the information needed to understand a vehicle's CAN bus traffic. A vehicle might have multiple CAN buses and every CAN bus is represented by its own dbc file.
Wondering what's the DBC file format? [Here](http://www.socialledge.com/sjsu/index.php?title=DBC_Format) and [Here](https://github.com/stefanhoelzl/CANpy/blob/master/docs/DBC_Specification.md) a couple of good overviews.

## How to start reverse engineering cars

[opendbc](https://github.com/commaai/opendbc) is integrated with [cabana](https://github.com/commaai/openpilot/tree/master/tools/cabana).

Use [panda](https://github.com/commaai/panda) to connect your car to a computer.

## How to use reverse engineered DBC
To create custom CAN simulations or send reverse engineered signals back to the car you can use [CANdevStudio](https://github.com/GENIVI/CANdevStudio) project.

## DBC file preprocessor

DBC files for different models of the same brand have a lot of overlap. Therefore, we wrote a preprocessor to create DBC files from a brand DBC file and a model specific DBC file. The source DBC files can be found in the generator folder. After changing one of the files run the generator.py script to regenerate the output files. These output files will be placed in the root of the opendbc repository and are suffixed by _generated.

## Good practices for contributing to opendbc

- Comments: the best way to store comments is to add them directly to the DBC files. For example:
```
CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping";
```
is a comment that refers to signal `LONG_ACCEL` in message `490`. Using comments is highly recommended, especially for doubts and uncertainties. [cabana](https://community.comma.ai/cabana/) can easily display/add/edit comments to signals and messages.

- Units: when applicable, it's recommended to convert signals into physical units, by using a proper signal factor. Using a SI unit is preferred, unless a non-SI unit rounds the signal factor much better.
For example:
```
SG_ VEHICLE_SPEED : 7|15@0+ (0.00278,0) [0|70] "m/s" PCM
```
is better than:
```
SG_ VEHICLE_SPEED : 7|15@0+ (0.00620,0) [0|115] "mph" PCM
```
However, the cleanest option is really:
```
SG_ VEHICLE_SPEED : 7|15@0+ (0.01,0) [0|250] "kph" PCM
```

- Signal size: always use the smallest amount of bits possible. For example, let's say I'm reverse engineering the gas pedal position and I've determined that it's in a 3 bytes message. For 0% pedal position I read a message value of `0x00 0x00 0x00`, while for 100% of pedal position I read `0x64 0x00 0x00`: clearly, the gas pedal position is within the first byte of the message and I might be tempted to define the signal `GAS_POS` as:
```
SG_ GAS_POS : 7|8@0+ (1,0) [0|100] "%" PCM
```
However, I can't be sure that the very first bit of the message is referred to the pedal position: I haven't seen it changing! Therefore, a safer way of defining the signal is:
```
SG_ GAS_POS : 6|7@0+ (1,0) [0|100] "%" PCM
```
which leaves the first bit unallocated. This prevents from very erroneous reading of the gas pedal position, in case the first bit is indeed used for something else.
# opendbc

opendbc is a Python API for your car. Read the speed, steering angle, and more. Send gas, braking, and steering commands.

## Structure
* [`opendbc/dbc/`](opendbc/dbc/) is a repository of [DBC](https://en.wikipedia.org/wiki/CAN_bus#DBC) files
* [`opendbc/can/`](opendbc/can/) is a library for parsing and building CAN messages from DBC files
* [`opendbc/car/`](opendbc/car/) is a high-level library for interfacing with cars using Python

## Quick start

```bash
git clone https://github.com/commaai/opendbc.git

cd opendbc

# Install the dependencies
pip3 install -e .[testing,docs]

# Build
scons -j8

# Run the tests
pytest .

# Run the linter
pre-commit run --all-files
```
Loading