Compare commits

...

4 Commits

Author SHA1 Message Date
Vehicle Researcher aed724beda openpilot v0.8.2 release 2021-02-23 16:46:22 -08:00
Vehicle Researcher 22a4193109 openpilot v0.8.1 release 2020-12-18 10:57:05 +00:00
Adeeb Shihadeh 29d9e1ce69 Fix commIssue due to frame drop and power draw (#2689)
Co-authored-by: robbederks <robbe.derks@gmail.com>
Co-authored-by: Willem Melching <willem.melching@gmail.com>
2020-12-04 10:41:00 +01:00
Vehicle Researcher 0b384ea101 openpilot v0.8.0 release 2020-11-24 21:53:25 +00:00
518 changed files with 20280 additions and 29265 deletions
+9 -1
View File
@@ -1,4 +1,5 @@
venv/ venv/
.clang-format
.DS_Store .DS_Store
.tags .tags
.ipynb_checkpoints .ipynb_checkpoints
@@ -6,7 +7,7 @@ venv/
.overlay_init .overlay_init
.overlay_consistent .overlay_consistent
.sconsign.dblite .sconsign.dblite
.vscode .vscode*
model2.png model2.png
a.out a.out
@@ -31,6 +32,7 @@ a.out
*.vcd *.vcd
config.json config.json
clcache clcache
compile_commands.json
persist persist
board/obj/ board/obj/
@@ -42,6 +44,7 @@ selfdrive/ui/_ui
selfdrive/test/longitudinal_maneuvers/out selfdrive/test/longitudinal_maneuvers/out
selfdrive/visiond/visiond selfdrive/visiond/visiond
selfdrive/loggerd/loggerd selfdrive/loggerd/loggerd
selfdrive/loggerd/bootlog
selfdrive/sensord/_gpsd selfdrive/sensord/_gpsd
selfdrive/sensord/_sensord selfdrive/sensord/_sensord
selfdrive/camerad/camerad selfdrive/camerad/camerad
@@ -53,6 +56,7 @@ one
openpilot openpilot
notebooks notebooks
xx xx
hyperthneed
panda_jungle panda_jungle
apks apks
openpilot-apks openpilot-apks
@@ -66,3 +70,7 @@ pandaextra
flycheck_* flycheck_*
cppcheck_report.txt cppcheck_report.txt
comma.sh
selfdrive/modeld/thneed/compile
models/*.thneed
+5 -11
View File
@@ -2,7 +2,7 @@
Our software is open source so you can solve your own problems without needing help from others. And if you solve a problem and are so kind, you can upstream it for the rest of the world to use. Our software is open source so you can solve your own problems without needing help from others. And if you solve a problem and are so kind, you can upstream it for the rest of the world to use.
Most open source development activity is coordinated through our [Discord](https://discord.comma.ai). A lot of documentation is available on our [medium](https://medium.com/@comma_ai/). Most open source development activity is coordinated through our [GitHub Discussions](https://github.com/commaai/openpilot/discussions) and [Discord](https://discord.comma.ai). A lot of documentation is available on our [medium](https://medium.com/@comma_ai/).
## Getting Started ## Getting Started
@@ -12,23 +12,19 @@ Most open source development activity is coordinated through our [Discord](https
## Testing ## Testing
### Local Testing
You can test your changes on your machine by running `run_docker_tests.sh`. This will run some automated tests in docker against your code.
### Automated Testing ### Automated Testing
All PRs and commits are automatically checked by Github Actions. Check out `.github/workflows/` for what Github Actions runs. Any new tests should be added to Github Actions. All PRs and commits are automatically checked by GitHub Actions. Check out `.github/workflows/` for what GitHub Actions runs. Any new tests should be added to GitHub Actions.
### Code Style and Linting ### Code Style and Linting
Code is automatically checked for style by Github Actions as part of the automated tests. You can also run these tests yourself by running `pre-commit run --all`. Code is automatically checked for style by GitHub Actions as part of the automated tests. You can also run these tests yourself by running `pre-commit run --all`.
## Car Ports (openpilot) ## Car Ports (openpilot)
We've released a [Model Port guide](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) for porting to Toyota/Lexus models. We've released a [Model Port guide](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) for porting to Toyota/Lexus models.
If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84). You might also be eligible for a bounty. If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84).
## Pull Requests ## Pull Requests
@@ -38,12 +34,10 @@ git clone https://github.com/commaai/openpilot.git --recursive
``` ```
Or alternatively, when on the master branch: Or alternatively, when on the master branch:
``` ```
git submodule init git submodule update --init
git submodule update
``` ```
The reasons for having submodules on a dedicated repository and our new development philosophy can be found in our [post about externalization](https://medium.com/@comma_ai/a-2020-theme-externalization-13b33326d8b3). The reasons for having submodules on a dedicated repository and our new development philosophy can be found in our [post about externalization](https://medium.com/@comma_ai/a-2020-theme-externalization-13b33326d8b3).
Modules that are in seperate repositories include: Modules that are in seperate repositories include:
* apks
* cereal * cereal
* laika * laika
* opendbc * opendbc
Vendored
+52 -18
View File
@@ -1,25 +1,39 @@
def phone(String ip, String step_label, String cmd) { def phone(String ip, String step_label, String cmd) {
def ci_env = "CI=1 TEST_DIR=${env.TEST_DIR} GIT_BRANCH=${env.GIT_BRANCH} GIT_COMMIT=${env.GIT_COMMIT}"
withCredentials([file(credentialsId: 'id_rsa_public', variable: 'key_file')]) { withCredentials([file(credentialsId: 'id_rsa_public', variable: 'key_file')]) {
sh label: step_label, def ssh_cmd = """
script: """ ssh -tt -o StrictHostKeyChecking=no -i ${key_file} -p 8022 'comma@${ip}' /usr/bin/bash <<'EOF'
ssh -tt -o StrictHostKeyChecking=no -i ${key_file} -p 8022 root@${ip} '${ci_env} /usr/bin/bash -le' <<'EOF'
echo \$\$ > /dev/cpuset/app/tasks || true set -e
echo \$PPID > /dev/cpuset/app/tasks || true
mkdir -p /dev/shm export CI=1
chmod 777 /dev/shm export TEST_DIR=${env.TEST_DIR}
export GIT_BRANCH=${env.GIT_BRANCH}
export GIT_COMMIT=${env.GIT_COMMIT}
source ~/.bash_profile
ln -snf ${env.TEST_DIR} /data/pythonpath
if [ -f /EON ]; then
echo \$\$ > /dev/cpuset/app/tasks || true
echo \$PPID > /dev/cpuset/app/tasks || true
mkdir -p /dev/shm
chmod 777 /dev/shm
fi
cd ${env.TEST_DIR} || true cd ${env.TEST_DIR} || true
${cmd} ${cmd}
exit 0 exit 0
EOF""" EOF"""
sh script: ssh_cmd, label: step_label
} }
} }
def phone_steps(String device_type, steps) { def phone_steps(String device_type, steps) {
lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) { lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) {
timeout(time: 60, unit: 'MINUTES') { timeout(time: 60, unit: 'MINUTES') {
phone(device_ip, "kill old processes", "pkill -f comma || true")
phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),)
steps.each { item -> steps.each { item ->
phone(device_ip, item[0], item[1]) phone(device_ip, item[0], item[1])
@@ -40,7 +54,7 @@ pipeline {
stages { stages {
stage('Release Build') { stage('Build release2') {
agent { agent {
docker { docker {
image 'python:3.7.3' image 'python:3.7.3'
@@ -104,16 +118,17 @@ pipeline {
stages { stages {
stage('parallel tests') { stage('parallel tests') {
parallel { parallel {
stage('Devel Build') { stage('Devel Build') {
environment { environment {
CI_PUSH = "${env.BRANCH_NAME == 'master' ? 'master-ci' : ' '}" CI_PUSH = "${env.BRANCH_NAME == 'master' ? 'master-ci' : ' '}"
} }
steps { steps {
phone_steps("eon", [ phone_steps("eon-build", [
["build", "SCONS_CACHE=1 scons -j4"],
["test athena", "nosetests -s selfdrive/athena/tests/test_athenad_old.py"],
["test manager", "python selfdrive/test/test_manager.py"],
["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"],
["build devel", "cd release && CI_PUSH=${env.CI_PUSH} ./build_devel.sh"], ["build devel", "cd release && CI_PUSH=${env.CI_PUSH} ./build_devel.sh"],
["test openpilot", "nosetests -s selfdrive/test/test_openpilot.py"],
["test cpu usage", "cd selfdrive/test/ && ./test_cpu_usage.py"],
["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"],
["test spinner build", "cd selfdrive/ui/spinner && make clean && make"], ["test spinner build", "cd selfdrive/ui/spinner && make clean && make"],
["test text window build", "cd selfdrive/ui/text && make clean && make"], ["test text window build", "cd selfdrive/ui/text && make clean && make"],
@@ -124,6 +139,7 @@ pipeline {
stage('Replay Tests') { stage('Replay Tests') {
steps { steps {
phone_steps("eon2", [ phone_steps("eon2", [
["build QCOM_REPLAY", "SCONS_CACHE=1 QCOM_REPLAY=1 scons -j4"],
["camerad/modeld replay", "cd selfdrive/test/process_replay && ./camera_replay.py"], ["camerad/modeld replay", "cd selfdrive/test/process_replay && ./camera_replay.py"],
]) ])
} }
@@ -132,16 +148,33 @@ pipeline {
stage('HW + Unit Tests') { stage('HW + Unit Tests') {
steps { steps {
phone_steps("eon", [ phone_steps("eon", [
["build cereal", "SCONS_CACHE=1 scons -j4 cereal/"], ["build", "SCONS_CACHE=1 scons -j4"],
["test sounds", "nosetests -s selfdrive/test/test_sounds.py"], ["test sounds", "nosetests -s selfdrive/test/test_sounds.py"],
["test boardd loopback", "nosetests -s selfdrive/boardd/tests/test_boardd_loopback.py"], ["test boardd loopback", "nosetests -s selfdrive/boardd/tests/test_boardd_loopback.py"],
["test loggerd", "CI=1 python selfdrive/loggerd/tests/test_loggerd.py"], ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"],
//["test camerad", "CI=1 python selfdrive/camerad/test/test_camerad.py"], // wait for shelf refactor ["test encoder", "python selfdrive/loggerd/tests/test_encoder.py"],
["test camerad", "python selfdrive/camerad/test/test_camerad.py"],
["test logcatd", "python selfdrive/logcatd/tests/test_logcatd_android.py"],
//["test updater", "python installer/updater/test_updater.py"], //["test updater", "python installer/updater/test_updater.py"],
]) ])
} }
} }
stage('Tici Build') {
environment {
R3_PUSH = "${env.BRANCH_NAME == 'master' ? '1' : ' '}"
}
steps {
phone_steps("tici", [
["build", "SCONS_CACHE=1 scons -j16"],
["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"],
["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"],
["test camerad", "python selfdrive/camerad/test/test_camerad.py"],
//["build release3-staging", "cd release && PUSH=${env.R3_PUSH} ./build_release3.sh"],
])
}
}
} }
} }
} }
@@ -158,3 +191,4 @@ pipeline {
} }
} }
} }
+37 -30
View File
@@ -64,55 +64,62 @@ Supported Cars
| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | | Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below |
| ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------| | ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------|
| Acura | ILX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>1</sup> | 25mph | | Acura | ILX 2016-19 | AcuraWatch Plus | openpilot | 25mph<sup>1</sup> | 25mph |
| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>1</sup> | 12mph | | Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph<sup>1</sup> | 12mph |
| Acura | RDX 2020 | AcuraWatch | Stock | 0mph | 3mph | | Acura | RDX 2020 | All | Stock | 0mph | 3mph |
| Honda | Accord 2018-20 | All | Stock | 0mph | 3mph | | Honda | Accord 2018-20 | All | Stock | 0mph | 3mph |
| Honda | Accord Hybrid 2018-20 | All | Stock | 0mph | 3mph | | Honda | Accord Hybrid 2018-20 | All | Stock | 0mph | 3mph |
| Honda | Civic Hatchback 2017-19 | Honda Sensing | Stock | 0mph | 12mph | | Honda | Civic Hatchback 2017-21 | Honda Sensing | Stock | 0mph | 12mph |
| Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | | Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph |
| Honda | Civic Sedan/Coupe 2019-20 | All | Stock | 0mph | 2mph<sup>2</sup> | | Honda | Civic Sedan/Coupe 2019-20 | All | Stock | 0mph | 2mph<sup>2</sup> |
| Honda | CR-V 2015-16 | Touring | openpilot | 25mph<sup>1</sup> | 12mph | | Honda | CR-V 2015-16 | Touring | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | CR-V 2017-20 | Honda Sensing | Stock | 0mph | 12mph | | Honda | CR-V 2017-20 | Honda Sensing | Stock | 0mph | 12mph |
| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph | | Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph |
| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph | | Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | HR-V 2019 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph | | Honda | HR-V 2019-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Insight 2019-20 | All | Stock | 0mph | 3mph | | Honda | Insight 2019-21 | All | Stock | 0mph | 3mph |
| Honda | Inspire 2018 | All | Stock | 0mph | 3mph |
| Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 0mph | | Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 0mph |
| Honda | Passport 2019 | All | openpilot | 25mph<sup>1</sup> | 12mph | | Honda | Passport 2019 | All | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Pilot 2016-19 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph | | Honda | Pilot 2016-19 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Honda | Ridgeline 2017-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph | | Honda | Ridgeline 2017-20 | Honda Sensing | openpilot | 25mph<sup>1</sup> | 12mph |
| Hyundai | Palisade 2020 | All | Stock | 0mph | 0mph | | Hyundai | Palisade 2020-21 | All | Stock | 0mph | 0mph |
| Hyundai | Sonata 2020 | All | Stock | 0mph | 0mph | | Hyundai | Sonata 2020-21 | All | Stock | 0mph | 0mph |
| Lexus | CT Hybrid 2017-18 | LSS | Stock<sup>3</sup>| 0mph | 0mph | | Lexus | CT Hybrid 2017-18 | LSS | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | ES 2019 | All | openpilot | 0mph | 0mph | | Lexus | ES 2019-20 | All | openpilot | 0mph | 0mph |
| Lexus | ES Hybrid 2018 | LSS | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | ES Hybrid 2019 | All | openpilot | 0mph | 0mph | | Lexus | ES Hybrid 2019 | All | openpilot | 0mph | 0mph |
| Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph | | Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph |
| Lexus | IS Hybrid 2017 | All | Stock | 0mph | 0mph | | Lexus | IS Hybrid 2017 | All | Stock | 0mph | 0mph |
| Lexus | NX 2018 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | NX Hybrid 2018 | All | Stock<sup>3</sup>| 0mph | 0mph | | Lexus | NX Hybrid 2018 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | RX 2016-18 | All | Stock<sup>3</sup>| 0mph | 0mph | | Lexus | RX 2016-18 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | RX 2020 | All | openpilot | 0mph | 0mph | | Lexus | RX 2020-21 | All | openpilot | 0mph | 0mph |
| Lexus | RX Hybrid 2016-19 | All | Stock<sup>3</sup>| 0mph | 0mph | | Lexus | RX Hybrid 2016-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Lexus | RX Hybrid 2020 | All | openpilot | 0mph | 0mph | | Lexus | RX Hybrid 2020 | All | openpilot | 0mph | 0mph |
| Toyota | Avalon 2016-18 | TSS-P | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph | | Toyota | Avalon 2016-18, 2021 | TSS-P | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Camry 2018-20 | All | Stock | 0mph<sup>4</sup> | 0mph | | Toyota | Camry 2018-20 | All | Stock | 0mph<sup>4</sup> | 0mph |
| Toyota | Camry Hybrid 2018-19 | All | Stock | 0mph<sup>4</sup> | 0mph | | Toyota | Camry 2021 | All | openpilot | 0mph | 0mph |
| Toyota | C-HR 2017-19 | All | Stock | 0mph | 0mph | | Toyota | Camry Hybrid 2018-20 | All | Stock | 0mph<sup>4</sup> | 0mph |
| Toyota | Camry Hybrid 2021 | All | openpilot | 0mph | 0mph |
| Toyota | C-HR 2017-20 | All | Stock | 0mph | 0mph |
| Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph | | Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph |
| Toyota | Corolla 2017-19 | All | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph | | Toyota | Corolla 2017-19 | All | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Corolla 2020 | All | openpilot | 0mph | 0mph | | Toyota | Corolla 2020-21 | All | openpilot | 0mph | 0mph |
| Toyota | Corolla Hatchback 2019-20 | All | openpilot | 0mph | 0mph | | Toyota | Corolla Hatchback 2019-21 | All | openpilot | 0mph | 0mph |
| Toyota | Corolla Hybrid 2020-21 | All | openpilot | 0mph | 0mph | | Toyota | Corolla Hybrid 2020-21 | All | openpilot | 0mph | 0mph |
| Toyota | Highlander 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph | | Toyota | Highlander 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Highlander 2020 | All | openpilot | 0mph | 0mph | | Toyota | Highlander 2020-21 | All | openpilot | 0mph | 0mph |
| Toyota | Highlander Hybrid 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph | | Toyota | Highlander Hybrid 2017-19 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Highlander Hybrid 2020 | All | openpilot | 0mph | 0mph | | Toyota | Highlander Hybrid 2020-21 | All | openpilot | 0mph | 0mph |
| Toyota | Prius 2016-20 | TSS-P | Stock<sup>3</sup>| 0mph | 0mph | | Toyota | Prius 2016-20 | TSS-P | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Prius 2021 | All | openpilot | 0mph | 0mph |
| Toyota | Prius Prime 2017-20 | All | Stock<sup>3</sup>| 0mph | 0mph | | Toyota | Prius Prime 2017-20 | All | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Prius Prime 2021 | All | openpilot | 0mph | 0mph |
| Toyota | Rav4 2016-18 | TSS-P | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph | | Toyota | Rav4 2016-18 | TSS-P | Stock<sup>3</sup>| 20mph<sup>1</sup> | 0mph |
| Toyota | Rav4 2019-21 | All | openpilot | 0mph | 0mph | | Toyota | Rav4 2019-21 | All | openpilot | 0mph | 0mph |
| Toyota | Rav4 Hybrid 2016-18 | TSS-P | Stock<sup>3</sup>| 0mph | 0mph | | Toyota | Rav4 Hybrid 2016-18 | TSS-P | Stock<sup>3</sup>| 0mph | 0mph |
| Toyota | Rav4 Hybrid 2019-20 | All | openpilot | 0mph | 0mph | | Toyota | Rav4 Hybrid 2019-21 | All | openpilot | 0mph | 0mph |
| Toyota | Sienna 2018-20 | All | Stock<sup>3</sup>| 0mph | 0mph | | Toyota | Sienna 2018-20 | All | Stock<sup>3</sup>| 0mph | 0mph |
<sup>1</sup>[Comma Pedal](https://github.com/commaai/openpilot/wiki/comma-pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).*** <br /> <sup>1</sup>[Comma Pedal](https://github.com/commaai/openpilot/wiki/comma-pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).*** <br />
@@ -125,6 +132,7 @@ Community Maintained Cars and Features
| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | | Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below |
| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------| | ----------| ------------------------------| ------------------| -----------------| -------------------| -------------|
| Audi | A3 2015, 2017 | Prestige | Stock | 0mph | 0mph |
| Buick | Regal 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph | | Buick | Regal 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Cadillac | ATS 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph | | Cadillac | ATS 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Chevrolet | Malibu 2017<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph | | Chevrolet | Malibu 2017<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
@@ -132,38 +140,40 @@ Community Maintained Cars and Features
| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Chrysler | Pacifica 2020 | Adaptive Cruise | Stock | 0mph | 39mph | | Chrysler | Pacifica 2020 | Adaptive Cruise | Stock | 0mph | 39mph |
| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Chrysler | Pacifica Hybrid 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | | Chrysler | Pacifica Hybrid 2019-21 | Adaptive Cruise | Stock | 0mph | 39mph |
| Genesis | G70 2018 | All | Stock | 0mph | 0mph | | Genesis | G70 2018 | All | Stock | 0mph | 0mph |
| Genesis | G80 2018 | All | Stock | 0mph | 0mph | | Genesis | G80 2018 | All | Stock | 0mph | 0mph |
| Genesis | G90 2018 | All | Stock | 0mph | 0mph | | Genesis | G90 2018 | All | Stock | 0mph | 0mph |
| GMC | Acadia Denali 2018<sup>2</sup>| Adaptive Cruise | openpilot | 0mph | 7mph | | GMC | Acadia 2018<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Holden | Astra 2017<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph | | Holden | Astra 2017<sup>1</sup> | Adaptive Cruise | openpilot | 0mph | 7mph |
| Hyundai | Elantra 2017-19 | SCC + LKAS | Stock | 19mph | 34mph | | Hyundai | Elantra 2017-19 | SCC + LKAS | Stock | 19mph | 34mph |
| Hyundai | Genesis 2015-16 | SCC + LKAS | Stock | 19mph | 37mph | | Hyundai | Genesis 2015-16 | SCC + LKAS | Stock | 19mph | 37mph |
| Hyundai | Ioniq Electric 2019-20 | SCC + LKAS | Stock | 0mph | 32mph | | Hyundai | Ioniq Electric 2019 | SCC + LKAS | Stock | 0mph | 32mph |
| Hyundai | Ioniq Electric 2020 | SCC + LKAS | Stock | 0mph | 0mph |
| Hyundai | Kona 2020 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Kona 2020 | SCC + LKAS | Stock | 0mph | 0mph |
| Hyundai | Kona EV 2019 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Kona EV 2019 | SCC + LKAS | Stock | 0mph | 0mph |
| Hyundai | Santa Fe 2019 | All | Stock | 0mph | 0mph | | Hyundai | Santa Fe 2019-20 | All | Stock | 0mph | 0mph |
| Hyundai | Sonata 2019 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Sonata 2018-2019 | SCC + LKAS | Stock | 0mph | 0mph |
| Hyundai | Veloster 2019 | SCC + LKAS | Stock | 5mph | 0mph | | Hyundai | Veloster 2019 | SCC + LKAS | Stock | 5mph | 0mph |
| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph |
| Jeep | Grand Cherokee 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | | Jeep | Grand Cherokee 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph |
| Kia | Forte 2018-19 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Forte 2018-19, 2021 | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Niro EV 2020 | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Optima 2017 | SCC + LKAS | Stock | 0mph | 32mph | | Kia | Optima 2017 | SCC + LKAS | Stock | 0mph | 32mph |
| Kia | Optima 2019 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Optima 2019 | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Sorento 2018 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Sorento 2018 | SCC + LKAS | Stock | 0mph | 0mph |
| Kia | Stinger 2018 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Stinger 2018 | SCC + LKAS | Stock | 0mph | 0mph |
| Nissan | Altima 2020 | ProPILOT | Stock | 0mph | 0mph |
| Nissan | Leaf 2018-20 | ProPILOT | Stock | 0mph | 0mph | | Nissan | Leaf 2018-20 | ProPILOT | Stock | 0mph | 0mph |
| Nissan | Rogue 2018-19 | ProPILOT | Stock | 0mph | 0mph | | Nissan | Rogue 2018-19 | ProPILOT | Stock | 0mph | 0mph |
| Nissan | X-Trail 2017 | ProPILOT | Stock | 0mph | 0mph | | Nissan | X-Trail 2017 | ProPILOT | Stock | 0mph | 0mph |
| Subaru | Ascent 2019 | EyeSight | Stock | 0mph | 0mph | | Subaru | Ascent 2019 | EyeSight | Stock | 0mph | 0mph |
| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | | Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph |
| Subaru | Forester 2019 | EyeSight | Stock | 0mph | 0mph | | Subaru | Forester 2019-20 | EyeSight | Stock | 0mph | 0mph |
| Subaru | Impreza 2017-19 | EyeSight | Stock | 0mph | 0mph | | Subaru | Impreza 2017-19 | EyeSight | Stock | 0mph | 0mph |
| Volkswagen| Golf 2015-19 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf 2015-19 | Driver Assistance | Stock | 0mph | 0mph |
<sup>1</sup>Requires an [OBD-II car harness](https://comma.ai/shop/products/comma-car-harness) and [community built giraffe](https://github.com/commaai/openpilot/wiki/GM). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).*** <br /> <sup>1</sup>Requires an [OBD-II car harness](https://comma.ai/shop/products/comma-car-harness) and [community built ASCM harness](https://github.com/commaai/openpilot/wiki/GM#hardware). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).*** <br />
<sup>2</sup>Requires a custom connector for the developer [car harness](https://comma.ai/shop/products/car-harness) <br />
Although it's not upstream, there's a community of people getting openpilot to run on Tesla's [here](https://tinkla.us/) Although it's not upstream, there's a community of people getting openpilot to run on Tesla's [here](https://tinkla.us/)
@@ -239,7 +249,6 @@ Many factors can impact the performance of openpilot DM, causing it to be unable
* Low light conditions, such as driving at night or in dark tunnels. * Low light conditions, such as driving at night or in dark tunnels.
* Bright light (due to oncoming headlights, direct sunlight, etc.). * Bright light (due to oncoming headlights, direct sunlight, etc.).
* The driver's face is partially or completely outside field of view of the driver facing camera. * The driver's face is partially or completely outside field of view of the driver facing camera.
* Right hand driving vehicles.
* The driver facing camera is obstructed, covered, or damaged. * The driver facing camera is obstructed, covered, or damaged.
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. A driver should not rely on openpilot DM to assess their level of attention. The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. A driver should not rely on openpilot DM to assess their level of attention.
@@ -259,7 +268,7 @@ By using openpilot, you agree to [our Privacy Policy](https://my.comma.ai/privac
Safety and Testing Safety and Testing
---- ----
* openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more detail. * openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more details.
* openpilot has software in the loop [tests](.github/workflows/test.yaml) that run on every commit. * openpilot has software in the loop [tests](.github/workflows/test.yaml) that run on every commit.
* The safety model code lives in panda and is written in C, see [code rigor](https://github.com/commaai/panda#code-rigor) for more details. * The safety model code lives in panda and is written in C, see [code rigor](https://github.com/commaai/panda#code-rigor) for more details.
* panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety). * panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety).
@@ -327,8 +336,6 @@ Directory Structure
├── test # Unit tests, system tests and a car simulator ├── test # Unit tests, system tests and a car simulator
└── ui # The UI └── ui # The UI
To understand how the services interact, see `cereal/service_list.yaml`.
Licensing Licensing
------ ------
+39
View File
@@ -1,3 +1,42 @@
Version 0.8.2 (2021-02-26)
========================
* Use model points directly in MPC (no more polyfits), making lateral planning more accurate
* Use model heading prediction for smoother lateral control
* Smarter actuator delay compensation
* Improve qcamera resolution for improved video in explorer and connect
* Adjust maximum engagement speed to better fit the model's training distribution
* New driver monitoring model trained with 3x more diverse data
* Improved face detection with masks
* More predictable DM alerts when visibility is bad
* Rewritten video streaming between openpilot processes
* Improved longitudinal tuning on TSS2 Corolla and Rav4 thanks to briskspirit!
* Audi A3 2015 and 2017 support thanks to keeleysam!
* Nissan Altima 2020 support thanks to avolmensky!
* Lexus ES Hybrid 2018 support thanks to TheInventorMan!
* Toyota Camry Hybrid 2021 support thanks to alancyau!
Version 0.8.1 (2020-12-21)
========================
* Original EON is deprecated, upgrade to comma two
* Better model performance in heavy rain
* Better lane positioning in turns
* Fixed bug where model would cut turns on empty roads at night
* Fixed issue where some Toyotas would not completely stop thanks to briskspirit!
* Toyota Camry 2021 with TSS2.5 support
* Hyundai Ioniq Electric 2020 support thanks to baldwalker!
Version 0.8.0 (2020-11-30)
========================
* New driving model: fully 3D and improved cut-in detection
* UI draws 2 road edges, 4 lanelines and paths in 3D
* Major fixes to cut-in detection for openpilot longitudinal
* Grey panda is no longer supported, upgrade to comma two or black panda
* Lexus NX 2018 support thanks to matt12eagles!
* Kia Niro EV 2020 support thanks to nickn17!
* Toyota Prius 2021 support thanks to rav4kumar!
* Improved lane positioning with uncertain lanelines, wide lanes and exits
* Improved lateral control for Prius and Subaru
Version 0.7.10 (2020-10-29) Version 0.7.10 (2020-10-29)
======================== ========================
* Grey panda is deprecated, upgrade to comma two or black panda * Grey panda is deprecated, upgrade to comma two or black panda
+152 -83
View File
@@ -1,10 +1,10 @@
import Cython
import distutils
import os import os
import shutil import shutil
import subprocess import subprocess
import sys import sys
import sysconfig
import platform import platform
import numpy as np
TICI = os.path.isfile('/TICI') TICI = os.path.isfile('/TICI')
Decider('MD5-timestamp') Decider('MD5-timestamp')
@@ -17,9 +17,27 @@ AddOption('--asan',
action='store_true', action='store_true',
help='turn on ASAN') help='turn on ASAN')
# Rebuild cython extensions if python, distutils, or cython change AddOption('--ubsan',
cython_dependencies = [Value(v) for v in (sys.version, distutils.__version__, Cython.__version__)] action='store_true',
Export('cython_dependencies') help='turn on UBSan')
AddOption('--clazy',
action='store_true',
help='build with clazy')
AddOption('--compile_db',
action='store_true',
help='build clang compilation database')
AddOption('--mpc-generate',
action='store_true',
help='regenerates the mpc sources')
AddOption('--external-sconscript',
action='store',
metavar='FILE',
dest='external_sconscript',
help='add an external SConscript to the build')
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
if platform.system() == "Darwin": if platform.system() == "Darwin":
@@ -31,11 +49,12 @@ if arch == "aarch64" and TICI:
USE_WEBCAM = os.getenv("USE_WEBCAM") is not None USE_WEBCAM = os.getenv("USE_WEBCAM") is not None
QCOM_REPLAY = arch == "aarch64" and os.getenv("QCOM_REPLAY") is not None QCOM_REPLAY = arch == "aarch64" and os.getenv("QCOM_REPLAY") is not None
lenv = {
"PATH": os.environ['PATH'],
}
if arch == "aarch64" or arch == "larch64": if arch == "aarch64" or arch == "larch64":
lenv = { lenv["LD_LIBRARY_PATH"] = '/data/data/com.termux/files/usr/lib'
"LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib',
"PATH": os.environ['PATH'],
}
if arch == "aarch64": if arch == "aarch64":
# android # android
@@ -47,6 +66,7 @@ if arch == "aarch64" or arch == "larch64":
] ]
libpath = [ libpath = [
"/usr/local/lib",
"/usr/lib", "/usr/lib",
"/system/vendor/lib64", "/system/vendor/lib64",
"/system/comma/usr/lib", "/system/comma/usr/lib",
@@ -75,17 +95,10 @@ if arch == "aarch64" or arch == "larch64":
if QCOM_REPLAY: if QCOM_REPLAY:
cflags += ["-DQCOM_REPLAY"] cflags += ["-DQCOM_REPLAY"]
cxxflags += ["-DQCOM_REPLAY"] cxxflags += ["-DQCOM_REPLAY"]
else: else:
cflags = [] cflags = []
cxxflags = [] cxxflags = []
cpppath = []
lenv = {
"PATH": "#external/bin:" + os.environ['PATH'],
}
cpppath = [
"#external/tensorflow/include",
]
if arch == "Darwin": if arch == "Darwin":
libpath = [ libpath = [
@@ -93,15 +106,16 @@ else:
"#cereal", "#cereal",
"#selfdrive/common", "#selfdrive/common",
"/usr/local/lib", "/usr/local/lib",
"/usr/local/opt/openssl/lib",
"/System/Library/Frameworks/OpenGL.framework/Libraries", "/System/Library/Frameworks/OpenGL.framework/Libraries",
] ]
cflags += ["-DGL_SILENCE_DEPRECATION"] cflags += ["-DGL_SILENCE_DEPRECATION"]
cxxflags += ["-DGL_SILENCE_DEPRECATION"] cxxflags += ["-DGL_SILENCE_DEPRECATION"]
cpppath += ["/usr/local/opt/openssl/include"]
else: else:
libpath = [ libpath = [
"#phonelibs/snpe/x86_64-linux-clang", "#phonelibs/snpe/x86_64-linux-clang",
"#phonelibs/libyuv/x64/lib", "#phonelibs/libyuv/x64/lib",
"#external/tensorflow/lib",
"#cereal", "#cereal",
"#selfdrive/common", "#selfdrive/common",
"/usr/lib", "/usr/lib",
@@ -110,7 +124,6 @@ else:
rpath = [ rpath = [
"phonelibs/snpe/x86_64-linux-clang", "phonelibs/snpe/x86_64-linux-clang",
"external/tensorflow/lib",
"cereal", "cereal",
"selfdrive/common" "selfdrive/common"
] ]
@@ -119,11 +132,14 @@ else:
rpath = [os.path.join(os.getcwd(), x) for x in rpath] rpath = [os.path.join(os.getcwd(), x) for x in rpath]
if GetOption('asan'): if GetOption('asan'):
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] ccflags = ["-fsanitize=address", "-fno-omit-frame-pointer"]
ldflags_asan = ["-fsanitize=address"] ldflags = ["-fsanitize=address"]
elif GetOption('ubsan'):
ccflags = ["-fsanitize=undefined"]
ldflags = ["-fsanitize=undefined"]
else: else:
ccflags_asan = [] ccflags = []
ldflags_asan = [] ldflags = []
# change pythonpath to this # change pythonpath to this
lenv["PYTHONPATH"] = Dir("#").path lenv["PYTHONPATH"] = Dir("#").path
@@ -142,11 +158,12 @@ env = Environment(
"-Wno-inconsistent-missing-override", "-Wno-inconsistent-missing-override",
"-Wno-c99-designator", "-Wno-c99-designator",
"-Wno-reorder-init-list", "-Wno-reorder-init-list",
] + cflags + ccflags_asan, ] + cflags + ccflags,
CPPPATH=cpppath + [ CPPPATH=cpppath + [
"#", "#",
"#selfdrive", "#selfdrive",
"#phonelibs/catch2/include",
"#phonelibs/bzip2", "#phonelibs/bzip2",
"#phonelibs/libyuv/include", "#phonelibs/libyuv/include",
"#phonelibs/openmax/include", "#phonelibs/openmax/include",
@@ -159,6 +176,8 @@ env = Environment(
"#phonelibs/linux/include", "#phonelibs/linux/include",
"#phonelibs/snpe/include", "#phonelibs/snpe/include",
"#phonelibs/nanovg", "#phonelibs/nanovg",
"#phonelibs/qrcode",
"#selfdrive/boardd",
"#selfdrive/common", "#selfdrive/common",
"#selfdrive/camerad", "#selfdrive/camerad",
"#selfdrive/camerad/include", "#selfdrive/camerad/include",
@@ -166,14 +185,15 @@ env = Environment(
"#selfdrive/modeld", "#selfdrive/modeld",
"#selfdrive/sensord", "#selfdrive/sensord",
"#selfdrive/ui", "#selfdrive/ui",
"#cereal/messaging",
"#cereal", "#cereal",
"#cereal/messaging",
"#cereal/visionipc",
"#opendbc/can", "#opendbc/can",
], ],
CC='clang', CC='clang',
CXX='clang++', CXX='clang++',
LINKFLAGS=ldflags_asan, LINKFLAGS=ldflags,
RPATH=rpath, RPATH=rpath,
@@ -181,63 +201,27 @@ env = Environment(
CXXFLAGS=["-std=c++1z"] + cxxflags, CXXFLAGS=["-std=c++1z"] + cxxflags,
LIBPATH=libpath + [ LIBPATH=libpath + [
"#cereal", "#cereal",
"#selfdrive/common",
"#phonelibs", "#phonelibs",
] "#opendbc/can",
"#selfdrive/boardd",
"#selfdrive/common",
],
CYTHONCFILESUFFIX=".cpp",
COMPILATIONDB_USE_ABSPATH=True,
tools=["default", "cython", "compilation_db"],
) )
qt_env = None if GetOption('compile_db'):
if arch in ["x86_64", "Darwin", "larch64"]: env.CompilationDatabase('compile_commands.json')
qt_env = env.Clone()
if arch == "Darwin":
qt_env['QTDIR'] = "/usr/local/opt/qt"
QT_BASE = "/usr/local/opt/qt/"
qt_dirs = [
QT_BASE + "include/",
QT_BASE + "include/QtWidgets",
QT_BASE + "include/QtGui",
QT_BASE + "include/QtCore",
QT_BASE + "include/QtDBus",
QT_BASE + "include/QtMultimedia",
]
qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"]
else:
qt_env['QTDIR'] = "/usr"
qt_dirs = [
f"/usr/include/{real_arch}-linux-gnu/qt5",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtWidgets",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtCore",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtDBus",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtMultimedia",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.5.1/QtGui",
]
qt_env.Tool('qt')
qt_env['CPPPATH'] += qt_dirs
qt_flags = [
"-D_REENTRANT",
"-DQT_NO_DEBUG",
"-DQT_WIDGETS_LIB",
"-DQT_GUI_LIB",
"-DQT_CORE_LIB"
]
qt_env['CXXFLAGS'] += qt_flags
if os.environ.get('SCONS_CACHE'): if os.environ.get('SCONS_CACHE'):
cache_dir = '/tmp/scons_cache' cache_dir = '/tmp/scons_cache'
if TICI:
cache_dir = '/data/scons_cache'
if os.getenv('CI'): if QCOM_REPLAY:
branch = os.getenv('GIT_BRANCH') cache_dir = '/tmp/scons_cache_qcom_replay'
if QCOM_REPLAY:
cache_dir = '/tmp/scons_cache_qcom_replay'
elif branch is not None and branch != 'master':
cache_dir_branch = '/tmp/scons_cache_' + branch
if not os.path.isdir(cache_dir_branch) and os.path.isdir(cache_dir):
shutil.copytree(cache_dir, cache_dir_branch)
cache_dir = cache_dir_branch
CacheDir(cache_dir) CacheDir(cache_dir)
node_interval = 5 node_interval = 5
@@ -261,9 +245,84 @@ def abspath(x):
# rpath works elsewhere # rpath works elsewhere
return x[0].path.rsplit("/", 1)[1][:-3] return x[0].path.rsplit("/", 1)[1][:-3]
# Cython build enviroment
py_include = sysconfig.get_paths()['include']
envCython = env.Clone()
envCython["CPPPATH"] += [py_include, np.get_include()]
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"]
envCython["LIBS"] = []
if arch == "Darwin":
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
elif arch == "aarch64":
envCython["LINKFLAGS"] = ["-shared"]
envCython["LIBS"] = [os.path.basename(py_include)]
else:
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
Export('envCython')
# Qt build environment
qt_env = None
if arch in ["x86_64", "Darwin", "larch64"]:
qt_env = env.Clone()
qt_modules = ["Widgets", "Gui", "Core", "DBus", "Multimedia", "Network", "Concurrent", "WebEngine", "WebEngineWidgets"]
qt_libs = []
if arch == "Darwin":
qt_env['QTDIR'] = "/usr/local/opt/qt"
QT_BASE = "/usr/local/opt/qt/"
qt_dirs = [
QT_BASE + "include/",
]
qt_dirs += [f"{QT_BASE}include/Qt{m}" for m in qt_modules]
qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"]
qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"]
else:
qt_env['QTDIR'] = "/usr"
qt_dirs = [
f"/usr/include/{real_arch}-linux-gnu/qt5",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.5.1/QtGui",
f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui",
]
qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules]
qt_libs = [f"Qt5{m}" for m in qt_modules]
if arch == "larch64":
qt_libs += ["GLESv2", "wayland-client"]
elif arch != "Darwin":
qt_libs += ["GL"]
qt_env.Tool('qt')
qt_env['CPPPATH'] += qt_dirs + ["#selfdrive/ui/qt/"]
qt_flags = [
"-D_REENTRANT",
"-DQT_NO_DEBUG",
"-DQT_WIDGETS_LIB",
"-DQT_GUI_LIB",
"-DQT_CORE_LIB"
]
qt_env['CXXFLAGS'] += qt_flags
qt_env['LIBPATH'] += ['#selfdrive/ui']
qt_env['LIBS'] = qt_libs
if GetOption("clazy"):
checks = [
"level0",
"level1",
"no-range-loop",
"no-non-pod-global-static",
]
qt_env['CXX'] = 'clazy'
qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0]
qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks)
Export('qt_env')
# still needed for apks # still needed for apks
zmq = 'zmq' zmq = 'zmq'
Export('env', 'qt_env', 'arch', 'zmq', 'SHARED', 'USE_WEBCAM', 'QCOM_REPLAY') Export('env', 'arch', 'real_arch', 'zmq', 'SHARED', 'USE_WEBCAM', 'QCOM_REPLAY')
# cereal and messaging are shared with the system # cereal and messaging are shared with the system
SConscript(['cereal/SConscript']) SConscript(['cereal/SConscript'])
@@ -273,26 +332,32 @@ if SHARED:
else: else:
cereal = [File('#cereal/libcereal.a')] cereal = [File('#cereal/libcereal.a')]
messaging = [File('#cereal/libmessaging.a')] messaging = [File('#cereal/libmessaging.a')]
visionipc = [File('#cereal/libvisionipc.a')]
Export('cereal', 'messaging') Export('cereal', 'messaging')
SConscript(['selfdrive/common/SConscript']) SConscript(['selfdrive/common/SConscript'])
Import('_common', '_visionipc', '_gpucommon', '_gpu_libs') Import('_common', '_gpucommon', '_gpu_libs')
if SHARED: if SHARED:
common, visionipc, gpucommon = abspath(common), abspath(visionipc), abspath(gpucommon) common, gpucommon = abspath(common), abspath(gpucommon)
else: else:
common = [_common, 'json11'] common = [_common, 'json11']
visionipc = _visionipc
gpucommon = [_gpucommon] + _gpu_libs gpucommon = [_gpucommon] + _gpu_libs
Export('common', 'visionipc', 'gpucommon') Export('common', 'gpucommon', 'visionipc')
# Build openpilot
SConscript(['cereal/SConscript'])
SConscript(['opendbc/can/SConscript']) SConscript(['opendbc/can/SConscript'])
SConscript(['phonelibs/SConscript'])
SConscript(['common/SConscript']) SConscript(['common/SConscript'])
SConscript(['common/kalman/SConscript']) SConscript(['common/kalman/SConscript'])
SConscript(['common/transformations/SConscript']) SConscript(['common/transformations/SConscript'])
SConscript(['phonelibs/SConscript'])
SConscript(['selfdrive/camerad/SConscript']) SConscript(['selfdrive/camerad/SConscript'])
SConscript(['selfdrive/modeld/SConscript']) SConscript(['selfdrive/modeld/SConscript'])
@@ -316,6 +381,10 @@ SConscript(['selfdrive/ui/SConscript'])
if arch != "Darwin": if arch != "Darwin":
SConscript(['selfdrive/logcatd/SConscript']) SConscript(['selfdrive/logcatd/SConscript'])
if real_arch == "x86_64":
if arch == "x86_64": SConscript(['tools/nui/SConscript'])
SConscript(['tools/lib/index_log/SConscript']) SConscript(['tools/lib/index_log/SConscript'])
external_sconscript = GetOption('external_sconscript')
if external_sconscript:
SConscript([external_sconscript])
Binary file not shown.
+8 -1
View File
@@ -1,14 +1,21 @@
gen gen
node_modules node_modules
package-lock.json package-lock.json
*.tmp
*.pyc *.pyc
__pycache__ __pycache__
.*.swp .*.swp
.*.swo .*.swo
libcereal*.a *.os
*.o
*.a
test_runner
libmessaging.* libmessaging.*
libmessaging_shared.* libmessaging_shared.*
services.h services.h
.sconsign.dblite .sconsign.dblite
libcereal_shared.* libcereal_shared.*
.mypy_cache/ .mypy_cache/
catch2/
+38 -20
View File
@@ -1,34 +1,33 @@
Import('env', 'arch', 'zmq', 'cython_dependencies') Import('env', 'envCython', 'arch', 'zmq', 'QCOM_REPLAY')
import shutil import shutil
cereal_dir = Dir('.')
gen_dir = Dir('gen') gen_dir = Dir('gen')
messaging_dir = Dir('messaging') messaging_dir = Dir('messaging')
# TODO: remove src-prefix and cereal from command string. can we set working directory? # Build cereal
schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp']
env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS") env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS")
env.Command(['gen/cpp/car.capnp.c++', 'gen/cpp/log.capnp.c++', 'gen/cpp/car.capnp.h', 'gen/cpp/log.capnp.h'], env.Command([f'gen/cpp/{s}.c++' for s in schema_files] + [f'gen/cpp/{s}.h' for s in schema_files],
['car.capnp', 'log.capnp'], schema_files,
'capnpc $SOURCES --src-prefix=cereal -o c++:' + gen_dir.path + '/cpp/') f"capnpc --src-prefix={cereal_dir.path} $SOURCES -o c++:{gen_dir.path}/cpp/")
if shutil.which('capnpc-java'): if shutil.which('capnpc-java'):
env.Command(['gen/java/Car.java', 'gen/java/Log.java'], env.Command(['gen/java/Car.java', 'gen/java/Log.java'],
['car.capnp', 'log.capnp'], schema_files,
'capnpc $SOURCES --src-prefix=cereal -o java:' + gen_dir.path + '/java/') f"capnpc $SOURCES --src-prefix={cereal_dir.path} -o java:{gen_dir.path}/java/")
# TODO: remove non shared cereal and messaging # TODO: remove non shared cereal and messaging
cereal_objects = env.SharedObject([ cereal_objects = env.SharedObject([f'gen/cpp/{s}.c++' for s in schema_files])
'gen/cpp/car.capnp.c++',
'gen/cpp/log.capnp.c++',
])
env.Library('cereal', cereal_objects) env.Library('cereal', cereal_objects)
env.SharedLibrary('cereal_shared', cereal_objects) env.SharedLibrary('cereal_shared', cereal_objects)
cereal_dir = Dir('.') # Build messaging
services_h = env.Command(['services.h'],
['service_list.yaml', 'services.py'], services_h = env.Command(['services.h'], ['services.py'], 'python3 ' + cereal_dir.path + '/services.py > $TARGET')
'python3 ' + cereal_dir.path + '/services.py > $TARGET')
messaging_objects = env.SharedObject([ messaging_objects = env.SharedObject([
'messaging/messaging.cc', 'messaging/messaging.cc',
@@ -51,14 +50,33 @@ if arch == "aarch64":
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq']) env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq'])
Depends('messaging/bridge.cc', services_h) Depends('messaging/bridge.cc', services_h)
# different target? envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq"])
#env.Program('messaging/demo', ['messaging/demo.cc'], LIBS=[messaging_lib, 'zmq'])
env.Command(['messaging/messaging_pyx.so', 'messaging/messaging_pyx.cpp'], # Build Vision IPC
cython_dependencies + [messaging_lib, 'messaging/messaging_pyx_setup.py', 'messaging/messaging_pyx.pyx', 'messaging/messaging.pxd'], vipc_sources = [
"cd " + messaging_dir.path + " && python3 messaging_pyx_setup.py build_ext --inplace") 'visionipc/ipc.cc',
'visionipc/visionipc_server.cc',
'visionipc/visionipc_client.cc',
'visionipc/visionbuf.cc',
]
if arch in ["aarch64", "larch64"] and (not QCOM_REPLAY):
vipc_sources += ['visionipc/visionbuf_ion.cc']
else:
vipc_sources += ['visionipc/visionbuf_cl.cc']
vipc_objects = env.SharedObject(vipc_sources)
vipc = env.Library('visionipc', vipc_objects)
libs = envCython["LIBS"]+["OpenCL", "zmq", vipc, messaging_lib]
if arch == "Darwin":
del libs[libs.index('OpenCL')]
envCython['FRAMEWORKS'] += ['OpenCL']
envCython.Program('visionipc/visionipc_pyx.so', 'visionipc/visionipc_pyx.pyx', LIBS=libs)
if GetOption('test'): if GetOption('test'):
env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib]) env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib])
env.Program('visionipc/test_runner', ['visionipc/test_runner.cc', 'visionipc/visionipc_tests.cc'], LIBS=[vipc, messaging_lib, 'zmq', 'pthread', 'OpenCL'])
+41 -23
View File
@@ -11,6 +11,8 @@ $Java.outerClassname("Car");
struct CarEvent @0x9b1657f34caf3ad3 { struct CarEvent @0x9b1657f34caf3ad3 {
name @0 :EventName; name @0 :EventName;
# event types
enable @1 :Bool; enable @1 :Bool;
noEntry @2 :Bool; noEntry @2 :Bool;
warning @3 :Bool; # alerts presented only when enabled or soft disabling warning @3 :Bool; # alerts presented only when enabled or soft disabling
@@ -21,7 +23,6 @@ struct CarEvent @0x9b1657f34caf3ad3 {
permanent @8 :Bool; # alerts presented regardless of openpilot state permanent @8 :Bool; # alerts presented regardless of openpilot state
enum EventName @0xbaa8c5d505f727de { enum EventName @0xbaa8c5d505f727de {
# TODO: copy from error list
canError @0; canError @0;
steerUnavailable @1; steerUnavailable @1;
brakeUnavailable @2; brakeUnavailable @2;
@@ -36,7 +37,6 @@ struct CarEvent @0x9b1657f34caf3ad3 {
buttonEnable @12; buttonEnable @12;
pedalPressed @13; pedalPressed @13;
cruiseDisabled @14; cruiseDisabled @14;
radarCanError @15;
speedTooLow @17; speedTooLow @17;
outOfSpace @18; outOfSpace @18;
overheat @19; overheat @19;
@@ -73,14 +73,11 @@ struct CarEvent @0x9b1657f34caf3ad3 {
preLaneChangeLeft @57; preLaneChangeLeft @57;
preLaneChangeRight @58; preLaneChangeRight @58;
laneChange @59; laneChange @59;
invalidGiraffeToyota @60;
internetConnectivityNeeded @61;
communityFeatureDisallowed @62; communityFeatureDisallowed @62;
lowMemory @63; lowMemory @63;
stockAeb @64; stockAeb @64;
ldw @65; ldw @65;
carUnrecognized @66; carUnrecognized @66;
radarCommIssue @67;
driverMonitorLowAcc @68; driverMonitorLowAcc @68;
invalidLkasSetting @69; invalidLkasSetting @69;
speedTooHigh @70; speedTooHigh @70;
@@ -94,15 +91,19 @@ struct CarEvent @0x9b1657f34caf3ad3 {
startupMaster @78; startupMaster @78;
fcw @79; fcw @79;
steerSaturated @80; steerSaturated @80;
whitePandaUnsupported @81;
startupGreyPanda @82;
belowEngageSpeed @84; belowEngageSpeed @84;
noGps @85; noGps @85;
wrongCruiseMode @87; wrongCruiseMode @87;
modeldLagging @89; modeldLagging @89;
deviceFalling @90; deviceFalling @90;
fanMalfunction @91; fanMalfunction @91;
cameraMalfunction @92;
gpsMalfunction @94;
startupOneplus @82;
processNotRunning @95;
radarCanErrorDEPRECATED @15;
radarCommIssueDEPRECATED @67;
gasUnavailableDEPRECATED @3; gasUnavailableDEPRECATED @3;
dataNeededDEPRECATED @16; dataNeededDEPRECATED @16;
modelCommIssueDEPRECATED @27; modelCommIssueDEPRECATED @27;
@@ -112,9 +113,13 @@ struct CarEvent @0x9b1657f34caf3ad3 {
driverMonitorOffDEPRECATED @42; driverMonitorOffDEPRECATED @42;
calibrationProgressDEPRECATED @47; calibrationProgressDEPRECATED @47;
invalidGiraffeHondaDEPRECATED @49; invalidGiraffeHondaDEPRECATED @49;
canErrorPersistentDEPRECATED @83; invalidGiraffeToyotaDEPRECATED @60;
internetConnectivityNeededDEPRECATED @61;
whitePandaUnsupportedDEPRECATED @81;
commIssueWarningDEPRECATED @83;
focusRecoverActiveDEPRECATED @86; focusRecoverActiveDEPRECATED @86;
neosUpdateRequiredDEPRECATED @88; neosUpdateRequiredDEPRECATED @88;
modelLagWarningDEPRECATED @93;
} }
} }
@@ -122,7 +127,6 @@ struct CarEvent @0x9b1657f34caf3ad3 {
# all speeds in m/s # all speeds in m/s
struct CarState { struct CarState {
errorsDEPRECATED @0 :List(CarEvent.EventName);
events @13 :List(CarEvent); events @13 :List(CarEvent);
# car speed # car speed
@@ -143,8 +147,8 @@ struct CarState {
brakeLights @19 :Bool; brakeLights @19 :Bool;
# steering wheel # steering wheel
steeringAngle @7 :Float32; # deg steeringAngleDeg @7 :Float32;
steeringRate @15 :Float32; # deg/s steeringRateDeg @15 :Float32;
steeringTorque @8 :Float32; # TODO: standardize units steeringTorque @8 :Float32; # TODO: standardize units
steeringTorqueEps @27 :Float32; # TODO: standardize units steeringTorqueEps @27 :Float32; # TODO: standardize units
steeringPressed @9 :Bool; # if the user is using the steering wheel steeringPressed @9 :Bool; # if the user is using the steering wheel
@@ -232,6 +236,8 @@ struct CarState {
gapAdjustCruise @11; gapAdjustCruise @11;
} }
} }
errorsDEPRECATED @0 :List(CarEvent.EventName);
} }
# ******* radar state @ 20hz ******* # ******* radar state @ 20hz *******
@@ -275,10 +281,6 @@ struct CarControl {
enabled @0 :Bool; enabled @0 :Bool;
active @7 :Bool; active @7 :Bool;
gasDEPRECATED @1 :Float32;
brakeDEPRECATED @2 :Float32;
steeringTorqueDEPRECATED @3 :Float32;
actuators @6 :Actuators; actuators @6 :Actuators;
cruiseControl @4 :CruiseControl; cruiseControl @4 :CruiseControl;
@@ -290,7 +292,7 @@ struct CarControl {
brake @1: Float32; brake @1: Float32;
# range from -1.0 - 1.0 # range from -1.0 - 1.0
steer @2: Float32; steer @2: Float32;
steerAngle @3: Float32; steeringAngleDeg @3: Float32;
} }
struct CruiseControl { struct CruiseControl {
@@ -326,8 +328,6 @@ struct CarControl {
} }
enum AudibleAlert { enum AudibleAlert {
# these are the choices from the Honda
# map as good as you can for your car
none @0; none @0;
chimeEngage @1; chimeEngage @1;
chimeDisengage @2; chimeDisengage @2;
@@ -339,6 +339,10 @@ struct CarControl {
chimeWarning2Repeat @8; chimeWarning2Repeat @8;
} }
} }
gasDEPRECATED @1 :Float32;
brakeDEPRECATED @2 :Float32;
steeringTorqueDEPRECATED @3 :Float32;
} }
# ****** car param ****** # ****** car param ******
@@ -355,6 +359,7 @@ struct CarParams {
minEnableSpeed @7 :Float32; minEnableSpeed @7 :Float32;
minSteerSpeed @8 :Float32; minSteerSpeed @8 :Float32;
maxSteeringAngleDeg @54 :Float32;
safetyModel @9 :SafetyModel; safetyModel @9 :SafetyModel;
safetyModelPassive @42 :SafetyModel = silent; safetyModelPassive @42 :SafetyModel = silent;
safetyParam @10 :Int16; safetyParam @10 :Int16;
@@ -396,11 +401,13 @@ struct CarParams {
steerRateCost @33 :Float32; # Lateral MPC cost on steering rate steerRateCost @33 :Float32; # Lateral MPC cost on steering rate
steerControlType @34 :SteerControlType; steerControlType @34 :SteerControlType;
radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN
minSpeedCan @51 :Float32; # Minimum vehicle speed from CAN (below this value drops to 0)
stoppingBrakeRate @52 :Float32; # brake_travel/s while trying to stop
startingBrakeRate @53 :Float32; # brake_travel/s while releasing on restart
steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds
openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control? openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control?
carVin @38 :Text; # VIN number queried during fingerprinting carVin @38 :Text; # VIN number queried during fingerprinting
isPandaBlack @39: Bool;
dashcamOnly @41: Bool; dashcamOnly @41: Bool;
transmissionType @43 :TransmissionType; transmissionType @43 :TransmissionType;
carFw @44 :List(CarFw); carFw @44 :List(CarFw);
@@ -432,10 +439,19 @@ struct CarParams {
} }
struct LateralINDITuning { struct LateralINDITuning {
outerLoopGain @0 :Float32; outerLoopGainBP @4 :List(Float32);
innerLoopGain @1 :Float32; outerLoopGainV @5 :List(Float32);
timeConstant @2 :Float32; innerLoopGainBP @6 :List(Float32);
actuatorEffectiveness @3 :Float32; innerLoopGainV @7 :List(Float32);
timeConstantBP @8 :List(Float32);
timeConstantV @9 :List(Float32);
actuatorEffectivenessBP @10 :List(Float32);
actuatorEffectivenessV @11 :List(Float32);
outerLoopGainDEPRECATED @0 :Float32;
innerLoopGainDEPRECATED @1 :Float32;
timeConstantDEPRECATED @2 :Float32;
actuatorEffectivenessDEPRECATED @3 :Float32;
} }
struct LateralLQRTuning { struct LateralLQRTuning {
@@ -533,4 +549,6 @@ struct CarParams {
fwdCamera @0; # Standard/default integration at LKAS camera fwdCamera @0; # Standard/default integration at LKAS camera
gateway @1; # Integration at vehicle's CAN gateway gateway @1; # Integration at vehicle's CAN gateway
} }
isPandaBlackDEPRECATED @39: Bool;
} }
+850
View File
@@ -0,0 +1,850 @@
using Cxx = import "./include/c++.capnp";
$Cxx.namespace("cereal");
using Java = import "./include/java.capnp";
$Java.package("ai.comma.openpilot.cereal");
$Java.outerClassname("Legacy");
@0x80ef1ec4889c2a63;
# legacy.capnp: a home for deprecated structs
struct LogRotate @0x9811e1f38f62f2d1 {
segmentNum @0 :Int32;
path @1 :Text;
}
struct LiveUI @0xc08240f996aefced {
rearViewCam @0 :Bool;
alertText1 @1 :Text;
alertText2 @2 :Text;
awarenessStatus @3 :Float32;
}
struct OrbslamCorrection @0x8afd33dc9b35e1aa {
correctionMonoTime @0 :UInt64;
prePositionECEF @1 :List(Float64);
postPositionECEF @2 :List(Float64);
prePoseQuatECEF @3 :List(Float32);
postPoseQuatECEF @4 :List(Float32);
numInliers @5 :UInt32;
}
struct EthernetPacket @0xa99a9d5b33cf5859 {
pkt @0 :Data;
ts @1 :Float32;
}
struct CellInfo @0xcff7566681c277ce {
timestamp @0 :UInt64;
repr @1 :Text; # android toString() for now
}
struct WifiScan @0xd4df5a192382ba0b {
bssid @0 :Text;
ssid @1 :Text;
capabilities @2 :Text;
frequency @3 :Int32;
level @4 :Int32;
timestamp @5 :Int64;
centerFreq0 @6 :Int32;
centerFreq1 @7 :Int32;
channelWidth @8 :ChannelWidth;
operatorFriendlyName @9 :Text;
venueName @10 :Text;
is80211mcResponder @11 :Bool;
passpoint @12 :Bool;
distanceCm @13 :Int32;
distanceSdCm @14 :Int32;
enum ChannelWidth @0xcb6a279f015f6b51 {
w20Mhz @0;
w40Mhz @1;
w80Mhz @2;
w160Mhz @3;
w80Plus80Mhz @4;
}
}
struct LiveEventData @0x94b7baa90c5c321e {
name @0 :Text;
value @1 :Int32;
}
struct ModelData @0xb8aad62cffef28a9 {
frameId @0 :UInt32;
frameAge @12 :UInt32;
frameDropPerc @13 :Float32;
timestampEof @9 :UInt64;
modelExecutionTime @14 :Float32;
gpuExecutionTime @16 :Float32;
rawPred @15 :Data;
path @1 :PathData;
leftLane @2 :PathData;
rightLane @3 :PathData;
lead @4 :LeadData;
freePath @6 :List(Float32);
settings @5 :ModelSettings;
leadFuture @7 :LeadData;
speed @8 :List(Float32);
meta @10 :MetaData;
longitudinal @11 :LongitudinalData;
struct PathData @0x8817eeea389e9f08 {
points @0 :List(Float32);
prob @1 :Float32;
std @2 :Float32;
stds @3 :List(Float32);
poly @4 :List(Float32);
validLen @5 :Float32;
}
struct LeadData @0xd1c9bef96d26fa91 {
dist @0 :Float32;
prob @1 :Float32;
std @2 :Float32;
relVel @3 :Float32;
relVelStd @4 :Float32;
relY @5 :Float32;
relYStd @6 :Float32;
relA @7 :Float32;
relAStd @8 :Float32;
}
struct ModelSettings @0xa26e3710efd3e914 {
bigBoxX @0 :UInt16;
bigBoxY @1 :UInt16;
bigBoxWidth @2 :UInt16;
bigBoxHeight @3 :UInt16;
boxProjection @4 :List(Float32);
yuvCorrection @5 :List(Float32);
inputTransform @6 :List(Float32);
}
struct MetaData @0x9744f25fb60f2bf8 {
engagedProb @0 :Float32;
desirePrediction @1 :List(Float32);
brakeDisengageProb @2 :Float32;
gasDisengageProb @3 :Float32;
steerOverrideProb @4 :Float32;
desireState @5 :List(Float32);
}
struct LongitudinalData @0xf98f999c6a071122 {
distances @2 :List(Float32);
speeds @0 :List(Float32);
accelerations @1 :List(Float32);
}
}
struct ECEFPoint @0xc25bbbd524983447 {
x @0 :Float64;
y @1 :Float64;
z @2 :Float64;
}
struct ECEFPointDEPRECATED @0xe10e21168db0c7f7 {
x @0 :Float32;
y @1 :Float32;
z @2 :Float32;
}
struct GPSPlannerPoints @0xab54c59699f8f9f3 {
curPosDEPRECATED @0 :ECEFPointDEPRECATED;
pointsDEPRECATED @1 :List(ECEFPointDEPRECATED);
curPos @6 :ECEFPoint;
points @7 :List(ECEFPoint);
valid @2 :Bool;
trackName @3 :Text;
speedLimit @4 :Float32;
accelTarget @5 :Float32;
}
struct GPSPlannerPlan @0xf5ad1d90cdc1dd6b {
valid @0 :Bool;
poly @1 :List(Float32);
trackName @2 :Text;
speed @3 :Float32;
acceleration @4 :Float32;
pointsDEPRECATED @5 :List(ECEFPointDEPRECATED);
points @6 :List(ECEFPoint);
xLookahead @7 :Float32;
}
struct UiNavigationEvent @0x90c8426c3eaddd3b {
type @0: Type;
status @1: Status;
distanceTo @2: Float32;
endRoadPointDEPRECATED @3: ECEFPointDEPRECATED;
endRoadPoint @4: ECEFPoint;
enum Type @0xe8db07dcf8fcea05 {
none @0;
laneChangeLeft @1;
laneChangeRight @2;
mergeLeft @3;
mergeRight @4;
turnLeft @5;
turnRight @6;
}
enum Status @0xb9aa88c75ef99a1f {
none @0;
passive @1;
approaching @2;
active @3;
}
}
struct LiveLocationData @0xb99b2bc7a57e8128 {
status @0 :UInt8;
# 3D fix
lat @1 :Float64;
lon @2 :Float64;
alt @3 :Float32; # m
# speed
speed @4 :Float32; # m/s
# NED velocity components
vNED @5 :List(Float32);
# roll, pitch, heading (x,y,z)
roll @6 :Float32; # WRT to center of earth?
pitch @7 :Float32; # WRT to center of earth?
heading @8 :Float32; # WRT to north?
# what are these?
wanderAngle @9 :Float32;
trackAngle @10 :Float32;
# car frame -- https://upload.wikimedia.org/wikipedia/commons/f/f5/RPY_angles_of_cars.png
# gyro, in car frame, deg/s
gyro @11 :List(Float32);
# accel, in car frame, m/s^2
accel @12 :List(Float32);
accuracy @13 :Accuracy;
source @14 :SensorSource;
# if we are fixing a location in the past
fixMonoTime @15 :UInt64;
gpsWeek @16 :Int32;
timeOfWeek @17 :Float64;
positionECEF @18 :List(Float64);
poseQuatECEF @19 :List(Float32);
pitchCalibration @20 :Float32;
yawCalibration @21 :Float32;
imuFrame @22 :List(Float32);
struct Accuracy @0x943dc4625473b03f {
pNEDError @0 :List(Float32);
vNEDError @1 :List(Float32);
rollError @2 :Float32;
pitchError @3 :Float32;
headingError @4 :Float32;
ellipsoidSemiMajorError @5 :Float32;
ellipsoidSemiMinorError @6 :Float32;
ellipsoidOrientationError @7 :Float32;
}
enum SensorSource @0xc871d3cc252af657 {
applanix @0;
kalman @1;
orbslam @2;
timing @3;
dummy @4;
}
}
struct OrbOdometry @0xd7700859ed1f5b76 {
# timing first
startMonoTime @0 :UInt64;
endMonoTime @1 :UInt64;
# fundamental matrix and error
f @2: List(Float64);
err @3: Float64;
# number of inlier points
inliers @4: Int32;
# for debug only
# indexed by endMonoTime features
# value is startMonoTime feature match
# -1 if no match
matches @5: List(Int16);
}
struct OrbFeatures @0xcd60164a8a0159ef {
timestampEof @0 :UInt64;
# transposed arrays of normalized image coordinates
# len(xs) == len(ys) == len(descriptors) * 32
xs @1 :List(Float32);
ys @2 :List(Float32);
descriptors @3 :Data;
octaves @4 :List(Int8);
# match index to last OrbFeatures
# -1 if no match
timestampLastEof @5 :UInt64;
matches @6: List(Int16);
}
struct OrbFeaturesSummary @0xd500d30c5803fa4f {
timestampEof @0 :UInt64;
timestampLastEof @1 :UInt64;
featureCount @2 :UInt16;
matchCount @3 :UInt16;
computeNs @4 :UInt64;
}
struct OrbKeyFrame @0xc8233c0345e27e24 {
# this is a globally unique id for the KeyFrame
id @0: UInt64;
# this is the location of the KeyFrame
pos @1: ECEFPoint;
# these are the features in the world
# len(dpos) == len(descriptors) * 32
dpos @2 :List(ECEFPoint);
descriptors @3 :Data;
}
struct KalmanOdometry @0x92e21bb7ea38793a {
trans @0 :List(Float32); # m/s in device frame
rot @1 :List(Float32); # rad/s in device frame
transStd @2 :List(Float32); # std m/s in device frame
rotStd @3 :List(Float32); # std rad/s in device frame
}
struct OrbObservation @0x9b326d4e436afec7 {
observationMonoTime @0 :UInt64;
normalizedCoordinates @1 :List(Float32);
locationECEF @2 :List(Float64);
matchDistance @3: UInt32;
}
struct CalibrationFeatures @0x8fdfadb254ea867a {
frameId @0 :UInt32;
p0 @1 :List(Float32);
p1 @2 :List(Float32);
status @3 :List(Int8);
}
struct NavStatus @0xbd8822120928120c {
isNavigating @0 :Bool;
currentAddress @1 :Address;
struct Address @0xce7cd672cacc7814 {
title @0 :Text;
lat @1 :Float64;
lng @2 :Float64;
house @3 :Text;
address @4 :Text;
street @5 :Text;
city @6 :Text;
state @7 :Text;
country @8 :Text;
}
}
struct NavUpdate @0xdb98be6565516acb {
isNavigating @0 :Bool;
curSegment @1 :Int32;
segments @2 :List(Segment);
struct LatLng @0x9eaef9187cadbb9b {
lat @0 :Float64;
lng @1 :Float64;
}
struct Segment @0xa5b39b4fc4d7da3f {
from @0 :LatLng;
to @1 :LatLng;
updateTime @2 :Int32;
distance @3 :Int32;
crossTime @4 :Int32;
exitNo @5 :Int32;
instruction @6 :Instruction;
parts @7 :List(LatLng);
enum Instruction @0xc5417a637451246f {
turnLeft @0;
turnRight @1;
keepLeft @2;
keepRight @3;
straight @4;
roundaboutExitNumber @5;
roundaboutExit @6;
roundaboutTurnLeft @7;
unkn8 @8;
roundaboutStraight @9;
unkn10 @10;
roundaboutTurnRight @11;
unkn12 @12;
roundaboutUturn @13;
unkn14 @14;
arrive @15;
exitLeft @16;
exitRight @17;
unkn18 @18;
uturn @19;
# ...
}
}
}
struct TrafficEvent @0xacfa74a094e62626 {
type @0 :Type;
distance @1 :Float32;
action @2 :Action;
resuming @3 :Bool;
enum Type @0xd85d75253435bf4b {
stopSign @0;
lightRed @1;
lightYellow @2;
lightGreen @3;
stopLight @4;
}
enum Action @0xa6f6ce72165ccb49 {
none @0;
yield @1;
stop @2;
resumeReady @3;
}
}
struct AndroidGnss @0xdfdf30d03fc485bd {
union {
measurements @0 :Measurements;
navigationMessage @1 :NavigationMessage;
}
struct Measurements @0xa20710d4f428d6cd {
clock @0 :Clock;
measurements @1 :List(Measurement);
struct Clock @0xa0e27b453a38f450 {
timeNanos @0 :Int64;
hardwareClockDiscontinuityCount @1 :Int32;
hasTimeUncertaintyNanos @2 :Bool;
timeUncertaintyNanos @3 :Float64;
hasLeapSecond @4 :Bool;
leapSecond @5 :Int32;
hasFullBiasNanos @6 :Bool;
fullBiasNanos @7 :Int64;
hasBiasNanos @8 :Bool;
biasNanos @9 :Float64;
hasBiasUncertaintyNanos @10 :Bool;
biasUncertaintyNanos @11 :Float64;
hasDriftNanosPerSecond @12 :Bool;
driftNanosPerSecond @13 :Float64;
hasDriftUncertaintyNanosPerSecond @14 :Bool;
driftUncertaintyNanosPerSecond @15 :Float64;
}
struct Measurement @0xd949bf717d77614d {
svId @0 :Int32;
constellation @1 :Constellation;
timeOffsetNanos @2 :Float64;
state @3 :Int32;
receivedSvTimeNanos @4 :Int64;
receivedSvTimeUncertaintyNanos @5 :Int64;
cn0DbHz @6 :Float64;
pseudorangeRateMetersPerSecond @7 :Float64;
pseudorangeRateUncertaintyMetersPerSecond @8 :Float64;
accumulatedDeltaRangeState @9 :Int32;
accumulatedDeltaRangeMeters @10 :Float64;
accumulatedDeltaRangeUncertaintyMeters @11 :Float64;
hasCarrierFrequencyHz @12 :Bool;
carrierFrequencyHz @13 :Float32;
hasCarrierCycles @14 :Bool;
carrierCycles @15 :Int64;
hasCarrierPhase @16 :Bool;
carrierPhase @17 :Float64;
hasCarrierPhaseUncertainty @18 :Bool;
carrierPhaseUncertainty @19 :Float64;
hasSnrInDb @20 :Bool;
snrInDb @21 :Float64;
multipathIndicator @22 :MultipathIndicator;
enum Constellation @0x9ef1f3ff0deb5ffb {
unknown @0;
gps @1;
sbas @2;
glonass @3;
qzss @4;
beidou @5;
galileo @6;
}
enum State @0xcbb9490adce12d72 {
unknown @0;
codeLock @1;
bitSync @2;
subframeSync @3;
towDecoded @4;
msecAmbiguous @5;
symbolSync @6;
gloStringSync @7;
gloTodDecoded @8;
bdsD2BitSync @9;
bdsD2SubframeSync @10;
galE1bcCodeLock @11;
galE1c2ndCodeLock @12;
galE1bPageSync @13;
sbasSync @14;
}
enum MultipathIndicator @0xc04e7b6231d4caa8 {
unknown @0;
detected @1;
notDetected @2;
}
}
}
struct NavigationMessage @0xe2517b083095fd4e {
type @0 :Int32;
svId @1 :Int32;
messageId @2 :Int32;
submessageId @3 :Int32;
data @4 :Data;
status @5 :Status;
enum Status @0xec1ff7996b35366f {
unknown @0;
parityPassed @1;
parityRebuilt @2;
}
}
}
struct QcomGnss @0xde94674b07ae51c1 {
logTs @0 :UInt64;
union {
measurementReport @1 :MeasurementReport;
clockReport @2 :ClockReport;
drMeasurementReport @3 :DrMeasurementReport;
drSvPoly @4 :DrSvPolyReport;
rawLog @5 :Data;
}
enum MeasurementSource @0xd71a12b6faada7ee {
gps @0;
glonass @1;
beidou @2;
}
enum SVObservationState @0xe81e829a0d6c83e9 {
idle @0;
search @1;
searchVerify @2;
bitEdge @3;
trackVerify @4;
track @5;
restart @6;
dpo @7;
glo10msBe @8;
glo10msAt @9;
}
struct MeasurementStatus @0xe501010e1bcae83b {
subMillisecondIsValid @0 :Bool;
subBitTimeIsKnown @1 :Bool;
satelliteTimeIsKnown @2 :Bool;
bitEdgeConfirmedFromSignal @3 :Bool;
measuredVelocity @4 :Bool;
fineOrCoarseVelocity @5 :Bool;
lockPointValid @6 :Bool;
lockPointPositive @7 :Bool;
lastUpdateFromDifference @8 :Bool;
lastUpdateFromVelocityDifference @9 :Bool;
strongIndicationOfCrossCorelation @10 :Bool;
tentativeMeasurement @11 :Bool;
measurementNotUsable @12 :Bool;
sirCheckIsNeeded @13 :Bool;
probationMode @14 :Bool;
glonassMeanderBitEdgeValid @15 :Bool;
glonassTimeMarkValid @16 :Bool;
gpsRoundRobinRxDiversity @17 :Bool;
gpsRxDiversity @18 :Bool;
gpsLowBandwidthRxDiversityCombined @19 :Bool;
gpsHighBandwidthNu4 @20 :Bool;
gpsHighBandwidthNu8 @21 :Bool;
gpsHighBandwidthUniform @22 :Bool;
multipathIndicator @23 :Bool;
imdJammingIndicator @24 :Bool;
lteB13TxJammingIndicator @25 :Bool;
freshMeasurementIndicator @26 :Bool;
multipathEstimateIsValid @27 :Bool;
directionIsValid @28 :Bool;
}
struct MeasurementReport @0xf580d7d86b7b8692 {
source @0 :MeasurementSource;
fCount @1 :UInt32;
gpsWeek @2 :UInt16;
glonassCycleNumber @3 :UInt8;
glonassNumberOfDays @4 :UInt16;
milliseconds @5 :UInt32;
timeBias @6 :Float32;
clockTimeUncertainty @7 :Float32;
clockFrequencyBias @8 :Float32;
clockFrequencyUncertainty @9 :Float32;
sv @10 :List(SV);
struct SV @0xf10c595ae7bb2c27 {
svId @0 :UInt8;
observationState @2 :SVObservationState;
observations @3 :UInt8;
goodObservations @4 :UInt8;
gpsParityErrorCount @5 :UInt16;
glonassFrequencyIndex @1 :Int8;
glonassHemmingErrorCount @6 :UInt8;
filterStages @7 :UInt8;
carrierNoise @8 :UInt16;
latency @9 :Int16;
predetectInterval @10 :UInt8;
postdetections @11 :UInt16;
unfilteredMeasurementIntegral @12 :UInt32;
unfilteredMeasurementFraction @13 :Float32;
unfilteredTimeUncertainty @14 :Float32;
unfilteredSpeed @15 :Float32;
unfilteredSpeedUncertainty @16 :Float32;
measurementStatus @17 :MeasurementStatus;
multipathEstimate @18 :UInt32;
azimuth @19 :Float32;
elevation @20 :Float32;
carrierPhaseCyclesIntegral @21 :Int32;
carrierPhaseCyclesFraction @22 :UInt16;
fineSpeed @23 :Float32;
fineSpeedUncertainty @24 :Float32;
cycleSlipCount @25 :UInt8;
}
}
struct ClockReport @0xca965e4add8f4f0b {
hasFCount @0 :Bool;
fCount @1 :UInt32;
hasGpsWeek @2 :Bool;
gpsWeek @3 :UInt16;
hasGpsMilliseconds @4 :Bool;
gpsMilliseconds @5 :UInt32;
gpsTimeBias @6 :Float32;
gpsClockTimeUncertainty @7 :Float32;
gpsClockSource @8 :UInt8;
hasGlonassYear @9 :Bool;
glonassYear @10 :UInt8;
hasGlonassDay @11 :Bool;
glonassDay @12 :UInt16;
hasGlonassMilliseconds @13 :Bool;
glonassMilliseconds @14 :UInt32;
glonassTimeBias @15 :Float32;
glonassClockTimeUncertainty @16 :Float32;
glonassClockSource @17 :UInt8;
bdsWeek @18 :UInt16;
bdsMilliseconds @19 :UInt32;
bdsTimeBias @20 :Float32;
bdsClockTimeUncertainty @21 :Float32;
bdsClockSource @22 :UInt8;
galWeek @23 :UInt16;
galMilliseconds @24 :UInt32;
galTimeBias @25 :Float32;
galClockTimeUncertainty @26 :Float32;
galClockSource @27 :UInt8;
clockFrequencyBias @28 :Float32;
clockFrequencyUncertainty @29 :Float32;
frequencySource @30 :UInt8;
gpsLeapSeconds @31 :UInt8;
gpsLeapSecondsUncertainty @32 :UInt8;
gpsLeapSecondsSource @33 :UInt8;
gpsToGlonassTimeBiasMilliseconds @34 :Float32;
gpsToGlonassTimeBiasMillisecondsUncertainty @35 :Float32;
gpsToBdsTimeBiasMilliseconds @36 :Float32;
gpsToBdsTimeBiasMillisecondsUncertainty @37 :Float32;
bdsToGloTimeBiasMilliseconds @38 :Float32;
bdsToGloTimeBiasMillisecondsUncertainty @39 :Float32;
gpsToGalTimeBiasMilliseconds @40 :Float32;
gpsToGalTimeBiasMillisecondsUncertainty @41 :Float32;
galToGloTimeBiasMilliseconds @42 :Float32;
galToGloTimeBiasMillisecondsUncertainty @43 :Float32;
galToBdsTimeBiasMilliseconds @44 :Float32;
galToBdsTimeBiasMillisecondsUncertainty @45 :Float32;
hasRtcTime @46 :Bool;
systemRtcTime @47 :UInt32;
fCountOffset @48 :UInt32;
lpmRtcCount @49 :UInt32;
clockResets @50 :UInt32;
}
struct DrMeasurementReport @0x8053c39445c6c75c {
reason @0 :UInt8;
seqNum @1 :UInt8;
seqMax @2 :UInt8;
rfLoss @3 :UInt16;
systemRtcValid @4 :Bool;
fCount @5 :UInt32;
clockResets @6 :UInt32;
systemRtcTime @7 :UInt64;
gpsLeapSeconds @8 :UInt8;
gpsLeapSecondsUncertainty @9 :UInt8;
gpsToGlonassTimeBiasMilliseconds @10 :Float32;
gpsToGlonassTimeBiasMillisecondsUncertainty @11 :Float32;
gpsWeek @12 :UInt16;
gpsMilliseconds @13 :UInt32;
gpsTimeBiasMs @14 :UInt32;
gpsClockTimeUncertaintyMs @15 :UInt32;
gpsClockSource @16 :UInt8;
glonassClockSource @17 :UInt8;
glonassYear @18 :UInt8;
glonassDay @19 :UInt16;
glonassMilliseconds @20 :UInt32;
glonassTimeBias @21 :Float32;
glonassClockTimeUncertainty @22 :Float32;
clockFrequencyBias @23 :Float32;
clockFrequencyUncertainty @24 :Float32;
frequencySource @25 :UInt8;
source @26 :MeasurementSource;
sv @27 :List(SV);
struct SV @0xf08b81df8cbf459c {
svId @0 :UInt8;
glonassFrequencyIndex @1 :Int8;
observationState @2 :SVObservationState;
observations @3 :UInt8;
goodObservations @4 :UInt8;
filterStages @5 :UInt8;
predetectInterval @6 :UInt8;
cycleSlipCount @7 :UInt8;
postdetections @8 :UInt16;
measurementStatus @9 :MeasurementStatus;
carrierNoise @10 :UInt16;
rfLoss @11 :UInt16;
latency @12 :Int16;
filteredMeasurementFraction @13 :Float32;
filteredMeasurementIntegral @14 :UInt32;
filteredTimeUncertainty @15 :Float32;
filteredSpeed @16 :Float32;
filteredSpeedUncertainty @17 :Float32;
unfilteredMeasurementFraction @18 :Float32;
unfilteredMeasurementIntegral @19 :UInt32;
unfilteredTimeUncertainty @20 :Float32;
unfilteredSpeed @21 :Float32;
unfilteredSpeedUncertainty @22 :Float32;
multipathEstimate @23 :UInt32;
azimuth @24 :Float32;
elevation @25 :Float32;
dopplerAcceleration @26 :Float32;
fineSpeed @27 :Float32;
fineSpeedUncertainty @28 :Float32;
carrierPhase @29 :Float64;
fCount @30 :UInt32;
parityErrorCount @31 :UInt16;
goodParity @32 :Bool;
}
}
struct DrSvPolyReport @0xb1fb80811a673270 {
svId @0 :UInt16;
frequencyIndex @1 :Int8;
hasPosition @2 :Bool;
hasIono @3 :Bool;
hasTropo @4 :Bool;
hasElevation @5 :Bool;
polyFromXtra @6 :Bool;
hasSbasIono @7 :Bool;
iode @8 :UInt16;
t0 @9 :Float64;
xyz0 @10 :List(Float64);
xyzN @11 :List(Float64);
other @12 :List(Float32);
positionUncertainty @13 :Float32;
ionoDelay @14 :Float32;
ionoDot @15 :Float32;
sbasIonoDelay @16 :Float32;
sbasIonoDot @17 :Float32;
tropoDelay @18 :Float32;
elevation @19 :Float32;
elevationDot @20 :Float32;
elevationUncertainty @21 :Float32;
velocityCoeff @22 :List(Float64);
}
}
struct LidarPts @0xe3d6685d4e9d8f7a {
r @0 :List(UInt16); # uint16 m*500.0
theta @1 :List(UInt16); # uint16 deg*100.0
reflect @2 :List(UInt8); # uint8 0-255
# For storing out of file.
idx @3 :UInt64;
# For storing in file
pkt @4 :Data;
}
+296 -1065
View File
File diff suppressed because it is too large Load Diff
+22 -6
View File
@@ -5,9 +5,10 @@
#include <csignal> #include <csignal>
#include <cerrno> #include <cerrno>
#include "services.h"
#include "impl_msgq.hpp" #include "impl_msgq.hpp"
volatile sig_atomic_t msgq_do_exit = 0; volatile sig_atomic_t msgq_do_exit = 0;
void sig_handler(int signal) { void sig_handler(int signal) {
@@ -15,14 +16,21 @@ void sig_handler(int signal) {
msgq_do_exit = 1; msgq_do_exit = 1;
} }
static bool service_exists(std::string path){
for (const auto& it : services) {
if (it.name == path) {
return true;
}
}
return false;
}
static size_t get_size(std::string endpoint){ static size_t get_size(std::string endpoint){
size_t sz = DEFAULT_SEGMENT_SIZE; size_t sz = DEFAULT_SEGMENT_SIZE;
#if !defined(QCOM) && !defined(QCOM2) if (endpoint == "roadCameraState" || endpoint == "driverCameraState" || endpoint == "wideRoadCameraState"){
if (endpoint == "frame" || endpoint == "frontFrame" || endpoint == "wideFrame"){
sz *= 10; sz *= 10;
} }
#endif
return sz; return sz;
} }
@@ -61,10 +69,14 @@ MSGQMessage::~MSGQMessage() {
this->close(); this->close();
} }
int MSGQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate){ int MSGQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){
assert(context); assert(context);
assert(address == "127.0.0.1"); assert(address == "127.0.0.1");
if (check_endpoint && !service_exists(std::string(endpoint))){
std::cout << "Warning, " << std::string(endpoint) << " is not in service list." << std::endl;
}
q = new msgq_queue_t; q = new msgq_queue_t;
int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint)); int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint));
if (r != 0){ if (r != 0){
@@ -150,9 +162,13 @@ MSGQSubSocket::~MSGQSubSocket(){
} }
} }
int MSGQPubSocket::connect(Context *context, std::string endpoint){ int MSGQPubSocket::connect(Context *context, std::string endpoint, bool check_endpoint){
assert(context); assert(context);
if (check_endpoint && !service_exists(std::string(endpoint))){
std::cout << "Warning, " << std::string(endpoint) << " is not in service list." << std::endl;
}
q = new msgq_queue_t; q = new msgq_queue_t;
int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint)); int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint));
if (r != 0){ if (r != 0){
+2 -2
View File
@@ -34,7 +34,7 @@ private:
msgq_queue_t * q = NULL; msgq_queue_t * q = NULL;
int timeout; int timeout;
public: public:
int connect(Context *context, std::string endpoint, std::string address, bool conflate=false); int connect(Context *context, std::string endpoint, std::string address, bool conflate=false, bool check_endpoint=true);
void setTimeout(int timeout); void setTimeout(int timeout);
void * getRawSocket() {return (void*)q;} void * getRawSocket() {return (void*)q;}
Message *receive(bool non_blocking=false); Message *receive(bool non_blocking=false);
@@ -45,7 +45,7 @@ class MSGQPubSocket : public PubSocket {
private: private:
msgq_queue_t * q = NULL; msgq_queue_t * q = NULL;
public: public:
int connect(Context *context, std::string endpoint); int connect(Context *context, std::string endpoint, bool check_endpoint=true);
int sendMessage(Message *message); int sendMessage(Message *message);
int send(char *data, size_t size); int send(char *data, size_t size);
~MSGQPubSocket(); ~MSGQPubSocket();
+12 -4
View File
@@ -54,7 +54,7 @@ ZMQMessage::~ZMQMessage() {
} }
int ZMQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate){ int ZMQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){
sock = zmq_socket(context->getRawContext(), ZMQ_SUB); sock = zmq_socket(context->getRawContext(), ZMQ_SUB);
if (sock == NULL){ if (sock == NULL){
return -1; return -1;
@@ -71,7 +71,11 @@ int ZMQSubSocket::connect(Context *context, std::string endpoint, std::string ad
zmq_setsockopt(sock, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl, sizeof(reconnect_ivl)); zmq_setsockopt(sock, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl, sizeof(reconnect_ivl));
full_endpoint = "tcp://" + address + ":"; full_endpoint = "tcp://" + address + ":";
full_endpoint += std::to_string(get_port(endpoint)); if (check_endpoint){
full_endpoint += std::to_string(get_port(endpoint));
} else {
full_endpoint += endpoint;
}
return zmq_connect(sock, full_endpoint.c_str()); return zmq_connect(sock, full_endpoint.c_str());
} }
@@ -103,14 +107,18 @@ ZMQSubSocket::~ZMQSubSocket(){
zmq_close(sock); zmq_close(sock);
} }
int ZMQPubSocket::connect(Context *context, std::string endpoint){ int ZMQPubSocket::connect(Context *context, std::string endpoint, bool check_endpoint){
sock = zmq_socket(context->getRawContext(), ZMQ_PUB); sock = zmq_socket(context->getRawContext(), ZMQ_PUB);
if (sock == NULL){ if (sock == NULL){
return -1; return -1;
} }
full_endpoint = "tcp://*:"; full_endpoint = "tcp://*:";
full_endpoint += std::to_string(get_port(endpoint)); if (check_endpoint){
full_endpoint += std::to_string(get_port(endpoint));
} else {
full_endpoint += endpoint;
}
return zmq_bind(sock, full_endpoint.c_str()); return zmq_bind(sock, full_endpoint.c_str());
} }
+2 -2
View File
@@ -32,7 +32,7 @@ private:
void * sock; void * sock;
std::string full_endpoint; std::string full_endpoint;
public: public:
int connect(Context *context, std::string endpoint, std::string address, bool conflate=false); int connect(Context *context, std::string endpoint, std::string address, bool conflate=false, bool check_endpoint=true);
void setTimeout(int timeout); void setTimeout(int timeout);
void * getRawSocket() {return sock;} void * getRawSocket() {return sock;}
Message *receive(bool non_blocking=false); Message *receive(bool non_blocking=false);
@@ -44,7 +44,7 @@ private:
void * sock; void * sock;
std::string full_endpoint; std::string full_endpoint;
public: public:
int connect(Context *context, std::string endpoint); int connect(Context *context, std::string endpoint, bool check_endpoint=true);
int sendMessage(Message *message); int sendMessage(Message *message);
int send(char *data, size_t size); int send(char *data, size_t size);
~ZMQPubSocket(); ~ZMQPubSocket();
+12 -32
View File
@@ -8,9 +8,13 @@ const bool MUST_USE_ZMQ = true;
const bool MUST_USE_ZMQ = false; const bool MUST_USE_ZMQ = false;
#endif #endif
bool messaging_use_zmq(){
return std::getenv("ZMQ") || MUST_USE_ZMQ;
}
Context * Context::create(){ Context * Context::create(){
Context * c; Context * c;
if (std::getenv("ZMQ") || MUST_USE_ZMQ){ if (messaging_use_zmq()){
c = new ZMQContext(); c = new ZMQContext();
} else { } else {
c = new MSGQContext(); c = new MSGQContext();
@@ -20,7 +24,7 @@ Context * Context::create(){
SubSocket * SubSocket::create(){ SubSocket * SubSocket::create(){
SubSocket * s; SubSocket * s;
if (std::getenv("ZMQ") || MUST_USE_ZMQ){ if (messaging_use_zmq()){
s = new ZMQSubSocket(); s = new ZMQSubSocket();
} else { } else {
s = new MSGQSubSocket(); s = new MSGQSubSocket();
@@ -28,33 +32,9 @@ SubSocket * SubSocket::create(){
return s; return s;
} }
SubSocket * SubSocket::create(Context * context, std::string endpoint){ SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){
SubSocket *s = SubSocket::create(); SubSocket *s = SubSocket::create();
int r = s->connect(context, endpoint, "127.0.0.1"); int r = s->connect(context, endpoint, address, conflate, check_endpoint);
if (r == 0) {
return s;
} else {
delete s;
return NULL;
}
}
SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address){
SubSocket *s = SubSocket::create();
int r = s->connect(context, endpoint, address);
if (r == 0) {
return s;
} else {
delete s;
return NULL;
}
}
SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address, bool conflate){
SubSocket *s = SubSocket::create();
int r = s->connect(context, endpoint, address, conflate);
if (r == 0) { if (r == 0) {
return s; return s;
@@ -66,7 +46,7 @@ SubSocket * SubSocket::create(Context * context, std::string endpoint, std::stri
PubSocket * PubSocket::create(){ PubSocket * PubSocket::create(){
PubSocket * s; PubSocket * s;
if (std::getenv("ZMQ") || MUST_USE_ZMQ){ if (messaging_use_zmq()){
s = new ZMQPubSocket(); s = new ZMQPubSocket();
} else { } else {
s = new MSGQPubSocket(); s = new MSGQPubSocket();
@@ -74,9 +54,9 @@ PubSocket * PubSocket::create(){
return s; return s;
} }
PubSocket * PubSocket::create(Context * context, std::string endpoint){ PubSocket * PubSocket::create(Context * context, std::string endpoint, bool check_endpoint){
PubSocket *s = PubSocket::create(); PubSocket *s = PubSocket::create();
int r = s->connect(context, endpoint); int r = s->connect(context, endpoint, check_endpoint);
if (r == 0) { if (r == 0) {
return s; return s;
@@ -88,7 +68,7 @@ PubSocket * PubSocket::create(Context * context, std::string endpoint){
Poller * Poller::create(){ Poller * Poller::create(){
Poller * p; Poller * p;
if (std::getenv("ZMQ") || MUST_USE_ZMQ){ if (messaging_use_zmq()){
p = new ZMQPoller(); p = new ZMQPoller();
} else { } else {
p = new MSGQPoller(); p = new MSGQPoller();
+7 -6
View File
@@ -12,6 +12,8 @@
#define MSG_MULTIPLE_PUBLISHERS 100 #define MSG_MULTIPLE_PUBLISHERS 100
bool messaging_use_zmq();
class Context { class Context {
public: public:
virtual void * getRawContext() = 0; virtual void * getRawContext() = 0;
@@ -32,24 +34,23 @@ public:
class SubSocket { class SubSocket {
public: public:
virtual int connect(Context *context, std::string endpoint, std::string address, bool conflate=false) = 0; virtual int connect(Context *context, std::string endpoint, std::string address, bool conflate=false, bool check_endpoint=true) = 0;
virtual void setTimeout(int timeout) = 0; virtual void setTimeout(int timeout) = 0;
virtual Message *receive(bool non_blocking=false) = 0; virtual Message *receive(bool non_blocking=false) = 0;
virtual void * getRawSocket() = 0; virtual void * getRawSocket() = 0;
static SubSocket * create(); static SubSocket * create();
static SubSocket * create(Context * context, std::string endpoint); static SubSocket * create(Context * context, std::string endpoint, std::string address="127.0.0.1", bool conflate=false, bool check_endpoint=true);
static SubSocket * create(Context * context, std::string endpoint, std::string address);
static SubSocket * create(Context * context, std::string endpoint, std::string address, bool conflate);
virtual ~SubSocket(){}; virtual ~SubSocket(){};
}; };
class PubSocket { class PubSocket {
public: public:
virtual int connect(Context *context, std::string endpoint) = 0; virtual int connect(Context *context, std::string endpoint, bool check_endpoint=true) = 0;
virtual int sendMessage(Message *message) = 0; virtual int sendMessage(Message *message) = 0;
virtual int send(char *data, size_t size) = 0; virtual int send(char *data, size_t size) = 0;
static PubSocket * create(); static PubSocket * create();
static PubSocket * create(Context * context, std::string endpoint); static PubSocket * create(Context * context, std::string endpoint, bool check_endpoint=true);
static PubSocket * create(Context * context, std::string endpoint, int port, bool check_endpoint=true);
virtual ~PubSocket(){}; virtual ~PubSocket(){};
}; };
+9 -9
View File
@@ -7,11 +7,11 @@ from libcpp cimport bool
from libc cimport errno from libc cimport errno
from messaging cimport Context as cppContext from .messaging cimport Context as cppContext
from messaging cimport SubSocket as cppSubSocket from .messaging cimport SubSocket as cppSubSocket
from messaging cimport PubSocket as cppPubSocket from .messaging cimport PubSocket as cppPubSocket
from messaging cimport Poller as cppPoller from .messaging cimport Poller as cppPoller
from messaging cimport Message as cppMessage from .messaging cimport Message as cppMessage
class MessagingError(Exception): class MessagingError(Exception):
@@ -59,12 +59,12 @@ cdef class Poller:
cdef int t = timeout cdef int t = timeout
with nogil: with nogil:
result = self.poller.poll(t) result = self.poller.poll(t)
for s in result: for s in result:
socket = SubSocket() socket = SubSocket()
socket.setPtr(s) socket.setPtr(s)
sockets.append(socket) sockets.append(socket)
return sockets return sockets
-58
View File
@@ -1,58 +0,0 @@
import os
import subprocess
import sysconfig
from distutils.core import Extension, setup # pylint: disable=import-error,no-name-in-module
from Cython.Build import cythonize
from Cython.Distutils import build_ext
TICI = os.path.isfile('/TICI')
def get_ext_filename_without_platform_suffix(filename):
name, ext = os.path.splitext(filename)
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
if ext_suffix == ext:
return filename
ext_suffix = ext_suffix.replace(ext, '')
idx = name.find(ext_suffix)
if idx == -1:
return filename
else:
return name[:idx] + ext
class BuildExtWithoutPlatformSuffix(build_ext):
def get_ext_filename(self, ext_name):
filename = super().get_ext_filename(ext_name)
return get_ext_filename_without_platform_suffix(filename)
sourcefiles = ['messaging_pyx.pyx']
extra_compile_args = ["-std=c++1z", "-Wno-nullability-completeness"]
libraries = ['zmq']
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg
if ARCH == "aarch64" and not TICI:
# android
extra_compile_args += ["-Wno-deprecated-register"]
libraries += ['gnustl_shared']
setup(name='messaging',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(
Extension(
"messaging_pyx",
language="c++",
sources=sourcefiles,
extra_compile_args=extra_compile_args,
libraries=libraries,
extra_objects=[
os.path.join(os.path.dirname(os.path.realpath(__file__)), '../', 'libmessaging.a'),
]
),
nthreads=4,
),
)
-13
View File
@@ -21,8 +21,6 @@
#include <stdio.h> #include <stdio.h>
#include "services.h"
#include "msgq.hpp" #include "msgq.hpp"
void sigusr2_handler(int signal) { void sigusr2_handler(int signal) {
@@ -83,20 +81,9 @@ void msgq_wait_for_subscriber(msgq_queue_t *q){
return; return;
} }
bool service_exists(std::string path){
for (const auto& it : services) {
if (it.name == path) {
return true;
}
}
return false;
}
int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){ int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){
assert(size < 0xFFFFFFFF); // Buffer must be smaller than 2^32 bytes assert(size < 0xFFFFFFFF); // Buffer must be smaller than 2^32 bytes
if (!service_exists(std::string(path))){
std::cout << "Warning, " << std::string(path) << " is not in service list." << std::endl;
}
std::signal(SIGUSR2, sigusr2_handler); std::signal(SIGUSR2, sigusr2_handler);
const char * prefix = "/dev/shm/"; const char * prefix = "/dev/shm/";
-180
View File
@@ -1,180 +0,0 @@
# TODO: these port numbers are hardcoded in c, fix this
# LogRotate: 8001 is a PUSH PULL socket between loggerd and visiond
# all ZMQ pub sub: port, should_log, frequency, (qlog_decimation)
# frame syncing packet
frame: [8002, true, 20., 1]
# accel, gyro, and compass
sensorEvents: [8003, true, 100., 100]
# GPS data, also global timestamp
gpsNMEA: [8004, true, 9.] # 9 msgs each sec
# CPU+MEM+GPU+BAT temps
thermal: [8005, true, 2., 1]
# List(CanData), list of can messages
can: [8006, true, 100.]
controlsState: [8007, true, 100., 100]
#liveEvent: [8008, true, 0.]
model: [8009, true, 20., 5]
features: [8010, true, 0.]
health: [8011, true, 2., 1]
radarState: [8012, true, 20., 5]
#liveUI: [8014, true, 0.]
encodeIdx: [8015, true, 20.]
liveTracks: [8016, true, 20.]
sendcan: [8017, true, 100.]
logMessage: [8018, true, 0.]
liveCalibration: [8019, true, 4., 4]
androidLog: [8020, true, 0.]
carState: [8021, true, 100., 10]
# 8022 is reserved for sshd
carControl: [8023, true, 100., 10]
plan: [8024, true, 20., 2]
liveLocation: [8025, true, 0., 1]
gpsLocation: [8026, true, 1., 1]
ethernetData: [8027, true, 0.]
navUpdate: [8028, true, 0.]
qcomGnss: [8029, true, 0.]
lidarPts: [8030, true, 0.]
procLog: [8031, true, 0.5]
gpsLocationExternal: [8032, true, 10., 1]
ubloxGnss: [8033, true, 10.]
clocks: [8034, true, 1., 1]
liveMpc: [8035, false, 20.]
liveLongitudinalMpc: [8036, false, 20.]
navStatus: [8038, true, 0.]
gpsLocationTrimble: [8039, true, 0.]
trimbleGnss: [8041, true, 0.]
ubloxRaw: [8042, true, 20.]
gpsPlannerPoints: [8043, true, 0.]
gpsPlannerPlan: [8044, true, 0.]
applanixRaw: [8046, true, 0.]
orbLocation: [8047, true, 0.]
trafficEvents: [8048, true, 0.]
liveLocationTiming: [8049, true, 0.]
orbslamCorrection: [8050, true, 0.]
liveLocationCorrected: [8051, true, 0.]
orbObservation: [8052, true, 0.]
applanixLocation: [8053, true, 0.]
liveLocationKalman: [8054, true, 20., 2]
uiNavigationEvent: [8055, true, 0.]
orbOdometry: [8057, true, 0.]
orbFeatures: [8058, false, 0.]
orbKeyFrame: [8059, true, 0.]
uiLayoutState: [8060, true, 0.]
frontEncodeIdx: [8061, true, 5.] # should be 20fps on tici
orbFeaturesSummary: [8062, true, 0.]
driverState: [8063, true, 5., 1]
liveParameters: [8064, true, 20., 2]
liveMapData: [8065, true, 0.]
cameraOdometry: [8066, true, 20., 5]
pathPlan: [8067, true, 20., 2]
kalmanOdometry: [8068, true, 0.]
thumbnail: [8069, true, 0.2, 1]
carEvents: [8070, true, 1., 1]
carParams: [8071, true, 0.02, 1]
frontFrame: [8072, true, 10.]
dMonitoringState: [8073, true, 5., 1]
offroadLayout: [8074, false, 0.]
wideEncodeIdx: [8075, true, 20.]
wideFrame: [8076, true, 20.]
modelV2: [8077, true, 20., 20]
testModel: [8040, false, 0.]
testLiveLocation: [8045, false, 0.]
testJoystick: [8056, false, 0.]
# 8080 is reserved for slave testing daemon
# 8762 is reserved for logserver
# manager -- base process to manage starting and stopping of all others
# subscribes: thermal
# **** processes that communicate with the outside world ****
# thermald -- decides when to start and stop onroad
# subscribes: health, location
# publishes: thermal
# boardd -- communicates with the car
# subscribes: sendcan
# publishes: can, health, ubloxRaw
# sensord -- publishes IMU and Magnetometer
# publishes: sensorEvents
# gpsd -- publishes EON's gps
# publishes: gpsNMEA
# camerad -- publishes camera frames
# publishes: frame, frontFrame, thumbnail
# subscribes: driverState
# dmonitoringmodeld -- runs face detection on camera frames
# publishes: driverState
# **** stateful data transformers ****
# modeld -- runs & publishes the model
# publishes: model, cameraOdometry
# subscribes: liveCalibration, pathPlan
# plannerd -- decides where to drive the car
# subscribes: carState, model, radarState, controlsState, liveParameters
# publishes: plan, pathPlan, liveMpc, liveLongitudinalMpc
# controlsd -- drives the car by sending CAN messages to panda
# subscribes: can, thermal, health, plan, pathPlan, dMonitoringState, liveCalibration, model
# publishes: carState, carControl, sendcan, controlsState, carEvents, carParams
# dmonitoringd -- processes driver monitoring data and publishes driver awareness
# subscribes: driverState, liveCalibration, carState, model, gpsLocation
# publishes: dMonitoringState
# radard -- processes the radar and vision data
# subscribes: can, controlsState, model, liveParameters
# publishes: radarState, liveTracks
# params_learner -- learns vehicle params by observing the vehicle dynamics
# subscribes: controlsState, sensorEvents, cameraOdometry
# publishes: liveParameters
# calibrationd -- reads posenet and applies a temporal filter on the frame region to look at
# subscribes: cameraOdometry
# publishes: liveCalibration
# ubloxd -- read raw ublox data and converts them in readable format
# subscribes: ubloxRaw
# publishes: ubloxGnss
# **** LOGGING SERVICE ****
# loggerd
# subscribes: EVERYTHING
# **** NON VITAL SERVICES ****
# ui
# subscribes: thermal, model, controlsState, uiLayout, liveCalibration, radarState, liveMpc, plusFrame, liveMapData
# uploader
# communicates through file system with loggerd
# deleter
# communicates through file system with loggerd and uploader
# logmessaged -- central logging service, can log to cloud
# publishes: logMessage
# logcatd -- fetches logcat info from android
# publishes: androidLog
# proclogd -- fetches process information
# publishes: procLog
# tombstoned -- reports native crashes
# athenad -- on request, open a sub socket and return the value
# updated -- waits for network access and tries to update every hour
+70 -20
View File
@@ -1,34 +1,84 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import yaml from typing import Optional
EON = os.path.isfile('/EON')
class Service(): class Service:
def __init__(self, port, should_log, frequency, decimation=None): def __init__(self, port: int, should_log: bool, frequency: float, decimation: Optional[int] = None):
self.port = port self.port = port
self.should_log = should_log self.should_log = should_log
self.frequency = frequency self.frequency = frequency
self.decimation = decimation self.decimation = decimation
service_list = {
"roadCameraState": Service(8002, True, 20., 1),
"sensorEvents": Service(8003, True, 100., 100),
"gpsNMEA": Service(8004, True, 9.),
"deviceState": Service(8005, True, 2., 1),
"can": Service(8006, True, 100.),
"controlsState": Service(8007, True, 100., 100),
"features": Service(8010, True, 0.),
"pandaState": Service(8011, True, 2., 1),
"radarState": Service(8012, True, 20., 5),
"roadEncodeIdx": Service(8015, True, 20., 1),
"liveTracks": Service(8016, True, 20.),
"sendcan": Service(8017, True, 100.),
"logMessage": Service(8018, True, 0.),
"liveCalibration": Service(8019, True, 4., 4),
"androidLog": Service(8020, True, 0., 1),
"carState": Service(8021, True, 100., 10),
"carControl": Service(8023, True, 100., 10),
"longitudinalPlan": Service(8024, True, 20., 2),
"liveLocation": Service(8025, True, 0., 1),
"gpsLocation": Service(8026, True, 1., 1),
"procLog": Service(8031, True, 0.5),
"gpsLocationExternal": Service(8032, True, 10., 1),
"ubloxGnss": Service(8033, True, 10.),
"clocks": Service(8034, True, 1., 1),
"liveMpc": Service(8035, False, 20.),
"liveLongitudinalMpc": Service(8036, False, 20.),
"ubloxRaw": Service(8042, True, 20.),
"liveLocationKalman": Service(8054, True, 20., 2),
"uiLayoutState": Service(8060, True, 0.),
"liveParameters": Service(8064, True, 20., 2),
"cameraOdometry": Service(8066, True, 20., 5),
"lateralPlan": Service(8067, True, 20., 2),
"thumbnail": Service(8069, True, 0.2, 1),
"carEvents": Service(8070, True, 1., 1),
"carParams": Service(8071, True, 0.02, 1),
"driverCameraState": Service(8072, True, 10. if EON else 20., 1),
"driverEncodeIdx": Service(8061, True, 10. if EON else 20., 1),
"driverState": Service(8063, True, 10. if EON else 20., 1),
"driverMonitoringState": Service(8073, True, 10. if EON else 20., 1),
"offroadLayout": Service(8074, False, 0.),
"wideRoadEncodeIdx": Service(8075, True, 20., 1),
"wideRoadCameraState": Service(8076, True, 20., 1),
"modelV2": Service(8077, True, 20., 20),
"managerState": Service(8078, True, 2., 1),
service_list_path = os.path.join(os.path.dirname(__file__), "service_list.yaml") "testModel": Service(8040, False, 0.),
"testLiveLocation": Service(8045, False, 0.),
"testJoystick": Service(8056, False, 0.),
}
service_list = {}
with open(service_list_path, "r") as f:
for k, v in yaml.safe_load(f).items():
decimation = None
if len(v) == 4:
decimation = v[3]
service_list[k] = Service(v[0], v[1], v[2], decimation) def build_header():
h = ""
h += "/* THIS IS AN AUTOGENERATED FILE, PLEASE EDIT services.py */\n"
h += "#ifndef __SERVICES_H\n"
h += "#define __SERVICES_H\n"
h += "struct service { char name[0x100]; int port; bool should_log; int frequency; int decimation; };\n"
h += "static struct service services[] = {\n"
for k, v in service_list.items():
should_log = "true" if v.should_log else "false"
decimation = -1 if v.decimation is None else v.decimation
h += ' { .name = "%s", .port = %d, .should_log = %s, .frequency = %d, .decimation = %d },\n' % \
(k, v.port, should_log, v.frequency, decimation)
h += "};\n"
h += "#endif\n"
return h
if __name__ == "__main__": if __name__ == "__main__":
print("/* THIS IS AN AUTOGENERATED FILE, PLEASE EDIT service_list.yaml */") print(build_header())
print("#ifndef __SERVICES_H")
print("#define __SERVICES_H")
print("struct service { char name[0x100]; int port; bool should_log; int frequency; int decimation; };")
print("static struct service services[] = {")
for k, v in service_list.items():
print(' { .name = "%s", .port = %d, .should_log = %s, .frequency = %d, .decimation = %d },' % (k, v.port, "true" if v.should_log else "false", v.frequency, -1 if v.decimation is None else v.decimation))
print("};")
print("#endif")
+2
View File
@@ -0,0 +1,2 @@
visionipc_pyx.cpp
*.so
View File
@@ -1,6 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
@@ -10,16 +9,19 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#ifdef __APPLE__
#define getsocket() socket(AF_UNIX, SOCK_STREAM, 0)
#else
#define getsocket() socket(AF_UNIX, SOCK_SEQPACKET, 0)
#endif
#include "ipc.h" #include "ipc.h"
int ipc_connect(const char* socket_path) { int ipc_connect(const char* socket_path) {
int err; int err;
#ifdef __APPLE__ int sock = getsocket();
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
#else
int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0);
#endif
if (sock < 0) return -1; if (sock < 0) return -1;
struct sockaddr_un addr = { struct sockaddr_un addr = {
.sun_family = AF_UNIX, .sun_family = AF_UNIX,
@@ -39,11 +41,8 @@ int ipc_bind(const char* socket_path) {
unlink(socket_path); unlink(socket_path);
#ifdef __APPLE__ int sock = getsocket();
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
#else
int sock = socket(AF_UNIX, SOCK_SEQPACKET, 0);
#endif
struct sockaddr_un addr = { struct sockaddr_un addr = {
.sun_family = AF_UNIX, .sun_family = AF_UNIX,
}; };
@@ -87,7 +86,6 @@ int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fd
cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds); cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds);
memcpy(CMSG_DATA(cmsg), fds, sizeof(int) * num_fds); memcpy(CMSG_DATA(cmsg), fds, sizeof(int) * num_fds);
// printf("send clen %d -> %d\n", num_fds, cmsg->cmsg_len);
} }
return sendmsg(fd, &msg, 0); return sendmsg(fd, &msg, 0);
} else { } else {
@@ -102,8 +100,6 @@ int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fd
recv_fds = (cmsg->cmsg_len - CMSG_LEN(0)); recv_fds = (cmsg->cmsg_len - CMSG_LEN(0));
assert(recv_fds > 0 && (recv_fds % sizeof(int)) == 0); assert(recv_fds > 0 && (recv_fds % sizeof(int)) == 0);
recv_fds /= sizeof(int); recv_fds /= sizeof(int);
// printf("recv clen %d -> %d\n", cmsg->cmsg_len, recv_fds);
// assert(cmsg->cmsg_len == CMSG_LEN(sizeof(int) * num_fds));
assert(fds && recv_fds <= num_fds); assert(fds && recv_fds <= num_fds);
memcpy(fds, CMSG_DATA(cmsg), sizeof(int) * recv_fds); memcpy(fds, CMSG_DATA(cmsg), sizeof(int) * recv_fds);
@@ -1,19 +1,7 @@
#ifndef IPC_H #pragma once
#define IPC_H #include <cstddef>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
int ipc_connect(const char* socket_path); int ipc_connect(const char* socket_path);
int ipc_bind(const char* socket_path); int ipc_bind(const char* socket_path);
int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds, int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds,
int *out_num_fds); int *out_num_fds);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
+2
View File
@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
+40
View File
@@ -0,0 +1,40 @@
#include "visionbuf.h"
#define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1))
#ifdef QCOM
// from libadreno_utils.so
extern "C" void compute_aligned_width_and_height(int width,
int height,
int bpp,
int tile_mode,
int raster_mode,
int padding_threshold,
int *aligned_w,
int *aligned_h);
#endif
void visionbuf_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h) {
#if defined(QCOM) && !defined(QCOM_REPLAY)
compute_aligned_width_and_height(ALIGN(width, 32), ALIGN(height, 32), 3, 0, 0, 512, aligned_w, aligned_h);
#else
*aligned_w = width; *aligned_h = height;
#endif
}
void VisionBuf::init_rgb(size_t width, size_t height, size_t stride) {
this->rgb = true;
this->width = width;
this->height = height;
this->stride = stride;
}
void VisionBuf::init_yuv(size_t width, size_t height){
this->rgb = false;
this->width = width;
this->height = height;
this->y = (uint8_t *)this->addr;
this->u = this->y + (width * height);
this->v = this->u + (width / 2 * height / 2);
}
+63
View File
@@ -0,0 +1,63 @@
#pragma once
#include "visionipc.h"
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
#define VISIONBUF_SYNC_FROM_DEVICE 0
#define VISIONBUF_SYNC_TO_DEVICE 1
enum VisionStreamType {
VISION_STREAM_RGB_BACK,
VISION_STREAM_RGB_FRONT,
VISION_STREAM_RGB_WIDE,
VISION_STREAM_YUV_BACK,
VISION_STREAM_YUV_FRONT,
VISION_STREAM_YUV_WIDE,
VISION_STREAM_MAX,
};
class VisionBuf {
public:
size_t len = 0;
size_t mmap_len = 0;
void * addr = nullptr;
int fd = 0;
bool rgb = false;
size_t width = 0;
size_t height = 0;
size_t stride = 0;
// YUV
uint8_t * y = nullptr;
uint8_t * u = nullptr;
uint8_t * v = nullptr;
// Visionipc
uint64_t server_id = 0;
size_t idx = 0;
VisionStreamType type;
// OpenCL
cl_mem buf_cl = nullptr;
cl_command_queue copy_q = nullptr;
// ion
int handle = 0;
bool owner = false;
void allocate(size_t len);
void import();
void init_cl(cl_device_id device_id, cl_context ctx);
void init_rgb(size_t width, size_t height, size_t stride);
void init_yuv(size_t width, size_t height);
void sync(int dir);
void free();
};
void visionbuf_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h);
+86
View File
@@ -0,0 +1,86 @@
#include "visionbuf.h"
#include <atomic>
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
std::atomic<int> offset = 0;
static void *malloc_with_fd(size_t len, int *fd) {
char full_path[0x100];
#ifdef __APPLE__
snprintf(full_path, sizeof(full_path)-1, "/tmp/visionbuf_%d_%d", getpid(), offset++);
#else
snprintf(full_path, sizeof(full_path)-1, "/dev/shm/visionbuf_%d_%d", getpid(), offset++);
#endif
*fd = open(full_path, O_RDWR | O_CREAT, 0777);
assert(*fd >= 0);
unlink(full_path);
ftruncate(*fd, len);
void *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
assert(addr != MAP_FAILED);
return addr;
}
void VisionBuf::allocate(size_t len) {
int fd;
void *addr = malloc_with_fd(len, &fd);
this->len = len;
this->mmap_len = len;
this->addr = addr;
this->fd = fd;
}
void VisionBuf::init_cl(cl_device_id device_id, cl_context ctx){
int err;
this->copy_q = clCreateCommandQueue(ctx, device_id, 0, &err);
assert(err == 0);
this->buf_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, this->len, this->addr, &err);
assert(err == 0);
}
void VisionBuf::import(){
assert(this->fd >= 0);
this->addr = mmap(NULL, this->mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED, this->fd, 0);
assert(this->addr != MAP_FAILED);
}
void VisionBuf::sync(int dir) {
int err = 0;
if (!this->buf_cl) return;
if (dir == VISIONBUF_SYNC_FROM_DEVICE) {
err = clEnqueueReadBuffer(this->copy_q, this->buf_cl, CL_FALSE, 0, this->len, this->addr, 0, NULL, NULL);
} else {
err = clEnqueueWriteBuffer(this->copy_q, this->buf_cl, CL_FALSE, 0, this->len, this->addr, 0, NULL, NULL);
}
assert(err == 0);
clFinish(this->copy_q);
}
void VisionBuf::free() {
if (this->buf_cl){
int err = clReleaseMemObject(this->buf_cl);
assert(err == 0);
clReleaseCommandQueue(this->copy_q);
}
munmap(this->addr, this->len);
close(this->fd);
}
@@ -36,7 +36,7 @@ static void ion_init() {
} }
} }
VisionBuf visionbuf_allocate(size_t len) { void VisionBuf::allocate(size_t len) {
int err; int err;
ion_init(); ion_init();
@@ -62,49 +62,58 @@ VisionBuf visionbuf_allocate(size_t len) {
memset(addr, 0, ion_alloc.len); memset(addr, 0, ion_alloc.len);
return (VisionBuf){ this->owner = true;
.len = len, this->len = len;
.mmap_len = ion_alloc.len, this->mmap_len = ion_alloc.len;
.addr = addr, this->addr = addr;
.handle = ion_alloc.handle, this->handle = ion_alloc.handle;
.fd = ion_fd_data.fd, this->fd = ion_fd_data.fd;
};
} }
VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx) { void VisionBuf::import(){
VisionBuf buf = visionbuf_allocate(len); int err;
int err = 0; assert(this->fd >= 0);
assert(((uintptr_t)buf.addr % DEVICE_PAGE_SIZE_CL) == 0); ion_init();
// Get handle
struct ion_fd_data fd_data = {0};
fd_data.fd = this->fd;
err = ioctl(ion_fd, ION_IOC_IMPORT, &fd_data);
assert(err == 0);
this->owner = false;
this->handle = fd_data.handle;
this->addr = mmap(NULL, this->mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED, this->fd, 0);
assert(this->addr != MAP_FAILED);
}
void VisionBuf::init_cl(cl_device_id device_id, cl_context ctx) {
int err;
assert(((uintptr_t)this->addr % DEVICE_PAGE_SIZE_CL) == 0);
cl_mem_ion_host_ptr ion_cl = {0}; cl_mem_ion_host_ptr ion_cl = {0};
ion_cl.ext_host_ptr.allocation_type = CL_MEM_ION_HOST_PTR_QCOM; ion_cl.ext_host_ptr.allocation_type = CL_MEM_ION_HOST_PTR_QCOM;
ion_cl.ext_host_ptr.host_cache_policy = CL_MEM_HOST_UNCACHED_QCOM; ion_cl.ext_host_ptr.host_cache_policy = CL_MEM_HOST_UNCACHED_QCOM;
ion_cl.ion_filedesc = buf.fd; ion_cl.ion_filedesc = this->fd;
ion_cl.ion_hostptr = buf.addr; ion_cl.ion_hostptr = this->addr;
buf.buf_cl = clCreateBuffer(ctx, this->buf_cl = clCreateBuffer(ctx,
CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM, CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM,
buf.len, &ion_cl, &err); this->len, &ion_cl, &err);
assert(err == 0); assert(err == 0);
return buf;
} }
void visionbuf_sync(const VisionBuf* buf, int dir) { void VisionBuf::sync(int dir) {
int err; int err;
struct ion_fd_data fd_data = {0};
fd_data.fd = buf->fd;
err = ioctl(ion_fd, ION_IOC_IMPORT, &fd_data);
assert(err == 0);
struct ion_flush_data flush_data = {0}; struct ion_flush_data flush_data = {0};
flush_data.handle = fd_data.handle; flush_data.handle = this->handle;
flush_data.vaddr = buf->addr; flush_data.vaddr = this->addr;
flush_data.offset = 0; flush_data.offset = 0;
flush_data.length = buf->len; flush_data.length = this->len;
// ION_IOC_INV_CACHES ~= DMA_FROM_DEVICE // ION_IOC_INV_CACHES ~= DMA_FROM_DEVICE
// ION_IOC_CLEAN_CACHES ~= DMA_TO_DEVICE // ION_IOC_CLEAN_CACHES ~= DMA_TO_DEVICE
@@ -112,34 +121,28 @@ void visionbuf_sync(const VisionBuf* buf, int dir) {
struct ion_custom_data custom_data = {0}; struct ion_custom_data custom_data = {0};
switch (dir) { assert(dir == VISIONBUF_SYNC_FROM_DEVICE || dir == VISIONBUF_SYNC_TO_DEVICE);
case VISIONBUF_SYNC_FROM_DEVICE: custom_data.cmd = (dir == VISIONBUF_SYNC_FROM_DEVICE) ?
custom_data.cmd = ION_IOC_INV_CACHES; ION_IOC_INV_CACHES : ION_IOC_CLEAN_CACHES;
break;
case VISIONBUF_SYNC_TO_DEVICE:
custom_data.cmd = ION_IOC_CLEAN_CACHES;
break;
default:
assert(0);
}
custom_data.arg = (unsigned long)&flush_data; custom_data.arg = (unsigned long)&flush_data;
err = ioctl(ion_fd, ION_IOC_CUSTOM, &custom_data); err = ioctl(ion_fd, ION_IOC_CUSTOM, &custom_data);
assert(err == 0); assert(err == 0);
struct ion_handle_data handle_data = {0};
handle_data.handle = fd_data.handle;
err = ioctl(ion_fd, ION_IOC_FREE, &handle_data);
assert(err == 0);
} }
void visionbuf_free(const VisionBuf* buf) { void VisionBuf::free() {
clReleaseMemObject(buf->buf_cl); if (this->buf_cl){
munmap(buf->addr, buf->mmap_len); int err = clReleaseMemObject(this->buf_cl);
close(buf->fd); assert(err == 0);
struct ion_handle_data handle_data = { }
.handle = buf->handle,
}; munmap(this->addr, this->mmap_len);
int ret = ioctl(ion_fd, ION_IOC_FREE, &handle_data); close(this->fd);
assert(ret == 0);
// Free the ION buffer if we also shared it
if (this->owner){
struct ion_handle_data handle_data = {.handle = this->handle};
int ret = ioctl(ion_fd, ION_IOC_FREE, &handle_data);
assert(ret == 0);
}
} }
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include <cstdint>
#include <cstddef>
constexpr int VISIONIPC_MAX_FDS = 64;
struct VisionIpcBufExtra {
uint32_t frame_id;
uint64_t timestamp_sof;
uint64_t timestamp_eof;
};
struct VisionIpcPacket {
uint64_t server_id;
size_t idx;
struct VisionIpcBufExtra extra;
};
+29
View File
@@ -0,0 +1,29 @@
# distutils: language = c++
#cython: language_level=3
from libcpp.string cimport string
from libcpp.vector cimport vector
from libc.stdint cimport uint32_t, uint64_t
from libcpp cimport bool
cdef extern from "visionbuf.h":
cdef enum VisionStreamType:
pass
cdef cppclass VisionBuf:
void * addr
size_t len
cdef extern from "visionipc.h":
struct VisionIpcBufExtra:
uint32_t frame_id
uint64_t timestamp_sof
uint64_t timestamp_eof
cdef extern from "visionipc_server.h":
cdef cppclass VisionIpcServer:
VisionIpcServer(string, void*, void*)
void create_buffers(VisionStreamType, size_t, bool, size_t, size_t)
VisionBuf * get_buffer(VisionStreamType)
void send(VisionBuf *, VisionIpcBufExtra *, bool)
void start_listener()
+119
View File
@@ -0,0 +1,119 @@
#include <chrono>
#include <cassert>
#include <iostream>
#include <thread>
#include "ipc.h"
#include "visionipc_client.h"
#include "visionipc_server.h"
VisionIpcClient::VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id, cl_context ctx) : name(name), type(type), device_id(device_id), ctx(ctx) {
msg_ctx = Context::create();
sock = SubSocket::create(msg_ctx, get_endpoint_name(name, type), "127.0.0.1", conflate, false);
poller = Poller::create();
poller->registerSocket(sock);
}
// Connect is not thread safe. Do not use the buffers while calling connect
bool VisionIpcClient::connect(bool blocking){
connected = false;
// Cleanup old buffers on reconnect
for (size_t i = 0; i < num_buffers; i++){
buffers[i].free();
}
num_buffers = 0;
// Connect to server socket and ask for all FDs of type
std::string path = "/tmp/visionipc_" + name;
int socket_fd = -1;
while (socket_fd < 0) {
socket_fd = ipc_connect(path.c_str());
if (socket_fd < 0) {
if (blocking){
std::cout << "VisionIpcClient connecting" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} else {
return false;
}
}
}
// Send stream type to server to request FDs
int r = ipc_sendrecv_with_fds(true, socket_fd, &type, sizeof(type), nullptr, 0, nullptr);
assert(r == sizeof(type));
// Get FDs
int fds[VISIONIPC_MAX_FDS];
VisionBuf bufs[VISIONIPC_MAX_FDS];
r = ipc_sendrecv_with_fds(false, socket_fd, &bufs, sizeof(bufs), fds, VISIONIPC_MAX_FDS, &num_buffers);
assert(num_buffers > 0);
assert(r == sizeof(VisionBuf) * num_buffers);
// Import buffers
for (size_t i = 0; i < num_buffers; i++){
buffers[i] = bufs[i];
buffers[i].fd = fds[i];
buffers[i].import();
if (buffers[i].rgb) {
buffers[i].init_rgb(buffers[i].width, buffers[i].height, buffers[i].stride);
} else {
buffers[i].init_yuv(buffers[i].width, buffers[i].height);
}
if (device_id) buffers[i].init_cl(device_id, ctx);
}
connected = true;
return true;
}
VisionBuf * VisionIpcClient::recv(VisionIpcBufExtra * extra, const int timeout_ms){
auto p = poller->poll(timeout_ms);
if (!p.size()){
return nullptr;
}
Message * r = sock->receive(true);
if (r == nullptr){
return nullptr;
}
// Get buffer
assert(r->getSize() == sizeof(VisionIpcPacket));
VisionIpcPacket *packet = (VisionIpcPacket*)r->getData();
assert(packet->idx < num_buffers);
VisionBuf * buf = &buffers[packet->idx];
if (buf->server_id != packet->server_id){
connected = false;
delete r;
return nullptr;
}
if (extra) {
*extra = packet->extra;
}
buf->sync(VISIONBUF_SYNC_TO_DEVICE);
delete r;
return buf;
}
VisionIpcClient::~VisionIpcClient(){
for (size_t i = 0; i < num_buffers; i++){
buffers[i].free();
}
delete sock;
delete poller;
delete msg_ctx;
}
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <vector>
#include <string>
#include <unistd.h>
#include "messaging.hpp"
#include "visionipc.h"
#include "visionbuf.h"
class VisionIpcClient {
private:
std::string name;
Context * msg_ctx;
SubSocket * sock;
Poller * poller;
VisionStreamType type;
cl_device_id device_id = nullptr;
cl_context ctx = nullptr;
void init_msgq(bool conflate);
public:
bool connected = false;
int num_buffers = 0;
VisionBuf buffers[VISIONIPC_MAX_FDS];
VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id=nullptr, cl_context ctx=nullptr);
~VisionIpcClient();
VisionBuf * recv(VisionIpcBufExtra * extra=nullptr, const int timeout_ms=100);
bool connect(bool blocking=true);
};
+49
View File
@@ -0,0 +1,49 @@
# distutils: language = c++
# cython: c_string_encoding=ascii, language_level=3
import sys
from libcpp.string cimport string
from libcpp cimport bool
from libc.string cimport memcpy
from libc.stdint cimport uint32_t, uint64_t
from .visionipc cimport VisionIpcServer as cppVisionIpcServer
from .visionipc cimport VisionBuf as cppVisionBuf
from .visionipc cimport VisionIpcBufExtra
cpdef enum VisionStreamType:
VISION_STREAM_RGB_BACK
VISION_STREAM_RGB_FRONT
VISION_STREAM_RGB_WIDE
VISION_STREAM_YUV_BACK
VISION_STREAM_YUV_FRONT
VISION_STREAM_YUV_WIDE
cdef class VisionIpcServer:
cdef cppVisionIpcServer * server
def __init__(self, string name):
self.server = new cppVisionIpcServer(name, NULL, NULL)
def create_buffers(self, VisionStreamType tp, size_t num_buffers, bool rgb, size_t width, size_t height):
self.server.create_buffers(tp, num_buffers, rgb, width, height)
def send(self, VisionStreamType tp, bytes data, uint32_t frame_id=0, uint64_t timestamp_sof=0, uint64_t timestamp_eof=0):
cdef cppVisionBuf * buf = self.server.get_buffer(tp)
# Populate buffer
assert buf.len == len(data)
memcpy(buf.addr, <char*>data, len(data))
cdef VisionIpcBufExtra extra
extra.frame_id = frame_id
extra.timestamp_sof = timestamp_sof
extra.timestamp_eof = timestamp_eof
self.server.send(buf, &extra, False)
def start_listener(self):
self.server.start_listener()
def __dealloc__(self):
del self.server
+179
View File
@@ -0,0 +1,179 @@
#include <iostream>
#include <chrono>
#include <cassert>
#include <random>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
#include "messaging.hpp"
#include "ipc.h"
#include "visionipc_server.h"
std::string get_endpoint_name(std::string name, VisionStreamType type){
if (messaging_use_zmq()){
assert(name == "camerad");
return std::to_string(9000 + static_cast<int>(type));
} else {
return "visionipc_" + name + "_" + std::to_string(type);
}
}
VisionIpcServer::VisionIpcServer(std::string name, cl_device_id device_id, cl_context ctx) : name(name), device_id(device_id), ctx(ctx) {
msg_ctx = Context::create();
std::random_device rd("/dev/urandom");
std::uniform_int_distribution<uint64_t> distribution(0,std::numeric_limits<uint64_t>::max());
server_id = distribution(rd);
}
void VisionIpcServer::create_buffers(VisionStreamType type, size_t num_buffers, bool rgb, size_t width, size_t height){
// TODO: assert that this type is not created yet
assert(num_buffers < VISIONIPC_MAX_FDS);
int aligned_w = 0, aligned_h = 0;
size_t size = 0;
size_t stride = 0; // Only used for RGB
if (rgb) {
visionbuf_compute_aligned_width_and_height(width, height, &aligned_w, &aligned_h);
size = (size_t)aligned_w * (size_t)aligned_h * 3;
stride = aligned_w * 3;
} else {
size = width * height * 3 / 2;
}
// Create map + alloc requested buffers
for (size_t i = 0; i < num_buffers; i++){
VisionBuf* buf = new VisionBuf();
buf->allocate(size);
buf->idx = i;
buf->type = type;
if (device_id) buf->init_cl(device_id, ctx);
rgb ? buf->init_rgb(width, height, stride) : buf->init_yuv(width, height);
buffers[type].push_back(buf);
}
cur_idx[type] = 0;
// Create msgq publisher for each of the `name` + type combos
// TODO: compute port number directly if using zmq
sockets[type] = PubSocket::create(msg_ctx, get_endpoint_name(name, type), false);
}
void VisionIpcServer::start_listener(){
listener_thread = std::thread(&VisionIpcServer::listener, this);
}
void VisionIpcServer::listener(){
std::cout << "Starting listener for: " << name << std::endl;
std::string path = "/tmp/visionipc_" + name;
int sock = ipc_bind(path.c_str());
assert(sock >= 0);
while (!should_exit){
// Wait for incoming connection
struct pollfd polls[1] = {{0}};
polls[0].fd = sock;
polls[0].events = POLLIN;
int ret = poll(polls, 1, 100);
if (ret < 0) {
if (errno == EINTR || errno == EAGAIN) continue;
std::cout << "poll failed, stopping listener" << std::endl;
break;
}
if (should_exit) break;
if (!polls[0].revents) {
continue;
}
// Handle incoming request
int fd = accept(sock, NULL, NULL);
assert(fd >= 0);
VisionStreamType type = VisionStreamType::VISION_STREAM_MAX;
int r = ipc_sendrecv_with_fds(false, fd, &type, sizeof(type), nullptr, 0, nullptr);
assert(r == sizeof(type));
if (buffers.count(type) <= 0) {
std::cout << "got request for invalid buffer type: " << type << std::endl;
close(fd);
continue;
}
int fds[VISIONIPC_MAX_FDS];
int num_fds = buffers[type].size();
VisionBuf bufs[VISIONIPC_MAX_FDS];
for (int i = 0; i < num_fds; i++){
fds[i] = buffers[type][i]->fd;
bufs[i] = *buffers[type][i];
// Remove some private openCL/ion metadata
bufs[i].buf_cl = 0;
bufs[i].copy_q = 0;
bufs[i].handle = 0;
bufs[i].owner = false;
bufs[i].server_id = server_id;
}
r = ipc_sendrecv_with_fds(true, fd, &bufs, sizeof(VisionBuf) * num_fds, fds, num_fds, nullptr);
close(fd);
}
std::cout << "Stopping listener for: " << name << std::endl;
close(sock);
}
VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type){
// Do we want to keep track if the buffer has been sent out yet and warn user?
assert(buffers.count(type));
auto b = buffers[type];
return b[cur_idx[type]++ % b.size()];
}
void VisionIpcServer::send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync){
if (sync) buf->sync(VISIONBUF_SYNC_FROM_DEVICE);
assert(buffers.count(buf->type));
assert(buf->idx < buffers[buf->type].size());
// Send over correct msgq socket
VisionIpcPacket packet = {0};
packet.server_id = server_id;
packet.idx = buf->idx;
packet.extra = *extra;
sockets[buf->type]->send((char*)&packet, sizeof(packet));
}
VisionIpcServer::~VisionIpcServer(){
should_exit = true;
listener_thread.join();
// VisionBuf cleanup
for( auto const& [type, buf] : buffers ) {
for (VisionBuf* b : buf){
b->free();
delete b;
}
}
// Messaging cleanup
for( auto const& [type, sock] : sockets ) {
delete sock;
}
delete msg_ctx;
}
+42
View File
@@ -0,0 +1,42 @@
#pragma once
#include <vector>
#include <string>
#include <thread>
#include <atomic>
#include <map>
#include "messaging.hpp"
#include "visionipc.h"
#include "visionbuf.h"
std::string get_endpoint_name(std::string name, VisionStreamType type);
class VisionIpcServer {
private:
cl_device_id device_id = nullptr;
cl_context ctx = nullptr;
uint64_t server_id;
std::atomic<bool> should_exit = false;
std::string name;
std::thread listener_thread;
std::map<VisionStreamType, std::atomic<size_t> > cur_idx;
std::map<VisionStreamType, std::vector<VisionBuf*> > buffers;
std::map<VisionStreamType, std::map<VisionBuf*, size_t> > idxs;
Context * msg_ctx;
std::map<VisionStreamType, PubSocket*> sockets;
void listener(void);
public:
VisionIpcServer(std::string name, cl_device_id device_id=nullptr, cl_context ctx=nullptr);
~VisionIpcServer();
VisionBuf * get_buffer(VisionStreamType type);
void create_buffers(VisionStreamType type, size_t num_buffers, bool rgb, size_t width, size_t height);
void send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync=true);
void start_listener();
};
+135
View File
@@ -0,0 +1,135 @@
#include <thread>
#include <chrono>
#include "catch2/catch.hpp"
#include "visionipc_server.h"
#include "visionipc_client.h"
static void zmq_sleep(int milliseconds=1000){
if (messaging_use_zmq()){
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}
}
TEST_CASE("Connecting"){
VisionIpcServer server("camerad");
server.create_buffers(VISION_STREAM_YUV_BACK, 1, false, 100, 100);
server.start_listener();
VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false);
REQUIRE(client.connect());
REQUIRE(client.connected);
}
TEST_CASE("Check buffers"){
size_t width = 100, height = 200, num_buffers = 5;
VisionIpcServer server("camerad");
server.create_buffers(VISION_STREAM_YUV_BACK, num_buffers, false, width, height);
server.start_listener();
VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false);
REQUIRE(client.connect());
REQUIRE(client.buffers[0].width == width);
REQUIRE(client.buffers[0].height == height);
REQUIRE(client.buffers[0].len);
REQUIRE(client.num_buffers == num_buffers);
}
TEST_CASE("Check yuv/rgb"){
VisionIpcServer server("camerad");
server.create_buffers(VISION_STREAM_YUV_BACK, 1, false, 100, 100);
server.create_buffers(VISION_STREAM_RGB_BACK, 1, true, 100, 100);
server.start_listener();
VisionIpcClient client_yuv = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false);
VisionIpcClient client_rgb = VisionIpcClient("camerad", VISION_STREAM_RGB_BACK, false);
client_yuv.connect();
client_rgb.connect();
REQUIRE(client_rgb.buffers[0].rgb == true);
REQUIRE(client_yuv.buffers[0].rgb == false);
}
TEST_CASE("Send single buffer"){
VisionIpcServer server("camerad");
server.create_buffers(VISION_STREAM_YUV_BACK, 1, true, 100, 100);
server.start_listener();
VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false);
REQUIRE(client.connect());
zmq_sleep();
VisionBuf * buf = server.get_buffer(VISION_STREAM_YUV_BACK);
REQUIRE(buf != nullptr);
*((uint64_t*)buf->addr) = 1234;
VisionIpcBufExtra extra = {0};
extra.frame_id = 1337;
server.send(buf, &extra);
VisionIpcBufExtra extra_recv = {0};
VisionBuf * recv_buf = client.recv(&extra_recv);
REQUIRE(recv_buf != nullptr);
REQUIRE(*(uint64_t*)recv_buf->addr == 1234);
REQUIRE(extra_recv.frame_id == extra.frame_id);
}
TEST_CASE("Test no conflate"){
VisionIpcServer server("camerad");
server.create_buffers(VISION_STREAM_YUV_BACK, 1, true, 100, 100);
server.start_listener();
VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false);
REQUIRE(client.connect());
zmq_sleep();
VisionBuf * buf = server.get_buffer(VISION_STREAM_YUV_BACK);
REQUIRE(buf != nullptr);
VisionIpcBufExtra extra = {0};
extra.frame_id = 1;
server.send(buf, &extra);
extra.frame_id = 2;
server.send(buf, &extra);
VisionIpcBufExtra extra_recv = {0};
VisionBuf * recv_buf = client.recv(&extra_recv);
REQUIRE(recv_buf != nullptr);
REQUIRE(extra_recv.frame_id == 1);
recv_buf = client.recv(&extra_recv);
REQUIRE(recv_buf != nullptr);
REQUIRE(extra_recv.frame_id == 2);
}
TEST_CASE("Test conflate"){
VisionIpcServer server("camerad");
server.create_buffers(VISION_STREAM_YUV_BACK, 1, true, 100, 100);
server.start_listener();
VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, true);
REQUIRE(client.connect());
zmq_sleep();
VisionBuf * buf = server.get_buffer(VISION_STREAM_YUV_BACK);
REQUIRE(buf != nullptr);
VisionIpcBufExtra extra = {0};
extra.frame_id = 1;
server.send(buf, &extra);
extra.frame_id = 2;
server.send(buf, &extra);
VisionIpcBufExtra extra_recv = {0};
VisionBuf * recv_buf = client.recv(&extra_recv);
REQUIRE(recv_buf != nullptr);
REQUIRE(extra_recv.frame_id == 2);
recv_buf = client.recv(&extra_recv);
REQUIRE(recv_buf == nullptr);
}
+3 -13
View File
@@ -1,14 +1,4 @@
Import('env', 'cython_dependencies') Import('envCython')
# Build cython clock module envCython.Program('clock.so', 'clock.pyx')
env.Command(['common_pyx.so', 'clock.cpp'], envCython.Program('params_pyx.so', 'params_pyx.pyx')
cython_dependencies + ['common_pyx_setup.py', 'clock.pyx'],
"cd common && python3 common_pyx_setup.py build_ext --inplace")
# Build cython params module
env.Command(['params_pyx.so', 'params_pyx.cpp'],
cython_dependencies + [
'params_pyx_setup.py', 'params_pyx.pyx', 'params_pxd.pxd',
'#selfdrive/common/params.cc', '#selfdrive/common/params.h',
'#selfdrive/common/util.c', '#selfdrive/common/util.h'],
"cd common && python3 params_pyx_setup.py build_ext --inplace")
+5 -1
View File
@@ -27,7 +27,11 @@ class Api():
'iat': now, 'iat': now,
'exp': now + timedelta(hours=1) 'exp': now + timedelta(hours=1)
} }
return jwt.encode(payload, self.private_key, algorithm='RS256').decode('utf8') token = jwt.encode(payload, self.private_key, algorithm='RS256')
if isinstance(token, bytes):
token = token.decode('utf8')
return token
def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): def api_get(endpoint, method='GET', timeout=None, access_token=None, **params):
backend = "https://api.commadotai.com/" backend = "https://api.commadotai.com/"
+5 -2
View File
@@ -1,8 +1,11 @@
import os import os
from pathlib import Path
from selfdrive.hardware import PC
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
from common.hardware import PC
if PC: if PC:
PERSIST = os.path.join(BASEDIR, "persist") PERSIST = os.path.join(str(Path.home()), ".comma", "persist")
else: else:
PERSIST = "/persist" PERSIST = "/persist"
+1
View File
@@ -1,3 +1,4 @@
# distutils: language = c++
# cython: language_level = 3 # cython: language_level = 3
from posix.time cimport clock_gettime, timespec, CLOCK_MONOTONIC_RAW, clockid_t from posix.time cimport clock_gettime, timespec, CLOCK_MONOTONIC_RAW, clockid_t
-20
View File
@@ -1,20 +0,0 @@
from distutils.core import Extension, setup # pylint: disable=import-error,no-name-in-module
from Cython.Build import cythonize
from common.cython_hacks import BuildExtWithoutPlatformSuffix
sourcefiles = ['clock.pyx']
extra_compile_args = ["-std=c++1z"]
setup(name='common',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(
Extension(
"common_pyx",
language="c++",
sources=sourcefiles,
extra_compile_args=extra_compile_args,
),
nthreads=4,
),
)
-8
View File
@@ -1,11 +1,3 @@
GPIO_HUB_RST_N = 30
GPIO_UBLOX_RST_N = 32
GPIO_UBLOX_SAFEBOOT_N = 33
GPIO_UBLOX_PWR_EN = 34
GPIO_STM_RST_N = 124
GPIO_STM_BOOT0 = 134
def gpio_init(pin, output): def gpio_init(pin, output):
try: try:
with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f: with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
-57
View File
@@ -1,57 +0,0 @@
import os
import random
from typing import cast
from cereal import log
from common.hardware_android import Android
from common.hardware_tici import Tici
from common.hardware_base import HardwareBase
EON = os.path.isfile('/EON')
TICI = os.path.isfile('/TICI')
PC = not (EON or TICI)
ANDROID = EON
NetworkType = log.ThermalData.NetworkType
NetworkStrength = log.ThermalData.NetworkStrength
class Pc(HardwareBase):
def get_sound_card_online(self):
return True
def get_imei(self, slot):
return "%015d" % random.randint(0, 1 << 32)
def get_serial(self):
return "cccccccc"
def get_subscriber_info(self):
return ""
def reboot(self, reason=None):
print("REBOOT!")
def get_network_type(self):
return NetworkType.wifi
def get_sim_info(self):
return {
'sim_id': '',
'mcc_mnc': None,
'network_type': ["Unknown"],
'sim_state': ["ABSENT"],
'data_connected': False
}
def get_network_strength(self, network_type):
return NetworkStrength.unknown
if EON:
HARDWARE = cast(HardwareBase, Android())
elif TICI:
HARDWARE = cast(HardwareBase, Tici())
else:
HARDWARE = cast(HardwareBase, Pc())
-41
View File
@@ -1,41 +0,0 @@
from abc import abstractmethod
class HardwareBase:
@staticmethod
def get_cmdline():
with open('/proc/cmdline') as f:
cmdline = f.read()
return {kv[0]: kv[1] for kv in [s.split('=') for s in cmdline.split(' ')] if len(kv) == 2}
@abstractmethod
def get_sound_card_online(self):
pass
@abstractmethod
def get_imei(self, slot):
pass
@abstractmethod
def get_serial(self):
pass
@abstractmethod
def get_subscriber_info(self):
pass
@abstractmethod
def reboot(self, reason=None):
pass
@abstractmethod
def get_network_type(self):
pass
@abstractmethod
def get_sim_info(self):
pass
@abstractmethod
def get_network_strength(self, network_type):
pass
-59
View File
@@ -1,59 +0,0 @@
import serial
from common.hardware_base import HardwareBase
from cereal import log
import subprocess
NetworkType = log.ThermalData.NetworkType
NetworkStrength = log.ThermalData.NetworkStrength
def run_at_command(cmd, timeout=0.1):
with serial.Serial("/dev/ttyUSB2", timeout=timeout) as ser:
ser.write(cmd + b"\r\n")
ser.readline() # Modem echos request
return ser.readline().decode().rstrip()
class Tici(HardwareBase):
def get_sound_card_online(self):
return True
def get_imei(self, slot):
if slot != 0:
return ""
for _ in range(10):
try:
imei = run_at_command(b"AT+CGSN")
if len(imei) == 15:
return imei
except serial.SerialException:
pass
raise RuntimeError("Error getting IMEI")
def get_serial(self):
return self.get_cmdline()['androidboot.serialno']
def get_subscriber_info(self):
return ""
def reboot(self, reason=None):
subprocess.check_output(["sudo", "reboot"])
def get_network_type(self):
return NetworkType.wifi
def get_sim_info(self):
return {
'sim_id': '',
'mcc_mnc': None,
'network_type': ["Unknown"],
'sim_state': ["ABSENT"],
'data_connected': False
}
def get_network_strength(self, network_type):
return NetworkStrength.unknown
+2 -5
View File
@@ -1,6 +1,3 @@
Import('env', 'cython_dependencies') Import('envCython')
env.Command(['simple_kalman_impl.so'],
cython_dependencies + ['simple_kalman_impl.pyx', 'simple_kalman_impl.pxd', 'simple_kalman_setup.py'],
"cd common/kalman && python3 simple_kalman_setup.py build_ext --inplace")
envCython.Program('simple_kalman_impl.so', 'simple_kalman_impl.pyx')
+1
View File
@@ -1,3 +1,4 @@
# distutils: language = c++
# cython: language_level=3 # cython: language_level=3
cdef class KF1D: cdef class KF1D:
-10
View File
@@ -1,10 +0,0 @@
from distutils.core import Extension, setup
from Cython.Build import cythonize
from common.cython_hacks import BuildExtWithoutPlatformSuffix
setup(name='Simple Kalman Implementation',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(Extension("simple_kalman_impl",
["simple_kalman_impl.pyx"])))
@@ -82,3 +82,6 @@ kf = KF1D(x0=[[x0_0], [x1_0]],
kf_speed = timeit.timeit("kf.update(1234)", setup=setup, number=10000) kf_speed = timeit.timeit("kf.update(1234)", setup=setup, number=10000)
kf_old_speed = timeit.timeit("kf_old.update(1234)", setup=setup, number=10000) kf_old_speed = timeit.timeit("kf_old.update(1234)", setup=setup, number=10000)
self.assertTrue(kf_speed < kf_old_speed / 4) self.assertTrue(kf_speed < kf_old_speed / 4)
if __name__ == "__main__":
unittest.main()
+19
View File
@@ -2,3 +2,22 @@ from common.params_pyx import Params, UnknownKeyName, put_nonblocking # pylint:
assert Params assert Params
assert UnknownKeyName assert UnknownKeyName
assert put_nonblocking assert put_nonblocking
if __name__ == "__main__":
import sys
from common.params_pyx import keys # pylint: disable=no-name-in-module, import-error
params = Params()
if len(sys.argv) == 3:
name = sys.argv[1]
val = sys.argv[2]
assert name.encode("utf-8") in keys.keys(), f"unknown param: {name}"
print(f"SET: {name} = {val}")
params.put(name, val)
elif len(sys.argv) == 2:
name = sys.argv[1]
assert name.encode("utf-8") in keys.keys(), f"unknown param: {name}"
print(f"GET: {name} = {params.get(name)}")
else:
for k in keys.keys():
print(f"GET: {k} = {params.get(k)}")
+1 -1
View File
@@ -4,7 +4,7 @@ from libcpp cimport bool
cdef extern from "selfdrive/common/params.cc": cdef extern from "selfdrive/common/params.cc":
pass pass
cdef extern from "selfdrive/common/util.c": cdef extern from "selfdrive/common/util.cc":
pass pass
cdef extern from "selfdrive/common/params.h": cdef extern from "selfdrive/common/params.h":
+10 -2
View File
@@ -2,7 +2,7 @@
# cython: language_level = 3 # cython: language_level = 3
from libcpp cimport bool from libcpp cimport bool
from libcpp.string cimport string from libcpp.string cimport string
from params_pxd cimport Params as c_Params from common.params_pxd cimport Params as c_Params
import os import os
import threading import threading
@@ -31,9 +31,11 @@ keys = {
b"GitCommit": [TxType.PERSISTENT], b"GitCommit": [TxType.PERSISTENT],
b"GitRemote": [TxType.PERSISTENT], b"GitRemote": [TxType.PERSISTENT],
b"GithubSshKeys": [TxType.PERSISTENT], b"GithubSshKeys": [TxType.PERSISTENT],
b"HardwareSerial": [TxType.PERSISTENT],
b"HasAcceptedTerms": [TxType.PERSISTENT], b"HasAcceptedTerms": [TxType.PERSISTENT],
b"HasCompletedSetup": [TxType.PERSISTENT], b"HasCompletedSetup": [TxType.PERSISTENT],
b"IsDriverViewEnabled": [TxType.CLEAR_ON_MANAGER_START], b"IsDriverViewEnabled": [TxType.CLEAR_ON_MANAGER_START],
b"IMEI": [TxType.PERSISTENT],
b"IsLdwEnabled": [TxType.PERSISTENT], b"IsLdwEnabled": [TxType.PERSISTENT],
b"IsMetric": [TxType.PERSISTENT], b"IsMetric": [TxType.PERSISTENT],
b"IsOffroad": [TxType.CLEAR_ON_MANAGER_START], b"IsOffroad": [TxType.CLEAR_ON_MANAGER_START],
@@ -42,8 +44,9 @@ keys = {
b"IsUpdateAvailable": [TxType.CLEAR_ON_MANAGER_START], b"IsUpdateAvailable": [TxType.CLEAR_ON_MANAGER_START],
b"IsUploadRawEnabled": [TxType.PERSISTENT], b"IsUploadRawEnabled": [TxType.PERSISTENT],
b"LastAthenaPingTime": [TxType.PERSISTENT], b"LastAthenaPingTime": [TxType.PERSISTENT],
b"LastUpdateTime": [TxType.PERSISTENT], b"LastGPSPosition": [TxType.PERSISTENT],
b"LastUpdateException": [TxType.PERSISTENT], b"LastUpdateException": [TxType.PERSISTENT],
b"LastUpdateTime": [TxType.PERSISTENT],
b"LiveParameters": [TxType.PERSISTENT], b"LiveParameters": [TxType.PERSISTENT],
b"OpenpilotEnabledToggle": [TxType.PERSISTENT], b"OpenpilotEnabledToggle": [TxType.PERSISTENT],
b"LaneChangeEnabled": [TxType.PERSISTENT], b"LaneChangeEnabled": [TxType.PERSISTENT],
@@ -55,11 +58,14 @@ keys = {
b"ReleaseNotes": [TxType.PERSISTENT], b"ReleaseNotes": [TxType.PERSISTENT],
b"ShouldDoUpdate": [TxType.CLEAR_ON_MANAGER_START], b"ShouldDoUpdate": [TxType.CLEAR_ON_MANAGER_START],
b"SubscriberInfo": [TxType.PERSISTENT], b"SubscriberInfo": [TxType.PERSISTENT],
b"SshEnabled": [TxType.PERSISTENT],
b"TermsVersion": [TxType.PERSISTENT], b"TermsVersion": [TxType.PERSISTENT],
b"Timezone": [TxType.PERSISTENT],
b"TrainingVersion": [TxType.PERSISTENT], b"TrainingVersion": [TxType.PERSISTENT],
b"UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START], b"UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START],
b"UpdateFailedCount": [TxType.CLEAR_ON_MANAGER_START], b"UpdateFailedCount": [TxType.CLEAR_ON_MANAGER_START],
b"Version": [TxType.PERSISTENT], b"Version": [TxType.PERSISTENT],
b"VisionRadarToggle": [TxType.PERSISTENT],
b"Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], b"Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
b"Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START], b"Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START],
b"Offroad_ConnectivityNeededPrompt": [TxType.CLEAR_ON_MANAGER_START], b"Offroad_ConnectivityNeededPrompt": [TxType.CLEAR_ON_MANAGER_START],
@@ -69,6 +75,8 @@ keys = {
b"Offroad_IsTakingSnapshot": [TxType.CLEAR_ON_MANAGER_START], b"Offroad_IsTakingSnapshot": [TxType.CLEAR_ON_MANAGER_START],
b"Offroad_NeosUpdate": [TxType.CLEAR_ON_MANAGER_START], b"Offroad_NeosUpdate": [TxType.CLEAR_ON_MANAGER_START],
b"Offroad_UpdateFailed": [TxType.CLEAR_ON_MANAGER_START], b"Offroad_UpdateFailed": [TxType.CLEAR_ON_MANAGER_START],
b"Offroad_HardwareUnsupported": [TxType.CLEAR_ON_MANAGER_START],
b"ForcePowerDown": [TxType.CLEAR_ON_MANAGER_START],
} }
def ensure_bytes(v): def ensure_bytes(v):
-33
View File
@@ -1,33 +0,0 @@
import os
import subprocess
from distutils.core import Extension, setup
from Cython.Build import cythonize
from common.cython_hacks import BuildExtWithoutPlatformSuffix
from common.basedir import BASEDIR
from common.hardware import TICI
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg
sourcefiles = ['params_pyx.pyx']
extra_compile_args = ["-std=c++11"]
if ARCH == "aarch64":
if TICI:
extra_compile_args += ["-DQCOM2"]
else:
extra_compile_args += ["-DQCOM"]
setup(name='common',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(
Extension(
"params_pyx",
language="c++",
sources=sourcefiles,
include_dirs=[BASEDIR, os.path.join(BASEDIR, 'selfdrive')],
extra_compile_args=extra_compile_args
)
)
)
+16 -6
View File
@@ -4,21 +4,31 @@ import os
import time import time
import multiprocessing import multiprocessing
from common.hardware import PC from common.clock import sec_since_boot # pylint: disable=no-name-in-module, import-error
from common.common_pyx import sec_since_boot # pylint: disable=no-name-in-module, import-error from selfdrive.hardware import PC, TICI
# time step for each process # time step for each process
DT_CTRL = 0.01 # controlsd DT_CTRL = 0.01 # controlsd
DT_MDL = 0.05 # model DT_MDL = 0.05 # model
DT_DMON = 0.1 # driver monitoring
DT_TRML = 0.5 # thermald and manager DT_TRML = 0.5 # thermald and manager
# driver monitoring
if TICI:
DT_DMON = 0.05
else:
DT_DMON = 0.1
class Priority: class Priority:
MIN_REALTIME = 52 # highest android process priority is 51 # CORE 2
CTRL_LOW = MIN_REALTIME # - modeld = 55
CTRL_HIGH = MIN_REALTIME + 1 # - camerad = 54
CTRL_LOW = 51 # plannerd & radard
# CORE 3
# - boardd = 55
CTRL_HIGH = 53
def set_realtime_priority(level): def set_realtime_priority(level):
+12 -12
View File
@@ -4,22 +4,19 @@ from common.basedir import BASEDIR
class Spinner(): class Spinner():
def __init__(self, noop=False): def __init__(self):
# spinner is currently only implemented for android try:
self.spinner_proc = None self.spinner_proc = subprocess.Popen(["./spinner"],
if not noop: stdin=subprocess.PIPE,
try: cwd=os.path.join(BASEDIR, "selfdrive", "ui"),
self.spinner_proc = subprocess.Popen(["./spinner"], close_fds=True)
stdin=subprocess.PIPE, except OSError:
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "spinner"), self.spinner_proc = None
close_fds=True)
except OSError:
self.spinner_proc = None
def __enter__(self): def __enter__(self):
return self return self
def update(self, spinner_text): def update(self, spinner_text: str):
if self.spinner_proc is not None: if self.spinner_proc is not None:
self.spinner_proc.stdin.write(spinner_text.encode('utf8') + b"\n") self.spinner_proc.stdin.write(spinner_text.encode('utf8') + b"\n")
try: try:
@@ -27,6 +24,9 @@ class Spinner():
except BrokenPipeError: except BrokenPipeError:
pass pass
def update_progress(self, cur: int, total: int):
self.update(str(int(100 * cur / total)))
def close(self): def close(self):
if self.spinner_proc is not None: if self.spinner_proc is not None:
try: try:
+8 -11
View File
@@ -6,17 +6,14 @@ from common.basedir import BASEDIR
class TextWindow: class TextWindow:
def __init__(self, s, noop=False): def __init__(self, text):
# text window is only implemented for android currently try:
self.text_proc = None self.text_proc = subprocess.Popen(["./text", text],
if not noop: stdin=subprocess.PIPE,
try: cwd=os.path.join(BASEDIR, "selfdrive", "ui"),
self.text_proc = subprocess.Popen(["./text", s], close_fds=True)
stdin=subprocess.PIPE, except OSError:
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "text"), self.text_proc = None
close_fds=True)
except OSError:
self.text_proc = None
def get_status(self): def get_status(self):
if self.text_proc is not None: if self.text_proc is not None:
+4 -6
View File
@@ -1,8 +1,6 @@
Import('env', 'cython_dependencies') Import('env', 'envCython')
d = Dir('.') transformations = env.Library('transformations', ['orientation.cc', 'coordinates.cc'])
Export('transformations')
env.Command(['transformations.so'], envCython.Program('transformations.so', 'transformations.pyx')
cython_dependencies + ['transformations.pxd', 'transformations.pyx',
'coordinates.cc', 'orientation.cc', 'coordinates.hpp', 'orientation.hpp'],
'cd ' + d.path + ' && python3 setup.py build_ext --inplace')
+62 -32
View File
@@ -1,29 +1,67 @@
import numpy as np import numpy as np
import common.transformations.orientation as orient
FULL_FRAME_SIZE = (1164, 874) import common.transformations.orientation as orient
W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1] from selfdrive.hardware import TICI
eon_focal_length = FOCAL = 910.0
## -- hardcoded hardware params --
eon_f_focal_length = 910.0
eon_d_focal_length = 860.0
leon_d_focal_length = 650.0
tici_f_focal_length = 2648.0
tici_e_focal_length = tici_d_focal_length = 567.0 # probably wrong? magnification is not consistent across frame
eon_f_frame_size = (1164, 874)
eon_d_frame_size = (1152, 864)
leon_d_frame_size = (816, 612)
tici_f_frame_size = tici_e_frame_size = tici_d_frame_size = (1928, 1208)
# aka 'K' aka camera_frame_from_view_frame # aka 'K' aka camera_frame_from_view_frame
eon_intrinsics = np.array([ eon_fcam_intrinsics = np.array([
[FOCAL, 0., W/2.], [eon_f_focal_length, 0.0, float(eon_f_frame_size[0])/2],
[ 0., FOCAL, H/2.], [0.0, eon_f_focal_length, float(eon_f_frame_size[1])/2],
[ 0., 0., 1.]]) [0.0, 0.0, 1.0]])
eon_intrinsics = eon_fcam_intrinsics # xx
leon_dcam_intrinsics = np.array([ leon_dcam_intrinsics = np.array([
[650, 0, 816//2], [leon_d_focal_length, 0.0, float(leon_d_frame_size[0])/2],
[ 0, 650, 612//2], [0.0, leon_d_focal_length, float(leon_d_frame_size[1])/2],
[ 0, 0, 1]]) [0.0, 0.0, 1.0]])
eon_dcam_intrinsics = np.array([ eon_dcam_intrinsics = np.array([
[860, 0, 1152//2], [eon_d_focal_length, 0.0, float(eon_d_frame_size[0])/2],
[ 0, 860, 864//2], [0.0, eon_d_focal_length, float(eon_d_frame_size[1])/2],
[ 0, 0, 1]]) [0.0, 0.0, 1.0]])
tici_fcam_intrinsics = np.array([
[tici_f_focal_length, 0.0, float(tici_f_frame_size[0])/2],
[0.0, tici_f_focal_length, float(tici_f_frame_size[1])/2],
[0.0, 0.0, 1.0]])
tici_dcam_intrinsics = np.array([
[tici_d_focal_length, 0.0, float(tici_d_frame_size[0])/2],
[0.0, tici_d_focal_length, float(tici_d_frame_size[1])/2],
[0.0, 0.0, 1.0]])
tici_ecam_intrinsics = tici_dcam_intrinsics
# aka 'K_inv' aka view_frame_from_camera_frame # aka 'K_inv' aka view_frame_from_camera_frame
eon_intrinsics_inv = np.linalg.inv(eon_intrinsics) eon_fcam_intrinsics_inv = np.linalg.inv(eon_fcam_intrinsics)
eon_intrinsics_inv = eon_fcam_intrinsics_inv # xx
tici_fcam_intrinsics_inv = np.linalg.inv(tici_fcam_intrinsics)
tici_ecam_intrinsics_inv = np.linalg.inv(tici_ecam_intrinsics)
if not TICI:
FULL_FRAME_SIZE = eon_f_frame_size
FOCAL = eon_f_focal_length
fcam_intrinsics = eon_fcam_intrinsics
else:
FULL_FRAME_SIZE = tici_f_frame_size
FOCAL = tici_f_focal_length
fcam_intrinsics = tici_fcam_intrinsics
W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1]
# device/mesh : x->forward, y-> right, z->down # device/mesh : x->forward, y-> right, z->down
@@ -69,9 +107,9 @@ def vp_from_ke(m):
return (m[0, 0]/m[2, 0], m[1, 0]/m[2, 0]) return (m[0, 0]/m[2, 0], m[1, 0]/m[2, 0])
def vp_from_rpy(rpy): def vp_from_rpy(rpy, intrinsics=fcam_intrinsics):
e = get_view_frame_from_road_frame(rpy[0], rpy[1], rpy[2], 1.22) e = get_view_frame_from_road_frame(rpy[0], rpy[1], rpy[2], 1.22)
ke = np.dot(eon_intrinsics, e) ke = np.dot(intrinsics, e)
return vp_from_ke(ke) return vp_from_ke(ke)
@@ -81,7 +119,7 @@ def roll_from_ke(m):
-(m[0, 0] - m[0, 1] * m[2, 0] / m[2, 1])) -(m[0, 0] - m[0, 1] * m[2, 0] / m[2, 1]))
def normalize(img_pts, intrinsics=eon_intrinsics): def normalize(img_pts, intrinsics=fcam_intrinsics):
# normalizes image coordinates # normalizes image coordinates
# accepts single pt or array of pts # accepts single pt or array of pts
intrinsics_inv = np.linalg.inv(intrinsics) intrinsics_inv = np.linalg.inv(intrinsics)
@@ -94,7 +132,7 @@ def normalize(img_pts, intrinsics=eon_intrinsics):
return img_pts_normalized[:, :2].reshape(input_shape) return img_pts_normalized[:, :2].reshape(input_shape)
def denormalize(img_pts, intrinsics=eon_intrinsics): def denormalize(img_pts, intrinsics=fcam_intrinsics, width=W, height=H):
# denormalizes image coordinates # denormalizes image coordinates
# accepts single pt or array of pts # accepts single pt or array of pts
img_pts = np.array(img_pts) img_pts = np.array(img_pts)
@@ -102,9 +140,9 @@ def denormalize(img_pts, intrinsics=eon_intrinsics):
img_pts = np.atleast_2d(img_pts) img_pts = np.atleast_2d(img_pts)
img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0], 1)))) img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0], 1))))
img_pts_denormalized = img_pts.dot(intrinsics.T) img_pts_denormalized = img_pts.dot(intrinsics.T)
img_pts_denormalized[img_pts_denormalized[:, 0] > W] = np.nan img_pts_denormalized[img_pts_denormalized[:, 0] > width] = np.nan
img_pts_denormalized[img_pts_denormalized[:, 0] < 0] = np.nan img_pts_denormalized[img_pts_denormalized[:, 0] < 0] = np.nan
img_pts_denormalized[img_pts_denormalized[:, 1] > H] = np.nan img_pts_denormalized[img_pts_denormalized[:, 1] > height] = np.nan
img_pts_denormalized[img_pts_denormalized[:, 1] < 0] = np.nan img_pts_denormalized[img_pts_denormalized[:, 1] < 0] = np.nan
return img_pts_denormalized[:, :2].reshape(input_shape) return img_pts_denormalized[:, :2].reshape(input_shape)
@@ -137,18 +175,10 @@ def img_from_device(pt_device):
return pt_img.reshape(input_shape)[:, :2] return pt_img.reshape(input_shape)[:, :2]
def get_camera_frame_from_calib_frame(camera_frame_from_road_frame): def get_camera_frame_from_calib_frame(camera_frame_from_road_frame, intrinsics=fcam_intrinsics):
camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)] camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)]
calib_frame_from_ground = np.dot(eon_intrinsics, calib_frame_from_ground = np.dot(intrinsics,
get_view_frame_from_road_frame(0, 0, 0, 1.22))[:, (0, 1, 3)] get_view_frame_from_road_frame(0, 0, 0, 1.22))[:, (0, 1, 3)]
ground_from_calib_frame = np.linalg.inv(calib_frame_from_ground) ground_from_calib_frame = np.linalg.inv(calib_frame_from_ground)
camera_frame_from_calib_frame = np.dot(camera_frame_from_ground, ground_from_calib_frame) camera_frame_from_calib_frame = np.dot(camera_frame_from_ground, ground_from_calib_frame)
return camera_frame_from_calib_frame return camera_frame_from_calib_frame
def pretransform_from_calib(calib):
roll, pitch, yaw, height = calib
view_frame_from_road_frame = get_view_frame_from_road_frame(roll, pitch, yaw, height)
camera_frame_from_road_frame = np.dot(eon_intrinsics, view_frame_from_road_frame)
camera_frame_from_calib_frame = get_camera_frame_from_calib_frame(camera_frame_from_road_frame)
return np.linalg.inv(camera_frame_from_calib_frame)
+53 -41
View File
@@ -1,34 +1,33 @@
import numpy as np import numpy as np
from common.transformations.camera import (FULL_FRAME_SIZE, eon_focal_length, from common.transformations.camera import (FULL_FRAME_SIZE,
FOCAL,
get_view_frame_from_road_frame, get_view_frame_from_road_frame,
get_view_frame_from_calib_frame, get_view_frame_from_calib_frame,
vp_from_ke) vp_from_ke)
# segnet # segnet
SEGNET_SIZE = (512, 384) SEGNET_SIZE = (512, 384)
segnet_frame_from_camera_frame = np.array([ def get_segnet_frame_from_camera_frame(segnet_size=SEGNET_SIZE, full_frame_size=FULL_FRAME_SIZE):
[float(SEGNET_SIZE[0])/FULL_FRAME_SIZE[0], 0., ], return np.array([[float(segnet_size[0]) / full_frame_size[0], 0.0],
[ 0., float(SEGNET_SIZE[1])/FULL_FRAME_SIZE[1]]]) [0.0, float(segnet_size[1]) / full_frame_size[1]]])
segnet_frame_from_camera_frame = get_segnet_frame_from_camera_frame() # xx
# model # model
MODEL_INPUT_SIZE = (320, 160) MODEL_INPUT_SIZE = (320, 160)
MODEL_YUV_SIZE = (MODEL_INPUT_SIZE[0], MODEL_INPUT_SIZE[1] * 3 // 2) MODEL_YUV_SIZE = (MODEL_INPUT_SIZE[0], MODEL_INPUT_SIZE[1] * 3 // 2)
MODEL_CX = MODEL_INPUT_SIZE[0]/2. MODEL_CX = MODEL_INPUT_SIZE[0] / 2.
MODEL_CY = 21. MODEL_CY = 21.
model_zoom = 1.25 model_fl = 728.0
model_height = 1.22 model_height = 1.22
# canonical model transform # canonical model transform
model_intrinsics = np.array( model_intrinsics = np.array([
[[ eon_focal_length / model_zoom, 0. , MODEL_CX], [model_fl, 0.0, MODEL_CX],
[ 0. , eon_focal_length / model_zoom, MODEL_CY], [0.0, model_fl, MODEL_CY],
[ 0. , 0. , 1.]]) [0.0, 0.0, 1.0]])
# MED model # MED model
@@ -36,34 +35,45 @@ MEDMODEL_INPUT_SIZE = (512, 256)
MEDMODEL_YUV_SIZE = (MEDMODEL_INPUT_SIZE[0], MEDMODEL_INPUT_SIZE[1] * 3 // 2) MEDMODEL_YUV_SIZE = (MEDMODEL_INPUT_SIZE[0], MEDMODEL_INPUT_SIZE[1] * 3 // 2)
MEDMODEL_CY = 47.6 MEDMODEL_CY = 47.6
medmodel_zoom = 1. medmodel_fl = 910.0
medmodel_intrinsics = np.array( medmodel_intrinsics = np.array([
[[ eon_focal_length / medmodel_zoom, 0. , 0.5 * MEDMODEL_INPUT_SIZE[0]], [medmodel_fl, 0.0, 0.5 * MEDMODEL_INPUT_SIZE[0]],
[ 0. , eon_focal_length / medmodel_zoom, MEDMODEL_CY], [0.0, medmodel_fl, MEDMODEL_CY],
[ 0. , 0. , 1.]]) [0.0, 0.0, 1.0]])
# CAL model # CAL model
CALMODEL_INPUT_SIZE = (512, 256) CALMODEL_INPUT_SIZE = (512, 256)
CALMODEL_YUV_SIZE = (CALMODEL_INPUT_SIZE[0], CALMODEL_INPUT_SIZE[1] * 3 // 2) CALMODEL_YUV_SIZE = (CALMODEL_INPUT_SIZE[0], CALMODEL_INPUT_SIZE[1] * 3 // 2)
CALMODEL_CY = 47.6 CALMODEL_CY = 47.6
calmodel_zoom = 1.5 calmodel_fl = 606.7
calmodel_intrinsics = np.array( calmodel_intrinsics = np.array([
[[ eon_focal_length / calmodel_zoom, 0. , 0.5 * CALMODEL_INPUT_SIZE[0]], [calmodel_fl, 0.0, 0.5 * CALMODEL_INPUT_SIZE[0]],
[ 0. , eon_focal_length / calmodel_zoom, CALMODEL_CY], [0.0, calmodel_fl, CALMODEL_CY],
[ 0. , 0. , 1.]]) [0.0, 0.0, 1.0]])
# BIG model # BIG model
BIGMODEL_INPUT_SIZE = (1024, 512) BIGMODEL_INPUT_SIZE = (1024, 512)
BIGMODEL_YUV_SIZE = (BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1] * 3 // 2) BIGMODEL_YUV_SIZE = (BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1] * 3 // 2)
bigmodel_zoom = 1. bigmodel_fl = 910.0
bigmodel_intrinsics = np.array( bigmodel_intrinsics = np.array([
[[ eon_focal_length / bigmodel_zoom, 0. , 0.5 * BIGMODEL_INPUT_SIZE[0]], [bigmodel_fl, 0.0, 0.5 * BIGMODEL_INPUT_SIZE[0]],
[ 0. , eon_focal_length / bigmodel_zoom, 256+MEDMODEL_CY], [0.0, bigmodel_fl, 256 + MEDMODEL_CY],
[ 0. , 0. , 1.]]) [0.0, 0.0, 1.0]])
# SBIG model (big model with the size of small model)
SBIGMODEL_INPUT_SIZE = (512, 256)
SBIGMODEL_YUV_SIZE = (SBIGMODEL_INPUT_SIZE[0], SBIGMODEL_INPUT_SIZE[1] * 3 // 2)
sbigmodel_fl = 455.0
sbigmodel_intrinsics = np.array([
[sbigmodel_fl, 0.0, 0.5 * SBIGMODEL_INPUT_SIZE[0]],
[0.0, sbigmodel_fl, 0.5 * (256 + MEDMODEL_CY)],
[0.0, 0.0, 1.0]])
model_frame_from_road_frame = np.dot(model_intrinsics, model_frame_from_road_frame = np.dot(model_intrinsics,
get_view_frame_from_road_frame(0, 0, 0, model_height)) get_view_frame_from_road_frame(0, 0, 0, model_height))
@@ -80,20 +90,21 @@ medmodel_frame_from_calib_frame = np.dot(medmodel_intrinsics,
model_frame_from_bigmodel_frame = np.dot(model_intrinsics, np.linalg.inv(bigmodel_intrinsics)) model_frame_from_bigmodel_frame = np.dot(model_intrinsics, np.linalg.inv(bigmodel_intrinsics))
medmodel_frame_from_bigmodel_frame = np.dot(medmodel_intrinsics, np.linalg.inv(bigmodel_intrinsics)) medmodel_frame_from_bigmodel_frame = np.dot(medmodel_intrinsics, np.linalg.inv(bigmodel_intrinsics))
# 'camera from model camera' # 'camera from model camera'
def get_model_height_transform(camera_frame_from_road_frame, height): def get_model_height_transform(camera_frame_from_road_frame, height):
camera_frame_from_road_ground = np.dot(camera_frame_from_road_frame, np.array([ camera_frame_from_road_ground = np.dot(camera_frame_from_road_frame, np.array([
[1, 0, 0], [1, 0, 0],
[0, 1, 0], [0, 1, 0],
[0, 0, 0], [0, 0, 0],
[0, 0, 1], [0, 0, 1],
])) ]))
camera_frame_from_road_high = np.dot(camera_frame_from_road_frame, np.array([ camera_frame_from_road_high = np.dot(camera_frame_from_road_frame, np.array([
[1, 0, 0], [1, 0, 0],
[0, 1, 0], [0, 1, 0],
[0, 0, height - model_height], [0, 0, height - model_height],
[0, 0, 1], [0, 0, 1],
])) ]))
road_high_from_camera_frame = np.linalg.inv(camera_frame_from_road_high) road_high_from_camera_frame = np.linalg.inv(camera_frame_from_road_high)
@@ -104,13 +115,14 @@ def get_model_height_transform(camera_frame_from_road_frame, height):
# camera_frame_from_model_frame aka 'warp matrix' # camera_frame_from_model_frame aka 'warp matrix'
# was: calibration.h/CalibrationTransform # was: calibration.h/CalibrationTransform
def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model_height): def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model_height, camera_fl=FOCAL):
vp = vp_from_ke(camera_frame_from_road_frame) vp = vp_from_ke(camera_frame_from_road_frame)
model_zoom = camera_fl / model_fl
model_camera_from_model_frame = np.array([ model_camera_from_model_frame = np.array([
[model_zoom, 0., vp[0] - MODEL_CX * model_zoom], [model_zoom, 0.0, vp[0] - MODEL_CX * model_zoom],
[ 0., model_zoom, vp[1] - MODEL_CY * model_zoom], [0.0, model_zoom, vp[1] - MODEL_CY * model_zoom],
[ 0., 0., 1.], [0.0, 0.0, 1.0],
]) ])
# This function is super slow, so skip it if height is very close to canonical # This function is super slow, so skip it if height is very close to canonical
+2 -6
View File
@@ -39,7 +39,7 @@ Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat){
return quat.toRotationMatrix(); return quat.toRotationMatrix();
} }
Eigen::Quaterniond rot2quat(Eigen::Matrix3d rot){ Eigen::Quaterniond rot2quat(const Eigen::Matrix3d &rot){
return ensure_unique(Eigen::Quaterniond(rot)); return ensure_unique(Eigen::Quaterniond(rot));
} }
@@ -47,7 +47,7 @@ Eigen::Matrix3d euler2rot(Eigen::Vector3d euler){
return quat2rot(euler2quat(euler)); return quat2rot(euler2quat(euler));
} }
Eigen::Vector3d rot2euler(Eigen::Matrix3d rot){ Eigen::Vector3d rot2euler(const Eigen::Matrix3d &rot){
return quat2euler(rot2quat(rot)); return quat2euler(rot2quat(rot));
} }
@@ -141,7 +141,3 @@ Eigen::Vector3d ned_euler_from_ecef(ECEF ecef_init, Eigen::Vector3d ecef_pose){
return {phi, theta, psi}; return {phi, theta, psi};
} }
int main(void){
}
+2 -2
View File
@@ -8,9 +8,9 @@ Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat);
Eigen::Quaterniond euler2quat(Eigen::Vector3d euler); Eigen::Quaterniond euler2quat(Eigen::Vector3d euler);
Eigen::Vector3d quat2euler(Eigen::Quaterniond quat); Eigen::Vector3d quat2euler(Eigen::Quaterniond quat);
Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat); Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat);
Eigen::Quaterniond rot2quat(Eigen::Matrix3d rot); Eigen::Quaterniond rot2quat(const Eigen::Matrix3d &rot);
Eigen::Matrix3d euler2rot(Eigen::Vector3d euler); Eigen::Matrix3d euler2rot(Eigen::Vector3d euler);
Eigen::Vector3d rot2euler(Eigen::Matrix3d rot); Eigen::Vector3d rot2euler(const Eigen::Matrix3d &rot);
Eigen::Matrix3d rot_matrix(double roll, double pitch, double yaw); Eigen::Matrix3d rot_matrix(double roll, double pitch, double yaw);
Eigen::Matrix3d rot(Eigen::Vector3d axis, double angle); Eigen::Matrix3d rot(Eigen::Vector3d axis, double angle);
Eigen::Vector3d ecef_euler_from_ned(ECEF ecef_init, Eigen::Vector3d ned_pose); Eigen::Vector3d ecef_euler_from_ned(ECEF ecef_init, Eigen::Vector3d ned_pose);
-20
View File
@@ -1,20 +0,0 @@
import numpy
from Cython.Build import cythonize
from distutils.core import Extension, setup # pylint: disable=import-error,no-name-in-module
from common.cython_hacks import BuildExtWithoutPlatformSuffix
setup(
name='Cython transformations wrapper',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(
Extension(
"transformations",
sources=["transformations.pyx"],
language="c++",
extra_compile_args=["-std=c++1z", "-Wno-cpp"],
include_dirs=[numpy.get_include()],
),
nthreads=4,
)
)
+16 -14
View File
@@ -1,18 +1,20 @@
from transformations cimport Matrix3, Vector3, Quaternion # distutils: language = c++
from transformations cimport ECEF, NED, Geodetic # cython: language_level = 3
from common.transformations.transformations cimport Matrix3, Vector3, Quaternion
from common.transformations.transformations cimport ECEF, NED, Geodetic
from transformations cimport euler2quat as euler2quat_c from common.transformations.transformations cimport euler2quat as euler2quat_c
from transformations cimport quat2euler as quat2euler_c from common.transformations.transformations cimport quat2euler as quat2euler_c
from transformations cimport quat2rot as quat2rot_c from common.transformations.transformations cimport quat2rot as quat2rot_c
from transformations cimport rot2quat as rot2quat_c from common.transformations.transformations cimport rot2quat as rot2quat_c
from transformations cimport euler2rot as euler2rot_c from common.transformations.transformations cimport euler2rot as euler2rot_c
from transformations cimport rot2euler as rot2euler_c from common.transformations.transformations cimport rot2euler as rot2euler_c
from transformations cimport rot_matrix as rot_matrix_c from common.transformations.transformations cimport rot_matrix as rot_matrix_c
from transformations cimport ecef_euler_from_ned as ecef_euler_from_ned_c from common.transformations.transformations cimport ecef_euler_from_ned as ecef_euler_from_ned_c
from transformations cimport ned_euler_from_ecef as ned_euler_from_ecef_c from common.transformations.transformations cimport ned_euler_from_ecef as ned_euler_from_ecef_c
from transformations cimport geodetic2ecef as geodetic2ecef_c from common.transformations.transformations cimport geodetic2ecef as geodetic2ecef_c
from transformations cimport ecef2geodetic as ecef2geodetic_c from common.transformations.transformations cimport ecef2geodetic as ecef2geodetic_c
from transformations cimport LocalCoord_c from common.transformations.transformations cimport LocalCoord_c
import cython import cython
+9 -10
View File
@@ -12,6 +12,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include <memory>
#include <thread> #include <thread>
#include <curl/curl.h> #include <curl/curl.h>
@@ -30,7 +31,7 @@
#include "common/framebuffer.h" #include "common/framebuffer.h"
#include "common/touch.h" #include "common/touch.h"
#include "common/utilpp.h" #include "common/util.h"
#define USER_AGENT "NEOSUpdater-0.2" #define USER_AGENT "NEOSUpdater-0.2"
@@ -183,7 +184,7 @@ struct Updater {
int fb_w, fb_h; int fb_w, fb_h;
FramebufferState *fb = NULL; std::unique_ptr<FrameBuffer> fb;
NVGcontext *vg = NULL; NVGcontext *vg = NULL;
int font_regular; int font_regular;
int font_semibold; int font_semibold;
@@ -227,11 +228,9 @@ struct Updater {
void ui_init() { void ui_init() {
touch_init(&touch); touch_init(&touch);
fb = framebuffer_init("updater", 0x00001000, false, fb = std::make_unique<FrameBuffer>("updater", 0x00001000, false, &fb_w, &fb_h);
&fb_w, &fb_h);
assert(fb);
framebuffer_set_power(fb, HWC_POWER_MODE_NORMAL); fb->set_power(HWC_POWER_MODE_NORMAL);
vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG); vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
assert(vg); assert(vg);
@@ -465,7 +464,7 @@ struct Updater {
while(battery_cap < min_battery_cap) { while(battery_cap < min_battery_cap) {
battery_cap = battery_capacity(); battery_cap = battery_capacity();
battery_cap_text = std::to_string(battery_cap); battery_cap_text = std::to_string(battery_cap);
usleep(1000000); util::sleep_for(1000);
} }
set_running(); set_running();
} }
@@ -483,7 +482,7 @@ struct Updater {
while(battery_cap < min_battery_cap) { while(battery_cap < min_battery_cap) {
battery_cap = battery_capacity(); battery_cap = battery_capacity();
battery_cap_text = std::to_string(battery_cap); battery_cap_text = std::to_string(battery_cap);
usleep(1000000); util::sleep_for(1000);
} }
set_running(); set_running();
} }
@@ -751,12 +750,12 @@ struct Updater {
glDisable(GL_BLEND); glDisable(GL_BLEND);
framebuffer_swap(fb); fb->swap();
assert(glGetError() == GL_NO_ERROR); assert(glGetError() == GL_NO_ERROR);
// no simple way to do 30fps vsync with surfaceflinger... // no simple way to do 30fps vsync with surfaceflinger...
usleep(30000); util::sleep_for(30);
} }
if (update_thread_handle.joinable()) { if (update_thread_handle.joinable()) {
+124 -9
View File
@@ -9,7 +9,12 @@ source "$BASEDIR/launch_env.sh"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
function two_init { function two_init {
# Restrict Android and other system processes to the first two cores # Wifi scan
wpa_cli IFNAME=wlan0 SCAN
# *** shield cores 2-3 ***
# android gets two cores
echo 0-1 > /dev/cpuset/background/cpus echo 0-1 > /dev/cpuset/background/cpus
echo 0-1 > /dev/cpuset/system-background/cpus echo 0-1 > /dev/cpuset/system-background/cpus
echo 0-1 > /dev/cpuset/foreground/cpus echo 0-1 > /dev/cpuset/foreground/cpus
@@ -19,14 +24,56 @@ function two_init {
# openpilot gets all the cores # openpilot gets all the cores
echo 0-3 > /dev/cpuset/app/cpus echo 0-3 > /dev/cpuset/app/cpus
# mask off 2-3 from RPS and XPS - Receive/Transmit Packet Steering
echo 3 | tee /sys/class/net/*/queues/*/rps_cpus
echo 3 | tee /sys/class/net/*/queues/*/xps_cpus
# *** set up governors ***
# +50mW offroad, +500mW onroad for 30% more RAM bandwidth
echo "performance" > /sys/class/devfreq/soc:qcom,cpubw/governor
echo 1056000 > /sys/class/devfreq/soc:qcom,m4m/max_freq
echo "performance" > /sys/class/devfreq/soc:qcom,m4m/governor
# unclear if these help, but they don't seem to hurt
echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor
echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu2/governor
# GPU
echo "performance" > /sys/class/devfreq/b00000.qcom,kgsl-3d0/governor
# /sys/class/devfreq/soc:qcom,mincpubw is the only one left at "powersave"
# it seems to gain nothing but a wasted 500mW
# *** set up IRQ affinities ***
# Collect RIL and other possibly long-running I/O interrupts onto CPU 1 # Collect RIL and other possibly long-running I/O interrupts onto CPU 1
echo 1 > /proc/irq/78/smp_affinity_list # qcom,smd-modem (LTE radio) echo 1 > /proc/irq/78/smp_affinity_list # qcom,smd-modem (LTE radio)
echo 1 > /proc/irq/33/smp_affinity_list # ufshcd (flash storage) echo 1 > /proc/irq/33/smp_affinity_list # ufshcd (flash storage)
echo 1 > /proc/irq/35/smp_affinity_list # wifi (wlan_pci) echo 1 > /proc/irq/35/smp_affinity_list # wifi (wlan_pci)
echo 1 > /proc/irq/6/smp_affinity_list # MDSS
# USB traffic needs realtime handling on cpu 3 # USB traffic needs realtime handling on cpu 3
[ -d "/proc/irq/733" ] && echo 3 > /proc/irq/733/smp_affinity_list # USB for LeEco [ -d "/proc/irq/733" ] && echo 3 > /proc/irq/733/smp_affinity_list # USB for LeEco
[ -d "/proc/irq/736" ] && echo 3 > /proc/irq/736/smp_affinity_list # USB for OP3T [ -d "/proc/irq/736" ] && echo 3 > /proc/irq/736/smp_affinity_list # USB for OP3T
# GPU and camera get cpu 2
CAM_IRQS="177 178 179 180 181 182 183 184 185 186 192"
for irq in $CAM_IRQS; do
echo 2 > /proc/irq/$irq/smp_affinity_list
done
echo 2 > /proc/irq/193/smp_affinity_list # GPU
# give GPU threads RT priority
for pid in $(pgrep "kgsl"); do
chrt -f -p 52 $pid
done
# the flippening!
LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
# disable bluetooth
service call bluetooth_manager 8
# Check for NEOS update # Check for NEOS update
if [ $(< /VERSION) != "$REQUIRED_NEOS_VERSION" ]; then if [ $(< /VERSION) != "$REQUIRED_NEOS_VERSION" ]; then
@@ -58,10 +105,75 @@ function two_init {
fi fi
} }
function launch { function tici_init {
# Wifi scan sudo su -c 'echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor'
wpa_cli IFNAME=wlan0 SCAN sudo su -c 'echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu4/governor'
# set success flag for current boot slot
sudo abctl --set_success
# Check if AGNOS update is required
if [ $(< /VERSION) != "$AGNOS_VERSION" ]; then
# Get number of slot to switch to
CUR_SLOT=$(abctl --boot_slot)
if [[ "$CUR_SLOT" == "_a" ]]; then
OTHER_SLOT="_b"
OTHER_SLOT_NUMBER="1"
else
OTHER_SLOT="_a"
OTHER_SLOT_NUMBER="0"
fi
echo "Cur slot $CUR_SLOT, target $OTHER_SLOT"
# Get expected hashes from manifest
MANIFEST="$DIR/selfdrive/hardware/tici/agnos.json"
SYSTEM_HASH_EXPECTED=$(jq -r ".[] | select(.name == \"system\") | .hash_raw" $MANIFEST)
SYSTEM_SIZE=$(jq -r ".[] | select(.name == \"system\") | .size" $MANIFEST)
BOOT_HASH_EXPECTED=$(jq -r ".[] | select(.name == \"boot\") | .hash_raw" $MANIFEST)
BOOT_SIZE=$(jq -r ".[] | select(.name == \"boot\") | .size" $MANIFEST)
echo "Expected hashes:"
echo "System: $SYSTEM_HASH_EXPECTED"
echo "Boot: $BOOT_HASH_EXPECTED"
# Read hashes from alternate partitions, should already be flashed by updated
SYSTEM_HASH=$(dd if="/dev/disk/by-partlabel/system$OTHER_SLOT" bs=1 skip="$SYSTEM_SIZE" count=64 2>/dev/null)
BOOT_HASH=$(dd if="/dev/disk/by-partlabel/boot$OTHER_SLOT" bs=1 skip="$BOOT_SIZE" count=64 2>/dev/null)
echo "Found hashes:"
echo "System: $SYSTEM_HASH"
echo "Boot: $BOOT_HASH"
if [[ "$SYSTEM_HASH" == "$SYSTEM_HASH_EXPECTED" && "$BOOT_HASH" == "$BOOT_HASH_EXPECTED" ]]; then
echo "Swapping active slot to $OTHER_SLOT_NUMBER"
# Clean hashes before swapping to prevent looping
dd if=/dev/zero of="/dev/disk/by-partlabel/system$OTHER_SLOT" bs=1 seek="$SYSTEM_SIZE" count=64
dd if=/dev/zero of="/dev/disk/by-partlabel/boot$OTHER_SLOT" bs=1 seek="$BOOT_SIZE" count=64
sync
abctl --set_active "$OTHER_SLOT_NUMBER"
sleep 1
sudo reboot
else
echo "Hash mismatch, downloading agnos"
if $DIR/selfdrive/hardware/tici/agnos.py $MANIFEST; then
echo "Download done, swapping active slot to $OTHER_SLOT_NUMBER"
# Clean hashes before swapping to prevent looping
dd if=/dev/zero of="/dev/disk/by-partlabel/system$OTHER_SLOT" bs=1 seek="$SYSTEM_SIZE" count=64
dd if=/dev/zero of="/dev/disk/by-partlabel/boot$OTHER_SLOT" bs=1 seek="$BOOT_SIZE" count=64
sync
abctl --set_active "$OTHER_SLOT_NUMBER"
fi
sleep 1
sudo reboot
fi
fi
}
function launch {
# Remove orphaned git lock if it exists on boot # Remove orphaned git lock if it exists on boot
[ -f "$DIR/.git/index.lock" ] && rm -f $DIR/.git/index.lock [ -f "$DIR/.git/index.lock" ] && rm -f $DIR/.git/index.lock
@@ -95,6 +207,7 @@ function launch {
echo "Restarting launch script ${LAUNCHER_LOCATION}" echo "Restarting launch script ${LAUNCHER_LOCATION}"
unset REQUIRED_NEOS_VERSION unset REQUIRED_NEOS_VERSION
unset AGNOS_VERSION
exec "${LAUNCHER_LOCATION}" exec "${LAUNCHER_LOCATION}"
else else
echo "openpilot backup found, not updating" echo "openpilot backup found, not updating"
@@ -104,15 +217,17 @@ function launch {
fi fi
fi fi
# comma two init
if [ -f /EON ]; then
two_init
fi
# handle pythonpath # handle pythonpath
ln -sfn $(pwd) /data/pythonpath ln -sfn $(pwd) /data/pythonpath
export PYTHONPATH="$PWD" export PYTHONPATH="$PWD"
# hardware specific init
if [ -f /EON ]; then
two_init
elif [ -f /TICI ]; then
tici_init
fi
# write tmux scrollback to a file # write tmux scrollback to a file
tmux capture-pane -pq -S-1000 > /tmp/launch_log tmux capture-pane -pq -S-1000 > /tmp/launch_log
+4
View File
@@ -10,6 +10,10 @@ if [ -z "$REQUIRED_NEOS_VERSION" ]; then
export REQUIRED_NEOS_VERSION="15-1" export REQUIRED_NEOS_VERSION="15-1"
fi fi
if [ -z "$AGNOS_VERSION" ]; then
export AGNOS_VERSION="0.6"
fi
if [ -z "$PASSIVE" ]; then if [ -z "$PASSIVE" ]; then
export PASSIVE="1" export PASSIVE="1"
fi fi
Binary file not shown.
Binary file not shown.
+1
View File
@@ -1,6 +1,7 @@
.mypy_cache/ .mypy_cache/
*.pyc *.pyc
*.os *.os
*.o
*.tmp *.tmp
*.dylib *.dylib
.*.swp .*.swp
+4 -4
View File
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "acura_ilx_2016_can.dbc starts here" CM_ "acura_ilx_2016_can.dbc starts here";
+4 -4
View File
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "acura_rdx_2018_can.dbc starts here" CM_ "acura_rdx_2018_can.dbc starts here";
+4 -3
View File
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2020.dbc starts here" CM_ "Imported file _bosch_2020.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -375,7 +376,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "acura_rdx_2020_can.dbc starts here" CM_ "acura_rdx_2020_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
+8 -5
View File
@@ -1,4 +1,4 @@
Import('env', 'cereal', 'cython_dependencies') Import('env', 'envCython', 'cereal')
import os import os
from opendbc.can.process_dbc import process from opendbc.can.process_dbc import process
@@ -13,10 +13,13 @@ for x in sorted(os.listdir('../')):
dbc = env.Command(out_fn, in_fn, compile_dbc) dbc = env.Command(out_fn, in_fn, compile_dbc)
dbcs.append(dbc) dbcs.append(dbc)
libdbc = env.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]+dbcs, LIBS=["capnp", "kj"]) libdbc = env.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]+dbcs, LIBS=["capnp", "kj"])
# Build packer and parser # Build packer and parser
env.Command(['packer_pyx.so', 'packer_pyx.cpp', 'parser_pyx.so', 'parser_pyx.cpp'], lenv = envCython.Clone()
cython_dependencies + [libdbc, cereal, 'common_pyx_setup.py', 'common.pxd', 'packer_pyx.pyx', 'parser_pyx.pyx', 'packer.cc', 'parser.cc'], lenv["LINKFLAGS"] += [libdbc[0].get_labspath()]
"cd opendbc/can && python3 common_pyx_setup.py build_ext --inplace") parser = lenv.Program('parser_pyx.so', 'parser_pyx.pyx')
packer = lenv.Program('packer_pyx.so', 'packer_pyx.pyx')
lenv.Depends(parser, libdbc)
lenv.Depends(packer, libdbc)
+3 -6
View File
@@ -97,18 +97,17 @@ unsigned int volkswagen_crc(unsigned int address, uint64_t d, int l) {
// a magic variable padding byte tacked onto the end of the payload. // a magic variable padding byte tacked onto the end of the payload.
// https://www.autosar.org/fileadmin/user_upload/standards/classic/4-3/AUTOSAR_SWS_CRCLibrary.pdf // https://www.autosar.org/fileadmin/user_upload/standards/classic/4-3/AUTOSAR_SWS_CRCLibrary.pdf
uint8_t *dat = (uint8_t *)&d;
uint8_t crc = 0xFF; // Standard init value for CRC8 8H2F/AUTOSAR uint8_t crc = 0xFF; // Standard init value for CRC8 8H2F/AUTOSAR
// CRC the payload first, skipping over the first byte where the CRC lives. // CRC the payload first, skipping over the first byte where the CRC lives.
for (int i = 1; i < l; i++) { for (int i = 1; i < l; i++) {
crc ^= dat[i]; crc ^= (d >> (i*8)) & 0xFF;
crc = crc8_lut_8h2f[crc]; crc = crc8_lut_8h2f[crc];
} }
// Look up and apply the magic final CRC padding byte, which permutes by CAN // Look up and apply the magic final CRC padding byte, which permutes by CAN
// address, and additionally (for SOME addresses) by the message counter. // address, and additionally (for SOME addresses) by the message counter.
uint8_t counter = dat[1] & 0x0F; uint8_t counter = ((d >> 8) & 0xFF) & 0x0F;
switch(address) { switch(address) {
case 0x86: // LWI_01 Steering Angle case 0x86: // LWI_01 Steering Angle
crc ^= (uint8_t[]){0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86}[counter]; crc ^= (uint8_t[]){0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86}[counter];
@@ -176,11 +175,9 @@ unsigned int pedal_checksum(uint64_t d, int l) {
d >>= ((8-l)*8); // remove padding d >>= ((8-l)*8); // remove padding
d >>= 8; // remove checksum d >>= 8; // remove checksum
uint8_t *dat = (uint8_t *)&d;
int i, j; int i, j;
for (i = 0; i < l - 1; i++) { for (i = 0; i < l - 1; i++) {
crc ^= dat[i]; crc ^= (d >> (i*8)) & 0xFF;
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
if ((crc & 0x80) != 0) { if ((crc & 0x80) != 0) {
crc = (uint8_t)((crc << 1) ^ poly); crc = (uint8_t)((crc << 1) ^ poly);
+1 -1
View File
@@ -56,7 +56,7 @@ public:
const std::vector<SignalParseOptions> &sigoptions); const std::vector<SignalParseOptions> &sigoptions);
void UpdateCans(uint64_t sec, const capnp::List<cereal::CanData>::Reader& cans); void UpdateCans(uint64_t sec, const capnp::List<cereal::CanData>::Reader& cans);
void UpdateValid(uint64_t sec); void UpdateValid(uint64_t sec);
void update_string(std::string data, bool sendcan); void update_string(const std::string &data, bool sendcan);
std::vector<SignalValue> query_latest(); std::vector<SignalValue> query_latest();
}; };
-94
View File
@@ -1,94 +0,0 @@
import os
import subprocess
import sysconfig
import platform
from distutils.core import Extension, setup # pylint: disable=import-error,no-name-in-module
from Cython.Build import cythonize
from Cython.Distutils import build_ext
ANNOTATE = os.getenv('ANNOTATE') is not None
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../"))
def get_ext_filename_without_platform_suffix(filename):
name, ext = os.path.splitext(filename)
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
if ext_suffix == ext:
return filename
ext_suffix = ext_suffix.replace(ext, '')
idx = name.find(ext_suffix)
if idx == -1:
return filename
else:
return name[:idx] + ext
class BuildExtWithoutPlatformSuffix(build_ext):
def get_ext_filename(self, ext_name):
filename = super().get_ext_filename(ext_name)
return get_ext_filename_without_platform_suffix(filename)
extra_compile_args = ["-std=c++1z", "-Wno-nullability-completeness"]
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg
if ARCH == "aarch64":
extra_compile_args += ["-Wno-deprecated-register"]
if platform.system() == "Darwin":
libdbc = "libdbc.dylib"
else:
libdbc = "libdbc.so"
extra_link_args = [os.path.join(BASEDIR, 'opendbc', 'can', libdbc)]
include_dirs = [
BASEDIR,
os.path.join(BASEDIR, 'phonelibs'),
]
# Build CAN Parser
setup(name='CAN parser',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(
Extension(
"parser_pyx",
language="c++",
sources=['parser_pyx.pyx'],
extra_compile_args=extra_compile_args,
include_dirs=include_dirs,
extra_link_args=extra_link_args,
),
nthreads=4,
annotate=ANNOTATE
),
)
if platform.system() == "Darwin":
os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib parser_pyx.so")
# Build CAN Packer
setup(name='CAN packer',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize(
Extension(
"packer_pyx",
language="c++",
sources=['packer_pyx.pyx'],
extra_compile_args=extra_compile_args,
include_dirs=include_dirs,
extra_link_args=extra_link_args,
),
nthreads=4,
annotate=ANNOTATE
),
)
if platform.system() == "Darwin":
os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib packer_pyx.so")
+3 -3
View File
@@ -8,8 +8,8 @@ from libcpp.string cimport string
from libcpp cimport bool from libcpp cimport bool
from posix.dlfcn cimport dlopen, dlsym, RTLD_LAZY from posix.dlfcn cimport dlopen, dlsym, RTLD_LAZY
from common cimport CANPacker as cpp_CANPacker from .common cimport CANPacker as cpp_CANPacker
from common cimport dbc_lookup, SignalPackValue, DBC from .common cimport dbc_lookup, SignalPackValue, DBC
cdef class CANPacker: cdef class CANPacker:
@@ -22,7 +22,7 @@ cdef class CANPacker:
def __init__(self, dbc_name): def __init__(self, dbc_name):
self.dbc = dbc_lookup(dbc_name) self.dbc = dbc_lookup(dbc_name)
if not self.dbc: if not self.dbc:
raise RuntimeError("Can't lookup" + dbc_name) raise RuntimeError(f"Can't lookup {dbc_name}")
self.packer = new cpp_CANPacker(dbc_name) self.packer = new cpp_CANPacker(dbc_name)
num_msgs = self.dbc[0].num_msgs num_msgs = self.dbc[0].num_msgs
+1 -1
View File
@@ -208,7 +208,7 @@ void CANParser::UpdateValid(uint64_t sec) {
} }
} }
void CANParser::update_string(std::string data, bool sendcan) { void CANParser::update_string(const std::string &data, bool sendcan) {
// format for board, make copy due to alignment issues, will be freed on out of scope // format for board, make copy due to alignment issues, will be freed on out of scope
auto amsg = kj::heapArray<capnp::word>((data.length() / sizeof(capnp::word)) + 1); auto amsg = kj::heapArray<capnp::word>((data.length() / sizeof(capnp::word)) + 1);
memcpy(amsg.begin(), data.data(), data.length()); memcpy(amsg.begin(), data.data(), data.length());
+2 -2
View File
@@ -8,8 +8,8 @@ from libc.stdint cimport uint32_t, uint64_t, uint16_t
from libcpp.map cimport map from libcpp.map cimport map
from libcpp cimport bool from libcpp cimport bool
from common cimport CANParser as cpp_CANParser from .common cimport CANParser as cpp_CANParser
from common cimport SignalParseOptions, MessageParseOptions, dbc_lookup, SignalValue, DBC from .common cimport SignalParseOptions, MessageParseOptions, dbc_lookup, SignalValue, DBC
import os import os
import numbers import numbers
@@ -300,6 +300,7 @@ BO_ 501 DASHBOARD: 8 XXX
SG_ ACC_DISTANCE_CONFIG_1 : 1|2@0+ (1,0) [0|3] "" XXX SG_ ACC_DISTANCE_CONFIG_1 : 1|2@0+ (1,0) [0|3] "" XXX
SG_ ACC_DISTANCE_CONFIG_2 : 41|2@0+ (1,0) [0|3] "" XXX SG_ ACC_DISTANCE_CONFIG_2 : 41|2@0+ (1,0) [0|3] "" XXX
SG_ SPEED_DIGITAL : 63|8@0+ (1,0) [0|255] "mph" XXX SG_ SPEED_DIGITAL : 63|8@0+ (1,0) [0|255] "mph" XXX
SG_ CRUISE_STATE : 38|3@0+ (1,0) [0|7] "" XXX
BO_ 639 NEW_MSG_27f: 8 XXX BO_ 639 NEW_MSG_27f: 8 XXX
SG_ INCREASING : 47|8@0+ (1,0) [0|255] "" XXX SG_ INCREASING : 47|8@0+ (1,0) [0|255] "" XXX
@@ -425,9 +426,11 @@ CM_ SG_ 500 ACC_STATUS_1 "2 briefly (9 packets) when ACC goes to green, 1 help w
CM_ SG_ 500 BRAKE_MAYBE "2046 in non-ACC and non-decel. Signal on deceleration. 818 for already stopped break."; CM_ SG_ 500 BRAKE_MAYBE "2046 in non-ACC and non-decel. Signal on deceleration. 818 for already stopped break.";
CM_ SG_ 500 ACC_STATUS_2 "set to 1 in non-ACC, 3 when ACC enabled (white icon), and 7 when ACC in use (green icon)"; CM_ SG_ 500 ACC_STATUS_2 "set to 1 in non-ACC, 3 when ACC enabled (white icon), and 7 when ACC in use (green icon)";
CM_ SG_ 500 BRAKE_BOOL_1 "set to 1 when ACC decel. 0 on non-ACC and accel."; CM_ SG_ 500 BRAKE_BOOL_1 "set to 1 when ACC decel. 0 on non-ACC and accel.";
CM_ SG_ 501 CRUISE_STATE "may just be an icon, but seems to indicate different cruise modes: ACC and Non-ACC and engaged state for both.";
CM_ SG_ 625 SPEED "zero on non-acc drives"; CM_ SG_ 625 SPEED "zero on non-acc drives";
CM_ SG_ 625 ACCEL_PERHAPS "set to 7767 on non-ACC drives. ACC drive 40k is constant speed, 42k is accelerating"; CM_ SG_ 625 ACCEL_PERHAPS "set to 7767 on non-ACC drives. ACC drive 40k is constant speed, 42k is accelerating";
CM_ SG_ 268 BRAKE_PERHAPS "triggers only on ACC braking"; CM_ SG_ 268 BRAKE_PERHAPS "triggers only on ACC braking";
CM_ SG_ 384 NEW_SIGNAL_1 "set in ACC gas driving. not set in electric human. not sure about gas human driving."; CM_ SG_ 384 NEW_SIGNAL_1 "set in ACC gas driving. not set in electric human. not sure about gas human driving.";
VAL_ 501 CRUISE_STATE 0 "Off" 1 "CC On" 2 "CC Engaged" 3 "ACC On" 4 "ACC Engaged";
VAL_ 746 PRNDL 5 "L" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 746 PRNDL 5 "L" 4 "D" 3 "N" 2 "R" 1 "P" ;
VAL_ 792 TURN_SIGNALS 2 "Right" 1 "Left" ; VAL_ 792 TURN_SIGNALS 2 "Right" 1 "Left" ;
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_accord_lx15t_2018_can.dbc starts here" CM_ "honda_accord_lx15t_2018_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_accord_s2t_2018_can.dbc starts here" CM_ "honda_accord_s2t_2018_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_civic_hatchback_ex_2017_can.dbc starts here" CM_ "honda_civic_hatchback_ex_2017_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_civic_sedan_16_diesel_2019_can.dbc starts here" CM_ "honda_civic_sedan_16_diesel_2019_can.dbc starts here";
BO_ 316 GAS_PEDAL_2: 8 XXX BO_ 316 GAS_PEDAL_2: 8 XXX
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_civic_touring_2016_can.dbc starts here" CM_ "honda_civic_touring_2016_can.dbc starts here";
+2 -2
View File
@@ -1,6 +1,6 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "honda_crv_ex_2017_body.dbc starts here" CM_ "honda_crv_ex_2017_body.dbc starts here";
BO_ 318291879 BSM_STATUS_RIGHT: 8 XXX BO_ 318291879 BSM_STATUS_RIGHT: 8 XXX
SG_ BSM_ALERT : 4|1@0+ (1,0) [0|1] "" XXX SG_ BSM_ALERT : 4|1@0+ (1,0) [0|1] "" XXX
SG_ BSM_MODE : 6|2@0+ (1,0) [0|3] "" XXX SG_ BSM_MODE : 6|2@0+ (1,0) [0|3] "" XXX
+4 -3
View File
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_crv_ex_2017_can.dbc starts here" CM_ "honda_crv_ex_2017_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_crv_executive_2016_can.dbc starts here" CM_ "honda_crv_executive_2016_can.dbc starts here";
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_crv_hybrid_2019_can.dbc starts here" CM_ "honda_crv_hybrid_2019_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_crv_touring_2016_can.dbc starts here" CM_ "honda_crv_touring_2016_can.dbc starts here";
+4 -4
View File
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_fit_ex_2018_can.dbc starts here" CM_ "honda_fit_ex_2018_can.dbc starts here";
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_hrv_touring_2019_can.dbc starts here" CM_ "honda_hrv_touring_2019_can.dbc starts here";
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _bosch_2018.dbc starts here" CM_ "Imported file _bosch_2018.dbc starts here";
VERSION "" VERSION ""
@@ -48,6 +48,7 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS
SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS
SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS
@@ -379,7 +380,7 @@ CM_ SG_ 577 LINE_DASHED "1 = line is dashed";
CM_ SG_ 577 LINE_SOLID "1 = line is solid"; CM_ SG_ 577 LINE_SOLID "1 = line is solid";
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
CM_ "honda_insight_ex_2019_can.dbc starts here" CM_ "honda_insight_ex_2019_can.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM BO_ 304 GAS_PEDAL_2: 8 PCM
+4 -4
View File
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_odyssey_exl_2018.dbc starts here" CM_ "honda_odyssey_exl_2018.dbc starts here";
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_odyssey_extreme_edition_2018_china_can.dbc starts here" CM_ "honda_odyssey_extreme_edition_2018_china_can.dbc starts here";
@@ -1,7 +1,7 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "AUTOGENERATED FILE, DO NOT EDIT";
CM_ "Imported file _comma.dbc starts here" CM_ "Imported file _comma.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
@@ -19,7 +19,7 @@ BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
CM_ "Imported file _honda_2017.dbc starts here" CM_ "Imported file _honda_2017.dbc starts here";
VERSION "" VERSION ""
@@ -251,7 +251,7 @@ VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ;
VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ;
VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ;
CM_ "honda_pilot_touring_2017_can.dbc starts here" CM_ "honda_pilot_touring_2017_can.dbc starts here";

Some files were not shown because too many files have changed in this diff Show More