diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000000000..1646e38274bda2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: spektor56 +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://www.buymeacoffee.com/spektor56', 'https://paypal.me/spektor56'] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index f01c556e8f4c05..00000000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve openpilot -title: '' -labels: 'bug' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**How to reproduce or log data** -Steps to reproduce the behavior, or a explorer/cabana link to the exact drive and timestamp of when the bug occurred. - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Device/Version information (please complete the following information):** - - Device: [e.g. EON/EON Gold] - - Version: [e.g. 0.6.4], or commit hash when on devel - - Car make/model [e.g. Toyota Prius 2016] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 72e1845d7e124f..00000000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,21 +0,0 @@ -Choose one of the templates below: - -# Fingerprint -This pull requests adds a fingerprint for . - -This is an explorer link to a drive with the stock system enabled: ... - -# Car support -This pull requests adds support for . - -This is an explorer link to a drive with the stock system enabled: ... -This is an explorer link to a drive with openpilot system enabled: ... - -# Feature -This pull requests adds feature X - -## Description -Explain what the feature does - -## Testing -Explain how the feature was tested. Either by the added unit tests, or what tests were performed while driving. diff --git a/.gitignore b/.gitignore index 789f2728f3bdff..14ba0bd05eab12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv/ +.clang-format .DS_Store .tags .ipynb_checkpoints @@ -6,9 +7,10 @@ venv/ .overlay_init .overlay_consistent .sconsign.dblite -.vscode +.vscode* model2.png a.out +.hypothesis *.dylib *.DSYM @@ -20,7 +22,9 @@ a.out .*.un~ *.tmp *.o +*.o-* *.os +*.os-* *.so *.a *.clb @@ -29,6 +33,7 @@ a.out *.vcd config.json clcache +compile_commands.json persist board/obj/ @@ -37,12 +42,15 @@ selfdrive/logcatd/logcatd selfdrive/mapd/default_speeds_by_region.json selfdrive/proclogd/proclogd selfdrive/ui/_ui +selfdrive/ui/_soundd selfdrive/test/longitudinal_maneuvers/out selfdrive/visiond/visiond selfdrive/loggerd/loggerd +selfdrive/loggerd/bootlog selfdrive/sensord/_gpsd selfdrive/sensord/_sensord selfdrive/camerad/camerad +selfdrive/camerad/test/ae_gray_test selfdrive/modeld/_modeld selfdrive/modeld/_dmonitoringmodeld /src/ @@ -51,9 +59,20 @@ one openpilot notebooks xx +hyperthneed panda_jungle +provisioning .coverage* +coverage.xml htmlcov pandaextra +.mypy_cache/ +flycheck_* + +cppcheck_report.txt +comma*.sh + +selfdrive/modeld/thneed/compile +models/*.thneed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4cccc2daf0ea1..bcf05016ca9d61 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. -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 [blog](https://blog.comma.ai/). ## Getting Started @@ -12,29 +12,34 @@ Most open source development activity is coordinated through our [Discord](https ## 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 -All PRs are automatically checked by travis. Check out `.travis.yml` for what travis runs. Any new tests sould be added to travis. +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 is automatically check for style by travis as part of the automated tests. You can also run these yourself by running `check_code_quality.sh`. +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) -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://blog.comma.ai/openpilot-port-guide-for-toyota-models/) 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. See our bounties at [comma.ai/bounties.html](https://comma.ai/bounties.html) +If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/). ## Pull Requests -Pull requests should be against the master branch. Before running master on in-car hardware, you'll need to run +Pull requests should be against the master branch. Before running master on in-car hardware, you'll need to clone the submodules too. That can be done by recursively cloning the repository: +``` +git clone https://github.com/commaai/openpilot.git --recursive +``` +Or alternatively, when on the master branch: ``` -git submodule init -git submodule update +git submodule update --init ``` -in order to pull down the submodules, such as `panda` and `opendbc`. +The reasons for having submodules on a dedicated repository and our new development philosophy can be found in our [post about externalization](https://blog.comma.ai/a-2020-theme-externalization/). +Modules that are in seperate repositories include: +* cereal +* laika +* opendbc +* panda +* rednose diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000000000..f6d07bc8579c51 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,275 @@ +def phone(String ip, String step_label, String cmd) { + withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) { + def ssh_cmd = """ +ssh -tt -o StrictHostKeyChecking=no -i ${key_file} -p 8022 'comma@${ip}' /usr/bin/bash <<'EOF' + +set -e + +export CI=1 +export TEST_DIR=${env.TEST_DIR} +export SOURCE_DIR=${env.SOURCE_DIR} +export GIT_BRANCH=${env.GIT_BRANCH} +export GIT_COMMIT=${env.GIT_COMMIT} + +source ~/.bash_profile +if [ -f /TICI ]; then + source /etc/profile +fi + +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 +${cmd} +exit 0 + +EOF""" + + sh script: ssh_cmd, label: step_label + } +} + +def phone_steps(String device_type, steps) { + lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) { + timeout(time: 150, unit: 'MINUTES') { + phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) + steps.each { item -> + phone(device_ip, item[0], item[1]) + } + } + } +} + +pipeline { + agent none + environment { + TEST_DIR = "/data/openpilot" + SOURCE_DIR = "/data/openpilot_source/" + } + options { + timeout(time: 3, unit: 'HOURS') + } + + stages { + + stage('Build release2') { + agent { + docker { + image 'python:3.7.3' + args '--user=root' + } + } + when { + branch 'devel-staging' + } + steps { + phone_steps("eon-build", [ + ["build release2-staging & dashcam-staging", "cd release && PUSH=1 ./build_release2.sh"], + ]) + } + } + + stage('Build release3') { + agent { + docker { + image 'python:3.7.3' + args '--user=root' + } + } + when { + branch 'devel-staging' + } + steps { + phone_steps("tici", [ + ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release3.sh"], + ]) + } + } + + stage('openpilot tests') { + when { + not { + anyOf { + branch 'master-ci'; branch 'devel'; branch 'devel-staging'; + branch 'release2'; branch 'release2-staging'; branch 'dashcam'; branch 'dashcam-staging'; + branch 'release3'; branch 'release3-staging'; branch 'dashcam3'; branch 'dashcam3-staging'; + branch 'testing-closet*'; branch 'hotfix-*' + } + } + } + + stages { + + /* + stage('PC tests') { + agent { + dockerfile { + filename 'Dockerfile.openpilotci' + args '--privileged --shm-size=1G --user=root' + } + } + stages { + stage('Build') { + steps { + sh 'scons -j$(nproc)' + } + } + } + post { + always { + // fix permissions since docker runs as another user + sh "chmod -R 777 ." + } + } + } + */ + + stage('On-device Tests') { + agent { + docker { + /* + filename 'Dockerfile.ondevice_ci' + args "--privileged -v /dev:/dev --shm-size=1G --user=root" + */ + image 'python:3.7.3' + args '--user=root' + } + } + + stages { + stage('parallel tests') { + parallel { + stage('Devel Tests') { + steps { + phone_steps("eon-build", [ + ["build devel", "cd $SOURCE_DIR/release && EXTRA_FILES='tools/' ./build_devel.sh"], + ["build openpilot", "cd selfdrive/manager && ./build.py"], + ["test manager", "python selfdrive/manager/test/test_manager.py"], + ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], + ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], + ]) + } + } + + stage('Replay Tests') { + steps { + phone_steps("eon2", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"], + ]) + } + } + + stage('HW + Unit Tests') { + steps { + phone_steps("eon", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test athena", "nosetests -s selfdrive/athena/tests/test_athenad_old.py"], + ["test sounds", "nosetests -s selfdrive/ui/tests/test_sounds.py"], + ["test boardd loopback", "nosetests -s selfdrive/boardd/tests/test_boardd_loopback.py"], + ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], + ["test encoder", "python selfdrive/loggerd/tests/test_encoder.py"], + ["test logcatd", "python selfdrive/logcatd/tests/test_logcatd_android.py"], + //["test updater", "python installer/updater/test_updater.py"], + ]) + } + } + + /* + stage('Power Consumption Tests') { + steps { + lock(resource: "", label: "c2-zookeeper", inversePrecedence: true, variable: 'device_ip', quantity: 1) { + timeout(time: 90, unit: 'MINUTES') { + sh script: "/home/batman/tools/zookeeper/enable_and_wait.py $device_ip 120", label: "turn on device" + phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) + phone(device_ip, "build", "scons -j4 && sync") + sh script: "/home/batman/tools/zookeeper/disable.py $device_ip", label: "turn off device" + sh script: "/home/batman/tools/zookeeper/enable_and_wait.py $device_ip 120", label: "turn on device" + sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 3", label: "idle power consumption after boot" + sh script: "/home/batman/tools/zookeeper/ignition.py 1", label: "go onroad" + sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 10", label: "onroad power consumption" + sh script: "/home/batman/tools/zookeeper/ignition.py 0", label: "go offroad" + sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 2", label: "idle power consumption offroad" + } + } + } + } + */ + + stage('tici Build') { + environment { + R3_PUSH = "${env.BRANCH_NAME == 'master' ? '1' : ' '}" + } + steps { + phone_steps("tici", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], + ]) + } + } + + stage('Unit Tests (tici)') { + steps { + phone_steps("tici2", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], + ["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"], + ]) + } + } + + stage('camerad') { + steps { + phone_steps("eon-party", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], + ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], + ]) + } + } + + stage('Tici camerad') { + steps { + phone_steps("tici-party", [ + ["build", "cd selfdrive/manager && ./build.py"], + ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], + ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], + ]) + } + } + + } + } + + stage('Push master-ci') { + when { + branch 'master' + } + steps { + phone_steps("eon-build", [ + ["push devel", "cd $SOURCE_DIR/release && PUSH='master-ci' ./build_devel.sh"], + ]) + } + } + + } + + post { + always { + cleanWs() + } + } + + } + + } + } + } +} + diff --git a/README.md b/README.md index 42770fe80f77eb..80b0af5ccfaf23 100644 --- a/README.md +++ b/README.md @@ -1,308 +1,180 @@ -[![](https://i.imgur.com/UelUjKAh.png)](#) - -Table of Contents -======================= - -* [What is openpilot?](#what-is-openpilot) -* [Integration with Stock Features](#integration-with-stock-features) -* [Supported Hardware](#supported-hardware) -* [Supported Cars](#supported-cars) -* [Community Maintained Cars and Features](#community-maintained-cars-and-features) -* [Installation Instructions](#installation-instructions) -* [Limitations of openpilot ALC and LDW](#limitations-of-openpilot-alc-and-ldw) -* [Limitations of openpilot ACC and FCW](#limitations-of-openpilot-acc-and-fcw) -* [Limitations of openpilot DM](#limitations-of-openpilot-dm) -* [User Data and comma Account](#user-data-and-comma-account) -* [Safety and Testing](#safety-and-testing) -* [Testing on PC](#testing-on-pc) -* [Community and Contributing](#community-and-contributing) -* [Directory Structure](#directory-structure) -* [Licensing](#licensing) - ---- - -What is openpilot? +🚨 Read before installing! 🚨 +------ +The branch you are currently looking at is made for Honda/Acura. It will not work on other cars at it's current state, so please check the list for other branches or [Shane](https://github.com/sshane/openpilot) for Toyota/Lexus vehicles. + +🚨 Comma Pedal Users: 🚨 +------ +This is the correct branch to use if you have a pedal installed in your Honda/Acura. Not using a pedal while running this branch will result in a cruise fault on startup. + +[![](https://i.imgur.com/jrobDpP.jpg)](#) + +πŸš— Installation ------ +* Install via URL: https://smiskol.com/fork/aragon7777/0.8.10-model-0.8.9-honda-pedal (NOTE: On the C3, simply use smiskol.com/fork with no https://) +* Install via SSH on Comma Two: `cd /data; cp -rf ./openpilot ./openpilot.bak; rm -rf ./openpilot; git clone -b 0.8.10-model-0.8.9-honda-pedal --single-branch https://github.com/Aragon7777/openpilot.git && reboot` +* Install via SSH on Comma Three: `cd /data; cp -rf ./openpilot ./openpilot.bak; rm -rf ./openpilot; git clone -b 0.8.10-model-0.8.9-honda-pedal --single-branch https://github.com/Aragon7777/openpilot.git && sudo reboot` +* If a NEOS upgrade or downgrade is required, it's always best to factory reset and install stock Openpilot for that specific NEOS version. After that, proceed. -[openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, openpilot performs the functions of Adaptive Cruise Control (ACC), Automated Lane Centering (ALC), Forward Collision Warning (FCW) and Lane Departure Warning (LDW) for a growing variety of supported [car makes, models and model years](#supported-cars). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers. - - - - - - - - - - - - - - -
- -Integration with Stock Features +πŸš— Other Branch Definitions ------ - -In all supported cars: -* Stock Lane Keep Assist (LKA) and stock ALC are replaced by openpilot ALC, which only functions when openpilot is engaged by the user. -* Stock LDW is replaced by openpilot LDW. - -Additionally, on specific supported cars (see ACC column in [supported cars](#supported-cars)): -* Stock ACC is replaced by openpilot ACC. -* openpilot FCW operates in addition to stock FCW. - -openpilot should preserve all other vehicle's stock features, including, but are not limited to: FCW, Automatic Emergency Braking (AEB), auto high-beam, blind spot warning, and side collision warning. - -Supported Hardware +* Full: All the goodies and changes from me (like custom alerts, engagement in extra gears, nudgeless ALC) and overall quality-of-life fixes included. +* Clean: Core code from two different forks merged together with little to no additions from me whatsoever. Same as if found in the wild. +* Coasting: Only works well on Hondas & GMs. Branch has the functionality to coast beyond the set speed (including downhills) instead of using the brakes. +* Devel: Branches in development. Check the commit history to see what's being worked on. No stability guarantees. +* Personal: Branches used on my own fleet of cars. No stability guarantees. +* Shane: Includes some or all of [Shane's fork abilities](https://github.com/sshane/openpilot): Edit settings via SSH with `python op_edit.py`. +* DP: Includes [Dragonpilot](https://github.com/dragonpilot-community/dragonpilot) as the core. [Dragonpilot](https://github.com/dragonpilot-community/dragonpilot) has many different customization options accessible from the UI. +* Spektor: Lane keeping assist can be activated independently of adaptive cruise control. Only for Hondas before 0.8.6, Toyota support added recently. +* Honda: Honda-specific branch that utilizes the follow distance selector on the steering wheel to specific profiles. Not recommended for other cars. +* DevUI: The fancy user-interface that has a bunch of useful stats on-screen, colored path depending on torque, brake light icon, and much more. It often ends up out of date or not working on new updates and constantly has to be fixed. As such, I'll try to add this to as many branches as possible but it may not always make it in. +* Nudge: If a branch is named nudge, it will feature the stock comma method of requiring you to bump the wheel before a lane change begins. The rest of the branchs have some form of nudgeless lane change where the car will simply move over when the blinker is activated. +* Pedal: Branch optomized to work well with the Comma Gas Pedal Interceptor. My pedal tweaks exist in every branch but recent versions such as 0.8.8 have conflicts with tuning where making it smooth for the pedal creates a terrible jerky experince for everyone else without one. Thus, a dedicated pedal branch was born. + +Example: `0.8.6-dp-spektor-toyota` would contain Dragonpilot as the core, Spektor's independent LKAS and ACC, and tested to work on Toyotas. +Example: `0.8.2-shane-spektor` would contain [Shane](https://github.com/sshane/openpilot) as the core, plus Spektor's independent LKAS and ACC for Hondas. +Example: `0.8.6-release-honda` is designed specifically for Honda's follow distance selector. Other cars would see no benefit. + +πŸš— Attention Shane Branch Users: ------ - -At the moment, openpilot supports the [EON DevKit](https://comma.ai/shop/products/eon-dashcam-devkit) and the [comma two](https://comma.ai/shop/products/comma-two-devkit). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect the EON or comma two to the car. In the future, we'd like to support other platforms as well, like gaming PCs. - -Supported Cars +* Certain branches of Shane contain **submodules**. You can easily see this is the case if some folders are blue. As such, sometimes extra commands are required for proper installation. Installation may or may not compile if installed directly via the URL on the device. + +SSH Install on the Comma Three (Replace with branch): +`cd /data; cp -rf ./openpilot ./openpilot.bak; rm -rf ./openpilot; git clone https://github.com/Aragon7777/openpilot.git openpilot; cd openpilot; git checkout REPLACE_THIS_WITH_BRANCH_NAME && git submodule update --init --recursive && sudo reboot` + +SSH Install on the Comma Two (Replace with branch): +`cd /data; cp -rf ./openpilot ./openpilot.bak; rm -rf ./openpilot; git clone https://github.com/Aragon7777/openpilot.git openpilot; cd openpilot; git checkout REPLACE_THIS_WITH_BRANCH_NAME && git submodule update --init --recursive && reboot` + +If you already installed but it fails to compile (Comma Three): +`git submodule update --init --recursive && sudo reboot` + +If you already installed but it fails to compile (Comma Two): +`git submodule update --init --recursive && reboot` + + +β†ͺ️ Spektor56 behavior explained: ------ - -| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | -| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------| -| Acura | ILX 2016-18 | AcuraWatch Plus | openpilot | 25mph5 | 25mph | -| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph5 | 12mph | -| Chrysler | Pacifica 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 | -| Honda | Accord 2018-19 | All | Stock | 0mph | 3mph | -| Honda | Accord Hybrid 2018-19 | All | Stock | 0mph | 3mph | -| Honda | Civic Hatchback 2017-19 | Honda Sensing | Stock | 0mph | 12mph | -| Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | -| Honda | Civic Sedan/Coupe 2019 | Honda Sensing | Stock | 0mph | 2mph | -| Honda | CR-V 2015-16 | Touring | openpilot | 25mph5 | 12mph | -| Honda | CR-V 2017-19 | Honda Sensing | Stock | 0mph | 12mph | -| Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph | -| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph5 | 12mph | -| Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph5 | 0mph | -| Honda | Passport 2019 | All | openpilot | 25mph5 | 12mph | -| Honda | Pilot 2016-18 | Honda Sensing | openpilot | 25mph5 | 12mph | -| Honda | Pilot 2019 | All | openpilot | 25mph5 | 12mph | -| Honda | Ridgeline 2017-19 | Honda Sensing | openpilot | 25mph5 | 12mph | -| Hyundai | Elantra 2017-191 | SCC + LKAS | Stock | 19mph | 34mph | -| Hyundai | Genesis 20181 | All | Stock | 19mph | 34mph | -| Hyundai | Santa Fe 20191 | All | Stock | 0mph | 0mph | -| Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph | -| Jeep | Grand Cherokee 2019 | Adaptive Cruise | Stock | 0mph | 39mph | -| Kia | Optima 20191 | SCC + LKAS | Stock | 0mph | 0mph | -| Kia | Sorento 20181 | All | Stock | 0mph | 0mph | -| Kia | Stinger 20181 | SCC + LKAS | Stock | 0mph | 0mph | -| Lexus | CT Hybrid 2017-18 | All | Stock4| 0mph | 0mph | -| Lexus | ES 2019 | All | openpilot | 0mph | 0mph | -| Lexus | ES Hybrid 2019 | All | openpilot | 0mph | 0mph | -| Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph | -| Lexus | IS Hybrid 2017 | All | Stock | 0mph | 0mph | -| Lexus | NX Hybrid 2018 | All | Stock4| 0mph | 0mph | -| Lexus | RX 2016-17 | All | Stock4| 0mph | 0mph | -| Lexus | RX 2020 | All | openpilot | 0mph | 0mph | -| Lexus | RX Hybrid 2016-19 | All | Stock4| 0mph | 0mph | -| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | -| Subaru | Impreza 2019-20 | EyeSight | Stock | 0mph | 0mph | -| Toyota | Avalon 2016 | TSS-P | Stock4| 20mph5 | 0mph | -| Toyota | Avalon 2017-18 | All | Stock4| 20mph5 | 0mph | -| Toyota | Camry 2018-19 | All | Stock | 0mph2 | 0mph | -| Toyota | Camry Hybrid 2018-19 | All | Stock | 0mph2 | 0mph | -| Toyota | C-HR 2017-19 | All | Stock | 0mph | 0mph | -| Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph | -| Toyota | Corolla 2017-19 | All | Stock4| 20mph5 | 0mph | -| Toyota | Corolla 2020 | All | openpilot | 0mph | 0mph | -| Toyota | Corolla Hatchback 2019-20 | All | openpilot | 0mph | 0mph | -| Toyota | Corolla Hybrid 2020 | All | openpilot | 0mph | 0mph | -| Toyota | Highlander 2017-19 | All | Stock4| 0mph | 0mph | -| Toyota | Highlander Hybrid 2017-19 | All | Stock4| 0mph | 0mph | -| Toyota | Highlander 2020 | All | openpilot | 0mph | 0mph | -| Toyota | Prius 2016 | TSS-P | Stock4| 0mph | 0mph | -| Toyota | Prius 2017-19 | All | Stock4| 0mph | 0mph | -| Toyota | Prius Prime 2017-20 | All | Stock4| 0mph | 0mph | -| Toyota | Rav4 2016 | TSS-P | Stock4| 20mph5 | 0mph | -| Toyota | Rav4 2017-18 | All | Stock4| 20mph5 | 0mph | -| Toyota | Rav4 2019 | All | openpilot | 0mph | 0mph | -| Toyota | Rav4 Hybrid 2016 | TSS-P | Stock4| 0mph | 0mph | -| Toyota | Rav4 Hybrid 2017-18 | All | Stock4| 0mph | 0mph | -| Toyota | Rav4 Hybrid 2019-20 | All | openpilot | 0mph | 0mph | -| Toyota | Sienna 2018 | All | Stock4| 0mph | 0mph | -| Volkswagen| Golf 2016-193 | Driver Assistance | Stock | 0mph | 0mph | - -1Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and open sourced [Hyundai giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai), designed for the 2019 Sante Fe; pinout may differ for other Hyundai and Kia models.
-228mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
-3Requires a [custom connector](https://community.comma.ai/wiki/index.php/Volkswagen#Integration_at_R242_Camera) for the [car harness](https://comma.ai/shop/products/car-harness)
- -Community Maintained Cars and Features +* Honda and Toyota: Behavior like stock Honda or Toyota Sensing, thanks to Spektor56. +* LKAS and ACC are two separate functions that can be used independently. +* LKAS: Lane-keeping-assist-system. +* LKAS is activated using the LKAS button the steering wheel. +* LKAS is active when the built in HUD lanelines are solid. +* LKAS is inactive when the built in HUD lanelines are outlined (Honda) or do not exist (Toyota). +* LKAS will disengage on brake, but automatically come back. +* LKAS will disengage below the Auto Lane Change (ALC) speed with blinker. +* LKAS will stay disengaged briefly after blinkers, this helps driver recenter wheel. +* LKAS will stay disengaged if seatbelt unlatched, door open, or unsupported gear. +* ACC: Adaptive cruise control. +* ACC is activated using the SET or RES(ume) button on the steering wheel. +* ACC will disengage on brake, and never automatically come back until reset by the driver. +* ACC can be adjusted in increments of 1MPH or +5MPH by holding, even with a (Honda) comma pedal. +* ACC will not engage if seatbelt unlatched, door open, or unsupported gear. +* Pedal: Speeds can now be set in increments of +/- 1 and hold down for +/- 5, just like stock behavior. +* Driver Monitoring: Driver monitoring remains exactly the same as Comma's policy. + Note: Due to the separation of LKAS/ACC, driver monitoring requires fully disengaging and disabling both ACC and LKAS via their respective buttons, or pressing MAIN to clear a disengagment required alert. Failing to do so quickly enough might get you marked as too distracted and locked out until restarting the vehicle. Driver monitoring as a whole has been unchanged but this is a side effect to take into consideration. + +β†ͺ️ Shane Settings (access by ./op_edit.py) ------ - -| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | -| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------| -| Buick | Regal 20186 | Adaptive Cruise | openpilot | 0mph | 7mph | -| Cadillac | ATS 20186 | Adaptive Cruise | openpilot | 0mph | 7mph | -| Chevrolet | Malibu 20176 | Adaptive Cruise | openpilot | 0mph | 7mph | -| Chevrolet | Volt 2017-186 | Adaptive Cruise | openpilot | 0mph | 7mph | -| GMC | Acadia Denali 20186| Adaptive Cruise | openpilot | 0mph | 7mph | -| Holden | Astra 20176 | Adaptive Cruise | openpilot | 0mph | 7mph | - -4When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota). ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).***
-5[Comma Pedal](https://community.comma.ai/wiki/index.php/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. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).***
-6Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and [community built giraffe](https://zoneos.com/volt/). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).***
- -Community Maintained Cars and Features are not verified by comma to meet our [safety model](SAFETY.md). Be extra cautious using them. They are only available after enabling the toggle in `Settings->Developer->Enable Community Features`. - -Installation Instructions +β€’ Follow distance can be adjusted by pressing the "GAP Adjust" button. I usually run "traffic". + +**My Personal Settings** + +1. camera_offset: 0.06 +2. global_df_mod: 1.0 +3. min_TR: 0.9 +4. alca_no_nudge_speed: 30.0 +5. steer_ratio: None +6. upload_on_hotspot: True +7. disengage_on_gas: False +8. update_behavior: auto (static) +9. dynamic_gas: True +10. hide_auto_df_alerts: False +11. log_auto_df: False (static) +12. support_white_panda: False (static) +13. disable_charging: 30 (static) +14. prius_use_pid: False (static) +15. use_lqr: True (static) +16. corollaTSS2_use_indi: False (static) +17. rav4TSS2_use_indi: False (static) +18. standstill_hack: False (static) +19. username: None + +↩️ Dragonpilot Branch (DP) Settings (access via UI): +------ +β€’ In order to get follow and acceleration profiles, you must enable them in the settings. Only then will the selectors show up while the car is on. + +**My Personal Settings** + +DP - General: +**Services:** +β€’ Enable Updater Service: Enabled +β€’ Enable Log Service: Enabled +β€’ Enable Uploader Service: Enabled +β€’ Enable Athenad Service: Enabled +β€’ Enable Appd Service: Enabled +**Hardware - General:** +β€’ Enable Hotspot On Boot: Disabled +β€’ Camera Offset: 6cm (if your car hugs one side of the road, tune this yourself) +β€’ Fan Mode: 0 +β€’ Enable Auto Shutdown: Disabled +**Hardware - Non-C2:** +β€’ All options disabled. Toggle these if needed + +DP - Controls: +**Lateral:** +β€’ Lateral Ctrl Mode: 2 +β€’ LCA Min Speed: 30mph +β€’ ALCA Delay: 1 second +β€’ ALCA Min Speed: 30mph (min speed for nudgeless lane changes to happen, set to your liking. To disable, set Lateral Ctrl Mode to 1) +β€’ Enable Cont. ALCA: Enabled (for some reason, in recent DP versions lane changes are buggy without this enabled. Use caution) +β€’ Use LQR Controller: Disabled (some people have had good results with this especially on toyotas, try it out) +β€’ Enable Steering Ratio Learner: Disabled (SR learner tends to learn badly causing ping-pongs in a few days) +β€’ Driving Path Offset: 0cm +**Longitudinal:** +β€’ Use Accel Profile: Enabled (this enables a button on the bottom right while the car is on to toggle between normal, sport, and economy accelerations) +β€’ Use Following Profile: Enabled (this enables a button on the bottom right while the car is on to toggle follow distances in seconds) +β€’ Allow Gas Pedal Pressed: Enabled (this is required to be enabled when using a branch with Spektor) +β€’ Enable Gear Safety Check: Disabled (this lets you run Openpilot in other gears like sport and low, use caution) +**Safety:** +Enable Device Temp Check: Enabled +Enable Max Ctrl Speed Check: Disabled + +DP - UI: +β€’ Display Mode: Leave at default +β€’ Screen Brightness: Auto +β€’ Alert Volume: Auto +β€’ Display Speed: Enabled +β€’ Display Lane Prediction: Enabled +β€’ Display Lead Car Indicator: Enabled +β€’ Display Turning Signal / Blinkers: Enabled +β€’ Display Event / Steer Icon: Enabled +β€’ Display Max Speed: Enabled +β€’ Display Driver Monitor Indicator: Enabled +β€’ Display Side Info: Enabled +β€’ Display Top Info Bar: Enabled + +DP - Cars: +β€’ Keep everything disabled unless you have something specific to use, like a torque-modded civic + +πŸš— General features across all branches (other than clean): ------ - -Install openpilot on a EON by entering ``https://openpilot.comma.ai`` during the installer setup. - -Follow this [video instructions](https://youtu.be/3nlkomHathI) to properly mount the EON on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise EON mounting. - -Before placing the device on your windshield, check the state and local laws and ordinances where you drive. Some state laws prohibit or restrict the placement of objects on the windshield of a motor vehicle. - -You will be able to engage openpilot after reviewing the onboarding screens and finishing the calibration procedure. - -Limitations of openpilot ALC and LDW ------- - -openpilot ALC and openpilot LDW do not automatically drive the vehicle or reduce the amount of attention that must be paid to operate your vehicle. The driver must always keep control of the steering wheel and be ready to correct the openpilot ALC action at all times. - -While changing lanes, openpilot is not capable of looking next to you or checking your blind spot. Only nudge the wheel to initiate a lane change after you have confirmed it's safe to do so. - -Many factors can impact the performance of openpilot ALC and openpilot LDW, causing them to be unable to function as intended. These include, but are not limited to: - -* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. -* The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc. -* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. -* The EON is mounted incorrectly. -* When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce. -* In the presence of restricted lanes or construction zones. -* When driving on highly banked roads or in presence of strong cross-wind. -* Extremely hot or cold temperatures. -* Bright light (due to oncoming headlights, direct sunlight, etc.). -* Driving on hills, narrow, or winding roads. - -The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times. - -Limitations of openpilot ACC and FCW ------- - -openpilot ACC and openpilot FCW are not systems that allow careless or inattentive driving. It is still necessary for the driver to pay close attention to the vehicle’s surroundings and to be ready to re-take control of the gas and the brake at all times. - -Many factors can impact the performance of openpilot ACC and openpilot FCW, causing them to be unable to function as intended. These include, but are not limited to: - -* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. -* The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc. -* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. -* The EON is mounted incorrectly. -* Approaching a toll booth, a bridge or a large metal plate. -* When driving on roads with pedestrians, cyclists, etc... -* In presence of traffic signs or stop lights, which are not detected by openpilot at this time. -* When the posted speed limit is below the user selected set speed. openpilot does not detect speed limits at this time. -* In presence of vehicles in the same lane that are not moving. -* When abrupt braking maneuvers are required. openpilot is designed to be limited in the amount of deceleration and acceleration that it can produce. -* When surrounding vehicles perform close cut-ins from neighbor lanes. -* Driving on hills, narrow, or winding roads. -* Extremely hot or cold temperatures. -* Bright light (due to oncoming headlights, direct sunlight, etc.). -* Interference from other equipment that generates radar waves. - -The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times. - -Limitations of openpilot DM ------- - -openpilot DM should not be considered an exact measurements of the status of alertness of the driver. - -Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to: - -* Low light conditions, such as driving at night or in dark tunnels. -* Bright light (due to oncoming headlights, direct sunlight, etc.). -* The driver 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 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. - -User Data and comma Account ------- - -By default, openpilot uploads the driving data to our servers. You can also access your data by pairing with the comma connect app ([iOS](https://apps.apple.com/us/app/comma-connect/id1456551889), [Android](https://play.google.com/store/apps/details?id=ai.comma.connect&hl=en_US)). We use your data to train better models and improve openpilot for everyone. - -openpilot is open source software: the user is free to disable data collection if they wish to do so. - -openpilot logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs. -The driver facing camera is only logged if you explicitly opt-in in settings. The microphone is not recorded. - -By using openpilot, you agree to [our Privacy Policy](https://my.comma.ai/privacy). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma for the use of this data. - -Safety and Testing ----- - -* openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more detail. -* openpilot has software in the loop [tests](run_docker_tests.sh) 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. -* panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety). -* Internally, we have a hardware in the loop Jenkins test suite that builds and unit tests the various processes. -* panda has additional hardware in the loop [tests](https://github.com/commaai/panda/blob/master/Jenkinsfile). -* We run the latest openpilot in a testing closet containing 10 EONs continuously replaying routes. - -Testing on PC ------- - -Check out the tools directory in master: lots of tools you can use to replay driving data, test and develop openpilot from your pc. - -Community and Contributing ------- - -openpilot is developed by [comma](https://comma.ai/) and by users like you. We welcome both pull requests and issues on [GitHub](http://github.com/commaai/openpilot). Bug fixes and new car ports are encouraged. - -You can add support for your car by following guides we have written for [Brand](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84) and [Model](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) ports. Generally, a car with adaptive cruise control and lane keep assist is a good candidate. [Join our Discord](https://discord.comma.ai) to discuss car ports: most car makes have a dedicated channel. - -Want to get paid to work on openpilot? [comma is hiring](https://comma.ai/jobs/). We also have a [bounty program](https://comma.ai/bounties.html). - -And [follow us on Twitter](https://twitter.com/comma_ai). - -Directory Structure ------- - . - β”œβ”€β”€ apk # The apk files used for the UI - β”œβ”€β”€ cereal # The messaging spec and libs used for all logs on EON - β”œβ”€β”€ common # Library like functionality we've developed here - β”œβ”€β”€ installer/updater # Manages auto-updates of openpilot - β”œβ”€β”€ opendbc # Files showing how to interpret data from cars - β”œβ”€β”€ panda # Code used to communicate on CAN - β”œβ”€β”€ phonelibs # Libraries used on EON - β”œβ”€β”€ pyextra # Libraries used on EON - └── selfdrive # Code needed to drive the car - β”œβ”€β”€ assets # Fonts and images for UI - β”œβ”€β”€ athena # Allows communication with the app - β”œβ”€β”€ boardd # Daemon to talk to the board - β”œβ”€β”€ camerad # Driver to capture images from the camera sensors - β”œβ”€β”€ car # Car specific code to read states and control actuators - β”œβ”€β”€ common # Shared C/C++ code for the daemons - β”œβ”€β”€ controls # Perception, planning and controls - β”œβ”€β”€ debug # Tools to help you debug and do car ports - β”œβ”€β”€ locationd # Soon to be home of precise location - β”œβ”€β”€ logcatd # Android logcat as a service - β”œβ”€β”€ loggerd # Logger and uploader of car data - β”œβ”€β”€ modeld # Driving and monitoring model runners - β”œβ”€β”€ proclogd # Logs information from proc - β”œβ”€β”€ sensord # IMU / GPS interface code - β”œβ”€β”€ tests # Unit tests, system tests and a car simulator - └── ui # The UI - -To understand how the services interact, see `cereal/service_list.yaml`. - -Licensing ------- - -openpilot is released under the MIT license. Some parts of the software are released under other licenses as specified. - -Any user of this software shall indemnify and hold harmless comma.ai, Inc. and its directors, officers, employees, agents, stockholders, affiliates, subcontractors and customers from and against all allegations, claims, actions, suits, demands, damages, liabilities, obligations, losses, settlements, judgments, costs and expenses (including without limitation attorneys’ fees and costs) which arise out of, relate to or result from any use of this software by user. - -**THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. -YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS. -NO WARRANTY EXPRESSED OR IMPLIED.** - ---- - - +* Alerts have mostly been rewritten. Better grammar, less annoying, and more details on specific events. +* Engagement sounds have been muted. For moderate or major warnings, the Tesla warning sound will play. +* Update prompt forcing an internet connection to check for updates has been disabled. +* Engagement in gears other than drive, such as sport and low. +* Reduced the potentional for false driving model lagging alerts. + +πŸ† Special Thanks +------ +[Spektor56](https://github.com/spektor56/openpilot) +[eisenheim](https://github.com/eyezenheim/openpilot) +[ShaneSmiskol](https://github.com/ShaneSmiskol/openpilot) +[wirelessnet2](https://github.com/wirelessnet2/openpilot) +[kegman](https://github.com/kegman/openpilot) +[cfranhonda](https://github.com/cfranhonda/openpilot) +[doktor](https://github.com/doktorsleepelss) +[qadmus](https://github.com/qadmus/openpilot) +[reddn](https://github.com/reddn) + +πŸ“¬ Contact +------ +If you'd like to reach out to me, message `Aragon#7777` on Discord, or tag me in #custom-forks on the official Comma server regarding this branch. diff --git a/RELEASES.md b/RELEASES.md index c0a859003bc03d..3434221a71cbd4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,6 +1,190 @@ +Version 0.8.8 (2021-08-27) +======================== + * New driving model with improved laneless performance + * Trained on 5000+ hours of diverse driving data from 3000+ users in 40+ countries + * Better anti-cheating methods during simulator training ensure the model hugs less when in laneless mode + * All new desire ground-truthing stack makes the model better at lane changes + * New driver monitoring model: improved performance on comma three + * NEOS 18 for comma two: update packages + * AGNOS 1.3 for comma three: fix display init at high temperatures + * Improved auto-exposure on comma three + * Hyundai Kona Hybrid 2020 support thanks to haram-KONA! + * Hyundai Sonata Hybrid 2021 support thanks to Matt-Wash-Burn! + * Kia Niro Hybrid 2021 support thanks to tetious! + +Version 0.8.7 (2021-07-31) +======================== + * comma three support! + * Navigation alpha for the comma three! + * Volkswagen T-Cross 2021 support thanks to jyoung8607! + +Version 0.8.6 (2021-07-21) +======================== + * Revamp lateral and longitudinal planners + * Refactor planner output API to be more readable and verbose + * Planners now output desired trajectories for speed, acceleration, curvature, and curvature rate + * Use MPC for longitudinal planning when no lead car is present, makes accel and decel smoother + * Remove "CHECK DRIVER FACE VISIBILITY" warning + * Fixed cruise fault on some TSS2.5 Camrys and international Toyotas + * Hyundai Elantra Hybrid 2021 support thanks to tecandrew! + * Hyundai Ioniq PHEV 2020 support thanks to YawWashout! + * Kia Niro Hybrid 2019 support thanks to jyoung8607! + * Ε koda Octavia RS 2016 support thanks to jyoung8607! + * Toyota Alphard 2020 support thanks to belm0! + * Volkswagen Golf SportWagen 2015 support thanks to jona96! + * Volkswagen Touran 2017 support thanks to jyoung8607! + +Version 0.8.5 (2021-06-11) +======================== + * NEOS update: improved reliability and stability with better voltage regulator configuration + * Smart model-based Forward Collision Warning + * CAN-based fingerprinting moved behind community features toggle + * Improved longitudinal control on Toyotas with a comma pedal + * Improved auto-brightness using road-facing camera + * Added "Software" settings page with updater controls + * Audi Q2 2018 support thanks to jyoung8607! + * Hyundai Elantra 2021 support thanks to CruiseBrantley! + * Lexus UX Hybrid 2019-2020 support thanks to brianhaugen2! + * Toyota Avalon Hybrid 2019 support thanks to jbates9011! + * SEAT Leon 2017 & 2020 support thanks to jyoung8607! + * Ε koda Octavia 2015 & 2019 support thanks to jyoung8607! + +Version 0.8.4 (2021-05-17) +======================== + * Delay controls start until system is ready + * Fuzzy car identification, enabled with Community Features toggle + * Localizer optimized for increased precision and less CPU usage + * Retuned lateral control to be more aggressive when model is confident + * Toyota Mirai 2021 support + * Lexus NX 300 2020 support thanks to goesreallyfast! + * Volkswagen Atlas 2018-19 support thanks to jyoung8607! + +Version 0.8.3 (2021-04-01) +======================== + * New model + * Trained on new diverse dataset from 2000+ users from 30+ countries + * Trained with improved segnet from the comma-pencil community project + * πŸ₯¬ Dramatically improved end-to-end lateral performance πŸ₯¬ + * Toggle added to disable the use of lanelines + * NEOS update: update packages and support for new UI + * New offroad UI based on Qt + * Default SSH key only used for setup + * Kia Ceed 2019 support thanks to ZanZaD13! + * Kia Seltos 2021 support thanks to speedking456! + * Added support for many Volkswagen and Ε koda models thanks to jyoung8607! + +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) +======================== + * Grey panda is deprecated, upgrade to comma two or black panda + * NEOS update: update to Python 3.8.2 and lower CPU frequency + * Improved thermals due to reduced CPU frequency + * Update SNPE to 1.41.0 + * Reduced offroad power consumption + * Various system stability improvements + * Acura RDX 2020 support thanks to csouers! + +Version 0.7.9 (2020-10-09) +======================== + * Improved car battery power management + * Improved updater robustness + * Improved realtime performance + * Reduced UI and modeld lags + * Increased torque on 2020 Hyundai Sonata and Palisade + +Version 0.7.8 (2020-08-19) +======================== + * New driver monitoring model: improved face detection and better compatibility with sunglasses + * Download NEOS operating system updates in the background + * Improved updater reliability and responsiveness + * Hyundai Kona 2020, Veloster 2019, and Genesis G70 2018 support thanks to xps-genesis! + +Version 0.7.7 (2020-07-20) +======================== + * White panda is no longer supported, upgrade to comma two or black panda + * Improved vehicle model estimation using high precision localizer + * Improved thermal management on comma two + * Improved autofocus for road-facing camera + * Improved noise performance for driver-facing camera + * Block lane change start using blindspot monitor on select Toyota, Hyundai, and Subaru + * Fix GM ignition detection + * Code cleanup and smaller release sizes + * Hyundai Sonata 2020 promoted to officially supported car + * Hyundai Ioniq Electric Limited 2019 and Ioniq SE 2020 support thanks to baldwalker! + * Subaru Forester 2019 and Ascent 2019 support thanks to martinl! + +Version 0.7.6.1 (2020-06-16) +======================== + * Hotfix: update kernel on some comma twos (orders #8570-#8680) + +Version 0.7.6 (2020-06-05) +======================== + * White panda is deprecated, upgrade to comma two or black panda + * 2017 Nissan X-Trail, 2018-19 Leaf and 2019 Rogue support thanks to avolmensky! + * 2017 Mazda CX-5 support in dashcam mode thanks to Jafaral! + * Huge CPU savings in modeld by using thneed! + * Lots of code cleanup and refactors + +Version 0.7.5 (2020-05-13) +======================== + * Right-Hand Drive support for both driving and driver monitoring! + * New driving model: improved at sharp turns and lead speed estimation + * New driver monitoring model: overall improvement on comma two + * Driver camera preview in settings to improve mounting position + * Added support for many Hyundai, Kia, Genesis models thanks to xx979xx! + * Improved lateral tuning for 2020 Toyota Rav 4 (hybrid) + +Version 0.7.4 (2020-03-20) +======================== + * New driving model: improved lane changes and lead car detection + * Improved driver monitoring model: improve eye detection + * Improved calibration stability + * Improved lateral control on some 2019 and 2020 Toyota Prius + * Improved lateral control on VW Golf: 20% more steering torque + * Fixed bug where some 2017 and 2018 Toyota C-HR would use the wrong steering angle sensor + * Support for Honda Insight thanks to theantihero! + * Code cleanup in car abstraction layers and ui + Version 0.7.3 (2020-02-21) ======================== - * Improved autofocus for road facing camera * Support for 2020 Highlander thanks to che220! * Support for 2018 Lexus NX 300h thanks to kengggg! * Speed up ECU firmware query @@ -422,96 +606,96 @@ Version 0.3.4 (2017-07-28) Version 0.3.3 (2017-06-28) =========================== - * Improved model trained on more data - * Alpha CR-V support thanks to energee and johnnwvs! - * Using the opendbc project for DBC files - * Minor performance improvements - * UI update thanks to pjlao307 - * Power off button - * 6% more torque on the Civic + * Improved model trained on more data + * Alpha CR-V support thanks to energee and johnnwvs! + * Using the opendbc project for DBC files + * Minor performance improvements + * UI update thanks to pjlao307 + * Power off button + * 6% more torque on the Civic Version 0.3.2 (2017-05-22) =========================== - * Minor stability bugfixes - * Added metrics and rear view mirror disable to settings - * Update model with more crowdsourced data + * Minor stability bugfixes + * Added metrics and rear view mirror disable to settings + * Update model with more crowdsourced data Version 0.3.1 (2017-05-17) =========================== - * visiond stability bugfix - * Add logging for angle and flashing + * visiond stability bugfix + * Add logging for angle and flashing Version 0.3.0 (2017-05-12) =========================== - * Add CarParams struct to improve the abstraction layer - * Refactor visiond IPC to support multiple clients - * Add raw GPS and beginning support for navigation - * Improve model in visiond using crowdsourced data - * Add improved system logging to diagnose instability - * Rewrite baseui in React Native - * Moved calibration to the cloud + * Add CarParams struct to improve the abstraction layer + * Refactor visiond IPC to support multiple clients + * Add raw GPS and beginning support for navigation + * Improve model in visiond using crowdsourced data + * Add improved system logging to diagnose instability + * Rewrite baseui in React Native + * Moved calibration to the cloud Version 0.2.9 (2017-03-01) =========================== - * Retain compatibility with NEOS v1 + * Retain compatibility with NEOS v1 Version 0.2.8 (2017-02-27) =========================== - * Fix bug where frames were being dropped in minute 71 + * Fix bug where frames were being dropped in minute 71 Version 0.2.7 (2017-02-08) =========================== - * Better performance and pictures at night - * Fix ptr alignment issue in boardd - * Fix brake error light, fix crash if too cold + * Better performance and pictures at night + * Fix ptr alignment issue in boardd + * Fix brake error light, fix crash if too cold Version 0.2.6 (2017-01-31) =========================== - * Fix bug in visiond model execution + * Fix bug in visiond model execution Version 0.2.5 (2017-01-30) =========================== - * Fix race condition in manager + * Fix race condition in manager Version 0.2.4 (2017-01-27) =========================== - * OnePlus 3T support - * Enable installation as NEOS app - * Various minor bugfixes + * OnePlus 3T support + * Enable installation as NEOS app + * Various minor bugfixes Version 0.2.3 (2017-01-11) =========================== - * Reduce space usage by 80% - * Add better logging - * Add Travis CI + * Reduce space usage by 80% + * Add better logging + * Add Travis CI Version 0.2.2 (2017-01-10) =========================== - * Board triggers started signal on CAN messages - * Improved autoexposure - * Handle out of space, improve upload status + * Board triggers started signal on CAN messages + * Improved autoexposure + * Handle out of space, improve upload status Version 0.2.1 (2016-12-14) =========================== - * Performance improvements, removal of more numpy - * Fix boardd process priority - * Make counter timer reset on use of steering wheel + * Performance improvements, removal of more numpy + * Fix boardd process priority + * Make counter timer reset on use of steering wheel Version 0.2 (2016-12-12) ========================= - * Car/Radar abstraction layers have shipped, see cereal/car.capnp - * controlsd has been refactored - * Shipped plant model and testing maneuvers - * visiond exits more gracefully now - * Hardware encoder in visiond should always init - * ui now turns off the screen after 30 seconds - * Switch to openpilot release branch for future releases - * Added preliminary Docker container to run tests on PC + * Car/Radar abstraction layers have shipped, see cereal/car.capnp + * controlsd has been refactored + * Shipped plant model and testing maneuvers + * visiond exits more gracefully now + * Hardware encoder in visiond should always init + * ui now turns off the screen after 30 seconds + * Switch to openpilot release branch for future releases + * Added preliminary Docker container to run tests on PC Version 0.1 (2016-11-29) ========================= - * Initial release of openpilot - * Adaptive cruise control is working - * Lane keep assist is working - * Support for Acura ILX 2016 with AcuraWatch Plus - * Support for Honda Civic 2016 Touring Edition + * Initial release of openpilot + * Adaptive cruise control is working + * Lane keep assist is working + * Support for Acura ILX 2016 with AcuraWatch Plus + * Support for Honda Civic 2016 Touring Edition diff --git a/SAFETY.md b/SAFETY.md index 5a3c287fe9988a..d36d53437efac6 100644 --- a/SAFETY.md +++ b/SAFETY.md @@ -1,7 +1,7 @@ openpilot Safety ====== -openpilot is an Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) system. +openpilot is an Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) system. Like other ACC and ALC systems, openpilot is a failsafe passive system and it requires the driver to be alert and to pay attention at all times. @@ -15,20 +15,20 @@ used safely** and openpilot is provided with no warranty of fitness for any purp openpilot is developed in good faith to be compliant with FMVSS requirements and to follow industry standards of safety for Level 2 Driver Assistance Systems. In particular, we observe ISO26262 guidelines, including those from [pertinent documents](https://www.nhtsa.gov/sites/nhtsa.dot.gov/files/documents/13498a_812_573_alcsystemreport.pdf) -released by NHTSA. In addition, we impose strict coding guidelines (like [MISRA C : 2012](https://www.misra.org.uk/MISRAHome/MISRAC2012/tabid/196/Default.aspx)) +released by NHTSA. In addition, we impose strict coding guidelines (like [MISRA C : 2012](https://www.misra.org.uk/what-is-misra/)) on parts of openpilot that are safety relevant. We also perform software-in-the-loop, hardware-in-the-loop and in-vehicle tests before each software release. Following Hazard and Risk Analysis and FMEA, at a very high level, we have designed openpilot ensuring two main safety requirements. -1. The driver must always be capable to immediately retake manual control of the vehicle, +1. The driver must always be capable to immediately retake manual control of the vehicle, by stepping on either pedal or by pressing the cancel button. 2. The vehicle must not alter its trajectory too quickly for the driver to safely react. This means that while the system is engaged, the actuators are constrained to operate within reasonable limits. -For vehicle specific implementation of the safety concept, refer to `panda/board/safety/`. +For additional safety implementation details, refer to [panda safety model](https://github.com/commaai/panda#safety-model). For vehicle specific implementation of the safety concept, refer to [panda/board/safety/](https://github.com/commaai/panda/tree/master/board/safety). **Extra note**: comma.ai strongly discourages the use of openpilot forks with safety code either missing or not fully meeting the above requirements. diff --git a/SConstruct b/SConstruct index 5944541b5b8155..02a93eb98d33b0 100644 --- a/SConstruct +++ b/SConstruct @@ -1,95 +1,174 @@ import os +import shutil import subprocess import sys +import sysconfig import platform +import numpy as np + +TICI = os.path.isfile('/TICI') +Decider('MD5-timestamp') AddOption('--test', action='store_true', help='build test files') +AddOption('--setup', + action='store_true', + help='build setup and installer files') + +AddOption('--kaitai', + action='store_true', + help='Regenerate kaitai struct parsers') + AddOption('--asan', action='store_true', help='turn on ASAN') -arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() +AddOption('--ubsan', + action='store_true', + 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('--snpe', + action='store_true', + help='use SNPE on PC') + +AddOption('--external-sconscript', + action='store', + metavar='FILE', + dest='external_sconscript', + help='add an external SConscript to the build') + +AddOption('--no-thneed', + action='store_true', + dest='no_thneed', + help='avoid using thneed') + +real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() if platform.system() == "Darwin": arch = "Darwin" -if arch == "aarch64": - lenv = { - "LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib', - "PATH": os.environ['PATH'], - "ANDROID_DATA": os.environ['ANDROID_DATA'], - "ANDROID_ROOT": os.environ['ANDROID_ROOT'], - } +if arch == "aarch64" and TICI: + arch = "larch64" + +USE_WEBCAM = os.getenv("USE_WEBCAM") is not None + +lenv = { + "PATH": os.environ['PATH'], +} + +if arch == "aarch64" or arch == "larch64": + lenv["LD_LIBRARY_PATH"] = '/data/data/com.termux/files/usr/lib' + + if arch == "aarch64": + # android + lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA'] + lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT'] cpppath = [ "#phonelibs/opencl/include", ] + libpath = [ - "#phonelibs/snpe/aarch64-android-clang3.8", + "/usr/local/lib", "/usr/lib", - "/data/data/com.termux/files/usr/lib", "/system/vendor/lib64", "/system/comma/usr/lib", "#phonelibs/nanovg", - "#phonelibs/libyuv/lib", ] - cflags = ["-DQCOM", "-mcpu=cortex-a57"] - cxxflags = ["-DQCOM", "-mcpu=cortex-a57"] - - rpath = ["/system/vendor/lib64"] + if arch == "larch64": + libpath += [ + "#phonelibs/snpe/larch64", + "#phonelibs/libyuv/larch64/lib", + "/usr/lib/aarch64-linux-gnu" + ] + cpppath += [ + "#selfdrive/camerad/include", + ] + cflags = ["-DQCOM2", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"] + rpath = ["/usr/local/lib"] + else: + libpath += [ + "#phonelibs/snpe/aarch64", + "#phonelibs/libyuv/lib", + "/system/vendor/lib64" + ] + cflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] + rpath = [] else: - lenv = { - "PATH": "#external/bin:" + os.environ['PATH'], - } - cpppath = [ - "#phonelibs/capnp-cpp/include", - "#phonelibs/capnp-c/include", - "#phonelibs/zmq/x64/include", - "#external/tensorflow/include", - ] + cflags = [] + cxxflags = [] + cpppath = [] if arch == "Darwin": + yuv_dir = "mac" if real_arch != "arm64" else "mac_arm64" libpath = [ - "#phonelibs/capnp-cpp/mac/lib", - "#phonelibs/capnp-c/mac/lib", - "#phonelibs/libyuv/mac/lib", - "#cereal", - "#selfdrive/common", + f"#phonelibs/libyuv/{yuv_dir}/lib", "/usr/local/lib", + "/opt/homebrew/lib", + "/usr/local/opt/openssl/lib", + "/opt/homebrew/opt/openssl/lib", "/System/Library/Frameworks/OpenGL.framework/Libraries", ] + cflags += ["-DGL_SILENCE_DEPRECATION"] + cxxflags += ["-DGL_SILENCE_DEPRECATION"] + cpppath += [ + "/opt/homebrew/include", + "/usr/local/opt/openssl/include", + "/opt/homebrew/opt/openssl/include" + ] else: libpath = [ - "#phonelibs/capnp-cpp/x64/lib", - "#phonelibs/capnp-c/x64/lib", "#phonelibs/snpe/x86_64-linux-clang", - "#phonelibs/zmq/x64/lib", "#phonelibs/libyuv/x64/lib", - "#external/zmq/lib", - "#external/tensorflow/lib", + "#phonelibs/mapbox-gl-native-qt/x86_64", "#cereal", "#selfdrive/common", "/usr/lib", "/usr/local/lib", ] - rpath = ["phonelibs/capnp-cpp/x64/lib", - "phonelibs/zmq/x64/lib", - "external/tensorflow/lib", - "cereal", - "selfdrive/common"] + rpath = [ + "phonelibs/snpe/x86_64-linux-clang", + "cereal", + "selfdrive/common" + ] # allows shared libraries to work globally rpath = [os.path.join(os.getcwd(), x) for x in rpath] - cflags = [] - cxxflags = [] +if GetOption('asan'): + ccflags = ["-fsanitize=address", "-fno-omit-frame-pointer"] + ldflags = ["-fsanitize=address"] +elif GetOption('ubsan'): + ccflags = ["-fsanitize=undefined"] + ldflags = ["-fsanitize=undefined"] +else: + ccflags = [] + ldflags = [] -ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else [] -ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else [] +# no --as-needed on mac linker +if arch != "Darwin": + ldflags += ["-Wl,--as-needed"] + +# Enable swaglog include in submodules +cflags += ["-DSWAGLOG"] +cxxflags += ["-DSWAGLOG"] # change pythonpath to this lenv["PYTHONPATH"] = Dir("#").path @@ -100,59 +179,65 @@ env = Environment( "-g", "-fPIC", "-O2", - "-Werror=implicit-function-declaration", - "-Werror=incompatible-pointer-types", - "-Werror=int-conversion", - "-Werror=return-type", - "-Werror=format-extra-args", - ] + cflags + ccflags_asan, + "-Wunused", + "-Werror", + "-Wno-unknown-warning-option", + "-Wno-deprecated-register", + "-Wno-register", + "-Wno-inconsistent-missing-override", + "-Wno-c99-designator", + "-Wno-reorder-init-list", + ] + cflags + ccflags, CPPPATH=cpppath + [ "#", - "#selfdrive", + "#phonelibs/catch2/include", "#phonelibs/bzip2", "#phonelibs/libyuv/include", "#phonelibs/openmax/include", - "#phonelibs/json/src", "#phonelibs/json11", - "#phonelibs/eigen", "#phonelibs/curl/include", - "#phonelibs/opencv/include", "#phonelibs/libgralloc/include", "#phonelibs/android_frameworks_native/include", "#phonelibs/android_hardware_libhardware/include", "#phonelibs/android_system_core/include", "#phonelibs/linux/include", "#phonelibs/snpe/include", + "#phonelibs/mapbox-gl-native-qt/include", "#phonelibs/nanovg", - "#selfdrive/common", - "#selfdrive/camerad", - "#selfdrive/camerad/include", - "#selfdrive/loggerd/include", - "#selfdrive/modeld", - "#cereal/messaging", + "#phonelibs/qrcode", + "#phonelibs", "#cereal", "#opendbc/can", ], CC='clang', CXX='clang++', - LINKFLAGS=ldflags_asan, + LINKFLAGS=ldflags, RPATH=rpath, CFLAGS=["-std=gnu11"] + cflags, - CXXFLAGS=["-std=c++14"] + cxxflags, - LIBPATH=libpath + - [ + CXXFLAGS=["-std=c++1z"] + cxxflags, + LIBPATH=libpath + [ "#cereal", - "#selfdrive/common", "#phonelibs", - ] + "#opendbc/can", + "#selfdrive/boardd", + "#selfdrive/common", + ], + CYTHONCFILESUFFIX=".cpp", + COMPILATIONDB_USE_ABSPATH=True, + tools=["default", "cython", "compilation_db"], ) -if os.environ.get('SCONS_CACHE'): - CacheDir('/tmp/scons_cache') +if GetOption('compile_db'): + env.CompilationDatabase('compile_commands.json') + +# Setup cache dir +cache_dir = '/data/scons_cache' if TICI else '/tmp/scons_cache' +CacheDir(cache_dir) +Clean(["."], cache_dir) node_interval = 5 node_count = 0 @@ -175,10 +260,104 @@ def abspath(x): # rpath works elsewhere return x[0].path.rsplit("/", 1)[1][:-3] -#zmq = 'zmq' -# still needed for apks -zmq = FindFile("libzmq.a", libpath) -Export('env', 'arch', 'zmq', 'SHARED') +# 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 = env.Clone() +qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning"] +if arch != "aarch64": + qt_modules += ["DBus"] + +qt_libs = [] +if arch == "Darwin": + if real_arch == "arm64": + qt_env['QTDIR'] = "/opt/homebrew/opt/qt@5" + else: + qt_env['QTDIR'] = "/usr/local/opt/qt@5" + qt_dirs = [ + os.path.join(qt_env['QTDIR'], "include"), + ] + qt_dirs += [f"{qt_env['QTDIR']}/include/Qt{m}" for m in qt_modules] + qt_env["LINKFLAGS"] += ["-F" + os.path.join(qt_env['QTDIR'], "lib")] + qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] +elif arch == "aarch64": + qt_env['QTDIR'] = "/system/comma/usr" + qt_dirs = [ + f"/system/comma/usr/include/qt", + ] + qt_dirs += [f"/system/comma/usr/include/qt/Qt{m}" for m in qt_modules] + + qt_libs = [f"Qt5{m}" for m in qt_modules] + qt_libs += ['EGL', 'GLESv3', 'c++_shared'] +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.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_QUICK_LIB", + "-DQT_QUICKWIDGETS_LIB", + "-DQT_QML_LIB", + "-DQT_CORE_LIB", + "-DQT_MESSAGELOGCONTEXT", +] +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('env', 'qt_env', 'arch', 'real_arch', 'SHARED', 'USE_WEBCAM') + +SConscript(['selfdrive/common/SConscript']) +Import('_common', '_gpucommon', '_gpu_libs') + +if SHARED: + common, gpucommon = abspath(common), abspath(gpucommon) +else: + common = [_common, 'json11'] + gpucommon = [_gpucommon] + _gpu_libs + +Export('common', 'gpucommon') # cereal and messaging are shared with the system SConscript(['cereal/SConscript']) @@ -188,46 +367,66 @@ if SHARED: else: cereal = [File('#cereal/libcereal.a')] messaging = [File('#cereal/libmessaging.a')] -Export('cereal', 'messaging') + visionipc = [File('#cereal/libvisionipc.a')] -SConscript(['selfdrive/common/SConscript']) -Import('_common', '_visionipc', '_gpucommon', '_gpu_libs') +Export('cereal', 'messaging', 'visionipc') -if SHARED: - common, visionipc, gpucommon = abspath(common), abspath(visionipc), abspath(gpucommon) -else: - common = [_common, 'json'] - visionipc = _visionipc - gpucommon = [_gpucommon] + _gpu_libs +# Build rednose library and ekf models -Export('common', 'visionipc', 'gpucommon') +rednose_config = { + 'generated_folder': '#selfdrive/locationd/models/generated', + 'to_build': { + 'live': ('#selfdrive/locationd/models/live_kf.py', True, ['live_kf_constants.h']), + 'car': ('#selfdrive/locationd/models/car_kf.py', True, []), + }, +} +if arch != "aarch64": + rednose_config['to_build'].update({ + 'gnss': ('#selfdrive/locationd/models/gnss_kf.py', True, []), + 'loc_4': ('#selfdrive/locationd/models/loc_kf.py', True, []), + 'pos_computer_4': ('#rednose/helpers/lst_sq_computer.py', False, []), + 'pos_computer_5': ('#rednose/helpers/lst_sq_computer.py', False, []), + 'feature_handler_5': ('#rednose/helpers/feature_handler.py', False, []), + 'lane': ('#xx/pipeline/lib/ekf/lane_kf.py', True, []), + }) + +Export('rednose_config') +SConscript(['rednose/SConscript']) + +# Build openpilot + +SConscript(['cereal/SConscript']) +SConscript(['panda/board/SConscript']) SConscript(['opendbc/can/SConscript']) +SConscript(['phonelibs/SConscript']) + SConscript(['common/SConscript']) SConscript(['common/kalman/SConscript']) -SConscript(['phonelibs/SConscript']) +SConscript(['common/transformations/SConscript']) -if arch != "Darwin": - SConscript(['selfdrive/camerad/SConscript']) - SConscript(['selfdrive/modeld/SConscript']) +SConscript(['selfdrive/camerad/SConscript']) +SConscript(['selfdrive/modeld/SConscript']) SConscript(['selfdrive/controls/lib/cluster/SConscript']) SConscript(['selfdrive/controls/lib/lateral_mpc/SConscript']) -SConscript(['selfdrive/controls/lib/longitudinal_mpc/SConscript']) +SConscript(['selfdrive/controls/lib/lead_mpc_lib/SConscript']) +SConscript(['selfdrive/controls/lib/longitudinal_mpc_lib/SConscript']) SConscript(['selfdrive/boardd/SConscript']) SConscript(['selfdrive/proclogd/SConscript']) +SConscript(['selfdrive/clocksd/SConscript']) -SConscript(['selfdrive/ui/SConscript']) SConscript(['selfdrive/loggerd/SConscript']) -if arch == "aarch64": - SConscript(['selfdrive/logcatd/SConscript']) - SConscript(['selfdrive/sensord/SConscript']) - SConscript(['selfdrive/clocksd/SConscript']) - SConscript(['selfdrive/locationd/SConscript']) -SConscript(['selfdrive/locationd/kalman/SConscript']) +SConscript(['selfdrive/sensord/SConscript']) +SConscript(['selfdrive/ui/SConscript']) + +if arch != "Darwin": + SConscript(['selfdrive/logcatd/SConscript']) -# TODO: finish cereal, dbcbuilder, MPC +external_sconscript = GetOption('external_sconscript') +if external_sconscript: + SConscript([external_sconscript]) diff --git a/apk/ai.comma.plus.black.apk b/apk/ai.comma.plus.black.apk deleted file mode 100644 index 94b3a6a1915a8c..00000000000000 Binary files a/apk/ai.comma.plus.black.apk and /dev/null differ diff --git a/apk/ai.comma.plus.frame.apk b/apk/ai.comma.plus.frame.apk deleted file mode 100644 index f52f80869cd916..00000000000000 Binary files a/apk/ai.comma.plus.frame.apk and /dev/null differ diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk deleted file mode 100644 index f829c3e3f92deb..00000000000000 Binary files a/apk/ai.comma.plus.offroad.apk and /dev/null differ diff --git a/cereal/.dockerignore b/cereal/.dockerignore deleted file mode 100644 index 5b2d46270d8cc8..00000000000000 --- a/cereal/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -.sconsign.dblite diff --git a/cereal/.github/workflows/tests.yml b/cereal/.github/workflows/tests.yml deleted file mode 100644 index 3b8f6ca8e03b87..00000000000000 --- a/cereal/.github/workflows/tests.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Tests - -on: [push, pull_request] - -jobs: - test: - - runs-on: ubuntu-16.04 - - steps: - - uses: actions/checkout@v2 - - name: Build docker image - run: docker build -t cereal . - - name: Unit Tests - run: | - docker run cereal bash -c "scons --test --asan -j$(nproc) && messaging/test_runner" - - name: Test ZMQ - run: | - docker run cereal bash -c "ZMQ=1 python -m unittest discover ." - - name: Test MSGQ - run: | - docker run cereal bash -c "MSGQ=1 python -m unittest discover ." - diff --git a/cereal/.gitignore b/cereal/.gitignore index e90f8c750f9b26..14cd02efff2110 100644 --- a/cereal/.gitignore +++ b/cereal/.gitignore @@ -1,14 +1,21 @@ gen node_modules package-lock.json +*.tmp *.pyc __pycache__ .*.swp .*.swo -libcereal*.a +*.os +*.o +*.a + +test_runner + libmessaging.* libmessaging_shared.* services.h .sconsign.dblite libcereal_shared.* - +.mypy_cache/ +catch2/ diff --git a/cereal/Dockerfile b/cereal/Dockerfile deleted file mode 100644 index f681dce68ff4b5..00000000000000 --- a/cereal/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -from ubuntu:16.04 - -RUN apt-get update && apt-get install -y libzmq3-dev clang wget git autoconf libtool curl make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl - -RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash -ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}" -RUN pyenv install 3.7.3 -RUN pyenv global 3.7.3 -RUN pyenv rehash -RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4 - -WORKDIR /project/cereal -COPY install_capnp.sh . -RUN ./install_capnp.sh - -ENV PYTHONPATH=/project - -COPY . . -RUN scons -c && scons -j$(nproc) diff --git a/cereal/README.md b/cereal/README.md deleted file mode 100644 index ec0efc67621992..00000000000000 --- a/cereal/README.md +++ /dev/null @@ -1,42 +0,0 @@ -What is cereal? ----- - -cereal is both a messaging spec for robotics systems as well as generic high performance IPC pub sub messaging with a single publisher and multiple subscribers. - -Imagine this use case: -* A sensor process reads gyro measurements directly from an IMU and publishes a sensorEvents packet -* A calibration process subscribes to the sensorEvents packet to use the IMU -* A localization process subscribes to the sensorEvents packet to use the IMU also - - -Messaging Spec ----- - -You'll find the message types in [log.capnp](log.capnp). It uses [Cap'n proto](https://capnproto.org/capnp-tool.html) and defines one struct called Event. - -All Events have a logMonoTime and a valid. Then a big union defines the packet type. - - -Pub Sub Backends ----- - -cereal supports two backends, one based on [zmq](https://zeromq.org/), the other called msgq, a custom pub sub based on shared memory that doesn't require the bytes to pass through the kernel. - -Example ---- -```python -import cereal.messaging as messaging - -# in subscriber -sm = messaging.SubMaster(['sensorEvents']) -while 1: - sm.update() - print(sm['sensorEvents']) - -# in publisher -pm = messaging.PubMaster(['sensorEvents']) -dat = messaging.new_message() -dat.init('sensorEvents', 1) -dat.sensorEvents[0] = {"gyro": {"v": [0.1, -0.1, 0.1]}} -pm.send('sensorEvents', dat) -``` diff --git a/cereal/SConscript b/cereal/SConscript index e0c1b2b52c16a4..10f3ab7f5d1b8e 100644 --- a/cereal/SConscript +++ b/cereal/SConscript @@ -1,68 +1,77 @@ -Import('env', 'arch', 'zmq') +Import('env', 'envCython', 'arch', 'common') +import shutil + +cereal_dir = Dir('.') gen_dir = Dir('gen') 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/car.capnp.c', 'gen/c/log.capnp.c', 'gen/c/car.capnp.h', 'gen/c/log.capnp.h'], - ['car.capnp', 'log.capnp'], - 'capnpc $SOURCES --src-prefix=cereal -o c:' + gen_dir.path + '/c/') -env.Command( - ['gen/cpp/car.capnp.c++', 'gen/cpp/log.capnp.c++', 'gen/cpp/car.capnp.h', 'gen/cpp/log.capnp.h'], - ['car.capnp', 'log.capnp'], - 'capnpc $SOURCES --src-prefix=cereal -o c++:' + gen_dir.path + '/cpp/') -import shutil +env.Command([f'gen/cpp/{s}.c++' for s in schema_files] + [f'gen/cpp/{s}.h' for s in schema_files], + schema_files, + f"capnpc --src-prefix={cereal_dir.path} $SOURCES -o c++:{gen_dir.path}/cpp/") + if shutil.which('capnpc-java'): - env.Command( - ['gen/java/Car.java', 'gen/java/Log.java'], - ['car.capnp', 'log.capnp'], - 'capnpc $SOURCES --src-prefix=cereal -o java:' + gen_dir.path + '/java/') + env.Command(['gen/java/Car.java', 'gen/java/Log.java'], + schema_files, + f"capnpc $SOURCES --src-prefix={cereal_dir.path} -o java:{gen_dir.path}/java/") # TODO: remove non shared cereal and messaging -cereal_objects = env.SharedObject([ - 'gen/c/car.capnp.c', - 'gen/c/log.capnp.c', - 'gen/cpp/car.capnp.c++', - 'gen/cpp/log.capnp.c++', - ]) +cereal_objects = env.SharedObject([f'gen/cpp/{s}.c++' for s in schema_files]) env.Library('cereal', cereal_objects) -env.SharedLibrary('cereal_shared', cereal_objects, LIBS=["capnp_c"]) +env.SharedLibrary('cereal_shared', cereal_objects) -cereal_dir = Dir('.') -services_h = env.Command( - ['services.h'], - ['service_list.yaml', 'services.py'], - 'python3 ' + cereal_dir.path + '/services.py > $TARGET') +# Build messaging + +services_h = env.Command(['services.h'], ['services.py'], 'python3 ' + cereal_dir.path + '/services.py > $TARGET') messaging_objects = env.SharedObject([ 'messaging/messaging.cc', 'messaging/impl_zmq.cc', 'messaging/impl_msgq.cc', 'messaging/msgq.cc', + 'messaging/socketmaster.cc', ]) messaging_lib = env.Library('messaging', messaging_objects) Depends('messaging/impl_zmq.cc', services_h) -# note, this rebuilds the deps shared, zmq is statically linked to make APK happy -# TODO: get APK to load system zmq to remove the static link -shared_lib_shared_lib = [zmq, 'm', 'stdc++'] + ["gnustl_shared"] if arch == "aarch64" else [zmq] -env.SharedLibrary('messaging_shared', messaging_objects, LIBS=shared_lib_shared_lib) - -env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq']) +env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq', common]) Depends('messaging/bridge.cc', services_h) -# different target? -#env.Program('messaging/demo', ['messaging/demo.cc'], LIBS=[messaging_lib, 'zmq']) +envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq", common]) + + +# Build Vision IPC +vipc_sources = [ + 'visionipc/ipc.cc', + 'visionipc/visionipc_server.cc', + 'visionipc/visionipc_client.cc', + 'visionipc/visionbuf.cc', +] + +if arch in ["aarch64", "larch64"]: + 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) -env.Command(['messaging/messaging_pyx.so'], - [messaging_lib, 'messaging/messaging_pyx_setup.py', 'messaging/messaging_pyx.pyx', 'messaging/messaging.pxd'], - "cd " + messaging_dir.path + " && python3 messaging_pyx_setup.py build_ext --inplace") +libs = envCython["LIBS"]+["OpenCL", "zmq", vipc, messaging_lib, common] +if arch == "aarch64": + libs += ["adreno_utils"] +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'): - 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, common]) + env.Program('visionipc/test_runner', ['visionipc/test_runner.cc', 'visionipc/visionipc_tests.cc'], LIBS=[vipc, messaging_lib, 'zmq', 'pthread', 'OpenCL', common]) diff --git a/cereal/SConstruct b/cereal/SConstruct deleted file mode 100644 index a72286b279bd74..00000000000000 --- a/cereal/SConstruct +++ /dev/null @@ -1,49 +0,0 @@ -import os -import subprocess - -zmq = 'zmq' -arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() - -cereal_dir = Dir('.') - -cpppath = [ - cereal_dir, - '/usr/lib/include', -] - -AddOption('--test', - action='store_true', - help='build test files') - -AddOption('--asan', - action='store_true', - help='turn on ASAN') - -ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else [] -ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else [] - -env = Environment( - ENV=os.environ, - CC='clang', - CXX='clang++', - CCFLAGS=[ - "-g", - "-fPIC", - "-O2", - "-Werror=implicit-function-declaration", - "-Werror=incompatible-pointer-types", - "-Werror=int-conversion", - "-Werror=return-type", - "-Werror=format-extra-args", - ] + ccflags_asan, - LDFLAGS=ldflags_asan, - LINKFLAGS=ldflags_asan, - - CFLAGS="-std=gnu11", - CXXFLAGS="-std=c++14", - CPPPATH=cpppath, -) - - -Export('env', 'zmq', 'arch') -SConscript(['SConscript']) diff --git a/cereal/__init__.py b/cereal/__init__.py index 2d3b48526b2c34..88a181cbc51da4 100644 --- a/cereal/__init__.py +++ b/cereal/__init__.py @@ -1,3 +1,4 @@ +# pylint: skip-file import os import capnp diff --git a/cereal/car.capnp b/cereal/car.capnp index 58ff3fb42e95cb..9e942e3166cffe 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -11,21 +11,21 @@ $Java.outerClassname("Car"); struct CarEvent @0x9b1657f34caf3ad3 { name @0 :EventName; + + # event types enable @1 :Bool; noEntry @2 :Bool; - warning @3 :Bool; + warning @3 :Bool; # alerts presented only when enabled or soft disabling userDisable @4 :Bool; softDisable @5 :Bool; immediateDisable @6 :Bool; preEnable @7 :Bool; - permanent @8 :Bool; + permanent @8 :Bool; # alerts presented regardless of openpilot state enum EventName @0xbaa8c5d505f727de { - # TODO: copy from error list canError @0; steerUnavailable @1; brakeUnavailable @2; - gasUnavailable @3; wrongGear @4; doorOpen @5; seatbeltNotLatched @6; @@ -37,8 +37,6 @@ struct CarEvent @0x9b1657f34caf3ad3 { buttonEnable @12; pedalPressed @13; cruiseDisabled @14; - radarCanError @15; - dataNeeded @16; speedTooLow @17; outOfSpace @18; overheat @19; @@ -49,31 +47,24 @@ struct CarEvent @0x9b1657f34caf3ad3 { pcmDisable @24; noTarget @25; radarFault @26; - modelCommIssueDEPRECATED @27; brakeHold @28; parkBrake @29; manualRestart @30; lowSpeedLockout @31; plannerError @32; - ipasOverride @33; - debugAlert @34; - steerTempUnavailableMute @35; + joystickDebug @34; + steerTempUnavailableSilent @35; resumeRequired @36; preDriverDistracted @37; promptDriverDistracted @38; driverDistracted @39; - geofence @40; - driverMonitorOn @41; - driverMonitorOff @42; preDriverUnresponsive @43; promptDriverUnresponsive @44; driverUnresponsive @45; belowSteerSpeed @46; - calibrationProgress @47; lowBattery @48; - invalidGiraffeHonda @49; vehicleModelInvalid @50; - controlsFailed @51; + accFaulted @51; sensorDataInvalid @52; commIssue @53; tooDistracted @54; @@ -82,15 +73,71 @@ struct CarEvent @0x9b1657f34caf3ad3 { preLaneChangeLeft @57; preLaneChangeRight @58; laneChange @59; - invalidGiraffeToyota @60; - internetConnectivityNeeded @61; communityFeatureDisallowed @62; lowMemory @63; stockAeb @64; ldw @65; carUnrecognized @66; - radarCommIssue @67; - driverMonitorLowAcc @68; + invalidLkasSetting @69; + speedTooHigh @70; + laneChangeBlocked @71; + relayMalfunction @72; + gasPressed @73; + stockFcw @74; + startup @75; + startupNoCar @76; + startupNoControl @77; + startupMaster @78; + startupFuzzyFingerprint @97; + startupNoFw @104; + fcw @79; + steerSaturated @80; + belowEngageSpeed @84; + noGps @85; + wrongCruiseMode @87; + modeldLagging @89; + deviceFalling @90; + fanMalfunction @91; + cameraMalfunction @92; + gpsMalfunction @94; + processNotRunning @95; + dashcamMode @96; + controlsInitializing @98; + usbError @99; + roadCameraError @100; + driverCameraError @101; + wideRoadCameraError @102; + localizerMalfunction @103; + highCpuUsage @105; + + driverMonitorLowAccDEPRECATED @68; + manualSteeringRequired @106; + manualLongitudinalRequired @107; + silentPedalPressed @108; + silentButtonEnable @109; + silentBrakeHold @110; + silentWrongGear @111; + parkGear @112; + + radarCanErrorDEPRECATED @15; + radarCommIssueDEPRECATED @67; + gasUnavailableDEPRECATED @3; + dataNeededDEPRECATED @16; + modelCommIssueDEPRECATED @27; + ipasOverrideDEPRECATED @33; + geofenceDEPRECATED @40; + driverMonitorOnDEPRECATED @41; + driverMonitorOffDEPRECATED @42; + calibrationProgressDEPRECATED @47; + invalidGiraffeHondaDEPRECATED @49; + invalidGiraffeToyotaDEPRECATED @60; + internetConnectivityNeededDEPRECATED @61; + whitePandaUnsupportedDEPRECATED @81; + commIssueWarningDEPRECATED @83; + focusRecoverActiveDEPRECATED @86; + neosUpdateRequiredDEPRECATED @88; + modelLagWarningDEPRECATED @93; + startupOneplusDEPRECATED @82; } } @@ -98,7 +145,6 @@ struct CarEvent @0x9b1657f34caf3ad3 { # all speeds in m/s struct CarState { - errorsDEPRECATED @0 :List(CarEvent.EventName); events @13 :List(CarEvent); # car speed @@ -116,17 +162,20 @@ struct CarState { # brake pedal, 0.0-1.0 brake @5 :Float32; # this is user pedal only brakePressed @6 :Bool; # this is user pedal only - brakeLights @19 :Bool; # steering wheel - steeringAngle @7 :Float32; # deg - steeringRate @15 :Float32; # deg/s - steeringTorque @8 :Float32; # TODO: standardize units + steeringAngleDeg @7 :Float32; + steeringAngleOffsetDeg @37 :Float32; # Offset betweens sensors in case there multiple + steeringRateDeg @15 :Float32; + steeringTorque @8 :Float32; # TODO: standardize units steeringTorqueEps @27 :Float32; # TODO: standardize units - steeringPressed @9 :Bool; # if the user is using the steering wheel - steeringRateLimited @29 :Bool; # if the torque is limited by the rate limiter + steeringPressed @9 :Bool; # if the user is using the steering wheel + steeringRateLimited @29 :Bool; # if the torque is limited by the rate limiter + steerWarning @35 :Bool; # temporary steer unavailble + steerError @36 :Bool; # permanent steer error stockAeb @30 :Bool; stockFcw @31 :Bool; + espDisabled @32 :Bool; # cruise state cruiseState @10 :CruiseState; @@ -148,9 +197,23 @@ struct CarState { # clutch (manual transmission only) clutchPressed @28 :Bool; + lkasEnabled @38 :Bool; + leftBlinkerOn @39 :Bool; + rightBlinkerOn @40 :Bool; + disengageByBrake @41 :Bool; + automaticLaneChange @42 :Bool; + belowLaneChangeSpeed @43 :Bool; + accEnabled @44 :Bool; + readdistancelines @45 :Int16; + engineRPM @46 :Float32; + # which packets this state came from canMonoTimes @12: List(UInt64); + # blindspot sensors + leftBlindspot @33 :Bool; # Is there something blocking the left lane change + rightBlindspot @34 :Bool; # Is there something blocking the right lane change + struct WheelSpeeds { # optional wheel speeds fl @0 :Float32; @@ -165,6 +228,7 @@ struct CarState { available @2 :Bool; speedOffset @3 :Float32; standstill @4 :Bool; + nonAdaptive @5 :Bool; } enum GearShifter { @@ -200,6 +264,9 @@ struct CarState { gapAdjustCruise @11; } } + + errorsDEPRECATED @0 :List(CarEvent.EventName); + brakeLightsDEPRECATED @19 :Bool; } # ******* radar state @ 20hz ******* @@ -243,10 +310,6 @@ struct CarControl { enabled @0 :Bool; active @7 :Bool; - gasDEPRECATED @1 :Float32; - brakeDEPRECATED @2 :Float32; - steeringTorqueDEPRECATED @3 :Float32; - actuators @6 :Actuators; cruiseControl @4 :CruiseControl; @@ -254,11 +317,12 @@ struct CarControl { struct Actuators { # range from 0.0 - 1.0 - gas @0: Float32; + gasDEPRECATED @0: Float32; brake @1: Float32; # range from -1.0 - 1.0 steer @2: Float32; - steerAngle @3: Float32; + steeringAngleDeg @3: Float32; + accel @4: Float32; # m/s^2 } struct CruiseControl { @@ -294,8 +358,6 @@ struct CarControl { } enum AudibleAlert { - # these are the choices from the Honda - # map as good as you can for your car none @0; chimeEngage @1; chimeDisengage @2; @@ -304,8 +366,13 @@ struct CarControl { chimeWarning2 @5; chimeWarningRepeat @6; chimePrompt @7; + chimeWarning2Repeat @8; } } + + gasDEPRECATED @1 :Float32; + brakeDEPRECATED @2 :Float32; + steeringTorqueDEPRECATED @3 :Float32; } # ****** car param ****** @@ -313,32 +380,35 @@ struct CarControl { struct CarParams { carName @0 :Text; carFingerprint @1 :Text; + fuzzyFingerprint @55 :Bool; enableGasInterceptor @2 :Bool; - enableCruise @3 :Bool; - enableCamera @4 :Bool; - enableDsu @5 :Bool; # driving support unit - enableApgs @6 :Bool; # advanced parking guidance system + pcmCruise @3 :Bool; # is openpilot's state tied to the PCM's cruise state? + enableDsu @5 :Bool; # driving support unit + enableApgs @6 :Bool; # advanced parking guidance system + enableBsm @56 :Bool; # blind spot monitoring + hasStockCamera @57 :Bool; # factory LKAS/LDW camera is present minEnableSpeed @7 :Float32; minSteerSpeed @8 :Float32; + maxSteeringAngleDeg @54 :Float32; safetyModel @9 :SafetyModel; safetyModelPassive @42 :SafetyModel = silent; safetyParam @10 :Int16; steerMaxBP @11 :List(Float32); steerMaxV @12 :List(Float32); - gasMaxBP @13 :List(Float32); - gasMaxV @14 :List(Float32); - brakeMaxBP @15 :List(Float32); - brakeMaxV @16 :List(Float32); + gasMaxBPDEPRECATED @13 :List(Float32); + gasMaxVDEPRECATED @14 :List(Float32); + brakeMaxBPDEPRECATED @15 :List(Float32); + brakeMaxVDEPRECATED @16 :List(Float32); # things about the car in the manual - mass @17 :Float32; # [kg] running weight - wheelbase @18 :Float32; # [m] distance from rear to front axle - centerToFront @19 :Float32; # [m] GC distance to front axle - steerRatio @20 :Float32; # [] ratio between front wheels and steering wheel angles - steerRatioRear @21 :Float32; # [] rear steering ratio wrt front steering (usually 0) + mass @17 :Float32; # [kg] curb weight: all fluids no cargo + wheelbase @18 :Float32; # [m] distance from rear axle to front axle + centerToFront @19 :Float32; # [m] distance from center of mass to front axle + steerRatio @20 :Float32; # [] ratio of steering wheel angle to front wheel angle + steerRatioRear @21 :Float32; # [] ratio of steering wheel angle to rear wheel angle (usually 0) # things we can derive rotationalInertia @22 :Float32; # [kg*m2] body rotational inertia @@ -363,17 +433,21 @@ struct CarParams { steerRateCost @33 :Float32; # Lateral MPC cost on steering rate steerControlType @34 :SteerControlType; 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) + stoppingDecelRate @52 :Float32; # m/s^2/s while trying to stop + startingAccelRate @53 :Float32; # m/s^2/s while trying to start steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control? carVin @38 :Text; # VIN number queried during fingerprinting - isPandaBlack @39: Bool; dashcamOnly @41: Bool; transmissionType @43 :TransmissionType; carFw @44 :List(CarFw); + radarTimeStep @45: Float32 = 0.05; # time delta between radar updates, 20Hz is very standard communityFeature @46: Bool; # true if a community maintained feature is detected fingerprintSource @49: FingerprintSource; + networkLocation @50 :NetworkLocation; # Where Panda/C2 is integrated into the car's CAN network struct LateralParams { torqueBP @0 :List(Int32); @@ -385,7 +459,9 @@ struct CarParams { kpV @1 :List(Float32); kiBP @2 :List(Float32); kiV @3 :List(Float32); - kf @4 :Float32; + kdBP @4 :List(Float32) = [0.]; + kdV @5 :List(Float32) = [0.]; + kf @6 :Float32; } struct LongitudinalPIDTuning { @@ -393,15 +469,26 @@ struct CarParams { kpV @1 :List(Float32); kiBP @2 :List(Float32); kiV @3 :List(Float32); - deadzoneBP @4 :List(Float32); - deadzoneV @5 :List(Float32); + kdBP @4 :List(Float32) = [0.]; + kdV @5 :List(Float32) = [0.]; + deadzoneBP @6 :List(Float32); + deadzoneV @7 :List(Float32); } struct LateralINDITuning { - outerLoopGain @0 :Float32; - innerLoopGain @1 :Float32; - timeConstant @2 :Float32; - actuatorEffectiveness @3 :Float32; + outerLoopGainBP @4 :List(Float32); + outerLoopGainV @5 :List(Float32); + innerLoopGainBP @6 :List(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 { @@ -441,6 +528,9 @@ struct CarParams { noOutput @19; # like silent but without silent CAN TXs hondaBoschHarness @20; volkswagenPq @21; + subaruLegacy @22; # pre-Global platform + hyundaiLegacy @23; + hyundaiCommunity @24; } enum SteerControlType { @@ -450,8 +540,10 @@ struct CarParams { enum TransmissionType { unknown @0; - automatic @1; - manual @2; + automatic @1; # Traditional auto, including DSG + manual @2; # True "stick shift" only + direct @3; # Electric vehicle or other direct drive + cvt @4; } struct CarFw { @@ -468,10 +560,21 @@ struct CarParams { fwdCamera @3; engine @4; unknown @5; + transmission @8; # Transmission Control Module + srs @9; # airbag + gateway @10; # can gateway + hud @11; # heads up display + combinationMeter @12; # instrument cluster # Toyota only dsu @6; apgs @7; + + # Honda only + vsa @13; # Vehicle Stability Assist + programmedFuelInjection @14; + electricBrakeBooster @15; + shiftByWire @16; } enum FingerprintSource { @@ -479,4 +582,12 @@ struct CarParams { fw @1; fixed @2; } + + enum NetworkLocation { + fwdCamera @0; # Standard/default integration at LKAS camera + gateway @1; # Integration at vehicle's CAN gateway + } + + enableCameraDEPRECATED @4 :Bool; + isPandaBlackDEPRECATED @39: Bool; } diff --git a/cereal/generate_javascript.sh b/cereal/generate_javascript.sh deleted file mode 100755 index d6525a64d95eed..00000000000000 --- a/cereal/generate_javascript.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -rm -r gen/ts -rm -r gen/js - -mkdir gen/ts -mkdir gen/js - -echo "Installing needed npm modules" -npm i capnpc-ts capnp-ts - -capnpc -o node_modules/.bin/capnpc-ts:gen/ts log.capnp car.capnp -capnpc -o node_modules/.bin/capnpc-ts:gen/ts car.capnp - -cat log.capnp | egrep '\([a-zA-Z]*\.[^\s]+\.[^s]+\)' | sed 's/^.*([a-zA-Z]*\.\([a-zA-Z.]*\)).*/\1/' | while read line -do - TOKEN=`echo $line | sed 's/\./_/g'` - ROOT=`echo $line | sed 's/\..*$//g'` - cat gen/ts/log.capnp.ts | grep '^import.*'${TOKEN} - if [[ "$?" == "1" ]] - then - sed -i 's/^\(import {.*\)'${ROOT}'\(,*\) \(.*\)$/\1'${ROOT}', '${TOKEN}'\2 \3/' ./gen/ts/log.capnp.ts - fi -done - -tsc ./gen/ts/* --lib es2015 --outDir ./gen/js diff --git a/cereal/install_capnp.sh b/cereal/install_capnp.sh deleted file mode 100755 index cc570b60ffc884..00000000000000 --- a/cereal/install_capnp.sh +++ /dev/null @@ -1,40 +0,0 @@ -set -e -echo "Installing capnp" - -cd /tmp -VERSION=0.6.1 -wget https://capnproto.org/capnproto-c++-${VERSION}.tar.gz -tar xvf capnproto-c++-${VERSION}.tar.gz -cd capnproto-c++-${VERSION} -CXXFLAGS="-fPIC" ./configure - -make -j$(nproc) -make install - -# manually build binaries statically -g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnp src/capnp/compiler/module-loader.o src/capnp/compiler/capnp.o ./.libs/libcapnpc.a ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread - -g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnpc-c++ src/capnp/compiler/capnpc-c++.o ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread - -g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnpc-capnp src/capnp/compiler/capnpc-capnp.o ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread - -cp .libs/capnp /usr/local/bin/ -cp .libs/capnpc-c++ /usr/local/bin/ -cp .libs/capnpc-capnp /usr/local/bin/ -cp .libs/*.a /usr/local/lib - -cd /tmp -echo "Installing c-capnp" -git clone https://github.com/commaai/c-capnproto.git -cd c-capnproto -git submodule update --init --recursive -autoreconf -f -i -s -CXXFLAGS="-fPIC" ./configure -make -j$(nproc) -make install - -# manually build binaries statically -gcc -fPIC -o .libs/capnpc-c compiler/capnpc-c.o compiler/schema.capnp.o compiler/str.o ./.libs/libcapnp_c.a - -cp .libs/capnpc-c /usr/local/bin/ -cp .libs/*.a /usr/local/lib diff --git a/cereal/legacy.capnp b/cereal/legacy.capnp new file mode 100644 index 00000000000000..0534dabc190b3f --- /dev/null +++ b/cereal/legacy.capnp @@ -0,0 +1,865 @@ +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 UiLayoutState @0x88dcce08ad29dda0 { + activeApp @0 :App; + sidebarCollapsed @1 :Bool; + mapEnabled @2 :Bool; + mockEngaged @3 :Bool; + + enum App @0x9917470acf94d285 { + home @0; + music @1; + nav @2; + settings @3; + none @4; + } +} + +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; +} + + diff --git a/cereal/log.capnp b/cereal/log.capnp index 46971d81a309e9..c21a3e58e1afe1 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -6,6 +6,7 @@ $Java.package("ai.comma.openpilot.cereal"); $Java.outerClassname("Log"); using Car = import "car.capnp"; +using Legacy = import "legacy.capnp"; @0xf3b1f17e25a4285b; @@ -22,6 +23,7 @@ struct Map(Key, Value) { struct InitData { kernelArgs @0 :List(Text); kernelVersion @15 :Text; + osVersion @18 :Text; gctx @1 :Text; dongleId @2 :Text; @@ -32,25 +34,36 @@ struct InitData { gitBranch @11 :Text; gitRemote @13 :Text; - androidBuildInfo @5 :AndroidBuildInfo; - androidSensors @6 :List(AndroidSensor); androidProperties @16 :Map(Text, Text); - chffrAndroidExtra @7 :ChffrAndroidExtra; - iosBuildInfo @14 :IosBuildInfo; pandaInfo @8 :PandaInfo; dirty @9 :Bool; passive @12 :Bool; - params @17 :Map(Text, Text); + params @17 :Map(Text, Data); enum DeviceType { unknown @0; neo @1; chffrAndroid @2; chffrIos @3; + tici @4; + pc @5; + } + + struct PandaInfo { + hasPanda @0 :Bool; + dongleId @1 :Text; + stVersion @2 :Text; + espVersion @3 :Text; } + # ***** deprecated stuff ***** + androidBuildInfo @5 :AndroidBuildInfo; + androidSensorsDEPRECATED @6 :List(AndroidSensor); + chffrAndroidExtraDEPRECATED @7 :ChffrAndroidExtra; + iosBuildInfoDEPRECATED @14 :IosBuildInfo; + struct AndroidBuildInfo { board @0 :Text; bootloader @1 :Text; @@ -105,35 +118,43 @@ struct InitData { osVersion @2 :Text; deviceModel @3 :Text; } - - struct PandaInfo { - hasPanda @0 :Bool; - dongleId @1 :Text; - stVersion @2 :Text; - espVersion @3 :Text; - } } struct FrameData { frameId @0 :UInt32; encodeId @1 :UInt32; # DEPRECATED - timestampEof @2 :UInt64; + + frameType @7 :FrameType; frameLength @3 :Int32; + + # Timestamps + timestampEof @2 :UInt64; + timestampSof @8 :UInt64; + + # Exposure integLines @4 :Int32; - globalGain @5 :Int32; + highConversionGain @20 :Bool; + gain @15 :Float32; # This includes highConversionGain if enabled + measuredGreyFraction @21 :Float32; + targetGreyFraction @22 :Float32; + + # Focus lensPos @11 :Int32; lensSag @12 :Float32; lensErr @13 :Float32; lensTruePos @14 :Float32; - image @6 :Data; - gainFrac @15 :Float32; + focusVal @16 :List(Int16); + focusConf @17 :List(UInt8); + sharpnessScore @18 :List(UInt16); + recoverState @19 :Int32; - frameType @7 :FrameType; - timestampSof @8 :UInt64; transform @10 :List(Float32); androidCaptureResult @9 :AndroidCaptureResult; + image @6 :Data; + globalGainDEPRECATED @5 :Int32; + enum FrameType { unknown @0; neo @1; @@ -182,6 +203,7 @@ struct SensorEventData { gyroUncalibrated @12 :SensorVec; proximity @13: Float32; light @14: Float32; + temperature @15: Float32; } source @8 :SensorSource; @@ -199,6 +221,10 @@ struct SensorEventData { lsm6ds3 @5; # accelerometer (c2) bmp280 @6; # barometer (c2) mmc3416x @7; # magnetometer (c2) + bmx055 @8; + rpr0521 @9; + lsm6ds3trc @10; + mmc5603nj @11; } } @@ -220,7 +246,7 @@ struct GpsLocationData { speed @4 :Float32; # Represents heading in degrees. - bearing @5 :Float32; + bearingDeg @5 :Float32; # Represents expected accuracy in meters. (presumably 1 sigma?) accuracy @6 :Float32; @@ -238,7 +264,7 @@ struct GpsLocationData { verticalAccuracy @10 :Float32; # Represents bearing accuracy in degrees. (presumably 1 sigma?) - bearingAccuracy @11 :Float32; + bearingAccuracyDeg @11 :Float32; # Represents velocity accuracy in m/s. (presumably 1 sigma?) speedAccuracy @12 :Float32; @@ -262,42 +288,47 @@ struct CanData { src @3 :UInt8; } -struct ThermalData { - cpu0 @0 :UInt16; - cpu1 @1 :UInt16; - cpu2 @2 :UInt16; - cpu3 @3 :UInt16; - mem @4 :UInt16; - gpu @5 :UInt16; - bat @6 :UInt32; - pa0 @21 :UInt16; - - # not thermal - freeSpace @7 :Float32; - batteryPercent @8 :Int16; - batteryStatus @9 :Text; - batteryCurrent @15 :Int32; - batteryVoltage @16 :Int32; +struct DeviceState @0xa4d8b5af2aa492eb { usbOnline @12 :Bool; networkType @22 :NetworkType; - offroadPowerUsage @23 :UInt32; # Power usage since going offroad in uWh + networkInfo @31 :NetworkInfo; + networkStrength @24 :NetworkStrength; + offroadPowerUsageUwh @23 :UInt32; + carBatteryCapacityUwh @25 :UInt32; - fanSpeed @10 :UInt16; + fanSpeedPercentDesired @10 :UInt16; started @11 :Bool; - startedTs @13 :UInt64; + startedMonoTime @13 :UInt64; - thermalStatus @14 :ThermalStatus; + lastAthenaPingTime @32 :UInt64; + + # system utilization + freeSpacePercent @7 :Float32; + memoryUsagePercent @19 :Int8; + gpuUsagePercent @33 :Int8; + cpuUsagePercent @34 :List(Int8); # per-core cpu usage + + # power + batteryPercent @8 :Int16; + batteryStatus @9 :Text; + batteryCurrent @15 :Int32; + batteryVoltage @16 :Int32; chargingError @17 :Bool; chargingDisabled @18 :Bool; - memUsedPercent @19 :Int8; - cpuPerc @20 :Int8; + # device thermals + cpuTempC @26 :List(Float32); + gpuTempC @27 :List(Float32); + memoryTempC @28 :Float32; + batteryTempC @29 :Float32; + ambientTempC @30 :Float32; + thermalStatus @14 :ThermalStatus; enum ThermalStatus { - green @0; # all processes run - yellow @1; # critical processes run (kill uploader), engage still allowed - red @2; # no engage, will disengage - danger @3; # immediate process shutdown + green @0; + yellow @1; + red @2; + danger @3; } enum NetworkType { @@ -307,31 +338,62 @@ struct ThermalData { cell3G @3; cell4G @4; cell5G @5; + ethernet @6; + } + + enum NetworkStrength { + unknown @0; + poor @1; + moderate @2; + good @3; + great @4; + } + + struct NetworkInfo { + technology @0 :Text; + operator @1 :Text; + band @2 :Text; + channel @3 :UInt16; + extra @4 :Text; + state @5 :Text; } + + # deprecated + cpu0DEPRECATED @0 :UInt16; + cpu1DEPRECATED @1 :UInt16; + cpu2DEPRECATED @2 :UInt16; + cpu3DEPRECATED @3 :UInt16; + memDEPRECATED @4 :UInt16; + gpuDEPRECATED @5 :UInt16; + batDEPRECATED @6 :UInt32; + pa0DEPRECATED @21 :UInt16; + cpuUsagePercentDEPRECATED @20 :Int8; } -struct HealthData { +struct PandaState @0xa7649e2575e4591e { # from can health voltage @0 :UInt32; current @1 :UInt32; ignitionLine @2 :Bool; controlsAllowed @3 :Bool; gasInterceptorDetected @4 :Bool; - startedSignalDetectedDeprecated @5 :Bool; hasGps @6 :Bool; canSendErrs @7 :UInt32; canFwdErrs @8 :UInt32; canRxErrs @19 :UInt32; gmlanSendErrs @9 :UInt32; - hwType @10 :HwType; + pandaType @10 :PandaType; fanSpeedRpm @11 :UInt16; usbPowerMode @12 :UsbPowerMode; ignitionCan @13 :Bool; safetyModel @14 :Car.CarParams.SafetyModel; + safetyParam @20 :Int16; faultStatus @15 :FaultStatus; powerSaveEnabled @16 :Bool; uptime @17 :UInt32; faults @18 :List(FaultType); + harnessStatus @21 :HarnessStatus; + heartbeatLost @22 :Bool; enum FaultStatus { none @0; @@ -341,15 +403,39 @@ struct HealthData { enum FaultType { relayMalfunction @0; - } - - enum HwType { + unusedInterruptHandled @1; + interruptRateCan1 @2; + interruptRateCan2 @3; + interruptRateCan3 @4; + interruptRateTach @5; + interruptRateGmlan @6; + interruptRateInterrupts @7; + interruptRateSpiDma @8; + interruptRateSpiCs @9; + interruptRateUart1 @10; + interruptRateUart2 @11; + interruptRateUart3 @12; + interruptRateUart5 @13; + interruptRateUartDma @14; + interruptRateUsb @15; + interruptRateTim1 @16; + interruptRateTim3 @17; + registerDivergent @18; + interruptRateKlineInit @19; + interruptRateClockSource @20; + interruptRateTick @21; + # Update max fault type in boardd when adding faults + } + + enum PandaType @0x8a58adf93e5b3751 { unknown @0; whitePanda @1; greyPanda @2; blackPanda @3; pedal @4; uno @5; + dos @6; + redPanda @7; } enum UsbPowerMode { @@ -358,29 +444,22 @@ struct HealthData { cdp @2; dcp @3; } -} -struct LiveUI { - rearViewCam @0 :Bool; - alertText1 @1 :Text; - alertText2 @2 :Text; - awarenessStatus @3 :Float32; + enum HarnessStatus { + notConnected @0; + normal @1; + flipped @2; + } + + startedSignalDetectedDEPRECATED @5 :Bool; } struct RadarState @0x9a185389d6fdd05f { canMonoTimes @10 :List(UInt64); mdMonoTime @6 :UInt64; - ftMonoTimeDEPRECATED @7 :UInt64; - controlsStateMonoTime @11 :UInt64; + carStateMonoTime @11 :UInt64; radarErrors @12 :List(Car.RadarData.Error); - # all deprecated - warpMatrixDEPRECATED @0 :List(Float32); - angleOffsetDEPRECATED @1 :Float32; - calStatusDEPRECATED @2 :Int8; - calCycleDEPRECATED @8 :Int32; - calPercDEPRECATED @9 :Int8; - leadOne @3 :LeadData; leadTwo @4 :LeadData; cumLagMs @5 :Float32; @@ -391,7 +470,6 @@ struct RadarState @0x9a185389d6fdd05f { vRel @2 :Float32; aRel @3 :Float32; vLead @4 :Float32; - aLeadDEPRECATED @5 :Float32; dPath @6 :Float32; vLat @7 :Float32; vLeadK @8 :Float32; @@ -401,24 +479,35 @@ struct RadarState @0x9a185389d6fdd05f { aLeadTau @12 :Float32; modelProb @13 :Float32; radar @14 :Bool; + + aLeadDEPRECATED @5 :Float32; } + + # deprecated + ftMonoTimeDEPRECATED @7 :UInt64; + warpMatrixDEPRECATED @0 :List(Float32); + angleOffsetDEPRECATED @1 :Float32; + calStatusDEPRECATED @2 :Int8; + calCycleDEPRECATED @8 :Int32; + calPercDEPRECATED @9 :Int8; } struct LiveCalibrationData { - # deprecated - warpMatrix @0 :List(Float32); - # camera_frame_from_model_frame - warpMatrix2 @5 :List(Float32); - warpMatrixBig @6 :List(Float32); calStatus @1 :Int8; calCycle @2 :Int32; calPerc @3 :Int8; + validBlocks @9 :Int32; # view_frame_from_road_frame # ui's is inversed needs new extrinsicMatrix @4 :List(Float32); # the direction of travel vector in device frame rpyCalib @7 :List(Float32); + rpyCalibSpread @8 :List(Float32); + + warpMatrixDEPRECATED @0 :List(Float32); + warpMatrix2DEPRECATED @5 :List(Float32); + warpMatrixBigDEPRECATED @6 :List(Float32); } struct LiveTracks { @@ -435,73 +524,45 @@ struct LiveTracks { } struct ControlsState @0x97ff69c53601abf1 { - canMonoTimeDEPRECATED @16 :UInt64; + startMonoTime @48 :UInt64; canMonoTimes @21 :List(UInt64); - radarStateMonoTimeDEPRECATED @17 :UInt64; - mdMonoTimeDEPRECATED @18 :UInt64; - planMonoTime @28 :UInt64; - pathPlanMonoTime @50 :UInt64; + longitudinalPlanMonoTime @28 :UInt64; + lateralPlanMonoTime @50 :UInt64; state @31 :OpenpilotState; - vEgo @0 :Float32; - vEgoRaw @32 :Float32; - aEgoDEPRECATED @1 :Float32; + enabled @19 :Bool; + active @36 :Bool; + longControlState @30 :LongControlState; vPid @2 :Float32; vTargetLead @3 :Float32; + vCruise @22 :Float32; upAccelCmd @4 :Float32; uiAccelCmd @5 :Float32; ufAccelCmd @33 :Float32; - yActualDEPRECATED @6 :Float32; - yDesDEPRECATED @7 :Float32; - upSteerDEPRECATED @8 :Float32; - uiSteerDEPRECATED @9 :Float32; - ufSteerDEPRECATED @34 :Float32; - aTargetMinDEPRECATED @10 :Float32; - aTargetMaxDEPRECATED @11 :Float32; aTarget @35 :Float32; - jerkFactor @12 :Float32; - angleSteers @13 :Float32; # Steering angle in degrees. - angleSteersDes @29 :Float32; - curvature @37 :Float32; # path curvature from vehicle model - hudLeadDEPRECATED @14 :Int32; - cumLagMs @15 :Float32; - startMonoTime @48 :UInt64; - mapValid @49 :Bool; + curvature @37 :Float32; # path curvature from vehicle model forceDecel @51 :Bool; - enabled @19 :Bool; - active @36 :Bool; - steerOverride @20 :Bool; - - vCruise @22 :Float32; - - rearViewCam @23 :Bool; + # UI alerts alertText1 @24 :Text; alertText2 @25 :Text; alertStatus @38 :AlertStatus; alertSize @39 :AlertSize; alertBlinkingRate @42 :Float32; alertType @44 :Text; - alertSoundDEPRECATED @45 :Text; alertSound @56 :Car.CarControl.HUDControl.AudibleAlert; - awarenessStatus @26 :Float32; - angleModelBiasDEPRECATED @27 :Float32; - gpsPlannerActive @40 :Bool; engageable @41 :Bool; # can OP be engaged? - driverMonitoringOn @43 :Bool; - - # maps - vCurvature @46 :Float32; - decelForTurn @47 :Bool; - decelForModel @54 :Bool; + cumLagMs @15 :Float32; canErrorCounter @57 :UInt32; lateralControlState :union { indiState @52 :LateralINDIState; pidState @53 :LateralPIDState; lqrState @55 :LateralLQRState; + angleState @58 :LateralAngleState; + debugState @59 :LateralDebugState; } enum OpenpilotState @0xdbe58b96d2d1ac61 { @@ -520,7 +581,7 @@ struct ControlsState @0x97ff69c53601abf1 { enum AlertStatus { normal @0; # low priority alert for user's convenience - userPrompt @1; # mid piority alert that might require user intervention + userPrompt @1; # mid priority alert that might require user intervention critical @2; # high priority alert that needs immediate user intervention } @@ -533,9 +594,9 @@ struct ControlsState @0x97ff69c53601abf1 { struct LateralINDIState { active @0 :Bool; - steerAngle @1 :Float32; - steerRate @2 :Float32; - steerAccel @3 :Float32; + steeringAngleDeg @1 :Float32; + steeringRateDeg @2 :Float32; + steeringAccelDeg @3 :Float32; rateSetPoint @4 :Float32; accelSetPoint @5 :Float32; accelError @6 :Float32; @@ -547,8 +608,8 @@ struct ControlsState @0x97ff69c53601abf1 { struct LateralPIDState { active @0 :Bool; - steerAngle @1 :Float32; - steerRate @2 :Float32; + steeringAngleDeg @1 :Float32; + steeringRateDeg @2 :Float32; angleError @3 :Float32; p @4 :Float32; i @5 :Float32; @@ -559,87 +620,149 @@ struct ControlsState @0x97ff69c53601abf1 { struct LateralLQRState { active @0 :Bool; - steerAngle @1 :Float32; + steeringAngleDeg @1 :Float32; i @2 :Float32; output @3 :Float32; lqrOutput @4 :Float32; saturated @5 :Bool; - } + } + struct LateralAngleState { + active @0 :Bool; + steeringAngleDeg @1 :Float32; + output @2 :Float32; + saturated @3 :Bool; + } -} + struct LateralDebugState { + active @0 :Bool; + steeringAngleDeg @1 :Float32; + output @2 :Float32; + saturated @3 :Bool; + } -struct LiveEventData { - name @0 :Text; - value @1 :Int32; + # deprecated + vEgoDEPRECATED @0 :Float32; + vEgoRawDEPRECATED @32 :Float32; + aEgoDEPRECATED @1 :Float32; + canMonoTimeDEPRECATED @16 :UInt64; + radarStateMonoTimeDEPRECATED @17 :UInt64; + mdMonoTimeDEPRECATED @18 :UInt64; + yActualDEPRECATED @6 :Float32; + yDesDEPRECATED @7 :Float32; + upSteerDEPRECATED @8 :Float32; + uiSteerDEPRECATED @9 :Float32; + ufSteerDEPRECATED @34 :Float32; + aTargetMinDEPRECATED @10 :Float32; + aTargetMaxDEPRECATED @11 :Float32; + rearViewCamDEPRECATED @23 :Bool; + driverMonitoringOnDEPRECATED @43 :Bool; + hudLeadDEPRECATED @14 :Int32; + alertSoundDEPRECATED @45 :Text; + angleModelBiasDEPRECATED @27 :Float32; + gpsPlannerActiveDEPRECATED @40 :Bool; + decelForTurnDEPRECATED @47 :Bool; + decelForModelDEPRECATED @54 :Bool; + awarenessStatusDEPRECATED @26 :Float32; + angleSteersDEPRECATED @13 :Float32; + vCurvatureDEPRECATED @46 :Float32; + mapValidDEPRECATED @49 :Bool; + jerkFactorDEPRECATED @12 :Float32; + steerOverrideDEPRECATED @20 :Bool; + steeringAngleDesiredDeg @29 :Float32; } -struct ModelData { +struct ModelDataV2 { frameId @0 :UInt32; - timestampEof @9 :UInt64; - - 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 { - points @0 :List(Float32); - prob @1 :Float32; - std @2 :Float32; - stds @3 :List(Float32); - poly @4 :List(Float32); + frameAge @1 :UInt32; + frameDropPerc @2 :Float32; + timestampEof @3 :UInt64; + modelExecutionTime @15 :Float32; + gpuExecutionTime @17 :Float32; + rawPredictions @16 :Data; + + # predicted future position, orientation, etc.. + position @4 :XYZTData; + orientation @5 :XYZTData; + velocity @6 :XYZTData; + orientationRate @7 :XYZTData; + + # prediction lanelines and road edges + laneLines @8 :List(XYZTData); + laneLineProbs @9 :List(Float32); + laneLineStds @13 :List(Float32); + roadEdges @10 :List(XYZTData); + roadEdgeStds @14 :List(Float32); + + # predicted lead cars + leads @11 :List(LeadDataV2); + leadsV3 @18 :List(LeadDataV3); + + meta @12 :MetaData; + + # All SI units and in device frame + struct XYZTData { + x @0 :List(Float32); + y @1 :List(Float32); + z @2 :List(Float32); + t @3 :List(Float32); + xStd @4 :List(Float32); + yStd @5 :List(Float32); + zStd @6 :List(Float32); } - struct LeadData { - 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 LeadDataV2 { + prob @0 :Float32; # probability that car is your lead at time t + t @1 :Float32; + + # x and y are relative position in device frame + # v is norm relative speed + # a is norm relative acceleration + xyva @2 :List(Float32); + xyvaStd @3 :List(Float32); } - struct ModelSettings { - 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 LeadDataV3 { + prob @0 :Float32; # probability that car is your lead at time t + probTime @1 :Float32; + t @2 :List(Float32); + + # x and y are relative position in device frame + # v absolute norm speed + # a is derivative of v + x @3 :List(Float32); + xStd @4 :List(Float32); + y @5 :List(Float32); + yStd @6 :List(Float32); + v @7 :List(Float32); + vStd @8 :List(Float32); + a @9 :List(Float32); + aStd @10 :List(Float32); } + struct MetaData { engagedProb @0 :Float32; desirePrediction @1 :List(Float32); - brakeDisengageProb @2 :Float32; - gasDisengageProb @3 :Float32; - steerOverrideProb @4 :Float32; - } + desireState @5 :List(Float32); + disengagePredictions @6 :DisengagePredictions; + hardBrakePredicted @7 :Bool; - struct LongitudinalData { - speeds @0 :List(Float32); - accelerations @1 :List(Float32); + # deprecated + brakeDisengageProbDEPRECATED @2 :Float32; + gasDisengageProbDEPRECATED @3 :Float32; + steerOverrideProbDEPRECATED @4 :Float32; } -} - -struct CalibrationFeatures { - frameId @0 :UInt32; - p0 @1 :List(Float32); - p1 @2 :List(Float32); - status @3 :List(Int8); + struct DisengagePredictions { + t @0 :List(Float32); + brakeDisengageProbs @1 :List(Float32); + gasDisengageProbs @2 :List(Float32); + steerOverrideProbs @3 :List(Float32); + brake3MetersPerSecondSquaredProbs @4 :List(Float32); + brake4MetersPerSecondSquaredProbs @5 :List(Float32); + brake5MetersPerSecondSquaredProbs @6 :List(Float32); + } } struct EncodeIndex { @@ -654,6 +777,8 @@ struct EncodeIndex { segmentId @4 :UInt32; # index into camera file in segment in encode order segmentIdEncode @5 :UInt32; + timestampSof @6 :UInt64; + timestampEof @7 :UInt64; enum Type { bigBoxLossless @0; # rcamera.mkv @@ -675,97 +800,81 @@ struct AndroidLogEntry { message @6 :Text; } -struct LogRotate { - segmentNum @0 :Int32; - path @1 :Text; -} - -struct Plan { - mdMonoTime @9 :UInt64; - radarStateMonoTime @10 :UInt64; - commIssue @31 :Bool; - - eventsDEPRECATED @13 :List(Car.CarEvent); - - # lateral, 3rd order polynomial - lateralValidDEPRECATED @0 :Bool; - dPolyDEPRECATED @1 :List(Float32); - laneWidthDEPRECATED @11 :Float32; - - # longitudinal - longitudinalValidDEPRECATED @2 :Bool; - vCruise @16 :Float32; - aCruise @17 :Float32; - vTarget @3 :Float32; - vTargetFuture @14 :Float32; - vMax @20 :Float32; - aTargetMinDEPRECATED @4 :Float32; - aTargetMaxDEPRECATED @5 :Float32; - aTarget @18 :Float32; - - vStart @26 :Float32; - aStart @27 :Float32; - - jerkFactor @6 :Float32; +struct LongitudinalPlan @0xe00b5b3eba12876c { + modelMonoTime @9 :UInt64; hasLead @7 :Bool; - hasLeftLaneDEPRECATED @23 :Bool; - hasRightLaneDEPRECATED @24 :Bool; fcw @8 :Bool; longitudinalPlanSource @15 :LongitudinalPlanSource; + processingDelay @29 :Float32; - # gps trajectory in car frame - gpsTrajectory @12 :GpsTrajectory; - - gpsPlannerActive @19 :Bool; - - # maps - vCurvature @21 :Float32; - decelForTurn @22 :Bool; - mapValid @25 :Bool; - radarValid @28 :Bool; - radarCanError @30 :Bool; + # desired speed/accel/jerk over next 2.5s + accels @32 :List(Float32); + speeds @33 :List(Float32); + jerks @34 :List(Float32); - processingDelay @29 :Float32; + enum LongitudinalPlanSource { + cruise @0; + lead0 @1; + lead1 @2; + lead2 @3; + e2e @4; + } + # deprecated + vCruiseDEPRECATED @16 :Float32; + aCruiseDEPRECATED @17 :Float32; + vTargetDEPRECATED @3 :Float32; + vTargetFutureDEPRECATED @14 :Float32; + aTargetDEPRECATED @18 :Float32; + vStartDEPRECATED @26 :Float32; + aStartDEPRECATED @27 :Float32; + vMaxDEPRECATED @20 :Float32; + radarStateMonoTimeDEPRECATED @10 :UInt64; + jerkFactorDEPRECATED @6 :Float32; + hasLeftLaneDEPRECATED @23 :Bool; + hasRightLaneDEPRECATED @24 :Bool; + aTargetMinDEPRECATED @4 :Float32; + aTargetMaxDEPRECATED @5 :Float32; + lateralValidDEPRECATED @0 :Bool; + longitudinalValidDEPRECATED @2 :Bool; + dPolyDEPRECATED @1 :List(Float32); + laneWidthDEPRECATED @11 :Float32; + vCurvatureDEPRECATED @21 :Float32; + decelForTurnDEPRECATED @22 :Bool; + mapValidDEPRECATED @25 :Bool; + radarValidDEPRECATED @28 :Bool; + radarCanErrorDEPRECATED @30 :Bool; + commIssueDEPRECATED @31 :Bool; + eventsDEPRECATED @13 :List(Car.CarEvent); + gpsTrajectoryDEPRECATED @12 :GpsTrajectory; + gpsPlannerActiveDEPRECATED @19 :Bool; struct GpsTrajectory { x @0 :List(Float32); y @1 :List(Float32); } - - enum LongitudinalPlanSource { - cruise @0; - mpc1 @1; - mpc2 @2; - mpc3 @3; - model @4; - } } -struct PathPlan { +struct LateralPlan @0xe1e9318e2ae8b51e { laneWidth @0 :Float32; - - dPoly @1 :List(Float32); - cPoly @2 :List(Float32); - cProb @3 :Float32; - lPoly @4 :List(Float32); lProb @5 :Float32; - rPoly @6 :List(Float32); rProb @7 :Float32; + dPathPoints @20 :List(Float32); + dProb @21 :Float32; - angleSteers @8 :Float32; # deg - rateSteers @13 :Float32; # deg/s mpcSolutionValid @9 :Bool; - paramsValid @10 :Bool; - modelValidDEPRECATED @12 :Bool; - angleOffset @11 :Float32; - sensorValid @14 :Bool; - commIssue @15 :Bool; - posenetValid @16 :Bool; desire @17 :Desire; laneChangeState @18 :LaneChangeState; laneChangeDirection @19 :LaneChangeDirection; + + # desired curvatures over next 2.5s in rad/m + psis @26 :List(Float32); + curvatures @27 :List(Float32); + curvatureRates @28 :List(Float32); + + lanelessMode @29 :Bool; + enum Desire { none @0; turnLeft @1; @@ -788,593 +897,81 @@ struct PathPlan { left @1; right @2; } -} - -struct LiveLocationData { - 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 { - 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 { - applanix @0; - kalman @1; - orbslam @2; - timing @3; - dummy @4; - } -} - -struct EthernetPacket { - pkt @0 :Data; - ts @1 :Float32; -} - -struct NavUpdate { - isNavigating @0 :Bool; - curSegment @1 :Int32; - segments @2 :List(Segment); - - struct LatLng { - lat @0 :Float64; - lng @1 :Float64; - } - - struct Segment { - 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 { - 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 NavStatus { - isNavigating @0 :Bool; - currentAddress @1 :Address; - - struct Address { - 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 CellInfo { - timestamp @0 :UInt64; - repr @1 :Text; # android toString() for now -} - -struct WifiScan { - 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 { - w20Mhz @0; - w40Mhz @1; - w80Mhz @2; - w160Mhz @3; - w80Plus80Mhz @4; - } -} - -struct AndroidGnss { - union { - measurements @0 :Measurements; - navigationMessage @1 :NavigationMessage; - } - - struct Measurements { - clock @0 :Clock; - measurements @1 :List(Measurement); - - struct Clock { - 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 { - 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 { - unknown @0; - gps @1; - sbas @2; - glonass @3; - qzss @4; - beidou @5; - galileo @6; - } - - enum State { - 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 { - unknown @0; - detected @1; - notDetected @2; - } - } - } - struct NavigationMessage { - type @0 :Int32; - svId @1 :Int32; - messageId @2 :Int32; - submessageId @3 :Int32; - data @4 :Data; - status @5 :Status; - - enum Status { - unknown @0; - parityPassed @1; - parityRebuilt @2; - } - } + # deprecated + curvatureDEPRECATED @22 :Float32; + curvatureRateDEPRECATED @23 :Float32; + rawCurvatureDEPRECATED @24 :Float32; + rawCurvatureRateDEPRECATED @25 :Float32; + cProbDEPRECATED @3 :Float32; + dPolyDEPRECATED @1 :List(Float32); + cPolyDEPRECATED @2 :List(Float32); + lPolyDEPRECATED @4 :List(Float32); + rPolyDEPRECATED @6 :List(Float32); + modelValidDEPRECATED @12 :Bool; + commIssueDEPRECATED @15 :Bool; + posenetValidDEPRECATED @16 :Bool; + sensorValidDEPRECATED @14 :Bool; + paramsValidDEPRECATED @10 :Bool; + steeringAngleDegDEPRECATED @8 :Float32; # deg + steeringRateDegDEPRECATED @13 :Float32; # deg/s + angleOffsetDegDEPRECATED @11 :Float32; } -struct QcomGnss { - 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 { - 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; +struct LiveLocationKalman { + + # More info on reference frames: + # https://github.com/commaai/openpilot/tree/master/common/transformations + + positionECEF @0 : Measurement; + positionGeodetic @1 : Measurement; + velocityECEF @2 : Measurement; + velocityNED @3 : Measurement; + velocityDevice @4 : Measurement; + accelerationDevice @5: Measurement; + + + # These angles are all eulers and roll, pitch, yaw + # orientationECEF transforms to rot matrix: ecef_from_device + orientationECEF @6 : Measurement; + calibratedOrientationECEF @20 : Measurement; + orientationNED @7 : Measurement; + angularVelocityDevice @8 : Measurement; + + # orientationNEDCalibrated transforms to rot matrix: NED_from_calibrated + calibratedOrientationNED @9 : Measurement; + + # Calibrated frame is simply device frame + # aligned with the vehicle + velocityCalibrated @10 : Measurement; + accelerationCalibrated @11 : Measurement; + angularVelocityCalibrated @12 : Measurement; + + gpsWeek @13 :Int32; + gpsTimeOfWeek @14 :Float64; + status @15 :Status; + unixTimestampMillis @16 :Int64; + inputsOK @17 :Bool = true; + posenetOK @18 :Bool = true; + gpsOK @19 :Bool = true; + sensorsOK @21 :Bool = true; + deviceStable @22 :Bool = true; + timeSinceReset @23 :Float64; + excessiveResets @24 :Bool; - sv @10 :List(SV); - - struct SV { - 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 { - 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 { - - 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 { - 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; - } + enum Status { + uninitialized @0; + uncalibrated @1; + valid @2; } - struct DrSvPolyReport { - 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 Measurement { + value @0 : List(Float64); + std @1 : List(Float64); + valid @2 : Bool; } } -struct LidarPts { - 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; -} - struct ProcLog { cpuTimes @0 :List(CPUTimes); mem @1 :Mem; @@ -1425,7 +1022,6 @@ struct ProcLog { inactive @6 :UInt64; shared @7 :UInt64; } - } struct UbloxGnss { @@ -1434,6 +1030,7 @@ struct UbloxGnss { ephemeris @1 :Ephemeris; ionoData @2 :IonoData; hwStatus @3 :HwStatus; + hwStatus2 @4 :HwStatus2; } struct MeasurementReport { @@ -1564,6 +1161,7 @@ struct UbloxGnss { aStatus @2 :AntennaSupervisorState; aPower @3 :AntennaPowerStatus; jamInd @4 :UInt8; + flags @5 :UInt8; enum AntennaSupervisorState { init @0; @@ -1579,6 +1177,24 @@ struct UbloxGnss { dontknow @2; } } + + struct HwStatus2 { + ofsI @0 :Int8; + magI @1 :UInt8; + ofsQ @2 :Int8; + magQ @3 :UInt8; + cfgSource @4 :ConfigSource; + lowLevCfg @5 :UInt32; + postStatus @6 :UInt32; + + enum ConfigSource { + undefined @0; + rom @1; + otp @2; + configpins @3; + flash @4; + } + } } struct Clocks { @@ -1593,7 +1209,7 @@ struct LiveMpcData { x @0 :List(Float32); y @1 :List(Float32); psi @2 :List(Float32); - delta @3 :List(Float32); + curvature @3 :List(Float32); qpIterations @4 :UInt32; calculationTime @5 :UInt64; cost @6 :Float64; @@ -1613,184 +1229,18 @@ struct LiveLongitudinalMpcData { cost @10 :Float64; } - -struct ECEFPointDEPRECATED @0xe10e21168db0c7f7 { - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; -} - -struct ECEFPoint @0xc25bbbd524983447 { - x @0 :Float64; - y @1 :Float64; - z @2 :Float64; -} - -struct GPSPlannerPoints { - 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 { - 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 TrafficEvent @0xacfa74a094e62626 { - type @0 :Type; - distance @1 :Float32; - action @2 :Action; - resuming @3 :Bool; - - enum Type { - stopSign @0; - lightRed @1; - lightYellow @2; - lightGreen @3; - stopLight @4; - } - - enum Action { - none @0; - yield @1; - stop @2; - resumeReady @3; - } - -} - -struct OrbslamCorrection { - correctionMonoTime @0 :UInt64; - prePositionECEF @1 :List(Float64); - postPositionECEF @2 :List(Float64); - prePoseQuatECEF @3 :List(Float32); - postPoseQuatECEF @4 :List(Float32); - numInliers @5 :UInt32; -} - -struct OrbObservation { - observationMonoTime @0 :UInt64; - normalizedCoordinates @1 :List(Float32); - locationECEF @2 :List(Float64); - matchDistance @3: UInt32; -} - -struct UiNavigationEvent { - type @0: Type; - status @1: Status; - distanceTo @2: Float32; - endRoadPointDEPRECATED @3: ECEFPointDEPRECATED; - endRoadPoint @4: ECEFPoint; - - enum Type { - none @0; - laneChangeLeft @1; - laneChangeRight @2; - mergeLeft @3; - mergeRight @4; - turnLeft @5; - turnRight @6; - } - - enum Status { - none @0; - passive @1; - approaching @2; - active @3; - } -} - -struct UiLayoutState { - activeApp @0 :App; - sidebarCollapsed @1 :Bool; - mapEnabled @2 :Bool; - - enum App { - home @0; - music @1; - nav @2; - settings @3; - } -} - struct Joystick { # convenient for debug and live tuning axes @0: List(Float32); buttons @1: List(Bool); } -struct OrbOdometry { - # 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 { - 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 { - timestampEof @0 :UInt64; - timestampLastEof @1 :UInt64; - - featureCount @2 :UInt16; - matchCount @3 :UInt16; - computeNs @4 :UInt64; -} - -struct OrbKeyFrame { - # 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 DriverState { frameId @0 :UInt32; - descriptorDEPRECATED @1 :List(Float32); - stdDEPRECATED @2 :Float32; + modelExecutionTime @14 :Float32; + dspExecutionTime @16 :Float32; + rawPredictions @15 :Data; + faceOrientation @3 :List(Float32); facePosition @4 :List(Float32); faceProb @5 :Float32; @@ -1798,19 +1248,26 @@ struct DriverState { rightEyeProb @7 :Float32; leftBlinkProb @8 :Float32; rightBlinkProb @9 :Float32; - irPwrDEPRECATED @10 :Float32; faceOrientationStd @11 :List(Float32); facePositionStd @12 :List(Float32); + sunglassesProb @13 :Float32; + poorVision @17 :Float32; + partialFace @18 :Float32; + distractedPose @19 :Float32; + distractedEyes @20 :Float32; + eyesOnRoad @21 :Float32; + phoneUse @22 :Float32; + + irPwrDEPRECATED @10 :Float32; + descriptorDEPRECATED @1 :List(Float32); + stdDEPRECATED @2 :Float32; } -struct DMonitoringState { - # TODO: deprecate old fields in controlsState +struct DriverMonitoringState @0xb83cda094a1da284 { events @0 :List(Car.CarEvent); faceDetected @1 :Bool; isDistracted @2 :Bool; awarenessStatus @3 :Float32; - isRHD @4 :Bool; - rhdChecked @5 :Bool; posePitchOffset @6 :Float32; posePitchValidCount @7 :UInt32; poseYawOffset @8 :Float32; @@ -1820,19 +1277,27 @@ struct DMonitoringState { awarenessPassive @12 :Float32; isLowStd @13 :Bool; hiStdCount @14 :UInt32; + isActiveMode @16 :Bool; + + isRHDDEPRECATED @4 :Bool; + isPreviewDEPRECATED @15 :Bool; + rhdCheckedDEPRECATED @5 :Bool; } struct Boot { wallTimeNanos @0 :UInt64; - lastKmsg @1 :Data; - lastPmsg @2 :Data; + pstore @4 :Map(Text, Data); + launchLog @3 :Text; + + lastKmsgDEPRECATED @1 :Data; + lastPmsgDEPRECATED @2 :Data; } struct LiveParametersData { valid @0 :Bool; gyroBias @1 :Float32; - angleOffset @2 :Float32; - angleOffsetAverage @3 :Float32; + angleOffsetDeg @2 :Float32; + angleOffsetAverageDeg @3 :Float32; stiffnessFactor @4 :Float32; steerRatio @5 :Float32; sensorValid @6 :Bool; @@ -1841,7 +1306,7 @@ struct LiveParametersData { posenetValid @9 :Bool; } -struct LiveMapData { +struct LiveMapDataDEPRECATED { speedLimitValid @0 :Bool; speedLimit @1 :Float32; speedAdvisoryValid @12 :Bool; @@ -1870,88 +1335,136 @@ struct CameraOdometry { rotStd @3 :List(Float32); # std rad/s in device frame } -struct KalmanOdometry { - 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 Sentinel { + enum SentinelType { + endOfSegment @0; + endOfRoute @1; + startOfSegment @2; + startOfRoute @3; + } + type @0 :SentinelType; + signal @1 :Int32; +} + +struct ManagerState { + processes @0 :List(ProcessState); + + struct ProcessState { + name @0 :Text; + pid @1 :Int32; + running @2 :Bool; + exitCode @3 :Int32; + } +} + +struct UploaderState { + immediateQueueSize @0 :UInt32; + immediateQueueCount @1 :UInt32; + rawQueueSize @2 :UInt32; + rawQueueCount @3 :UInt32; + + # stats for last successfully uploaded file + lastTime @4 :Float32; # s + lastSpeed @5 :Float32; # MB/s + lastFilename @6 :Text; } struct Event { - # in nanoseconds? - logMonoTime @0 :UInt64; + logMonoTime @0 :UInt64; # nanoseconds valid @67 :Bool = true; union { + # *********** log metadata *********** initData @1 :InitData; - frame @2 :FrameData; + sentinel @73 :Sentinel; + + # *********** bootlog *********** + boot @60 :Boot; + + # ********** openpilot daemon msgs ********** gpsNMEA @3 :GPSNMEAData; - sensorEventDEPRECATED @4 :SensorEventData; can @5 :List(CanData); - thermal @6 :ThermalData; controlsState @7 :ControlsState; - liveEventDEPRECATED @8 :List(LiveEventData); - model @9 :ModelData; - features @10 :CalibrationFeatures; sensorEvents @11 :List(SensorEventData); - health @12 :HealthData; + pandaState @12 :PandaState; radarState @13 :RadarState; - liveUIDEPRECATED @14 :LiveUI; - encodeIdx @15 :EncodeIndex; liveTracks @16 :List(LiveTracks); sendcan @17 :List(CanData); - logMessage @18 :Text; liveCalibration @19 :LiveCalibrationData; - androidLogEntry @20 :AndroidLogEntry; - gpsLocation @21 :GpsLocationData; carState @22 :Car.CarState; carControl @23 :Car.CarControl; - plan @24 :Plan; - liveLocation @25 :LiveLocationData; - ethernetData @26 :List(EthernetPacket); - navUpdate @27 :NavUpdate; - cellInfo @28 :List(CellInfo); - wifiScan @29 :List(WifiScan); - androidGnss @30 :AndroidGnss; - qcomGnss @31 :QcomGnss; - lidarPts @32 :LidarPts; - procLog @33 :ProcLog; + longitudinalPlan @24 :LongitudinalPlan; + lateralPlan @64 :LateralPlan; ubloxGnss @34 :UbloxGnss; - clocks @35 :Clocks; - liveMpc @36 :LiveMpcData; - liveLongitudinalMpc @37 :LiveLongitudinalMpcData; - navStatus @38 :NavStatus; ubloxRaw @39 :Data; - gpsPlannerPoints @40 :GPSPlannerPoints; - gpsPlannerPlan @41 :GPSPlannerPlan; - applanixRaw @42 :Data; - trafficEvents @43 :List(TrafficEvent); - liveLocationTiming @44 :LiveLocationData; - orbslamCorrectionDEPRECATED @45 :OrbslamCorrection; - liveLocationCorrected @46 :LiveLocationData; - orbObservation @47 :List(OrbObservation); gpsLocationExternal @48 :GpsLocationData; - location @49 :LiveLocationData; - uiNavigationEvent @50 :UiNavigationEvent; - liveLocationKalman @51 :LiveLocationData; - testJoystick @52 :Joystick; - orbOdometry @53 :OrbOdometry; - orbFeatures @54 :OrbFeatures; - applanixLocation @55 :LiveLocationData; - orbKeyFrame @56 :OrbKeyFrame; - uiLayoutState @57 :UiLayoutState; - orbFeaturesSummary @58 :OrbFeaturesSummary; driverState @59 :DriverState; - boot @60 :Boot; liveParameters @61 :LiveParametersData; - liveMapData @62 :LiveMapData; cameraOdometry @63 :CameraOdometry; - pathPlan @64 :PathPlan; - kalmanOdometry @65 :KalmanOdometry; thumbnail @66: Thumbnail; carEvents @68: List(Car.CarEvent); carParams @69: Car.CarParams; - frontFrame @70: FrameData; - dMonitoringState @71: DMonitoringState; + driverMonitoringState @71: DriverMonitoringState; + liveLocationKalman @72 :LiveLocationKalman; + modelV2 @75 :ModelDataV2; + + # camera stuff, each camera state has a matching encode idx + roadCameraState @2 :FrameData; + driverCameraState @70: FrameData; + wideRoadCameraState @74: FrameData; + roadEncodeIdx @15 :EncodeIndex; + driverEncodeIdx @76 :EncodeIndex; + wideRoadEncodeIdx @77 :EncodeIndex; + + # systems stuff + androidLog @20 :AndroidLogEntry; + managerState @78 :ManagerState; + uploaderState @79 :UploaderState; + procLog @33 :ProcLog; + clocks @35 :Clocks; + deviceState @6 :DeviceState; + logMessage @18 :Text; + + + # *********** debug *********** + testJoystick @52 :Joystick; + + # *********** legacy + deprecated *********** + model @9 :Legacy.ModelData; # TODO: rename modelV2 and mark this as deprecated + liveMpcDEPRECATED @36 :LiveMpcData; + liveLongitudinalMpcDEPRECATED @37 :LiveLongitudinalMpcData; + liveLocationKalmanDEPRECATED @51 :Legacy.LiveLocationData; + orbslamCorrectionDEPRECATED @45 :Legacy.OrbslamCorrection; + liveUIDEPRECATED @14 :Legacy.LiveUI; + sensorEventDEPRECATED @4 :SensorEventData; + liveEventDEPRECATED @8 :List(Legacy.LiveEventData); + liveLocationDEPRECATED @25 :Legacy.LiveLocationData; + ethernetDataDEPRECATED @26 :List(Legacy.EthernetPacket); + cellInfoDEPRECATED @28 :List(Legacy.CellInfo); + wifiScanDEPRECATED @29 :List(Legacy.WifiScan); + uiNavigationEventDEPRECATED @50 :Legacy.UiNavigationEvent; + liveMapDataDEPRECATED @62 :LiveMapDataDEPRECATED; + gpsPlannerPointsDEPRECATED @40 :Legacy.GPSPlannerPoints; + gpsPlannerPlanDEPRECATED @41 :Legacy.GPSPlannerPlan; + applanixRawDEPRECATED @42 :Data; + androidGnssDEPRECATED @30 :Legacy.AndroidGnss; + qcomGnssDEPRECATD @31 :Legacy.QcomGnss; + lidarPtsDEPRECATED @32 :Legacy.LidarPts; + navStatusDEPRECATED @38 :Legacy.NavStatus; + trafficEventsDEPRECATED @43 :List(Legacy.TrafficEvent); + liveLocationTimingDEPRECATED @44 :Legacy.LiveLocationData; + liveLocationCorrectedDEPRECATED @46 :Legacy.LiveLocationData; + navUpdateDEPRECATED @27 :Legacy.NavUpdate; + orbObservationDEPRECATED @47 :List(Legacy.OrbObservation); + locationDEPRECATED @49 :Legacy.LiveLocationData; + orbOdometryDEPRECATED @53 :Legacy.OrbOdometry; + orbFeaturesDEPRECATED @54 :Legacy.OrbFeatures; + applanixLocationDEPRECATED @55 :Legacy.LiveLocationData; + orbKeyFrameDEPRECATED @56 :Legacy.OrbKeyFrame; + orbFeaturesSummaryDEPRECATED @58 :Legacy.OrbFeaturesSummary; + featuresDEPRECATED @10 :Legacy.CalibrationFeatures; + kalmanOdometryDEPRECATED @65 :Legacy.KalmanOdometry; + gpsLocationDEPRECATED @21 :GpsLocationData; + uiLayoutStateDEPRECATED @57 :Legacy.UiLayoutState; } } diff --git a/cereal/logger/logger.h b/cereal/logger/logger.h new file mode 100644 index 00000000000000..e21509352f76db --- /dev/null +++ b/cereal/logger/logger.h @@ -0,0 +1,20 @@ +#pragma once + +#ifdef SWAGLOG +#include "selfdrive/common/swaglog.h" +#else + +#define CLOUDLOG_DEBUG 10 +#define CLOUDLOG_INFO 20 +#define CLOUDLOG_WARNING 30 +#define CLOUDLOG_ERROR 40 +#define CLOUDLOG_CRITICAL 50 + +#define cloudlog(lvl, fmt, ...) printf(fmt "\n", ## __VA_ARGS__) + +#define LOGD(fmt, ...) cloudlog(CLOUDLOG_DEBUG, fmt, ## __VA_ARGS__) +#define LOG(fmt, ...) cloudlog(CLOUDLOG_INFO, fmt, ## __VA_ARGS__) +#define LOGW(fmt, ...) cloudlog(CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) +#define LOGE(fmt, ...) cloudlog(CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) + +#endif diff --git a/cereal/maptile.capnp b/cereal/maptile.capnp deleted file mode 100644 index 336901392aa306..00000000000000 --- a/cereal/maptile.capnp +++ /dev/null @@ -1,53 +0,0 @@ -using Cxx = import "./include/c++.capnp"; -$Cxx.namespace("cereal"); - -using Java = import "./include/java.capnp"; -$Java.package("ai.comma.openpilot.cereal"); -$Java.outerClassname("Map"); - -@0xa086df597ef5d7a0; - -# Geometry -struct Point { - x @0: Float64; - y @1: Float64; - z @2: Float64; -} - -struct PolyLine { - points @0: List(Point); -} - -# Map features -struct Lane { - id @0 :Text; - - leftBoundary @1 :LaneBoundary; - rightBoundary @2 :LaneBoundary; - - leftAdjacentId @3 :Text; - rightAdjacentId @4 :Text; - - inboundIds @5 :List(Text); - outboundIds @6 :List(Text); - - struct LaneBoundary { - polyLine @0 :PolyLine; - startHeading @1 :Float32; # WRT north - } -} - -# Map tiles -struct TileSummary { - version @0 :Text; - updatedAt @1 :UInt64; # Millis since epoch - - level @2 :UInt8; - x @3 :UInt16; - y @4 :UInt16; -} - -struct MapTile { - summary @0 :TileSummary; - lanes @1 :List(Lane); -} diff --git a/cereal/messaging/__init__.py b/cereal/messaging/__init__.py index e5a004740dfaaa..0440104eb73a22 100644 --- a/cereal/messaging/__init__.py +++ b/cereal/messaging/__init__.py @@ -1,14 +1,22 @@ # must be build with scons from .messaging_pyx import Context, Poller, SubSocket, PubSocket # pylint: disable=no-name-in-module, import-error from .messaging_pyx import MultiplePublishersError, MessagingError # pylint: disable=no-name-in-module, import-error +import os import capnp -assert MultiplePublishersError -assert MessagingError +from typing import Optional, List, Union +from collections import deque from cereal import log from cereal.services import service_list +assert MultiplePublishersError +assert MessagingError + +NO_TRAVERSAL_LIMIT = 2**64-1 +AVG_FREQ_HISTORY = 100 +SIMULATION = "SIMULATION" in os.environ + # sec_since_boot is faster, but allow to run standalone too try: from common.realtime import sec_since_boot @@ -19,21 +27,29 @@ context = Context() -def new_message(): +def log_from_bytes(dat: bytes) -> capnp.lib.capnp._DynamicStructReader: + return log.Event.from_bytes(dat, traversal_limit_in_words=NO_TRAVERSAL_LIMIT) + +def new_message(service: Optional[str] = None, size: Optional[int] = None) -> capnp.lib.capnp._DynamicStructBuilder: dat = log.Event.new_message() dat.logMonoTime = int(sec_since_boot() * 1e9) dat.valid = True + if service is not None: + if size is None: + dat.init(service) + else: + dat.init(service, size) return dat -def pub_sock(endpoint): +def pub_sock(endpoint: str) -> PubSocket: sock = PubSocket() sock.connect(context, endpoint) return sock -def sub_sock(endpoint, poller=None, addr="127.0.0.1", conflate=False, timeout=None): +def sub_sock(endpoint: str, poller: Optional[Poller] = None, addr: str = "127.0.0.1", + conflate: bool = False, timeout: Optional[int] = None) -> SubSocket: sock = SubSocket() - addr = addr.encode('utf8') - sock.connect(context, endpoint, addr, conflate) + sock.connect(context, endpoint, addr.encode('utf8'), conflate) if timeout is not None: sock.setTimeout(timeout) @@ -43,9 +59,9 @@ def sub_sock(endpoint, poller=None, addr="127.0.0.1", conflate=False, timeout=No return sock -def drain_sock_raw(sock, wait_for_one=False): +def drain_sock_raw(sock: SubSocket, wait_for_one: bool = False) -> List[bytes]: """Receive all message currently available on the queue""" - ret = [] + ret: List[bytes] = [] while 1: if wait_for_one and len(ret) == 0: dat = sock.receive() @@ -59,26 +75,26 @@ def drain_sock_raw(sock, wait_for_one=False): return ret -def drain_sock(sock, wait_for_one=False): +def drain_sock(sock: SubSocket, wait_for_one: bool = False) -> List[capnp.lib.capnp._DynamicStructReader]: """Receive all message currently available on the queue""" - ret = [] + ret: List[capnp.lib.capnp._DynamicStructReader] = [] while 1: if wait_for_one and len(ret) == 0: dat = sock.receive() else: dat = sock.receive(non_blocking=True) - if dat is None: # Timeout hit + if dat is None: # Timeout hit break - dat = log.Event.from_bytes(dat) + dat = log_from_bytes(dat) ret.append(dat) return ret # TODO: print when we drop packets? -def recv_sock(sock, wait=False): +def recv_sock(sock: SubSocket, wait: bool = False) -> Union[None, capnp.lib.capnp._DynamicStructReader]: """Same as drain sock, but only returns latest message. Consider using conflate instead.""" dat = None @@ -88,88 +104,87 @@ def recv_sock(sock, wait=False): else: rcv = sock.receive(non_blocking=True) - if rcv is None: # Timeout hit + if rcv is None: # Timeout hit break dat = rcv if dat is not None: - dat = log.Event.from_bytes(dat) + dat = log_from_bytes(dat) return dat -def recv_one(sock): +def recv_one(sock: SubSocket) -> Union[None, capnp.lib.capnp._DynamicStructReader]: dat = sock.receive() if dat is not None: - dat = log.Event.from_bytes(dat) + dat = log_from_bytes(dat) return dat -def recv_one_or_none(sock): +def recv_one_or_none(sock: SubSocket) -> Union[None, capnp.lib.capnp._DynamicStructReader]: dat = sock.receive(non_blocking=True) if dat is not None: - dat = log.Event.from_bytes(dat) + dat = log_from_bytes(dat) return dat -def recv_one_retry(sock): +def recv_one_retry(sock: SubSocket) -> capnp.lib.capnp._DynamicStructReader: """Keep receiving until we get a message""" while True: dat = sock.receive() if dat is not None: - return log.Event.from_bytes(dat) - -# TODO: This does not belong in messaging -def get_one_can(logcan): - while True: - can = recv_one_retry(logcan) - if len(can.can) > 0: - return can + return log_from_bytes(dat) class SubMaster(): - def __init__(self, services, ignore_alive=None, addr="127.0.0.1"): - self.poller = Poller() + def __init__(self, services: List[str], poll: Optional[List[str]] = None, + ignore_alive: Optional[List[str]] = None, ignore_avg_freq: Optional[List[str]] = None, + addr: str = "127.0.0.1"): self.frame = -1 - self.updated = {s : False for s in services} - self.rcv_time = {s : 0. for s in services} - self.rcv_frame = {s : 0 for s in services} - self.alive = {s : False for s in services} + self.updated = {s: False for s in services} + self.rcv_time = {s: 0. for s in services} + self.rcv_frame = {s: 0 for s in services} + self.alive = {s: False for s in services} + self.recv_dts = {s: deque([0.0] * AVG_FREQ_HISTORY, maxlen=AVG_FREQ_HISTORY) for s in services} self.sock = {} self.freq = {} self.data = {} - self.logMonoTime = {} self.valid = {} + self.logMonoTime = {} - if ignore_alive is not None: - self.ignore_alive = ignore_alive - else: - self.ignore_alive = [] + self.poller = Poller() + self.non_polled_services = [s for s in services if poll is not None and + len(poll) and s not in poll] + + self.ignore_average_freq = [] if ignore_avg_freq is None else ignore_avg_freq + self.ignore_alive = [] if ignore_alive is None else ignore_alive for s in services: if addr is not None: - self.sock[s] = sub_sock(s, poller=self.poller, addr=addr, conflate=True) + p = self.poller if s not in self.non_polled_services else None + self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True) self.freq[s] = service_list[s].frequency - data = new_message() try: - data.init(s) - except capnp.lib.capnp.KjException: - # lists - data.init(s, 0) + data = new_message(s) + except capnp.lib.capnp.KjException: # pylint: disable=c-extension-no-member + data = new_message(s, 0) # lists self.data[s] = getattr(data, s) self.logMonoTime[s] = 0 self.valid[s] = data.valid - def __getitem__(self, s): + def __getitem__(self, s: str) -> capnp.lib.capnp._DynamicStructReader: return self.data[s] - def update(self, timeout=1000): + def update(self, timeout: int = 1000) -> None: msgs = [] for sock in self.poller.poll(timeout): msgs.append(recv_one_or_none(sock)) + + # non-blocking receive for non-polled sockets + for s in self.non_polled_services: + msgs.append(recv_one_or_none(self.sock[s])) self.update_msgs(sec_since_boot(), msgs) - def update_msgs(self, cur_time, msgs): - # TODO: add optional input that specify the service to wait for + def update_msgs(self, cur_time: float, msgs: List[capnp.lib.capnp._DynamicStructReader]) -> None: self.frame += 1 self.updated = dict.fromkeys(self.updated, False) for msg in msgs: @@ -178,44 +193,59 @@ def update_msgs(self, cur_time, msgs): s = msg.which() self.updated[s] = True + + if self.rcv_time[s] > 1e-5 and self.freq[s] > 1e-5 and (s not in self.non_polled_services) \ + and (s not in self.ignore_average_freq): + self.recv_dts[s].append(cur_time - self.rcv_time[s]) + self.rcv_time[s] = cur_time self.rcv_frame[s] = self.frame self.data[s] = getattr(msg, s) self.logMonoTime[s] = msg.logMonoTime self.valid[s] = msg.valid - for s in self.data: - # arbitrary small number to avoid float comparison. If freq is 0, we can skip the check - if self.freq[s] > 1e-5: - # alive if delay is within 10x the expected frequency - self.alive[s] = (cur_time - self.rcv_time[s]) < (10. / self.freq[s]) - else: + if SIMULATION: self.alive[s] = True - def all_alive(self, service_list=None): + if not SIMULATION: + for s in self.data: + # arbitrary small number to avoid float comparison. If freq is 0, we can skip the check + if self.freq[s] > 1e-5: + # alive if delay is within 10x the expected frequency + self.alive[s] = (cur_time - self.rcv_time[s]) < (10. / self.freq[s]) + + # alive if average frequency is higher than 90% of expected frequency + avg_dt = sum(self.recv_dts[s]) / AVG_FREQ_HISTORY + expected_dt = 1 / (self.freq[s] * 0.90) + self.alive[s] = self.alive[s] and (avg_dt < expected_dt) + else: + self.alive[s] = True + + def all_alive(self, service_list=None) -> bool: if service_list is None: # check all service_list = self.alive.keys() return all(self.alive[s] for s in service_list if s not in self.ignore_alive) - def all_valid(self, service_list=None): + def all_valid(self, service_list=None) -> bool: if service_list is None: # check all service_list = self.valid.keys() return all(self.valid[s] for s in service_list) - def all_alive_and_valid(self, service_list=None): + def all_alive_and_valid(self, service_list=None) -> bool: if service_list is None: # check all service_list = self.alive.keys() return self.all_alive(service_list=service_list) and self.all_valid(service_list=service_list) - class PubMaster(): - def __init__(self, services): + def __init__(self, services: List[str]): self.sock = {} for s in services: self.sock[s] = pub_sock(s) - def send(self, s, dat): - # accept either bytes or capnp builder + def send(self, s: str, dat: Union[bytes, capnp.lib.capnp._DynamicStructBuilder]) -> None: if not isinstance(dat, bytes): dat = dat.to_bytes() self.sock[s].send(dat) + + def all_readers_updated(self, s: str) -> bool: + return self.sock[s].all_readers_updated() diff --git a/cereal/messaging/bridge.cc b/cereal/messaging/bridge.cc index 8e29566ca26c64..d4bdfcea714c53 100644 --- a/cereal/messaging/bridge.cc +++ b/cereal/messaging/bridge.cc @@ -1,59 +1,74 @@ -#include -#include +#include #include #include +#include #include +#include typedef void (*sighandler_t)(int sig); +#include "impl_msgq.h" +#include "impl_zmq.h" #include "services.h" -#include "impl_msgq.hpp" -#include "impl_zmq.hpp" - void sigpipe_handler(int sig) { assert(sig == SIGPIPE); std::cout << "SIGPIPE received" << std::endl; } -static std::vector get_services() { - std::vector name_list; - +static std::vector get_services(std::string whitelist_str, bool zmq_to_msgq) { + std::vector service_list; for (const auto& it : services) { std::string name = it.name; - if (name == "plusFrame" || name == "uiLayoutState") continue; - name_list.push_back(name); + bool in_whitelist = whitelist_str.find(name) != std::string::npos; + if (name == "plusFrame" || name == "uiLayoutState" || (zmq_to_msgq && !in_whitelist)) { + continue; + } + service_list.push_back(name); } - - return name_list; + return service_list; } - -int main(void){ +int main(int argc, char** argv) { signal(SIGPIPE, (sighandler_t)sigpipe_handler); - auto endpoints = get_services(); + bool zmq_to_msgq = argc > 2; + std::string ip = zmq_to_msgq ? argv[1] : "127.0.0.1"; + std::string whitelist_str = zmq_to_msgq ? std::string(argv[2]) : ""; + + Poller *poller; + Context *pub_context; + Context *sub_context; + if (zmq_to_msgq) { // republishes zmq debugging messages as msgq + poller = new ZMQPoller(); + pub_context = new MSGQContext(); + sub_context = new ZMQContext(); + } else { + poller = new MSGQPoller(); + pub_context = new ZMQContext(); + sub_context = new MSGQContext(); + } std::map sub2pub; + for (auto endpoint: get_services(whitelist_str, zmq_to_msgq)) { + PubSocket * pub_sock; + SubSocket * sub_sock; + if (zmq_to_msgq) { + pub_sock = new MSGQPubSocket(); + sub_sock = new ZMQSubSocket(); + } else { + pub_sock = new ZMQPubSocket(); + sub_sock = new MSGQSubSocket(); + } + pub_sock->connect(pub_context, endpoint); + sub_sock->connect(sub_context, endpoint, ip, false); - Context *zmq_context = new ZMQContext(); - Context *msgq_context = new MSGQContext(); - Poller *poller = new MSGQPoller(); - - for (auto endpoint: endpoints){ - SubSocket * msgq_sock = new MSGQSubSocket(); - msgq_sock->connect(msgq_context, endpoint, "127.0.0.1", false); - poller->registerSocket(msgq_sock); - - PubSocket * zmq_sock = new ZMQPubSocket(); - zmq_sock->connect(zmq_context, endpoint); - - sub2pub[msgq_sock] = zmq_sock; + poller->registerSocket(sub_sock); + sub2pub[sub_sock] = pub_sock; } - - while (true){ - for (auto sub_sock : poller->poll(100)){ + while (true) { + for (auto sub_sock : poller->poll(100)) { Message * msg = sub_sock->receive(); if (msg == NULL) continue; sub2pub[sub_sock]->sendMessage(msg); diff --git a/cereal/messaging/catch2/catch.hpp b/cereal/messaging/catch2/catch.hpp deleted file mode 100644 index 5feb2a4bea7dba..00000000000000 --- a/cereal/messaging/catch2/catch.hpp +++ /dev/null @@ -1,17075 +0,0 @@ -/* - * Catch v2.9.2 - * Generated: 2019-08-08 13:35:12.279703 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 9 -#define CATCH_VERSION_PATCH 2 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -#ifdef __APPLE__ -# include -# if TARGET_OS_OSX == 1 -# define CATCH_PLATFORM_MAC -# elif TARGET_OS_IPHONE == 1 -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -#if defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif - -#ifdef __clang__ - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") -# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic pop" ) - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic pop" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic pop" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic pop" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -# if _MSC_VER >= 1900 // Visual Studio 2015 or newer -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -# endif - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Check if string_view is available and usable -// The check is split apart to work around v140 (VS2015) preprocessor issue... -#if defined(__has_include) -#if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW -#endif -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Check if optional is available and usable -#if defined(__has_include) -# if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL -# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // __has_include - -//////////////////////////////////////////////////////////////////////////////// -// Check if byte is available and usable -#if defined(__has_include) -# if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# define CATCH_INTERNAL_CONFIG_CPP17_BYTE -# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // __has_include - -//////////////////////////////////////////////////////////////////////////////// -// Check if variant is available and usable -#if defined(__has_include) -# if __has_include() && defined(CATCH_CPP17_OR_GREATER) -# if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 -# include -# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) -# define CATCH_CONFIG_NO_CPP17_VARIANT -# else -# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT -# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) -# else -# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT -# endif // defined(__clang__) && (__clang_major__ < 8) -# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // __has_include - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) -# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept; - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. c_str() must return a null terminated - /// string, however, and so the StringRef will internally take ownership - /// (taking a copy), if necessary. In theory this ownership is not externally - /// visible - but it does mean (substring) StringRefs should not be shared between - /// threads. - class StringRef { - public: - using size_type = std::size_t; - - private: - friend struct StringRefTestAccess; - - char const* m_start; - size_type m_size; - - char* m_data = nullptr; - - void takeOwnership(); - - static constexpr char const* const s_empty = ""; - - public: // construction/ assignment - StringRef() noexcept - : StringRef( s_empty, 0 ) - {} - - StringRef( StringRef const& other ) noexcept - : m_start( other.m_start ), - m_size( other.m_size ) - {} - - StringRef( StringRef&& other ) noexcept - : m_start( other.m_start ), - m_size( other.m_size ), - m_data( other.m_data ) - { - other.m_data = nullptr; - } - - StringRef( char const* rawChars ) noexcept; - - StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - ~StringRef() noexcept { - delete[] m_data; - } - - auto operator = ( StringRef const &other ) noexcept -> StringRef& { - delete[] m_data; - m_data = nullptr; - m_start = other.m_start; - m_size = other.m_size; - return *this; - } - - operator std::string() const; - - void swap( StringRef& other ) noexcept; - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != ( StringRef const& other ) const noexcept -> bool; - - auto operator[] ( size_type index ) const noexcept -> char; - - public: // named queries - auto empty() const noexcept -> bool { - return m_size == 0; - } - auto size() const noexcept -> size_type { - return m_size; - } - - auto numberOfCharacters() const noexcept -> size_type; - auto c_str() const -> char const*; - - public: // substrings and searches - auto substr( size_type start, size_type size ) const noexcept -> StringRef; - - // Returns the current start pointer. - // Note that the pointer can change when if the StringRef is a substring - auto currentData() const noexcept -> char const*; - - private: // ownership queries - may not be consistent between calls - auto isOwned() const noexcept -> bool; - auto isSubstring() const noexcept -> bool; - }; - - auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; - auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; - auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } - -} // namespace Catch - -inline auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_type_traits.hpp - - -#include - -namespace Catch{ - -#ifdef CATCH_CPP17_OR_GREATER - template - inline constexpr auto is_unique = std::true_type{}; - - template - inline constexpr auto is_unique = std::bool_constant< - (!std::is_same_v && ...) && is_unique - >{}; -#else - -template -struct is_unique : std::true_type{}; - -template -struct is_unique : std::integral_constant -::value - && is_unique::value - && is_unique::value ->{}; - -#endif -} - -// end catch_type_traits.hpp -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - \ - template class L1, typename...E1, template class L2, typename...E2> \ - constexpr auto append(L1, L2) noexcept -> L1 { return {}; }\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - constexpr auto append(L1, L2, Rest...) noexcept -> decltype(append(L1{}, Rest{}...)) { return {}; }\ - template< template class L1, typename...E1, typename...Rest>\ - constexpr auto append(L1, TypeList, Rest...) noexcept -> L1 { return {}; }\ - \ - template< template class Container, template class List, typename...elems>\ - constexpr auto rewrap(List) noexcept -> TypeList> { return {}; }\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - constexpr auto rewrap(List,Elements...) noexcept -> decltype(append(TypeList>{}, rewrap(Elements{}...))) { return {}; }\ - \ - template