From fb942020149934aeb59e5fbe644f72fa861a5fe9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 17 Aug 2023 03:16:31 -0700 Subject: [PATCH 001/159] Multilang: enable Thai (#29447) enable thai in the ui --- selfdrive/ui/translations/languages.json | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/ui/translations/languages.json b/selfdrive/ui/translations/languages.json index 693f24f44b..fa659e18ba 100644 --- a/selfdrive/ui/translations/languages.json +++ b/selfdrive/ui/translations/languages.json @@ -4,6 +4,7 @@ "Français": "main_fr", "Português": "main_pt-BR", "Türkçe": "main_tr", + "ไทย": "main_th", "中文(繁體)": "main_zh-CHT", "中文(简体)": "main_zh-CHS", "한국어": "main_ko", From ad32816fd6bdd744e7f596209822707494d3ba5e Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Thu, 17 Aug 2023 15:51:16 +0000 Subject: [PATCH 002/159] setup cleanup (#29419) * setup cleanup * update ci * update ci * export variables for mac os * check env * what is in the profile script? * install pyenv the same everywhere * temporarily disable brew cache * temporarily disable brew cache * try fixing pyenv virtualenv-init * try this * inject shims path earlier * try alternate install method * switch back to brew install * try eval "$(pyenv init --path)" * add eval "\$(pyenv init --path)" --- .github/workflows/selfdrive_tests.yaml | 7 +++---- tools/install_python_dependencies.sh | 16 ++++++++++------ tools/mac_setup.sh | 9 +-------- tools/openpilot_env.sh | 22 ---------------------- tools/ubuntu_setup.sh | 7 ------- 5 files changed, 14 insertions(+), 47 deletions(-) delete mode 100755 tools/openpilot_env.sh diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 65e10e61ed..427c96c0ec 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -149,18 +149,17 @@ jobs: PYTHONWARNINGS: default - name: Build openpilot run: | - source tools/openpilot_env.sh + eval "$(pyenv init --path)" poetry run scons -j$(nproc) - name: Run tests run: | - source tools/openpilot_env.sh - export PYTHONPATH=$PWD + eval "$(pyenv init --path)" poetry run tools/plotjuggler/test_plotjuggler.py - name: Pre Cache - Cleanup scons cache if: github.ref == 'refs/heads/master' run: | - source tools/openpilot_env.sh rm -rf /tmp/scons_cache/* + eval "$(pyenv init --path)" poetry run scons -j$(nproc) --cache-populate - name: Save scons cache id: scons-save-cache diff --git a/tools/install_python_dependencies.sh b/tools/install_python_dependencies.sh index 075dec3bff..70021f5c2e 100755 --- a/tools/install_python_dependencies.sh +++ b/tools/install_python_dependencies.sh @@ -14,21 +14,19 @@ if ! command -v "pyenv" > /dev/null 2>&1; then echo "pyenv install ..." curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash - echo -e "\n. ~/.pyenvrc" >> $RC_FILE cat < "${HOME}/.pyenvrc" if [ -z "\$PYENV_ROOT" ]; then export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH export PYENV_ROOT="\$HOME/.pyenv" + eval "\$(pyenv init --path)" eval "\$(pyenv init -)" eval "\$(pyenv virtualenv-init -)" fi EOF + echo -e "\nsource ~/.pyenvrc" >> $RC_FILE - # setup now without restarting shell - export PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH - export PYENV_ROOT="$HOME/.pyenv" - eval "$(pyenv init -)" - eval "$(pyenv virtualenv-init -)" + # activate pyenv now + source $RC_FILE fi export MAKEFLAGS="-j$(nproc)" @@ -52,6 +50,12 @@ pip install poetry==1.5.1 poetry config virtualenvs.prefer-active-python true --local echo "PYTHONPATH=${PWD}" > $ROOT/.env +if [[ "$(uname)" == 'Darwin' ]]; then + echo "# msgq doesn't work on mac" >> $ROOT/.env + echo "export ZMQ=1" >> $ROOT/.env + echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> $ROOT/.env +fi + poetry self add poetry-dotenv-plugin@^0.1.0 echo "pip packages install..." diff --git a/tools/mac_setup.sh b/tools/mac_setup.sh index 45bdf90383..3892efd6bb 100755 --- a/tools/mac_setup.sh +++ b/tools/mac_setup.sh @@ -46,6 +46,7 @@ brew "libtool" brew "llvm" brew "openssl@3.0" brew "pyenv" +brew "pyenv-virtualenv" brew "qt@5" brew "zeromq" brew "gcc@12" @@ -69,16 +70,8 @@ export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/openssl@3/include" export PYCURL_CURL_CONFIG=/usr/bin/curl-config export PYCURL_SSL_LIBRARY=openssl -# openpilot environment -if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then - echo "source $ROOT/tools/openpilot_env.sh" >> $RC_FILE - source "$ROOT/tools/openpilot_env.sh" - echo "Added openpilot_env to RC file: $RC_FILE" -fi - # install python dependencies $DIR/install_python_dependencies.sh -eval "$(pyenv init --path)" echo "[ ] installed python dependencies t=$SECONDS" echo diff --git a/tools/openpilot_env.sh b/tools/openpilot_env.sh deleted file mode 100755 index 59108312ac..0000000000 --- a/tools/openpilot_env.sh +++ /dev/null @@ -1,22 +0,0 @@ -if [ -z "$OPENPILOT_ENV" ]; then - export PATH="$HOME/.pyenv/bin:$PATH" - - # Pyenv suggests we place the below two lines in .profile before we source - # .bashrc, but there is no simple way to guarantee we do this correctly - # programmatically across heterogeneous systems. For end-user convenience, - # we add the lines here as a workaround. - # https://github.com/pyenv/pyenv/issues/1906 - export PYENV_ROOT="$HOME/.pyenv" - - if [[ "$(uname)" == 'Linux' ]]; then - eval "$(pyenv virtualenv-init -)" - elif [[ "$(uname)" == 'Darwin' ]]; then - # msgq doesn't work on mac - export ZMQ=1 - export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - fi - eval "$(pyenv init --path)" - eval "$(pyenv init -)" - - export OPENPILOT_ENV=1 -fi diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 581b785252..9007611cc4 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -141,13 +141,6 @@ fi # python setup $DIR/install_python_dependencies.sh -source ~/.bashrc -if [ -z "$OPENPILOT_ENV" ]; then - printf "\nsource %s/tools/openpilot_env.sh" "$ROOT" >> ~/.bashrc - source ~/.bashrc - echo "added openpilot_env to bashrc" -fi - echo echo "---- OPENPILOT SETUP DONE ----" echo "Open a new shell or configure your active shell env by running:" From 59abb469ea4a8443ea07a0638acbc6ece0c9ddd2 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 17 Aug 2023 10:30:55 -0700 Subject: [PATCH 003/159] SCons: respect cache read only (#29437) * respect readonly * gitignore and move to correct folder * also copy old --- .gitignore | 1 + SConstruct | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 85c196aea8..8744237584 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ venv/ .tags .ipynb_checkpoints .idea +.moc_files .overlay_init .overlay_consistent .sconsign.dblite diff --git a/SConstruct b/SConstruct index 3d75dccf9b..e384e31d94 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,5 @@ import os +import shutil import subprocess import sys import sysconfig @@ -334,7 +335,18 @@ qt_flags = [ qt_env['CXXFLAGS'] += qt_flags qt_env['LIBPATH'] += ['#selfdrive/ui'] qt_env['LIBS'] = qt_libs -qt_env['QT3_MOCHPREFIX'] = cache_dir + '/moc_files/moc_' + +# Have to respect cache-readonly +if GetOption('cache_readonly'): + local_moc_files_dir = Dir("#.moc_files").abspath + cache_moc_files_dir = cache_dir + "/moc_files" + if os.path.exists(local_moc_files_dir): + shutil.rmtree(local_moc_files_dir) + if os.path.exists(cache_moc_files_dir): + shutil.copytree(cache_moc_files_dir, local_moc_files_dir) + qt_env['QT3_MOCHPREFIX'] = local_moc_files_dir + "/moc_" +else: + qt_env['QT3_MOCHPREFIX'] = cache_dir + '/moc_files/moc_' if GetOption("clazy"): checks = [ From 1887d9197ab495bb8f4dd2826730e6d53528dd65 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 18 Aug 2023 02:37:42 +0800 Subject: [PATCH 004/159] ui/networking: pass network by value (#29448) --- selfdrive/ui/qt/offroad/networking.cc | 4 ++-- selfdrive/ui/qt/offroad/networking.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index b147671b42..628a92fb58 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -77,7 +77,7 @@ void Networking::refresh() { an->refresh(); } -void Networking::connectToNetwork(const Network &n) { +void Networking::connectToNetwork(const Network n) { if (wifi->isKnownConnection(n.ssid)) { wifi->activateWifiConnection(n.ssid); wifiWidget->refresh(); @@ -310,7 +310,7 @@ WifiItem *WifiUI::getItem(int n) { auto item = n < wifi_items.size() ? wifi_items[n] : wifi_items.emplace_back(new WifiItem(tr("CONNECTING..."), tr("FORGET"))); if (!item->parentWidget()) { QObject::connect(item, &WifiItem::connectToNetwork, this, &WifiUI::connectToNetwork); - QObject::connect(item, &WifiItem::forgotNetwork, [this](const Network &n) { + QObject::connect(item, &WifiItem::forgotNetwork, [this](const Network n) { if (ConfirmationDialog::confirm(tr("Forget Wi-Fi Network \"%1\"?").arg(QString::fromUtf8(n.ssid)), tr("Forget"), this)) wifi->forgetConnection(n.ssid); }); diff --git a/selfdrive/ui/qt/offroad/networking.h b/selfdrive/ui/qt/offroad/networking.h index 7078bf9693..cdcdf067ab 100644 --- a/selfdrive/ui/qt/offroad/networking.h +++ b/selfdrive/ui/qt/offroad/networking.h @@ -12,8 +12,9 @@ public: void setItem(const Network& n, const QPixmap &icon, bool show_forget_btn, const QPixmap &strength); signals: - void connectToNetwork(const Network &n); - void forgotNetwork(const Network &n); + // Cannot pass Network by reference. it may change after the signal is sent. + void connectToNetwork(const Network n); + void forgotNetwork(const Network n); protected: ElidedLabel* ssidLabel; @@ -43,7 +44,7 @@ private: std::vector wifi_items; signals: - void connectToNetwork(const Network &n); + void connectToNetwork(const Network n); public slots: void refresh(); @@ -91,6 +92,6 @@ public slots: void refresh(); private slots: - void connectToNetwork(const Network &n); + void connectToNetwork(const Network n); void wrongPassword(const QString &ssid); }; From 61a00d267380f8ea75e5d7b6aeb7d0dc5e17d763 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 18 Aug 2023 02:42:35 +0800 Subject: [PATCH 005/159] replay/logreader: use unique_ptr for `mbr_` (#29440) --- tools/replay/logreader.cc | 12 +++--------- tools/replay/logreader.h | 3 +-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tools/replay/logreader.cc b/tools/replay/logreader.cc index 9a5df2eeed..74aebceae5 100644 --- a/tools/replay/logreader.cc +++ b/tools/replay/logreader.cc @@ -29,8 +29,7 @@ Event::Event(const kj::ArrayPtr &amsg, bool frame) : reader(a LogReader::LogReader(size_t memory_pool_block_size) { #ifdef HAS_MEMORY_RESOURCE const size_t buf_size = sizeof(Event) * memory_pool_block_size; - pool_buffer_ = ::operator new(buf_size); - mbr_ = new std::pmr::monotonic_buffer_resource(pool_buffer_, buf_size); + mbr_ = std::make_unique(buf_size); #endif events.reserve(memory_pool_block_size); } @@ -39,11 +38,6 @@ LogReader::~LogReader() { for (Event *e : events) { delete e; } - -#ifdef HAS_MEMORY_RESOURCE - delete mbr_; - ::operator delete(pool_buffer_); -#endif } bool LogReader::load(const std::string &url, std::atomic *abort, @@ -69,7 +63,7 @@ bool LogReader::parse(const std::set &allow, std::atomic words((const capnp::word *)raw_.data(), raw_.size() / sizeof(capnp::word)); while (words.size() > 0 && !(abort && *abort)) { #ifdef HAS_MEMORY_RESOURCE - Event *evt = new (mbr_) Event(words); + Event *evt = new (mbr_.get()) Event(words); #else Event *evt = new Event(words); #endif @@ -85,7 +79,7 @@ bool LogReader::parse(const std::set &allow, std::atomicwhich == cereal::Event::WIDE_ROAD_ENCODE_IDX) { #ifdef HAS_MEMORY_RESOURCE - Event *frame_evt = new (mbr_) Event(words, true); + Event *frame_evt = new (mbr_.get()) Event(words, true); #else Event *frame_evt = new Event(words, true); #endif diff --git a/tools/replay/logreader.h b/tools/replay/logreader.h index 010839af22..1aa8c98b45 100644 --- a/tools/replay/logreader.h +++ b/tools/replay/logreader.h @@ -61,7 +61,6 @@ private: bool parse(const std::set &allow, std::atomic *abort); std::string raw_; #ifdef HAS_MEMORY_RESOURCE - std::pmr::monotonic_buffer_resource *mbr_ = nullptr; - void *pool_buffer_ = nullptr; + std::unique_ptr mbr_; #endif }; From 1944945d9dfee6f42a875b119a5cf60daf8ade09 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 17 Aug 2023 13:23:06 -0700 Subject: [PATCH 006/159] Revert "setup cleanup (#29419)" (#29451) This reverts commit ad32816fd6bdd744e7f596209822707494d3ba5e. --- .github/workflows/selfdrive_tests.yaml | 7 ++++--- tools/install_python_dependencies.sh | 16 ++++++---------- tools/mac_setup.sh | 9 ++++++++- tools/openpilot_env.sh | 22 ++++++++++++++++++++++ tools/ubuntu_setup.sh | 7 +++++++ 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100755 tools/openpilot_env.sh diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 427c96c0ec..65e10e61ed 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -149,17 +149,18 @@ jobs: PYTHONWARNINGS: default - name: Build openpilot run: | - eval "$(pyenv init --path)" + source tools/openpilot_env.sh poetry run scons -j$(nproc) - name: Run tests run: | - eval "$(pyenv init --path)" + source tools/openpilot_env.sh + export PYTHONPATH=$PWD poetry run tools/plotjuggler/test_plotjuggler.py - name: Pre Cache - Cleanup scons cache if: github.ref == 'refs/heads/master' run: | + source tools/openpilot_env.sh rm -rf /tmp/scons_cache/* - eval "$(pyenv init --path)" poetry run scons -j$(nproc) --cache-populate - name: Save scons cache id: scons-save-cache diff --git a/tools/install_python_dependencies.sh b/tools/install_python_dependencies.sh index 70021f5c2e..075dec3bff 100755 --- a/tools/install_python_dependencies.sh +++ b/tools/install_python_dependencies.sh @@ -14,19 +14,21 @@ if ! command -v "pyenv" > /dev/null 2>&1; then echo "pyenv install ..." curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash + echo -e "\n. ~/.pyenvrc" >> $RC_FILE cat < "${HOME}/.pyenvrc" if [ -z "\$PYENV_ROOT" ]; then export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH export PYENV_ROOT="\$HOME/.pyenv" - eval "\$(pyenv init --path)" eval "\$(pyenv init -)" eval "\$(pyenv virtualenv-init -)" fi EOF - echo -e "\nsource ~/.pyenvrc" >> $RC_FILE - # activate pyenv now - source $RC_FILE + # setup now without restarting shell + export PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH + export PYENV_ROOT="$HOME/.pyenv" + eval "$(pyenv init -)" + eval "$(pyenv virtualenv-init -)" fi export MAKEFLAGS="-j$(nproc)" @@ -50,12 +52,6 @@ pip install poetry==1.5.1 poetry config virtualenvs.prefer-active-python true --local echo "PYTHONPATH=${PWD}" > $ROOT/.env -if [[ "$(uname)" == 'Darwin' ]]; then - echo "# msgq doesn't work on mac" >> $ROOT/.env - echo "export ZMQ=1" >> $ROOT/.env - echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> $ROOT/.env -fi - poetry self add poetry-dotenv-plugin@^0.1.0 echo "pip packages install..." diff --git a/tools/mac_setup.sh b/tools/mac_setup.sh index 3892efd6bb..45bdf90383 100755 --- a/tools/mac_setup.sh +++ b/tools/mac_setup.sh @@ -46,7 +46,6 @@ brew "libtool" brew "llvm" brew "openssl@3.0" brew "pyenv" -brew "pyenv-virtualenv" brew "qt@5" brew "zeromq" brew "gcc@12" @@ -70,8 +69,16 @@ export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/openssl@3/include" export PYCURL_CURL_CONFIG=/usr/bin/curl-config export PYCURL_SSL_LIBRARY=openssl +# openpilot environment +if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then + echo "source $ROOT/tools/openpilot_env.sh" >> $RC_FILE + source "$ROOT/tools/openpilot_env.sh" + echo "Added openpilot_env to RC file: $RC_FILE" +fi + # install python dependencies $DIR/install_python_dependencies.sh +eval "$(pyenv init --path)" echo "[ ] installed python dependencies t=$SECONDS" echo diff --git a/tools/openpilot_env.sh b/tools/openpilot_env.sh new file mode 100755 index 0000000000..59108312ac --- /dev/null +++ b/tools/openpilot_env.sh @@ -0,0 +1,22 @@ +if [ -z "$OPENPILOT_ENV" ]; then + export PATH="$HOME/.pyenv/bin:$PATH" + + # Pyenv suggests we place the below two lines in .profile before we source + # .bashrc, but there is no simple way to guarantee we do this correctly + # programmatically across heterogeneous systems. For end-user convenience, + # we add the lines here as a workaround. + # https://github.com/pyenv/pyenv/issues/1906 + export PYENV_ROOT="$HOME/.pyenv" + + if [[ "$(uname)" == 'Linux' ]]; then + eval "$(pyenv virtualenv-init -)" + elif [[ "$(uname)" == 'Darwin' ]]; then + # msgq doesn't work on mac + export ZMQ=1 + export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES + fi + eval "$(pyenv init --path)" + eval "$(pyenv init -)" + + export OPENPILOT_ENV=1 +fi diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 9007611cc4..581b785252 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -141,6 +141,13 @@ fi # python setup $DIR/install_python_dependencies.sh +source ~/.bashrc +if [ -z "$OPENPILOT_ENV" ]; then + printf "\nsource %s/tools/openpilot_env.sh" "$ROOT" >> ~/.bashrc + source ~/.bashrc + echo "added openpilot_env to bashrc" +fi + echo echo "---- OPENPILOT SETUP DONE ----" echo "Open a new shell or configure your active shell env by running:" From b8b1e17a21390d9a80b1b0643c0001129292576c Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 18 Aug 2023 05:43:40 +0800 Subject: [PATCH 007/159] ui/networking: do not skip the connected network (#29396) * do not skip connected network * simplify * revert * revert * no implicit * ifwt * fix missing ssid * makes more sense to only update security_type once (first vs. last) * better comment --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/offroad/wifiManager.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc index e233139708..391cc9fb50 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.cc +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -99,15 +99,22 @@ void WifiManager::refreshFinished(QDBusPendingCallWatcher *watcher) { auto properties = replay.value(); const QByteArray ssid = properties["Ssid"].toByteArray(); - uint32_t strength = properties["Strength"].toUInt(); - if (ssid.isEmpty() || (seenNetworks.contains(ssid) && strength <= seenNetworks[ssid].strength)) continue; + if (ssid.isEmpty()) continue; + + // May be multiple access points for each SSID. + // Use first for ssid and security type, then update connected status and strength using all + if (!seenNetworks.contains(ssid)) { + seenNetworks[ssid] = {ssid, 0U, ConnectedType::DISCONNECTED, getSecurityType(properties)}; + } - SecurityType security = getSecurityType(properties); - ConnectedType ctype = ConnectedType::DISCONNECTED; if (path.path() == activeAp) { - ctype = (ssid == connecting_to_network) ? ConnectedType::CONNECTING : ConnectedType::CONNECTED; + seenNetworks[ssid].connected = (ssid == connecting_to_network) ? ConnectedType::CONNECTING : ConnectedType::CONNECTED; + } + + uint32_t strength = properties["Strength"].toUInt(); + if (seenNetworks[ssid].strength < strength) { + seenNetworks[ssid].strength = strength; } - seenNetworks[ssid] = {ssid, strength, ctype, security}; } emit refreshSignal(); From 62a88e504d9ad82f6d070a11a3499bf89c19d08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Thu, 17 Aug 2023 15:36:14 -0700 Subject: [PATCH 008/159] Unpin numpy (#29421) * Unpin numpy * Update lock file * leave acados comment * Fix warnings * Fix more paramsd warnings --- poetry.lock | 61 +++++++++++------------ pyproject.toml | 2 +- selfdrive/controls/lib/lateral_planner.py | 2 +- selfdrive/locationd/paramsd.py | 26 +++++----- 4 files changed, 44 insertions(+), 47 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1b1a75e599..16bfe6f375 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2178,39 +2178,36 @@ setuptools = "*" [[package]] name = "numpy" -version = "1.23.5" -description = "NumPy is the fundamental package for array computing with Python." +version = "1.25.2" +description = "Fundamental package for array computing in Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "numpy-1.23.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63"}, - {file = "numpy-1.23.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d"}, - {file = "numpy-1.23.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43"}, - {file = "numpy-1.23.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1"}, - {file = "numpy-1.23.5-cp310-cp310-win32.whl", hash = "sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280"}, - {file = "numpy-1.23.5-cp310-cp310-win_amd64.whl", hash = "sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6"}, - {file = "numpy-1.23.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96"}, - {file = "numpy-1.23.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa"}, - {file = "numpy-1.23.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2"}, - {file = "numpy-1.23.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387"}, - {file = "numpy-1.23.5-cp311-cp311-win32.whl", hash = "sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0"}, - {file = "numpy-1.23.5-cp311-cp311-win_amd64.whl", hash = "sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d"}, - {file = "numpy-1.23.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a"}, - {file = "numpy-1.23.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9"}, - {file = "numpy-1.23.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398"}, - {file = "numpy-1.23.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb"}, - {file = "numpy-1.23.5-cp38-cp38-win32.whl", hash = "sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07"}, - {file = "numpy-1.23.5-cp38-cp38-win_amd64.whl", hash = "sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e"}, - {file = "numpy-1.23.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f"}, - {file = "numpy-1.23.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de"}, - {file = "numpy-1.23.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d"}, - {file = "numpy-1.23.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719"}, - {file = "numpy-1.23.5-cp39-cp39-win32.whl", hash = "sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481"}, - {file = "numpy-1.23.5-cp39-cp39-win_amd64.whl", hash = "sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df"}, - {file = "numpy-1.23.5-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8"}, - {file = "numpy-1.23.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135"}, - {file = "numpy-1.23.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d"}, - {file = "numpy-1.23.5.tar.gz", hash = "sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a"}, + {file = "numpy-1.25.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:db3ccc4e37a6873045580d413fe79b68e47a681af8db2e046f1dacfa11f86eb3"}, + {file = "numpy-1.25.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:90319e4f002795ccfc9050110bbbaa16c944b1c37c0baeea43c5fb881693ae1f"}, + {file = "numpy-1.25.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dfe4a913e29b418d096e696ddd422d8a5d13ffba4ea91f9f60440a3b759b0187"}, + {file = "numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f08f2e037bba04e707eebf4bc934f1972a315c883a9e0ebfa8a7756eabf9e357"}, + {file = "numpy-1.25.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bec1e7213c7cb00d67093247f8c4db156fd03075f49876957dca4711306d39c9"}, + {file = "numpy-1.25.2-cp310-cp310-win32.whl", hash = "sha256:7dc869c0c75988e1c693d0e2d5b26034644399dd929bc049db55395b1379e044"}, + {file = "numpy-1.25.2-cp310-cp310-win_amd64.whl", hash = "sha256:834b386f2b8210dca38c71a6e0f4fd6922f7d3fcff935dbe3a570945acb1b545"}, + {file = "numpy-1.25.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c5462d19336db4560041517dbb7759c21d181a67cb01b36ca109b2ae37d32418"}, + {file = "numpy-1.25.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c5652ea24d33585ea39eb6a6a15dac87a1206a692719ff45d53c5282e66d4a8f"}, + {file = "numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d60fbae8e0019865fc4784745814cff1c421df5afee233db6d88ab4f14655a2"}, + {file = "numpy-1.25.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:60e7f0f7f6d0eee8364b9a6304c2845b9c491ac706048c7e8cf47b83123b8dbf"}, + {file = "numpy-1.25.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:bb33d5a1cf360304754913a350edda36d5b8c5331a8237268c48f91253c3a364"}, + {file = "numpy-1.25.2-cp311-cp311-win32.whl", hash = "sha256:5883c06bb92f2e6c8181df7b39971a5fb436288db58b5a1c3967702d4278691d"}, + {file = "numpy-1.25.2-cp311-cp311-win_amd64.whl", hash = "sha256:5c97325a0ba6f9d041feb9390924614b60b99209a71a69c876f71052521d42a4"}, + {file = "numpy-1.25.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b79e513d7aac42ae918db3ad1341a015488530d0bb2a6abcbdd10a3a829ccfd3"}, + {file = "numpy-1.25.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:eb942bfb6f84df5ce05dbf4b46673ffed0d3da59f13635ea9b926af3deb76926"}, + {file = "numpy-1.25.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e0746410e73384e70d286f93abf2520035250aad8c5714240b0492a7302fdca"}, + {file = "numpy-1.25.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7806500e4f5bdd04095e849265e55de20d8cc4b661b038957354327f6d9b295"}, + {file = "numpy-1.25.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8b77775f4b7df768967a7c8b3567e309f617dd5e99aeb886fa14dc1a0791141f"}, + {file = "numpy-1.25.2-cp39-cp39-win32.whl", hash = "sha256:2792d23d62ec51e50ce4d4b7d73de8f67a2fd3ea710dcbc8563a51a03fb07b01"}, + {file = "numpy-1.25.2-cp39-cp39-win_amd64.whl", hash = "sha256:76b4115d42a7dfc5d485d358728cdd8719be33cc5ec6ec08632a5d6fca2ed380"}, + {file = "numpy-1.25.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:1a1329e26f46230bf77b02cc19e900db9b52f398d6722ca853349a782d4cff55"}, + {file = "numpy-1.25.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c3abc71e8b6edba80a01a52e66d83c5d14433cbcd26a40c329ec7ed09f37901"}, + {file = "numpy-1.25.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:1b9735c27cea5d995496f46a8b1cd7b408b3f34b6d50459d9ac8fe3a20cc17bf"}, + {file = "numpy-1.25.2.tar.gz", hash = "sha256:fd608e19c8d7c55021dffd43bfe5492fab8cc105cc8986f813f8c3c048b38760"}, ] [[package]] @@ -4164,4 +4161,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "849f9d091efd79cb02fffa24846ddb1dd2857cfdce45527093e3bef7d0bc3598" +content-hash = "4b2510f1465520a9dc757f64861f4fcea9d9663c0ecdebd23b329ef5e0205863" diff --git a/pyproject.toml b/pyproject.toml index 4ceaef54ef..d9cc49bfd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ hexdump = "*" Jinja2 = "*" json-rpc = "*" libusb1 = "*" -numpy = "~1.23" # pinned for acados +numpy = "*" onnx = ">=1.14.0" onnxruntime-gpu = { version = ">=1.15.1", platform = "linux", markers = "platform_machine == 'x86_64'" } pillow = "*" diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py index baea407498..38258b4b5d 100644 --- a/selfdrive/controls/lib/lateral_planner.py +++ b/selfdrive/controls/lib/lateral_planner.py @@ -132,7 +132,7 @@ class LateralPlanner: lateralPlan.psis = self.lat_mpc.x_sol[0:CONTROL_N, 2].tolist() lateralPlan.curvatures = (self.lat_mpc.x_sol[0:CONTROL_N, 3]/self.v_ego).tolist() - lateralPlan.curvatureRates = [float(x/self.v_ego) for x in self.lat_mpc.u_sol[0:CONTROL_N - 1]] + [0.0] + lateralPlan.curvatureRates = [float(x.item() / self.v_ego) for x in self.lat_mpc.u_sol[0:CONTROL_N - 1]] + [0.0] lateralPlan.mpcSolutionValid = bool(plan_solution_valid) lateralPlan.solverExecutionTime = self.lat_mpc.solve_time diff --git a/selfdrive/locationd/paramsd.py b/selfdrive/locationd/paramsd.py index de1265f0d7..1644ceaf92 100755 --- a/selfdrive/locationd/paramsd.py +++ b/selfdrive/locationd/paramsd.py @@ -85,8 +85,8 @@ class ParamsLearner: # We observe the current stiffness and steer ratio (with a high observation noise) to bound # the respective estimate STD. Otherwise the STDs keep increasing, causing rapid changes in the # states in longer routes (especially straight stretches). - stiffness = float(self.kf.x[States.STIFFNESS]) - steer_ratio = float(self.kf.x[States.STEER_RATIO]) + stiffness = float(self.kf.x[States.STIFFNESS].item()) + steer_ratio = float(self.kf.x[States.STEER_RATIO].item()) self.kf.predict_and_observe(t, ObservationKind.STIFFNESS, np.array([[stiffness]])) self.kf.predict_and_observe(t, ObservationKind.STEER_RATIO, np.array([[steer_ratio]])) @@ -198,14 +198,14 @@ def main(sm=None, pm=None): learner = ParamsLearner(CP, CP.steerRatio, 1.0, 0.0) x = learner.kf.x - angle_offset_average = clip(math.degrees(x[States.ANGLE_OFFSET]), + angle_offset_average = clip(math.degrees(x[States.ANGLE_OFFSET].item()), angle_offset_average - MAX_ANGLE_OFFSET_DELTA, angle_offset_average + MAX_ANGLE_OFFSET_DELTA) - angle_offset = clip(math.degrees(x[States.ANGLE_OFFSET] + x[States.ANGLE_OFFSET_FAST]), + angle_offset = clip(math.degrees(x[States.ANGLE_OFFSET].item() + x[States.ANGLE_OFFSET_FAST].item()), angle_offset - MAX_ANGLE_OFFSET_DELTA, angle_offset + MAX_ANGLE_OFFSET_DELTA) - roll = clip(float(x[States.ROAD_ROLL]), roll - ROLL_MAX_DELTA, roll + ROLL_MAX_DELTA) - roll_std = float(P[States.ROAD_ROLL]) + roll = clip(float(x[States.ROAD_ROLL].item()), roll - ROLL_MAX_DELTA, roll + ROLL_MAX_DELTA) + roll_std = float(P[States.ROAD_ROLL].item()) # Account for the opposite signs of the yaw rates - sensors_valid = bool(abs(learner.speed * (x[States.YAW_RATE] + learner.yaw_rate)) < LATERAL_ACC_SENSOR_THRESHOLD) + sensors_valid = bool(abs(learner.speed * (x[States.YAW_RATE].item() + learner.yaw_rate)) < LATERAL_ACC_SENSOR_THRESHOLD) avg_offset_valid = check_valid_with_hysteresis(avg_offset_valid, angle_offset_average, OFFSET_MAX, OFFSET_LOWERED_MAX) total_offset_valid = check_valid_with_hysteresis(total_offset_valid, angle_offset, OFFSET_MAX, OFFSET_LOWERED_MAX) roll_valid = check_valid_with_hysteresis(roll_valid, roll, ROLL_MAX, ROLL_LOWERED_MAX) @@ -215,8 +215,8 @@ def main(sm=None, pm=None): liveParameters = msg.liveParameters liveParameters.posenetValid = True liveParameters.sensorValid = sensors_valid - liveParameters.steerRatio = float(x[States.STEER_RATIO]) - liveParameters.stiffnessFactor = float(x[States.STIFFNESS]) + liveParameters.steerRatio = float(x[States.STEER_RATIO].item()) + liveParameters.stiffnessFactor = float(x[States.STIFFNESS].item()) liveParameters.roll = roll liveParameters.angleOffsetAverageDeg = angle_offset_average liveParameters.angleOffsetDeg = angle_offset @@ -228,10 +228,10 @@ def main(sm=None, pm=None): 0.2 <= liveParameters.stiffnessFactor <= 5.0, min_sr <= liveParameters.steerRatio <= max_sr, )) - liveParameters.steerRatioStd = float(P[States.STEER_RATIO]) - liveParameters.stiffnessFactorStd = float(P[States.STIFFNESS]) - liveParameters.angleOffsetAverageStd = float(P[States.ANGLE_OFFSET]) - liveParameters.angleOffsetFastStd = float(P[States.ANGLE_OFFSET_FAST]) + liveParameters.steerRatioStd = float(P[States.STEER_RATIO].item()) + liveParameters.stiffnessFactorStd = float(P[States.STIFFNESS].item()) + liveParameters.angleOffsetAverageStd = float(P[States.ANGLE_OFFSET].item()) + liveParameters.angleOffsetFastStd = float(P[States.ANGLE_OFFSET_FAST].item()) if DEBUG: liveParameters.filterState = log.LiveLocationKalman.Measurement.new_message() liveParameters.filterState.value = x.tolist() From 282fd778aa303542d5752b0edc3e40db8de10696 Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Thu, 17 Aug 2023 22:43:02 +0000 Subject: [PATCH 009/159] venv in code directory (#29452) put venv in code directory --- .dockerignore | 3 +++ .gitignore | 1 + tools/install_python_dependencies.sh | 1 + 3 files changed, 5 insertions(+) diff --git a/.dockerignore b/.dockerignore index 4a19eb9c3f..1f261adf30 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,9 @@ *.so *.a +venv/ +.venv/ + notebooks phone massivemap diff --git a/.gitignore b/.gitignore index 8744237584..004c0a6441 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv/ +.venv/ .env .clang-format .DS_Store diff --git a/tools/install_python_dependencies.sh b/tools/install_python_dependencies.sh index 075dec3bff..ffa9a6efef 100755 --- a/tools/install_python_dependencies.sh +++ b/tools/install_python_dependencies.sh @@ -50,6 +50,7 @@ pip install pip==23.2.1 pip install poetry==1.5.1 poetry config virtualenvs.prefer-active-python true --local +poetry config virtualenvs.in-project true --local echo "PYTHONPATH=${PWD}" > $ROOT/.env poetry self add poetry-dotenv-plugin@^0.1.0 From 111b6438c6a27a4fc3992606321c2282a04ed6cb Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Thu, 17 Aug 2023 17:03:35 -0600 Subject: [PATCH 010/159] Swap `belowSteerSpeed` and `resumeRequired` alert priorities (#28795) * GM: Don't send belowSteerSpeed when resumeRequired * Set belowSteerSpeed alert to LOW priority, resumeRequired to MID * Add script to output all events and their priorities by type * Set CP, CS, sm * Subscribe to same messages as controlsd * Create callable alerts * Remove event print script * Remove sng check --- selfdrive/controls/lib/events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index e552e18966..0230a5775c 100755 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -238,7 +238,7 @@ def below_steer_speed_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.S f"Steer Unavailable Below {get_display_speed(CP.minSteerSpeed, metric)}", "", AlertStatus.userPrompt, AlertSize.small, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.prompt, 0.4) + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.prompt, 0.4) def calibration_incomplete_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: @@ -505,7 +505,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = { "Press Resume to Exit Standstill", "", AlertStatus.userPrompt, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .2), + Priority.MID, VisualAlert.none, AudibleAlert.none, .2), }, EventName.belowSteerSpeed: { From 3563292e6538a9aaf98800e28f9a6557994d8968 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 17 Aug 2023 16:26:30 -0700 Subject: [PATCH 011/159] test_models: remove body standstill exception (#29453) * remove body exception * bump to master --- panda | 2 +- selfdrive/car/tests/test_models.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/panda b/panda index 1f475a8aff..aed103d537 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 1f475a8affc5270227af18e9c418b5fcd12575b9 +Subproject commit aed103d5372d1e5b3fb686d2aa8f111081b37fd0 diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py index 1868526dd9..c40d8bb505 100755 --- a/selfdrive/car/tests/test_models.py +++ b/selfdrive/car/tests/test_models.py @@ -322,9 +322,7 @@ class TestCarModelBase(unittest.TestCase): # TODO: check rest of panda's carstate (steering, ACC main on, etc.) checks['gasPressed'] += CS.gasPressed != self.safety.get_gas_pressed_prev() - if self.CP.carName not in ("body",): - # TODO: fix standstill mismatches for other makes - checks['standstill'] += CS.standstill == self.safety.get_vehicle_moving() + checks['standstill'] += CS.standstill == self.safety.get_vehicle_moving() # TODO: remove this exception once this mismatch is resolved brake_pressed = CS.brakePressed From 2fa09a9ad7cc4d1dc47c45e12189968d42d69998 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 17 Aug 2023 16:32:23 -0700 Subject: [PATCH 012/159] common/gpio: fix warning on re-export (#29457) --- common/gpio.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/gpio.py b/common/gpio.py index 5ec23bf7b1..88a9479a60 100644 --- a/common/gpio.py +++ b/common/gpio.py @@ -1,3 +1,4 @@ +import os from functools import lru_cache from typing import Optional, List @@ -26,6 +27,9 @@ def gpio_read(pin: int) -> Optional[bool]: return val def gpio_export(pin: int) -> None: + if os.path.isdir(f"/sys/class/gpio/gpio{pin}"): + return + try: with open("/sys/class/gpio/export", 'w') as f: f.write(str(pin)) From 6d2922b8e6f6ef29b6d17ea7a1c3d16b40e2236f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 17 Aug 2023 20:51:52 -0700 Subject: [PATCH 013/159] ui/map: slight turn lane types (#29446) * add slight turns * bump cereal * revert * hmm, i like this better * whops * fix * bump --- cereal | 2 +- .../direction_turn_slight_left_inactive.png | Bin 0 -> 3696 bytes .../direction_turn_slight_right_inactive.png | Bin 0 -> 3743 bytes selfdrive/navd/helpers.py | 7 ++++++- selfdrive/ui/qt/maps/map_instructions.h | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 selfdrive/assets/navigation/direction_turn_slight_left_inactive.png create mode 100644 selfdrive/assets/navigation/direction_turn_slight_right_inactive.png diff --git a/cereal b/cereal index 2077dd1a1b..1ee48e0110 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 2077dd1a1b0054713102aee8197434f8cfa07de7 +Subproject commit 1ee48e0110a46fbdd9db50ed89a38bb5a748cfcb diff --git a/selfdrive/assets/navigation/direction_turn_slight_left_inactive.png b/selfdrive/assets/navigation/direction_turn_slight_left_inactive.png new file mode 100644 index 0000000000000000000000000000000000000000..37f1f83627230de134165009353608a9605ac4e8 GIT binary patch literal 3696 zcmc&%i8qvg7k|b!wwO>V%E*K)QMSoCmWiNFg`xG|-07o!J z238>L`h9b9fY0al6%>#_Zde)W0TmxamjHlI24kR$i*#8oaK7tocdT>!^4^3-X09qf zmmq?_L|^C3x}~L1i5^H`SYLN)FQDg?mqLZscE02KIjdf{^ii4&Q;Mx-rzl&Iaq!^<7UfCKTJzTouXbP&EiXKtw1?m4(U4T^V8!eYQ ztH3RONxZ#EuBR~TQt!siy3JMQD)UeZQ*-%Dn&Biq;s#Rmn{VD$QrlM_JRUEE#`;N0 z_+f2GZ1AG~MWe=XEqogWjpc1fXkh;o{!z%Y?EP_{gjTm=H#Q$tO_;3+0&sA3ZT83G zS8zrH<|u0m`Aq}Hj;D1j=Db?1T+gshP;B1$>4t=@w<19SXLN2|&2AG*<0bdb!Tm*)`TpxlHLO-GSymG13(b1`FX&2LH?*cNs zK69O)Pq?E_u4q`UU;CCBz>*g)JI?Z4I^{5oG0C5vGbC1>b8Kv1h~0Bv3NPHtK^vYJ`BJ4Ds{WBG{i!6Y532t1Z4#P;3=`aZ`^xue+t=X8 z>t9|IWpncU2}+(oE`q6(G8-9Nt|ibi-8s89Gc+_b58Rm{aux%+RJ;@gKhd=2KPUd! z2g40RFgGFZHhx)UAS#D~lCSXm7I9IK-q1XBBM>(G>@{|9hE^mvR*hqB=Dvv9REPht z_of6prvQP78k%v(3athN1YA`QTl^Ti>Ax<6;R7u;@=sHxD>_1c*@?IB*{d`weV+p` zgFk&T5S=Rl>Xia$?9D8%&+MjOY&SG6qsX)`r+_HRp_17kkNw}}9B*xXLqUg!?e%{2 zaK#fZZ?}*0^45@o&4;9txA#OuM1myNDxe&`sHSsFKjDhJbVnyAMxqL@h8vk9(S%wN zK2_Gf_iJb4uw_Y~@tdbhy@lpnGZ#W1h6*0{$ySEr1UEJN6wL<84&$tyT-=G7)CF(`gH>td*LU?^Jub)GsuH`u$k3S z?iqgGfy;L97@EIvDj_es*5be1KFZkG129t{jOuvqyWQo2Cp8G#wg# zasO6xEFUAdjge%`Bh(Aj@_CL?w5owbJ?d-2^@F&q^)#cY$<`hga*f==ZP*urR8e!zhNkO_@a3_y z84+sQZV=8A17h0A3jh6Ehv)!{YJM&rl(ZyML*KndYo5Ppsr>>X04M~*JIWoKLS58i zxW8#sQ6(v-)5-}c$W)#8HP6J*{R^5D^oyptx}T>mWR~-*ilDAaF=ZTFoSn58`y3g) zy}dE?$(4v1B<1O9S-1RE2NxHYH}|Ep35*h!e`I5bCmX)3icu&OTe9*&lwZA8$(Pl` zGw&FeLGK~CwDMBJ421VqXoC8K&>z#Sf+3<}su9@^X4x;(I%gmJAi|XP?IANV*b#@} z3q3WN3p+)x*E7~4f31V12fYqLJ}!$IP$nWV8HNE2Mz^!AcJn-#68T_C5XQHx@oC54 z7X%0@H_nyZY%nJOaiu5;#Oq146QB%|7&K;{NVt0+`!hQfL4ESm5l{$j0ZkwDgV-22I{oBDmN| zTGX?Pw-ci;)Y=&nl}^Vr;VY#yPyv!m=CepJ&cE(_pP8XvwYRs-gt}IY+Yax_Br!Lm zOV{Z2jL`2u^&^_oj#m83yWsnb60&}#`$uPcQxNH zo}bqzJeuCsQ>)jSZ;4}NhVRBO|ETqIE^vm}j0fC^${~#!4S}b?$&tN$$#Lt~SmAGF zkd(mlk7eEpkm#RJ!?ZI<*%uGW|Yu{iP;8`-M^Uc%FK)h?S38Xo? z1g2YLcvkyqanFBdq29WE8>aJ=X&_v_VAEOk>ZU`^V`06U<>n&l1me82y2lNNJMwVJ zWP0A`bSv$J0ddJdwTo>fF7>vywv>(RnB2u{MST7!UV+VfSfN*b`jO*-$`Gzj3C1(X zMWdkvO26+lwI7{gvA=lCon{?at)hDz!54>5BbtRwDt~y;VMpU%re~ zi84_uG{ZFwWvTqG^1VFoH%=S9>+jUxVeB;GE}QMuKn>KeLF0^V&kpC-)j1cp3;8EM zvr;oh%lt!&vr3({yPfNn*AJenz6$-+pQ8m=PmaznRdfC(AsTvgi?oPf2Hq+N-YFaY zCdM~e${mAR$)c$dk;Wq-Hr+2A4RCfG1sV}6c3BG109@~Gja+lXNC6J_ZNH~Rb7>}& zz83issiH!7!Ce(7!-LX>6k7{*Y==*srQQ+d4ghuI>>SMkY0^!~7)B&!Uh_YN=nphlT_4OXK zA*SfjGgjDmzd&S+Lk`i}c!xc|Ei5XT(i@Uj$Br_^`G=ggvq*1PR{ls32l{PNEMLg= zP=c#0%2i^9%bEm8IP5(m2Vo~m8s3c!ZV>-E9Q6?W;R9RtzK0Z-e1!j3RX2r-!9#q*CNa1=EMJI4WMK;l7Gk^gljoQ|smp{8W zls-%X$j901mJ8`kVX0%$oIv$yg1nza!Li)@d=0OtE(HT@*l=k6R30mQs+hlMRn)zcC>7EdIMklAqjx#wc@X( zEYCJE$+=nU4w==7_E1vdVm3$ToKM86QlV>qne4^if&0AZ=s>@ys`_D_{|%eRWQVIt z6qN+dM;#1(*!Y`ZS{TMAOd3jNJ4@KmjJ=dP+t%>@Briv)x3{-W%`l}e9Jp(-$+|SY z1(7jkL_>_=y389Vz(TG1)iLp>jxrAI4_Kk)sa}CWj>SJ)EdV{`#qx*q(@z91EewL+ z(CDn=CkWhg%L4+V>biEwLHDYEusxjtvW_@G=HM}VPz!REM`L=w`*9wUvVc$Eayux^ zXZDqA;1jI@i3j4P?sf!IM}zm$k34ry9p9tRu z;Uu0eq!>a$7z;37Mhw7$dXs9|SHubj+HY{)nbZPR-3@6A{UG3(%WQ2cXGj3KN@8eZ z5#R*YMC08f_)&n-=uu`=7-%b!ueFK+g#(E1oST~JpsoK9MnmQPNxmfSt>y7XfrjDe zqBg0~pJ8X6Wy}VPFd3q??w(ko1hDHbd|OyZQXSivC0i>!hjXyrw0Hj5k+o5vD0Jz*FUl9SMbmKx% z6L7yVX>9Xx2KSo^E9p)vaK9N?R&=z30Mv4!|GWBh?4!^)iTJMFMgY7pXmf)KJ-7IO E0lb8=pa1{> literal 0 HcmV?d00001 diff --git a/selfdrive/assets/navigation/direction_turn_slight_right_inactive.png b/selfdrive/assets/navigation/direction_turn_slight_right_inactive.png new file mode 100644 index 0000000000000000000000000000000000000000..8be224581142f30d8c48fe22e8832d61f63d6261 GIT binary patch literal 3743 zcmd5<`8$-~`+o*g4B0|dwxYK+sj-tWWGU;|vL!?qYa~Rbu?}GxYa^6pWJ|+^55BUE0{XW~-%r49y8+t-#5ccb@_#;RvvfZ&G7D6OF+_n7U8861wlMu(; z?^s4c1R1BbHU0+pD39*McK)DE3^pH)Q1;=K&FyJD(n*~#I6-(|T7F_SgiX#Q6N5N0 z@alV?@8tU$bu-thLsxK(snq!$t&Oc#@@~Eul4k#we=~GNo0~)VEm_{Io7vse+`Kj6 zbl0kd6Y%ZM%m(&~#%{D?;ftxwn2-;daqQjjUXs4odDV zWA1ed=rV*8vyz6{)s)UOEnSS%&G;3%vKkryecjyXsFD7S?9~sqT1)bZo;7u|YK0(3 zr_PD1{_H0rvCq8$1Ze|M{3-zS?fLVkQkTO|G9PtUescq4V)!(* zv@DAzBa7L8sW2x7)HsUy%p$^7b20}=gCd|_m>!dFhkbP`he$AC^w)}pcz;h5Ua;WJ)xTWaS;E4 z$Vh(>b=>Ywi`cPa313iU);b5!WHr<`mz89ysHnvC^~9g)-i%M^P3Kk(;&R4|aa~$f zeTcdiwm7K%F!L5ROWB-vPCV1}W|@L66ZwP;1pbzheqjSrh8 z!C~AHx2+67>o?BcEp&FWp^w5l=XRq!mJU{r-4;HyXFblwJw9cl3!?j0Q>(VHJK;;m z*)t0rL(#WyZ#(~E{dnTMJvGy{-zYHsXv^q=j@=;*HwEkaj@f6SM>JC@RJRV$% z^!f@y_=n9dqxEw^{Gjz}LBYHS(z=n~p|Z4F$+PfD_%9G#hZ_xXll|{}I(FN^MT|PxcioKSE{ls-$oMX_0YarY~IC zg0R2awQs>>8+vTxvMdOD8tG*TE`)~hp*fxY$MXZ8(@{@x#`6`qC(1{@ug3r0nJuz3 z&SXtA`W#d4(s_OA01s>JjT?KtXYwy* zk=FuGNfe+yd%C%Gbb$>d`jZGjuHB*6G07ebiw`2fpIW6`oE7UExw`LwRZ03;zV>^e zQ@3Gh(Vz;3uJA1Fv}$0O@ounz@@px5&x}_*6B`1 z@BV8MbrU ztG$2u-r>ZaHLINUvYk=5BkK=+o8*xN?vly*x|))UYrb<}>#T2RU{0VX&4qwVrEa=U zvOGY5Nsq^eH-xt5)@&}lGff8+cHQewWGwtd*|m3GWF2&X86izRhfi_0rDC6KC@FqL zZ>rSIOijh2V_o7We^FdZ{sdp!u0ve@Mb%|zXaD!~h$)&et@w`g1&huqO*U--!-Q+RvqA!idgv2Zrw&C;~br+O6 zaOn|Py0G9Cn>_ZGx7)mJqGq&!-ZWRSq>PffVcgGu(YnlLl5bGMTMfy+x>(<}nQ-gj zNeGI1A^VfumzRLze+|I!I>HY1YT*T0RK<2&dN7s_!xKouSZ|bheZMHu9lfiQ`s2xM z<`CV$=q9ImUWU-PX;n*0OReKsXNE>sNV{;m_%c`V5gEs82A1^Nj~ch~zJ7!|{$9;q z88@2_)pn@Vx$gyN7}yMz7S|n(+`vps zD8PA3G!6O2pck!1OX;q57_LA2N`${Sjg$N~QM$#)B9GXY&3G``4S5R8!7}KFWY>Mm zDt#IzsvsNQOt5MD_RI@QfS1 zOV3O?_#_ZDZN1AepVh$j(5#A?T&)Bo5J91hd8p^SvY#>W(aMNJ_@3)w6^vyMvZ(d; zM=M!c5qZj3FGLA(NN~C~y3uIR%6M8zLjp0_B~CIo-}ak2$JcNykIHHmmEkmps(qsw zBd0zyh?1b)HRC>>Gp>JSJ=26`zym<{rm{Cc%O`}i8uQ>U*ohRkiu3Q$niNR2Ru3Vx zD1PK>nw|5JsjapF0NZiZ$_?kYe*?_T1=bo9aJ*}!4(R9W1)f%Ciwt}47@lvzzGz*+9W*W2lTJBecq1W zKR)!r$B6>o&VjOJ(fqHVL$83iSqskp<9QC`Mnpt}PS(N|%273?R4q$UMcP8dc}!hh z9qrw_cMXS(hF=O%jwp8jwfCrox;d z2OCi=ri4uZuVL?x66V9A4YC&WHkkNp8!JD1&O%WOEA!JI ztYRiFFE9J{^3#*S(0&L~&%MxN76#xcqGk!!;FIGq?ARf)nt zdH|?)3*Tbpf^VAYFs~Q4l>x+()5$+Nl>iW~R0e();uK)l5 literal 0 HcmV?d00001 diff --git a/selfdrive/navd/helpers.py b/selfdrive/navd/helpers.py index 050c571923..5957816334 100644 --- a/selfdrive/navd/helpers.py +++ b/selfdrive/navd/helpers.py @@ -8,6 +8,9 @@ from common.conversions import Conversions from common.numpy_fast import clip from common.params import Params +DIRECTIONS = ('left', 'right', 'straight') +MODIFIABLE_DIRECTIONS = ('left', 'right') + EARTH_MEAN_RADIUS = 6371007.2 SPEED_CONVERSIONS = { 'km/h': Conversions.KPH_TO_MS, @@ -119,8 +122,10 @@ def coordinate_from_param(param: str, params: Optional[Params] = None) -> Option def string_to_direction(direction: str) -> str: - for d in ['left', 'right', 'straight']: + for d in DIRECTIONS: if d in direction: + if 'slight' in direction and d in MODIFIABLE_DIRECTIONS: + return 'slight' + d.capitalize() return d return 'none' diff --git a/selfdrive/ui/qt/maps/map_instructions.h b/selfdrive/ui/qt/maps/map_instructions.h index 26bcb4d580..163c223a2d 100644 --- a/selfdrive/ui/qt/maps/map_instructions.h +++ b/selfdrive/ui/qt/maps/map_instructions.h @@ -11,6 +11,8 @@ static std::map DIRECTIONS = { {cereal::NavInstruction::Direction::LEFT, "left"}, {cereal::NavInstruction::Direction::RIGHT, "right"}, {cereal::NavInstruction::Direction::STRAIGHT, "straight"}, + {cereal::NavInstruction::Direction::SLIGHT_LEFT, "slight_left"}, + {cereal::NavInstruction::Direction::SLIGHT_RIGHT, "slight_right"}, }; class MapInstructions : public QWidget { From 8dcd108972b7a434d91dd00686de669236edf148 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 17 Aug 2023 21:02:09 -0700 Subject: [PATCH 014/159] Rename CivicParams (#29459) * CivicParams -> ReferenceCarParams * remove usage in interface * better name * revert --- selfdrive/car/__init__.py | 15 +++++++-------- selfdrive/car/honda/interface.py | 14 +++++++------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py index 48ac84dd13..156161c796 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -40,9 +40,8 @@ def gen_empty_fingerprint(): return {i: {} for i in range(0, 8)} -# FIXME: hardcoding honda civic 2016 touring params so they can be used to -# scale unknown params for other cars -class CivicParams: +# these params were derived for the Civic and used to calculate params for other cars +class VehicleDynamicsParams: MASS = 1326. + STD_CARGO_KG WHEELBASE = 2.70 CENTER_TO_FRONT = WHEELBASE * 0.4 @@ -55,18 +54,18 @@ class CivicParams: # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase def scale_rot_inertia(mass, wheelbase): - return CivicParams.ROTATIONAL_INERTIA * mass * wheelbase ** 2 / (CivicParams.MASS * CivicParams.WHEELBASE ** 2) + return VehicleDynamicsParams.ROTATIONAL_INERTIA * mass * wheelbase ** 2 / (VehicleDynamicsParams.MASS * VehicleDynamicsParams.WHEELBASE ** 2) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors def scale_tire_stiffness(mass, wheelbase, center_to_front, tire_stiffness_factor): center_to_rear = wheelbase - center_to_front - tire_stiffness_front = (CivicParams.TIRE_STIFFNESS_FRONT * tire_stiffness_factor) * mass / CivicParams.MASS * \ - (center_to_rear / wheelbase) / (CivicParams.CENTER_TO_REAR / CivicParams.WHEELBASE) + tire_stiffness_front = (VehicleDynamicsParams.TIRE_STIFFNESS_FRONT * tire_stiffness_factor) * mass / VehicleDynamicsParams.MASS * \ + (center_to_rear / wheelbase) / (VehicleDynamicsParams.CENTER_TO_REAR / VehicleDynamicsParams.WHEELBASE) - tire_stiffness_rear = (CivicParams.TIRE_STIFFNESS_REAR * tire_stiffness_factor) * mass / CivicParams.MASS * \ - (center_to_front / wheelbase) / (CivicParams.CENTER_TO_FRONT / CivicParams.WHEELBASE) + tire_stiffness_rear = (VehicleDynamicsParams.TIRE_STIFFNESS_REAR * tire_stiffness_factor) * mass / VehicleDynamicsParams.MASS * \ + (center_to_front / wheelbase) / (VehicleDynamicsParams.CENTER_TO_FRONT / VehicleDynamicsParams.WHEELBASE) return tire_stiffness_front, tire_stiffness_rear diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 3d8efa31b3..248be60ee5 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -5,7 +5,7 @@ from common.conversions import Conversions as CV from common.numpy_fast import interp from selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, \ HONDA_BOSCH_ALT_BRAKE_SIGNAL, HONDA_BOSCH_RADARLESS -from selfdrive.car import STD_CARGO_KG, CivicParams, create_button_event, get_safety_config +from selfdrive.car import STD_CARGO_KG, create_button_event, get_safety_config from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.disable_ecu import disable_ecu @@ -89,9 +89,9 @@ class CarInterface(CarInterfaceBase): eps_modified = True if candidate == CAR.CIVIC: - ret.mass = CivicParams.MASS - ret.wheelbase = CivicParams.WHEELBASE - ret.centerToFront = CivicParams.CENTER_TO_FRONT + ret.mass = 1326. + STD_CARGO_KG + ret.wheelbase = 2.70 + ret.centerToFront = ret.wheelbase * 0.4 ret.steerRatio = 15.38 # 10.93 is end-to-end spec if eps_modified: # stock request input values: 0x0000, 0x00DE, 0x014D, 0x01EF, 0x0290, 0x0377, 0x0454, 0x0610, 0x06EE @@ -107,9 +107,9 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.1], [0.33]] elif candidate in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CIVIC_2022): - ret.mass = CivicParams.MASS - ret.wheelbase = CivicParams.WHEELBASE - ret.centerToFront = CivicParams.CENTER_TO_FRONT + ret.mass = 1326. + STD_CARGO_KG + ret.wheelbase = 2.70 + ret.centerToFront = ret.wheelbase * 0.4 ret.steerRatio = 15.38 # 10.93 is end-to-end spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] From f76ffbdbbcef50ba201edc0349f777e4e372b515 Mon Sep 17 00:00:00 2001 From: Jason Young <46612682+jyoung8607@users.noreply.github.com> Date: Fri, 18 Aug 2023 00:06:07 -0400 Subject: [PATCH 015/159] interfaces: add common STD_CARGO_KG to mass (#29416) * cleanup std_cargo_kg * fix Sonata mass * remove snowflake construct --------- Co-authored-by: Shane Smiskol --- selfdrive/car/chrysler/interface.py | 10 ++-- selfdrive/car/ford/interface.py | 14 ++--- selfdrive/car/gm/interface.py | 28 +++++----- selfdrive/car/honda/interface.py | 36 ++++++------- selfdrive/car/hyundai/interface.py | 74 +++++++++++++-------------- selfdrive/car/interfaces.py | 6 ++- selfdrive/car/mazda/interface.py | 10 ++-- selfdrive/car/nissan/interface.py | 8 +-- selfdrive/car/subaru/interface.py | 18 +++---- selfdrive/car/tesla/interface.py | 4 +- selfdrive/car/toyota/interface.py | 40 +++++++-------- selfdrive/car/volkswagen/interface.py | 56 ++++++++++---------- 12 files changed, 154 insertions(+), 150 deletions(-) diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index 22b2073883..a3c0b0c7a1 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.chrysler.values import CAR, RAM_HD, RAM_DT, RAM_CARS, ChryslerFlags from selfdrive.car.interfaces import CarInterfaceBase @@ -35,7 +35,7 @@ class CarInterface(CarInterfaceBase): # Chrysler if candidate in (CAR.PACIFICA_2017_HYBRID, CAR.PACIFICA_2018, CAR.PACIFICA_2018_HYBRID, CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020): - ret.mass = 2242. + STD_CARGO_KG + ret.mass = 2242. ret.wheelbase = 3.089 ret.steerRatio = 16.2 # Pacifica Hybrid 2017 @@ -46,7 +46,7 @@ class CarInterface(CarInterfaceBase): # Jeep elif candidate in (CAR.JEEP_CHEROKEE, CAR.JEEP_CHEROKEE_2019): - ret.mass = 1778 + STD_CARGO_KG + ret.mass = 1778 ret.wheelbase = 2.71 ret.steerRatio = 16.7 ret.steerActuatorDelay = 0.2 @@ -61,7 +61,7 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.2 ret.wheelbase = 3.88 ret.steerRatio = 16.3 - ret.mass = 2493. + STD_CARGO_KG + ret.mass = 2493. ret.minSteerSpeed = 14.5 # Older EPS FW allow steer to zero if any(fw.ecu == 'eps' and fw.fwVersion[:4] <= b"6831" for fw in car_fw): @@ -71,7 +71,7 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.2 ret.wheelbase = 3.785 ret.steerRatio = 15.61 - ret.mass = 3405. + STD_CARGO_KG + ret.mass = 3405. ret.minSteerSpeed = 16 CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning, 1.0, False) diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index d74baa3ce4..990d14de93 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -2,7 +2,7 @@ from cereal import car from panda import Panda from common.conversions import Conversions as CV -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.ford.fordcan import CanBus from selfdrive.car.ford.values import CANFD_CAR, CAR, Ecu from selfdrive.car.interfaces import CarInterfaceBase @@ -39,33 +39,33 @@ class CarInterface(CarInterfaceBase): if candidate == CAR.BRONCO_SPORT_MK1: ret.wheelbase = 2.67 ret.steerRatio = 17.7 - ret.mass = 1625 + STD_CARGO_KG + ret.mass = 1625 elif candidate == CAR.ESCAPE_MK4: ret.wheelbase = 2.71 ret.steerRatio = 16.7 - ret.mass = 1750 + STD_CARGO_KG + ret.mass = 1750 elif candidate == CAR.EXPLORER_MK6: ret.wheelbase = 3.025 ret.steerRatio = 16.8 - ret.mass = 2050 + STD_CARGO_KG + ret.mass = 2050 elif candidate == CAR.F_150_MK14: # required trim only on SuperCrew ret.wheelbase = 3.69 ret.steerRatio = 17.0 - ret.mass = 2000 + STD_CARGO_KG + ret.mass = 2000 elif candidate == CAR.FOCUS_MK4: ret.wheelbase = 2.7 ret.steerRatio = 15.0 - ret.mass = 1350 + STD_CARGO_KG + ret.mass = 1350 elif candidate == CAR.MAVERICK_MK1: ret.wheelbase = 3.076 ret.steerRatio = 17.0 - ret.mass = 1650 + STD_CARGO_KG + ret.mass = 1650 else: raise ValueError(f"Unsupported car: {candidate}") diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 3748fd8868..8e139947a6 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -4,7 +4,7 @@ from math import fabs, exp from panda import Panda from common.conversions import Conversions as CV -from selfdrive.car import STD_CARGO_KG, create_button_event, get_safety_config +from selfdrive.car import create_button_event, get_safety_config from selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG from selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus from selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD @@ -135,7 +135,7 @@ class CarInterface(CarInterfaceBase): ret.longitudinalActuatorDelayUpperBound = 0.5 # large delay to initially start braking if candidate == CAR.VOLT: - ret.mass = 1607. + STD_CARGO_KG + ret.mass = 1607. ret.wheelbase = 2.69 ret.steerRatio = 17.7 # Stock 15.7, LiveParameters ret.tireStiffnessFactor = 0.469 # Stock Michelin Energy Saver A/S, LiveParameters @@ -149,13 +149,13 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.2 elif candidate == CAR.MALIBU: - ret.mass = 1496. + STD_CARGO_KG + ret.mass = 1496. ret.wheelbase = 2.83 ret.steerRatio = 15.8 ret.centerToFront = ret.wheelbase * 0.4 # wild guess elif candidate == CAR.HOLDEN_ASTRA: - ret.mass = 1363. + STD_CARGO_KG + ret.mass = 1363. ret.wheelbase = 2.662 # Remaining parameters copied from Volt for now ret.centerToFront = ret.wheelbase * 0.4 @@ -163,7 +163,7 @@ class CarInterface(CarInterfaceBase): elif candidate == CAR.ACADIA: ret.minEnableSpeed = -1. # engage speed is decided by pcm - ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4353. * CV.LB_TO_KG ret.wheelbase = 2.86 ret.steerRatio = 14.4 # end to end is 13.46 ret.centerToFront = ret.wheelbase * 0.4 @@ -171,27 +171,27 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) elif candidate == CAR.BUICK_LACROSSE: - ret.mass = 1712. + STD_CARGO_KG + ret.mass = 1712. ret.wheelbase = 2.91 ret.steerRatio = 15.8 ret.centerToFront = ret.wheelbase * 0.4 # wild guess CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) elif candidate == CAR.BUICK_REGAL: - ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2 + ret.mass = 3779. * CV.LB_TO_KG # (3849+3708)/2 ret.wheelbase = 2.83 # 111.4 inches in meters ret.steerRatio = 14.4 # guess for tourx ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx elif candidate == CAR.CADILLAC_ATS: - ret.mass = 1601. + STD_CARGO_KG + ret.mass = 1601. ret.wheelbase = 2.78 ret.steerRatio = 15.3 ret.centerToFront = ret.wheelbase * 0.5 elif candidate == CAR.ESCALADE: ret.minEnableSpeed = -1. # engage speed is decided by pcm - ret.mass = 5653. * CV.LB_TO_KG + STD_CARGO_KG # (5552+5815)/2 + ret.mass = 5653. * CV.LB_TO_KG # (5552+5815)/2 ret.wheelbase = 2.95 # 116 inches in meters ret.steerRatio = 17.3 ret.centerToFront = ret.wheelbase * 0.5 @@ -199,7 +199,7 @@ class CarInterface(CarInterfaceBase): elif candidate == CAR.ESCALADE_ESV: ret.minEnableSpeed = -1. # engage speed is decided by pcm - ret.mass = 2739. + STD_CARGO_KG + ret.mass = 2739. ret.wheelbase = 3.302 ret.steerRatio = 17.3 ret.centerToFront = ret.wheelbase * 0.5 @@ -209,7 +209,7 @@ class CarInterface(CarInterfaceBase): ret.tireStiffnessFactor = 1.0 elif candidate == CAR.BOLT_EUV: - ret.mass = 1669. + STD_CARGO_KG + ret.mass = 1669. ret.wheelbase = 2.63779 ret.steerRatio = 16.8 ret.centerToFront = ret.wheelbase * 0.4 @@ -218,7 +218,7 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) elif candidate == CAR.SILVERADO: - ret.mass = 2450. + STD_CARGO_KG + ret.mass = 2450. ret.wheelbase = 3.75 ret.steerRatio = 16.3 ret.centerToFront = ret.wheelbase * 0.5 @@ -231,14 +231,14 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) elif candidate == CAR.EQUINOX: - ret.mass = 3500. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3500. * CV.LB_TO_KG ret.wheelbase = 2.72 ret.steerRatio = 14.4 ret.centerToFront = ret.wheelbase * 0.4 CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) elif candidate == CAR.TRAILBLAZER: - ret.mass = 1345. + STD_CARGO_KG + ret.mass = 1345. ret.wheelbase = 2.64 ret.steerRatio = 16.8 ret.centerToFront = ret.wheelbase * 0.4 diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 248be60ee5..1025eb6212 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -5,7 +5,7 @@ from common.conversions import Conversions as CV from common.numpy_fast import interp from selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, \ HONDA_BOSCH_ALT_BRAKE_SIGNAL, HONDA_BOSCH_RADARLESS -from selfdrive.car import STD_CARGO_KG, create_button_event, get_safety_config +from selfdrive.car import create_button_event, get_safety_config from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.disable_ecu import disable_ecu @@ -89,7 +89,7 @@ class CarInterface(CarInterfaceBase): eps_modified = True if candidate == CAR.CIVIC: - ret.mass = 1326. + STD_CARGO_KG + ret.mass = 1326. ret.wheelbase = 2.70 ret.centerToFront = ret.wheelbase * 0.4 ret.steerRatio = 15.38 # 10.93 is end-to-end spec @@ -107,7 +107,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.1], [0.33]] elif candidate in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CIVIC_2022): - ret.mass = 1326. + STD_CARGO_KG + ret.mass = 1326. ret.wheelbase = 2.70 ret.centerToFront = ret.wheelbase * 0.4 ret.steerRatio = 15.38 # 10.93 is end-to-end spec @@ -115,7 +115,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate in (CAR.ACCORD, CAR.ACCORDH): - ret.mass = 3279. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3279. * CV.LB_TO_KG ret.wheelbase = 2.83 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 16.33 # 11.82 is spec end-to-end @@ -128,7 +128,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] elif candidate == CAR.ACURA_ILX: - ret.mass = 3095. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3095. * CV.LB_TO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.37 ret.steerRatio = 18.61 # 15.3 is spec end-to-end @@ -137,7 +137,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate in (CAR.CRV, CAR.CRV_EU): - ret.mass = 3572. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3572. * CV.LB_TO_KG ret.wheelbase = 2.62 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 16.89 # as spec @@ -147,7 +147,7 @@ class CarInterface(CarInterfaceBase): ret.wheelSpeedFactor = 1.025 elif candidate == CAR.CRV_5G: - ret.mass = 3410. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3410. * CV.LB_TO_KG ret.wheelbase = 2.66 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 16.0 # 12.3 is spec end-to-end @@ -164,7 +164,7 @@ class CarInterface(CarInterfaceBase): ret.wheelSpeedFactor = 1.025 elif candidate == CAR.CRV_HYBRID: - ret.mass = 1667. + STD_CARGO_KG # mean of 4 models in kg + ret.mass = 1667. # mean of 4 models in kg ret.wheelbase = 2.66 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 16.0 # 12.3 is spec end-to-end @@ -174,7 +174,7 @@ class CarInterface(CarInterfaceBase): ret.wheelSpeedFactor = 1.025 elif candidate == CAR.FIT: - ret.mass = 2644. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 2644. * CV.LB_TO_KG ret.wheelbase = 2.53 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 13.06 @@ -183,7 +183,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] elif candidate == CAR.FREED: - ret.mass = 3086. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3086. * CV.LB_TO_KG ret.wheelbase = 2.74 # the remaining parameters were copied from FIT ret.centerToFront = ret.wheelbase * 0.39 @@ -193,7 +193,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] elif candidate in (CAR.HRV, CAR.HRV_3G): - ret.mass = 3125 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3125 * CV.LB_TO_KG ret.wheelbase = 2.61 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 15.2 @@ -206,7 +206,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] # TODO: can probably use some tuning elif candidate == CAR.ACURA_RDX: - ret.mass = 3935. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3935. * CV.LB_TO_KG ret.wheelbase = 2.68 ret.centerToFront = ret.wheelbase * 0.38 ret.steerRatio = 15.0 # as spec @@ -215,7 +215,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate == CAR.ACURA_RDX_3G: - ret.mass = 4068. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4068. * CV.LB_TO_KG ret.wheelbase = 2.75 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 11.95 # as spec @@ -224,7 +224,7 @@ class CarInterface(CarInterfaceBase): ret.tireStiffnessFactor = 0.677 elif candidate in (CAR.ODYSSEY, CAR.ODYSSEY_CHN): - ret.mass = 1900. + STD_CARGO_KG + ret.mass = 1900. ret.wheelbase = 3.00 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 14.35 # as spec @@ -236,7 +236,7 @@ class CarInterface(CarInterfaceBase): ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end elif candidate == CAR.PILOT: - ret.mass = 4278. * CV.LB_TO_KG + STD_CARGO_KG # average weight + ret.mass = 4278. * CV.LB_TO_KG # average weight ret.wheelbase = 2.86 ret.centerToFront = ret.wheelbase * 0.428 ret.steerRatio = 16.0 # as spec @@ -245,7 +245,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38], [0.11]] elif candidate == CAR.RIDGELINE: - ret.mass = 4515. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4515. * CV.LB_TO_KG ret.wheelbase = 3.18 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 15.59 # as spec @@ -254,7 +254,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38], [0.11]] elif candidate == CAR.INSIGHT: - ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 2987. * CV.LB_TO_KG ret.wheelbase = 2.7 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 15.0 # 12.58 is spec end-to-end @@ -263,7 +263,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] elif candidate == CAR.HONDA_E: - ret.mass = 3338.8 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3338.8 * CV.LB_TO_KG ret.wheelbase = 2.5 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 16.71 diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 45b9f0923f..ed0dab54fc 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -6,7 +6,7 @@ from selfdrive.car.hyundai.hyundaicanfd import CanBus from selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \ EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, Buttons from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR -from selfdrive.car import STD_CARGO_KG, create_button_event, get_safety_config +from selfdrive.car import create_button_event, get_safety_config from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.disable_ecu import disable_ecu @@ -62,180 +62,180 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) if candidate in (CAR.SANTA_FE, CAR.SANTA_FE_2022, CAR.SANTA_FE_HEV_2022, CAR.SANTA_FE_PHEV_2022): - ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3982. * CV.LB_TO_KG ret.wheelbase = 2.766 # Values from optimizer ret.steerRatio = 16.55 # 13.8 is spec end-to-end ret.tireStiffnessFactor = 0.82 elif candidate in (CAR.SONATA, CAR.SONATA_HYBRID): - ret.mass = 1513. + STD_CARGO_KG + ret.mass = 1513. ret.wheelbase = 2.84 ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable ret.tireStiffnessFactor = 0.65 elif candidate == CAR.SONATA_LF: - ret.mass = 1536. + STD_CARGO_KG + ret.mass = 1536. ret.wheelbase = 2.804 ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable elif candidate == CAR.PALISADE: - ret.mass = 1999. + STD_CARGO_KG + ret.mass = 1999. ret.wheelbase = 2.90 ret.steerRatio = 15.6 * 1.15 ret.tireStiffnessFactor = 0.63 elif candidate == CAR.ELANTRA: - ret.mass = 1275. + STD_CARGO_KG + ret.mass = 1275. ret.wheelbase = 2.7 ret.steerRatio = 15.4 # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535 ret.tireStiffnessFactor = 0.385 # stiffnessFactor settled on 1.0081302973865127 ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.ELANTRA_2021: - ret.mass = (2800. * CV.LB_TO_KG) + STD_CARGO_KG + ret.mass = 2800. * CV.LB_TO_KG ret.wheelbase = 2.72 ret.steerRatio = 12.9 ret.tireStiffnessFactor = 0.65 elif candidate == CAR.ELANTRA_HEV_2021: - ret.mass = (3017. * CV.LB_TO_KG) + STD_CARGO_KG + ret.mass = 3017. * CV.LB_TO_KG ret.wheelbase = 2.72 ret.steerRatio = 12.9 ret.tireStiffnessFactor = 0.65 elif candidate == CAR.HYUNDAI_GENESIS: - ret.mass = 2060. + STD_CARGO_KG + ret.mass = 2060. ret.wheelbase = 3.01 ret.steerRatio = 16.5 ret.minSteerSpeed = 60 * CV.KPH_TO_MS elif candidate in (CAR.KONA, CAR.KONA_EV, CAR.KONA_HEV, CAR.KONA_EV_2022): - ret.mass = {CAR.KONA_EV: 1685., CAR.KONA_HEV: 1425., CAR.KONA_EV_2022: 1743.}.get(candidate, 1275.) + STD_CARGO_KG + ret.mass = {CAR.KONA_EV: 1685., CAR.KONA_HEV: 1425., CAR.KONA_EV_2022: 1743.}.get(candidate, 1275.) ret.wheelbase = 2.6 ret.steerRatio = 13.42 # Spec ret.tireStiffnessFactor = 0.385 elif candidate in (CAR.IONIQ, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV_2019, CAR.IONIQ_HEV_2022, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV): - ret.mass = 1490. + STD_CARGO_KG # weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx + ret.mass = 1490. # weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx ret.wheelbase = 2.7 ret.steerRatio = 13.73 # Spec ret.tireStiffnessFactor = 0.385 if candidate in (CAR.IONIQ, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV_2019): ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.VELOSTER: - ret.mass = 2917. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 2917. * CV.LB_TO_KG ret.wheelbase = 2.80 ret.steerRatio = 13.75 * 1.15 ret.tireStiffnessFactor = 0.5 elif candidate == CAR.TUCSON: - ret.mass = 3520. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3520. * CV.LB_TO_KG ret.wheelbase = 2.67 ret.steerRatio = 14.00 * 1.15 ret.tireStiffnessFactor = 0.385 elif candidate in (CAR.TUCSON_4TH_GEN, CAR.TUCSON_HYBRID_4TH_GEN): - ret.mass = 1630. + STD_CARGO_KG # average + ret.mass = 1630. # average ret.wheelbase = 2.756 ret.steerRatio = 16. ret.tireStiffnessFactor = 0.385 elif candidate == CAR.SANTA_CRUZ_1ST_GEN: - ret.mass = 1870. + STD_CARGO_KG # weight from Limited trim - the only supported trim + ret.mass = 1870. # weight from Limited trim - the only supported trim ret.wheelbase = 3.000 # steering ratio according to Hyundai News https://www.hyundainews.com/assets/documents/original/48035-2022SantaCruzProductGuideSpecsv2081521.pdf ret.steerRatio = 14.2 # Kia elif candidate == CAR.KIA_SORENTO: - ret.mass = 1985. + STD_CARGO_KG + ret.mass = 1985. ret.wheelbase = 2.78 ret.steerRatio = 14.4 * 1.1 # 10% higher at the center seems reasonable elif candidate in (CAR.KIA_NIRO_EV, CAR.KIA_NIRO_EV_2ND_GEN, CAR.KIA_NIRO_PHEV, CAR.KIA_NIRO_HEV_2021, CAR.KIA_NIRO_HEV_2ND_GEN): - ret.mass = 3543. * CV.LB_TO_KG + STD_CARGO_KG # average of all the cars + ret.mass = 3543. * CV.LB_TO_KG # average of all the cars ret.wheelbase = 2.7 ret.steerRatio = 13.6 # average of all the cars ret.tireStiffnessFactor = 0.385 if candidate == CAR.KIA_NIRO_PHEV: ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.KIA_SELTOS: - ret.mass = 1337. + STD_CARGO_KG + ret.mass = 1337. ret.wheelbase = 2.63 ret.steerRatio = 14.56 elif candidate == CAR.KIA_SPORTAGE_5TH_GEN: - ret.mass = 1700. + STD_CARGO_KG # weight from SX and above trims, average of FWD and AWD versions + ret.mass = 1700. # weight from SX and above trims, average of FWD and AWD versions ret.wheelbase = 2.756 ret.steerRatio = 13.6 # steering ratio according to Kia News https://www.kiamedia.com/us/en/models/sportage/2023/specifications elif candidate in (CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.KIA_OPTIMA_H): - ret.mass = 3558. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3558. * CV.LB_TO_KG ret.wheelbase = 2.80 ret.steerRatio = 13.75 ret.tireStiffnessFactor = 0.5 if candidate == CAR.KIA_OPTIMA_G4: ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate in (CAR.KIA_STINGER, CAR.KIA_STINGER_2022): - ret.mass = 1825. + STD_CARGO_KG + ret.mass = 1825. ret.wheelbase = 2.78 ret.steerRatio = 14.4 * 1.15 # 15% higher at the center seems reasonable elif candidate == CAR.KIA_FORTE: - ret.mass = 2878. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 2878. * CV.LB_TO_KG ret.wheelbase = 2.80 ret.steerRatio = 13.75 ret.tireStiffnessFactor = 0.5 elif candidate == CAR.KIA_CEED: - ret.mass = 1450. + STD_CARGO_KG + ret.mass = 1450. ret.wheelbase = 2.65 ret.steerRatio = 13.75 ret.tireStiffnessFactor = 0.5 elif candidate in (CAR.KIA_K5_2021, CAR.KIA_K5_HEV_2020): - ret.mass = 3381. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3381. * CV.LB_TO_KG ret.wheelbase = 2.85 ret.steerRatio = 13.27 # 2021 Kia K5 Steering Ratio (all trims) ret.tireStiffnessFactor = 0.5 elif candidate == CAR.KIA_EV6: - ret.mass = 2055 + STD_CARGO_KG + ret.mass = 2055 ret.wheelbase = 2.9 ret.steerRatio = 16. ret.tireStiffnessFactor = 0.65 elif candidate in (CAR.IONIQ_5, CAR.IONIQ_6): - ret.mass = 1948 + STD_CARGO_KG + ret.mass = 1948 ret.wheelbase = 2.97 ret.steerRatio = 14.26 ret.tireStiffnessFactor = 0.65 elif candidate == CAR.KIA_SPORTAGE_HYBRID_5TH_GEN: - ret.mass = 1767. + STD_CARGO_KG # SX Prestige trim support only + ret.mass = 1767. # SX Prestige trim support only ret.wheelbase = 2.756 ret.steerRatio = 13.6 elif candidate in (CAR.KIA_SORENTO_4TH_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN): ret.wheelbase = 2.81 ret.steerRatio = 13.5 # average of the platforms if candidate == CAR.KIA_SORENTO_4TH_GEN: - ret.mass = 3957 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3957 * CV.LB_TO_KG else: - ret.mass = 4537 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4537 * CV.LB_TO_KG elif candidate == CAR.KIA_CARNIVAL_4TH_GEN: - ret.mass = 2087. + STD_CARGO_KG + ret.mass = 2087. ret.wheelbase = 3.09 ret.steerRatio = 14.23 # Genesis elif candidate == CAR.GENESIS_GV60_EV_1ST_GEN: - ret.mass = 2205 + STD_CARGO_KG + ret.mass = 2205 ret.wheelbase = 2.9 # https://www.motor1.com/reviews/586376/2023-genesis-gv60-first-drive/#:~:text=Relative%20to%20the%20related%20Ioniq,5%2FEV6%27s%2014.3%3A1. ret.steerRatio = 12.6 elif candidate == CAR.GENESIS_G70: ret.steerActuatorDelay = 0.1 - ret.mass = 1640.0 + STD_CARGO_KG + ret.mass = 1640.0 ret.wheelbase = 2.84 ret.steerRatio = 13.56 elif candidate == CAR.GENESIS_G70_2020: - ret.mass = 3673.0 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3673.0 * CV.LB_TO_KG ret.wheelbase = 2.83 ret.steerRatio = 12.9 elif candidate == CAR.GENESIS_GV70_1ST_GEN: - ret.mass = 1950. + STD_CARGO_KG + ret.mass = 1950. ret.wheelbase = 2.87 ret.steerRatio = 14.6 elif candidate == CAR.GENESIS_G80: - ret.mass = 2060. + STD_CARGO_KG + ret.mass = 2060. ret.wheelbase = 3.01 ret.steerRatio = 16.5 elif candidate == CAR.GENESIS_G90: - ret.mass = 2200. + STD_CARGO_KG + ret.mass = 2200. ret.wheelbase = 3.15 ret.steerRatio = 12.069 elif candidate == CAR.GENESIS_GV80: - ret.mass = 2258. + STD_CARGO_KG + ret.mass = 2258. ret.wheelbase = 2.95 ret.steerRatio = 14.14 diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index a7173018cd..a9966c2bb7 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -9,7 +9,7 @@ from common.conversions import Conversions as CV from common.kalman.simple_kalman import KF1D from common.numpy_fast import clip from common.realtime import DT_CTRL -from selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness +from selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction from selfdrive.controls.lib.events import Events from selfdrive.controls.lib.vehicle_model import VehicleModel @@ -99,6 +99,10 @@ class CarInterfaceBase(ABC): ret = CarInterfaceBase.get_std_params(candidate) ret = cls._get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs) + # Vehicle mass is published curb weight plus assumed payload such as a human driver; notCars have no assumed payload + if not ret.notCar: + ret.mass = ret.mass + STD_CARGO_KG + # Set params dependent on values set by the car interface ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, ret.tireStiffnessFactor) diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 1286b2aa32..cb89c4c448 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -2,7 +2,7 @@ from cereal import car from common.conversions import Conversions as CV from selfdrive.car.mazda.values import CAR, LKAS_LIMITS -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.interfaces import CarInterfaceBase ButtonType = car.CarState.ButtonEvent.Type @@ -25,19 +25,19 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) if candidate in (CAR.CX5, CAR.CX5_2022): - ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3655 * CV.LB_TO_KG ret.wheelbase = 2.7 ret.steerRatio = 15.5 elif candidate in (CAR.CX9, CAR.CX9_2021): - ret.mass = 4217 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4217 * CV.LB_TO_KG ret.wheelbase = 3.1 ret.steerRatio = 17.6 elif candidate == CAR.MAZDA3: - ret.mass = 2875 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 2875 * CV.LB_TO_KG ret.wheelbase = 2.7 ret.steerRatio = 14.0 elif candidate == CAR.MAZDA6: - ret.mass = 3443 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3443 * CV.LB_TO_KG ret.wheelbase = 2.83 ret.steerRatio = 15.5 diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index f26dea43af..423a1bf8de 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 from cereal import car -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.nissan.values import CAR @@ -22,17 +22,17 @@ class CarInterface(CarInterfaceBase): ret.radarUnavailable = True if candidate in (CAR.ROGUE, CAR.XTRAIL): - ret.mass = 1610 + STD_CARGO_KG + ret.mass = 1610 ret.wheelbase = 2.705 ret.centerToFront = ret.wheelbase * 0.44 elif candidate in (CAR.LEAF, CAR.LEAF_IC): - ret.mass = 1610 + STD_CARGO_KG + ret.mass = 1610 ret.wheelbase = 2.705 ret.centerToFront = ret.wheelbase * 0.44 elif candidate == CAR.ALTIMA: # Altima has EPS on C-CAN unlike the others that have it on V-CAN ret.safetyConfigs[0].safetyParam = 1 # EPS is on alternate bus - ret.mass = 1492 + STD_CARGO_KG + ret.mass = 1492 ret.wheelbase = 2.824 ret.centerToFront = ret.wheelbase * 0.44 diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index 7b532a1b22..eab39420cc 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.subaru.values import CAR, LKAS_ANGLE, GLOBAL_GEN2, PREGLOBAL_CARS, SubaruFlags @@ -37,7 +37,7 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) if candidate == CAR.ASCENT: - ret.mass = 2031. + STD_CARGO_KG + ret.mass = 2031. ret.wheelbase = 2.89 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 13.5 @@ -48,7 +48,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.0025, 0.1], [0.00025, 0.01]] elif candidate == CAR.IMPREZA: - ret.mass = 1568. + STD_CARGO_KG + ret.mass = 1568. ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 15 @@ -59,7 +59,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.3], [0.02, 0.03]] elif candidate == CAR.IMPREZA_2020: - ret.mass = 1480. + STD_CARGO_KG + ret.mass = 1480. ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 17 # learned, 14 stock @@ -69,7 +69,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.045, 0.042, 0.20], [0.04, 0.035, 0.045]] elif candidate in (CAR.FORESTER, CAR.FORESTER_2022): - ret.mass = 1568. + STD_CARGO_KG + ret.mass = 1568. ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 17 # learned, 14 stock @@ -79,7 +79,7 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.065, 0.2], [0.001, 0.015, 0.025]] elif candidate in (CAR.OUTBACK, CAR.LEGACY, CAR.OUTBACK_2023): - ret.mass = 1568. + STD_CARGO_KG + ret.mass = 1568. ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 17 @@ -87,20 +87,20 @@ class CarInterface(CarInterfaceBase): elif candidate in (CAR.FORESTER_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018): ret.safetyConfigs[0].safetyParam = 1 # Outback 2018-2019 and Forester have reversed driver torque signal - ret.mass = 1568 + STD_CARGO_KG + ret.mass = 1568 ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 20 # learned, 14 stock elif candidate == CAR.LEGACY_PREGLOBAL: - ret.mass = 1568 + STD_CARGO_KG + ret.mass = 1568 ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 12.5 # 14.5 stock ret.steerActuatorDelay = 0.15 elif candidate == CAR.OUTBACK_PREGLOBAL: - ret.mass = 1568 + STD_CARGO_KG + ret.mass = 1568 ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 20 # learned, 14 stock diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index afd3fb3be4..209f00873a 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -2,7 +2,7 @@ from cereal import car from panda import Panda from selfdrive.car.tesla.values import CANBUS, CAR -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.interfaces import CarInterfaceBase @@ -42,7 +42,7 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.25 if candidate in (CAR.AP2_MODELS, CAR.AP1_MODELS): - ret.mass = 2100. + STD_CARGO_KG + ret.mass = 2100. ret.wheelbase = 2.959 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 15.0 diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index efadc27246..6be01c1c0e 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -4,7 +4,7 @@ from common.conversions import Conversions as CV from panda import Panda from selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \ MIN_ACC_SPEED, EPS_SCALE, EV_HYBRID_CAR, UNSUPPORTED_DSU_CAR, NO_STOP_TIMER_CAR, ANGLE_CONTROL_CAR -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.interfaces import CarInterfaceBase EventName = car.CarEvent.EventName @@ -49,7 +49,7 @@ class CarInterface(CarInterfaceBase): ret.wheelbase = 2.70 ret.steerRatio = 15.74 # unknown end-to-end spec ret.tireStiffnessFactor = 0.6371 # hand-tune - ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3045. * CV.LB_TO_KG # Only give steer angle deadzone to for bad angle sensor prius for fw in car_fw: if fw.ecu == "eps" and not fw.fwVersion == b'8965B47060\x00\x00\x00\x00\x00\x00': @@ -61,20 +61,20 @@ class CarInterface(CarInterfaceBase): ret.wheelbase = 2.78 ret.steerRatio = 17.4 ret.tireStiffnessFactor = 0.5533 - ret.mass = 3340. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3340. * CV.LB_TO_KG elif candidate in (CAR.RAV4, CAR.RAV4H): stop_and_go = True if (candidate in CAR.RAV4H) else False ret.wheelbase = 2.65 ret.steerRatio = 16.88 # 14.5 is spec end-to-end ret.tireStiffnessFactor = 0.5533 - ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid + ret.mass = 3650. * CV.LB_TO_KG # mean between normal and hybrid elif candidate == CAR.COROLLA: ret.wheelbase = 2.70 ret.steerRatio = 18.27 ret.tireStiffnessFactor = 0.444 # not optimized yet - ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid + ret.mass = 2860. * CV.LB_TO_KG # mean between normal and hybrid elif candidate in (CAR.LEXUS_RX, CAR.LEXUS_RXH, CAR.LEXUS_RX_TSS2, CAR.LEXUS_RXH_TSS2): stop_and_go = True @@ -82,28 +82,28 @@ class CarInterface(CarInterfaceBase): ret.steerRatio = 16. # 14.8 is spec end-to-end ret.wheelSpeedFactor = 1.035 ret.tireStiffnessFactor = 0.5533 - ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max + ret.mass = 4481. * CV.LB_TO_KG # mean between min and max elif candidate in (CAR.CHR, CAR.CHRH, CAR.CHR_TSS2, CAR.CHRH_TSS2): stop_and_go = True ret.wheelbase = 2.63906 ret.steerRatio = 13.6 ret.tireStiffnessFactor = 0.7933 - ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3300. * CV.LB_TO_KG elif candidate in (CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2): stop_and_go = True ret.wheelbase = 2.82448 ret.steerRatio = 13.7 ret.tireStiffnessFactor = 0.7933 - ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid + ret.mass = 3400. * CV.LB_TO_KG # mean between normal and hybrid elif candidate in (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2): stop_and_go = True ret.wheelbase = 2.8194 # average of 109.8 and 112.2 in ret.steerRatio = 16.0 ret.tireStiffnessFactor = 0.8 - ret.mass = 4516. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid + ret.mass = 4516. * CV.LB_TO_KG # mean between normal and hybrid elif candidate in (CAR.AVALON, CAR.AVALON_2019, CAR.AVALONH_2019, CAR.AVALON_TSS2, CAR.AVALONH_TSS2): # starting from 2019, all Avalon variants have stop and go @@ -112,14 +112,14 @@ class CarInterface(CarInterfaceBase): ret.wheelbase = 2.82 ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download ret.tireStiffnessFactor = 0.7983 - ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid + ret.mass = 3505. * CV.LB_TO_KG # mean between normal and hybrid elif candidate in (CAR.RAV4_TSS2, CAR.RAV4_TSS2_2022, CAR.RAV4H_TSS2, CAR.RAV4H_TSS2_2022, CAR.RAV4_TSS2_2023, CAR.RAV4H_TSS2_2023): ret.wheelbase = 2.68986 ret.steerRatio = 14.3 ret.tireStiffnessFactor = 0.7933 - ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid + ret.mass = 3585. * CV.LB_TO_KG # Average between ICE and Hybrid ret.lateralTuning.init('pid') ret.lateralTuning.pid.kiBP = [0.0] ret.lateralTuning.pid.kpBP = [0.0] @@ -140,7 +140,7 @@ class CarInterface(CarInterfaceBase): ret.wheelbase = 2.67 # Average between 2.70 for sedan and 2.64 for hatchback ret.steerRatio = 13.9 ret.tireStiffnessFactor = 0.444 # not optimized yet - ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3060. * CV.LB_TO_KG elif candidate in (CAR.LEXUS_ES, CAR.LEXUS_ESH, CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2): if candidate not in (CAR.LEXUS_ES,): # TODO: LEXUS_ES may have sng @@ -148,53 +148,53 @@ class CarInterface(CarInterfaceBase): ret.wheelbase = 2.8702 ret.steerRatio = 16.0 # not optimized ret.tireStiffnessFactor = 0.444 # not optimized yet - ret.mass = 3677. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max + ret.mass = 3677. * CV.LB_TO_KG # mean between min and max elif candidate == CAR.SIENNA: stop_and_go = True ret.wheelbase = 3.03 ret.steerRatio = 15.5 ret.tireStiffnessFactor = 0.444 - ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4590. * CV.LB_TO_KG elif candidate in (CAR.LEXUS_IS, CAR.LEXUS_IS_TSS2, CAR.LEXUS_RC): ret.wheelbase = 2.79908 ret.steerRatio = 13.3 ret.tireStiffnessFactor = 0.444 - ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3736.8 * CV.LB_TO_KG elif candidate == CAR.LEXUS_CTH: stop_and_go = True ret.wheelbase = 2.60 ret.steerRatio = 18.6 ret.tireStiffnessFactor = 0.517 - ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max + ret.mass = 3108 * CV.LB_TO_KG # mean between min and max elif candidate in (CAR.LEXUS_NX, CAR.LEXUS_NXH, CAR.LEXUS_NX_TSS2, CAR.LEXUS_NXH_TSS2): stop_and_go = True ret.wheelbase = 2.66 ret.steerRatio = 14.7 ret.tireStiffnessFactor = 0.444 # not optimized yet - ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4070 * CV.LB_TO_KG elif candidate == CAR.PRIUS_TSS2: ret.wheelbase = 2.70002 # from toyota online sepc. ret.steerRatio = 13.4 # True steerRatio from older prius ret.tireStiffnessFactor = 0.6371 # hand-tune - ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 3115. * CV.LB_TO_KG elif candidate == CAR.MIRAI: stop_and_go = True ret.wheelbase = 2.91 ret.steerRatio = 14.8 ret.tireStiffnessFactor = 0.8 - ret.mass = 4300. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4300. * CV.LB_TO_KG elif candidate in (CAR.ALPHARD_TSS2, CAR.ALPHARDH_TSS2): ret.wheelbase = 3.00 ret.steerRatio = 14.2 ret.tireStiffnessFactor = 0.444 - ret.mass = 4305. * CV.LB_TO_KG + STD_CARGO_KG + ret.mass = 4305. * CV.LB_TO_KG ret.centerToFront = ret.wheelbase * 0.44 ret.enableBsm = 0x3F6 in fingerprint[0] and candidate in TSS2_CAR diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index 2b0603f162..66b6239cb3 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -1,7 +1,7 @@ from cereal import car from panda import Panda from common.conversions import Conversions as CV -from selfdrive.car import STD_CARGO_KG, get_safety_config +from selfdrive.car import get_safety_config from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.volkswagen.values import CAR, PQ_CARS, CANBUS, NetworkLocation, TransmissionType, GearShifter @@ -101,32 +101,32 @@ class CarInterface(CarInterfaceBase): # Per-chassis tuning values, override tuning defaults here if desired if candidate == CAR.ARTEON_MK1: - ret.mass = 1733 + STD_CARGO_KG + ret.mass = 1733 ret.wheelbase = 2.84 elif candidate == CAR.ATLAS_MK1: - ret.mass = 2011 + STD_CARGO_KG + ret.mass = 2011 ret.wheelbase = 2.98 elif candidate == CAR.CRAFTER_MK2: - ret.mass = 2100 + STD_CARGO_KG + ret.mass = 2100 ret.wheelbase = 3.64 # SWB, LWB is 4.49, TBD how to detect difference ret.minSteerSpeed = 50 * CV.KPH_TO_MS elif candidate == CAR.GOLF_MK7: - ret.mass = 1397 + STD_CARGO_KG + ret.mass = 1397 ret.wheelbase = 2.62 elif candidate == CAR.JETTA_MK7: - ret.mass = 1328 + STD_CARGO_KG + ret.mass = 1328 ret.wheelbase = 2.71 elif candidate == CAR.PASSAT_MK8: - ret.mass = 1551 + STD_CARGO_KG + ret.mass = 1551 ret.wheelbase = 2.79 elif candidate == CAR.PASSAT_NMS: - ret.mass = 1503 + STD_CARGO_KG + ret.mass = 1503 ret.wheelbase = 2.80 ret.minEnableSpeed = 20 * CV.KPH_TO_MS # ACC "basic", no FtS ret.minSteerSpeed = 50 * CV.KPH_TO_MS @@ -134,86 +134,86 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) elif candidate == CAR.POLO_MK6: - ret.mass = 1230 + STD_CARGO_KG + ret.mass = 1230 ret.wheelbase = 2.55 elif candidate == CAR.SHARAN_MK2: - ret.mass = 1639 + STD_CARGO_KG + ret.mass = 1639 ret.wheelbase = 2.92 ret.minSteerSpeed = 50 * CV.KPH_TO_MS ret.steerActuatorDelay = 0.2 elif candidate == CAR.TAOS_MK1: - ret.mass = 1498 + STD_CARGO_KG + ret.mass = 1498 ret.wheelbase = 2.69 elif candidate == CAR.TCROSS_MK1: - ret.mass = 1150 + STD_CARGO_KG + ret.mass = 1150 ret.wheelbase = 2.60 elif candidate == CAR.TIGUAN_MK2: - ret.mass = 1715 + STD_CARGO_KG + ret.mass = 1715 ret.wheelbase = 2.74 elif candidate == CAR.TOURAN_MK2: - ret.mass = 1516 + STD_CARGO_KG + ret.mass = 1516 ret.wheelbase = 2.79 elif candidate == CAR.TRANSPORTER_T61: - ret.mass = 1926 + STD_CARGO_KG + ret.mass = 1926 ret.wheelbase = 3.00 # SWB, LWB is 3.40, TBD how to detect difference ret.minSteerSpeed = 14.0 elif candidate == CAR.TROC_MK1: - ret.mass = 1413 + STD_CARGO_KG + ret.mass = 1413 ret.wheelbase = 2.63 elif candidate == CAR.AUDI_A3_MK3: - ret.mass = 1335 + STD_CARGO_KG + ret.mass = 1335 ret.wheelbase = 2.61 elif candidate == CAR.AUDI_Q2_MK1: - ret.mass = 1205 + STD_CARGO_KG + ret.mass = 1205 ret.wheelbase = 2.61 elif candidate == CAR.AUDI_Q3_MK2: - ret.mass = 1623 + STD_CARGO_KG + ret.mass = 1623 ret.wheelbase = 2.68 elif candidate == CAR.SEAT_ATECA_MK1: - ret.mass = 1900 + STD_CARGO_KG + ret.mass = 1900 ret.wheelbase = 2.64 elif candidate == CAR.SEAT_LEON_MK3: - ret.mass = 1227 + STD_CARGO_KG + ret.mass = 1227 ret.wheelbase = 2.64 elif candidate == CAR.SKODA_FABIA_MK4: - ret.mass = 1266 + STD_CARGO_KG + ret.mass = 1266 ret.wheelbase = 2.56 elif candidate == CAR.SKODA_KAMIQ_MK1: - ret.mass = 1265 + STD_CARGO_KG + ret.mass = 1265 ret.wheelbase = 2.66 elif candidate == CAR.SKODA_KAROQ_MK1: - ret.mass = 1278 + STD_CARGO_KG + ret.mass = 1278 ret.wheelbase = 2.66 elif candidate == CAR.SKODA_KODIAQ_MK1: - ret.mass = 1569 + STD_CARGO_KG + ret.mass = 1569 ret.wheelbase = 2.79 elif candidate == CAR.SKODA_OCTAVIA_MK3: - ret.mass = 1388 + STD_CARGO_KG + ret.mass = 1388 ret.wheelbase = 2.68 elif candidate == CAR.SKODA_SCALA_MK1: - ret.mass = 1192 + STD_CARGO_KG + ret.mass = 1192 ret.wheelbase = 2.65 elif candidate == CAR.SKODA_SUPERB_MK3: - ret.mass = 1505 + STD_CARGO_KG + ret.mass = 1505 ret.wheelbase = 2.84 else: From d827cd6a83cbcc4f8231706f085df0d2ec5ef69f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 17 Aug 2023 22:42:12 -0700 Subject: [PATCH 016/159] map eta: use pair (#29460) use pair --- selfdrive/ui/qt/maps/map_eta.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/selfdrive/ui/qt/maps/map_eta.cc b/selfdrive/ui/qt/maps/map_eta.cc index 13e11e5597..9dbbad2845 100644 --- a/selfdrive/ui/qt/maps/map_eta.cc +++ b/selfdrive/ui/qt/maps/map_eta.cc @@ -30,12 +30,12 @@ void MapETA::paintEvent(QPaintEvent *event) { void MapETA::updateETA(float s, float s_typical, float d) { // ETA auto eta_t = QDateTime::currentDateTime().addSecs(s).time(); - auto eta = format_24h ? std::array{eta_t.toString("HH:mm"), tr("eta")} - : std::array{eta_t.toString("h:mm a").split(' ')[0], eta_t.toString("a")}; + auto eta = format_24h ? std::pair{eta_t.toString("HH:mm"), tr("eta")} + : std::pair{eta_t.toString("h:mm a").split(' ')[0], eta_t.toString("a")}; // Remaining time - auto remaining = s < 3600 ? std::array{QString::number(int(s / 60)), tr("min")} - : std::array{QString("%1:%2").arg((int)s / 3600).arg(((int)s % 3600) / 60, 2, 10, QLatin1Char('0')), tr("hr")}; + auto remaining = s < 3600 ? std::pair{QString::number(int(s / 60)), tr("min")} + : std::pair{QString("%1:%2").arg((int)s / 3600).arg(((int)s % 3600) / 60, 2, 10, QLatin1Char('0')), tr("hr")}; QString color = "#25DA6E"; if (s / s_typical > 1.5) color = "#DA3025"; @@ -44,13 +44,13 @@ void MapETA::updateETA(float s, float s_typical, float d) { // Distance float num = uiState()->scene.is_metric ? (d / 1000.0) : (d * METER_TO_MILE); - auto distance = std::array{QString::number(num, 'f', num < 100 ? 1 : 0), - uiState()->scene.is_metric ? tr("km") : tr("mi")}; + auto distance = std::pair{QString::number(num, 'f', num < 100 ? 1 : 0), + uiState()->scene.is_metric ? tr("km") : tr("mi")}; eta_doc.setHtml(QString(R"()") - .arg(eta[0], eta[1], color, remaining[0], remaining[1], distance[0], distance[1])); + .arg(eta.first, eta.second, color, remaining.first, remaining.second, distance.first, distance.second)); setVisible(d >= MANEUVER_TRANSITION_THRESHOLD); update(); From efefcfdca581fd75868b993426dfde21c21c1531 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 18 Aug 2023 13:58:18 +0800 Subject: [PATCH 017/159] ui/map: better rounding for distances (#29151) * round distance * use same format in ETA * remove vanish * restore translate * use nearbyint * update translations * mark finished * consistent style * we don't include this anywhere in ui, needed? * fix missing std --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/maps/map_eta.cc | 5 ++- selfdrive/ui/qt/maps/map_helpers.cc | 17 ++++++++++ selfdrive/ui/qt/maps/map_helpers.h | 2 +- selfdrive/ui/qt/maps/map_instructions.cc | 17 +++------- selfdrive/ui/qt/maps/map_instructions.h | 1 - selfdrive/ui/translations/main_de.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_fr.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_ja.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_ko.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_pt-BR.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_th.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_tr.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_zh-CHS.ts | 43 +++++++++--------------- selfdrive/ui/translations/main_zh-CHT.ts | 43 +++++++++--------------- 14 files changed, 168 insertions(+), 261 deletions(-) diff --git a/selfdrive/ui/qt/maps/map_eta.cc b/selfdrive/ui/qt/maps/map_eta.cc index 9dbbad2845..322861ed15 100644 --- a/selfdrive/ui/qt/maps/map_eta.cc +++ b/selfdrive/ui/qt/maps/map_eta.cc @@ -3,6 +3,7 @@ #include #include +#include "selfdrive/ui/qt/maps/map_helpers.h" #include "selfdrive/ui/ui.h" const float MANEUVER_TRANSITION_THRESHOLD = 10; @@ -43,9 +44,7 @@ void MapETA::updateETA(float s, float s_typical, float d) { color = "#DAA725"; // Distance - float num = uiState()->scene.is_metric ? (d / 1000.0) : (d * METER_TO_MILE); - auto distance = std::pair{QString::number(num, 'f', num < 100 ? 1 : 0), - uiState()->scene.is_metric ? tr("km") : tr("mi")}; + auto distance = map_format_distance(d, uiState()->scene.is_metric); eta_doc.setHtml(QString(R"(
%1%2 %4%5 %6%7
diff --git a/selfdrive/ui/qt/maps/map_helpers.cc b/selfdrive/ui/qt/maps/map_helpers.cc index 95db4f2bbd..0f96638820 100644 --- a/selfdrive/ui/qt/maps/map_helpers.cc +++ b/selfdrive/ui/qt/maps/map_helpers.cc @@ -129,6 +129,23 @@ std::optional coordinate_from_param(const std::string ¶ } } +// return {distance, unit} +std::pair map_format_distance(float d, bool is_metric) { + auto round_distance = [](float d) -> float { + return (d > 10) ? std::nearbyint(d) : std::nearbyint(d * 10) / 10.0; + }; + + d = std::max(d, 0.0f); + if (is_metric) { + return (d > 500) ? std::pair{QString::number(round_distance(d / 1000)), QObject::tr("km")} + : std::pair{QString::number(50 * std::nearbyint(d / 50)), QObject::tr("m")}; + } else { + float feet = d * METER_TO_FOOT; + return (feet > 500) ? std::pair{QString::number(round_distance(d * METER_TO_MILE)), QObject::tr("mi")} + : std::pair{QString::number(50 * std::nearbyint(d / 50)), QObject::tr("ft")}; + } +} + double angle_difference(double angle1, double angle2) { double diff = fmod(angle2 - angle1 + 180.0, 360.0) - 180.0; return diff < -180.0 ? diff + 360.0 : diff; diff --git a/selfdrive/ui/qt/maps/map_helpers.h b/selfdrive/ui/qt/maps/map_helpers.h index f9c56107e3..0090753a40 100644 --- a/selfdrive/ui/qt/maps/map_helpers.h +++ b/selfdrive/ui/qt/maps/map_helpers.h @@ -25,6 +25,6 @@ QMapbox::CoordinatesCollections coordinate_to_collection(const QMapbox::Coordina QMapbox::CoordinatesCollections capnp_coordinate_list_to_collection(const capnp::List::Reader &coordinate_list); QMapbox::CoordinatesCollections coordinate_list_to_collection(const QList &coordinate_list); QList polyline_to_coordinate_list(const QString &polylineString); - std::optional coordinate_from_param(const std::string ¶m); +std::pair map_format_distance(float d, bool is_metric); double angle_difference(double angle1, double angle2); diff --git a/selfdrive/ui/qt/maps/map_instructions.cc b/selfdrive/ui/qt/maps/map_instructions.cc index 5910fe8143..0901213c76 100644 --- a/selfdrive/ui/qt/maps/map_instructions.cc +++ b/selfdrive/ui/qt/maps/map_instructions.cc @@ -3,6 +3,7 @@ #include #include +#include "selfdrive/ui/qt/maps/map_helpers.h" #include "selfdrive/ui/ui.h" const QString ICON_SUFFIX = ".png"; @@ -63,18 +64,6 @@ void MapInstructions::buildPixmapCache() { } } -QString MapInstructions::getDistance(float d) { - d = std::max(d, 0.0f); - if (uiState()->scene.is_metric) { - return (d > 500) ? QString::number(d / 1000, 'f', 1) + tr(" km") - : QString::number(50 * qRound(d / 50)) + tr(" m"); - } else { - float feet = d * METER_TO_FOOT; - return (feet > 500) ? QString::number(d * METER_TO_MILE, 'f', 1) + tr(" mi") - : QString::number(50 * qRound(feet / 50)) + tr(" ft"); - } -} - void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruction) { setUpdatesEnabled(false); @@ -85,7 +74,9 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct primary->setText(primary_str); secondary->setVisible(secondary_str.length() > 0); secondary->setText(secondary_str); - distance->setText(getDistance(instruction.getManeuverDistance())); + + auto distance_str_pair = map_format_distance(instruction.getManeuverDistance(), uiState()->scene.is_metric); + distance->setText(QString("%1 %2").arg(distance_str_pair.first, distance_str_pair.second)); // Show arrow with direction QString type = QString::fromStdString(instruction.getManeuverType()); diff --git a/selfdrive/ui/qt/maps/map_instructions.h b/selfdrive/ui/qt/maps/map_instructions.h index 163c223a2d..6c08cb9b9e 100644 --- a/selfdrive/ui/qt/maps/map_instructions.h +++ b/selfdrive/ui/qt/maps/map_instructions.h @@ -31,6 +31,5 @@ private: public: MapInstructions(QWidget * parent=nullptr); void buildPixmapCache(); - QString getDistance(float d); void updateInstructions(cereal::NavInstruction::Reader instruction); }; diff --git a/selfdrive/ui/translations/main_de.ts b/selfdrive/ui/translations/main_de.ts index 74b60f4b74..a1b8faa2e3 100644 --- a/selfdrive/ui/translations/main_de.ts +++ b/selfdrive/ui/translations/main_de.ts @@ -354,33 +354,6 @@ hr std - - km - km - - - mi - mi - - - - MapInstructions - - km - km - - - m - m - - - mi - mi - - - ft - fuß - MapSettings @@ -620,6 +593,22 @@ vor %n Tagen + + km + km + + + m + m + + + mi + mi + + + ft + fuß + Reset diff --git a/selfdrive/ui/translations/main_fr.ts b/selfdrive/ui/translations/main_fr.ts index 369502b589..14ca4df954 100644 --- a/selfdrive/ui/translations/main_fr.ts +++ b/selfdrive/ui/translations/main_fr.ts @@ -354,33 +354,6 @@ hr h - - km - km - - - mi - mi - - - - MapInstructions - - km - km - - - m - m - - - mi - mi - - - ft - ft - MapSettings @@ -621,6 +594,22 @@ il y a %n jours + + km + km + + + m + m + + + mi + mi + + + ft + ft + Reset diff --git a/selfdrive/ui/translations/main_ja.ts b/selfdrive/ui/translations/main_ja.ts index ef9eb93e80..e766204660 100644 --- a/selfdrive/ui/translations/main_ja.ts +++ b/selfdrive/ui/translations/main_ja.ts @@ -353,33 +353,6 @@ hr 時間 - - km - キロメートル - - - mi - マイル - - - - MapInstructions - - km - キロメートル - - - m - メートル - - - mi - マイル - - - ft - フィート - MapSettings @@ -616,6 +589,22 @@ %n 日前 + + km + キロメートル + + + m + メートル + + + mi + マイル + + + ft + フィート + Reset diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts index b2473a3fb9..851c306a47 100644 --- a/selfdrive/ui/translations/main_ko.ts +++ b/selfdrive/ui/translations/main_ko.ts @@ -353,33 +353,6 @@ hr 시간 - - km - km - - - mi - mi - - - - MapInstructions - - km - km - - - m - m - - - mi - mi - - - ft - ft - MapSettings @@ -617,6 +590,22 @@ %n 일전 + + km + km + + + m + m + + + mi + mi + + + ft + ft + Reset diff --git a/selfdrive/ui/translations/main_pt-BR.ts b/selfdrive/ui/translations/main_pt-BR.ts index d102fb39ca..7aa0c7c49b 100644 --- a/selfdrive/ui/translations/main_pt-BR.ts +++ b/selfdrive/ui/translations/main_pt-BR.ts @@ -354,33 +354,6 @@ hr hr - - km - km - - - mi - mi - - - - MapInstructions - - km - km - - - m - m - - - mi - milha - - - ft - pés - MapSettings @@ -621,6 +594,22 @@ há %n dias + + km + km + + + m + m + + + mi + milha + + + ft + pés + Reset diff --git a/selfdrive/ui/translations/main_th.ts b/selfdrive/ui/translations/main_th.ts index 843356c402..9ef2d8a913 100644 --- a/selfdrive/ui/translations/main_th.ts +++ b/selfdrive/ui/translations/main_th.ts @@ -353,33 +353,6 @@ hr ชม. - - km - กม. - - - mi - ไมล์ - - - - MapInstructions - - km - กม. - - - m - ม. - - - mi - ไมล์ - - - ft - ฟุต - MapSettings @@ -617,6 +590,22 @@ %n วันที่แล้ว + + km + กม. + + + m + ม. + + + mi + ไมล์ + + + ft + ฟุต + Reset diff --git a/selfdrive/ui/translations/main_tr.ts b/selfdrive/ui/translations/main_tr.ts index 612ad11043..ad882f5786 100644 --- a/selfdrive/ui/translations/main_tr.ts +++ b/selfdrive/ui/translations/main_tr.ts @@ -353,33 +353,6 @@ hr saat - - km - km - - - mi - mil - - - - MapInstructions - - km - km - - - m - m - - - mi - mil - - - ft - ft - MapSettings @@ -616,6 +589,22 @@ %n gün önce + + km + km + + + m + m + + + mi + mil + + + ft + ft + Reset diff --git a/selfdrive/ui/translations/main_zh-CHS.ts b/selfdrive/ui/translations/main_zh-CHS.ts index 17c768eb79..48eb63338b 100644 --- a/selfdrive/ui/translations/main_zh-CHS.ts +++ b/selfdrive/ui/translations/main_zh-CHS.ts @@ -353,33 +353,6 @@ hr 小时 - - km - km - - - mi - mi - - - - MapInstructions - - km - km - - - m - m - - - mi - mi - - - ft - ft - MapSettings @@ -617,6 +590,22 @@ %n 天前 + + km + km + + + m + m + + + mi + mi + + + ft + ft + Reset diff --git a/selfdrive/ui/translations/main_zh-CHT.ts b/selfdrive/ui/translations/main_zh-CHT.ts index 084cc13c3c..6eacb6428c 100644 --- a/selfdrive/ui/translations/main_zh-CHT.ts +++ b/selfdrive/ui/translations/main_zh-CHT.ts @@ -353,33 +353,6 @@ hr 小時 - - km - km - - - mi - mi - - - - MapInstructions - - km - km - - - m - m - - - mi - mi - - - ft - ft - MapSettings @@ -617,6 +590,22 @@ %n 天前 + + km + km + + + m + m + + + mi + mi + + + ft + ft + Reset From 19767da6688f0f9ae1b91f332a78d76af2745811 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 18 Aug 2023 00:37:32 -0700 Subject: [PATCH 018/159] CAN fingerprint: test fingerprint response (#29462) * test finger * split up --- selfdrive/car/tests/test_can_fingerprint.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/tests/test_can_fingerprint.py b/selfdrive/car/tests/test_can_fingerprint.py index 4142f7f373..9f3f232980 100755 --- a/selfdrive/car/tests/test_can_fingerprint.py +++ b/selfdrive/car/tests/test_can_fingerprint.py @@ -10,17 +10,20 @@ from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS class TestCanFingerprint(unittest.TestCase): @parameterized.expand([(c, f) for c, f in FINGERPRINTS.items()]) def test_can_fingerprint(self, car_model, fingerprints): - # Tests online fingerprinting function on offline fingerprints + """Tests online fingerprinting function on offline fingerprints""" + for fingerprint in fingerprints: # can have multiple fingerprints for each platform can = messaging.new_message('can', 1) - can.can = [log.CanData(address=address, dat=b'\x00' * length) - for address, length in fingerprint.items()] + can.can = [log.CanData(address=address, dat=b'\x00' * length, src=src) + for address, length in fingerprint.items() for src in (0, 1)] fingerprint_iter = iter([can]) empty_can = messaging.new_message('can', 0) car_fingerprint, finger = can_fingerprint(lambda: next(fingerprint_iter, empty_can)) # noqa: B023 self.assertEqual(car_fingerprint, car_model) + self.assertEqual(finger[0], fingerprint) + self.assertEqual(finger[1], fingerprint) if __name__ == "__main__": From 0c50dd9d0fb1d6cec9c40a552d91c43b406bafd5 Mon Sep 17 00:00:00 2001 From: Terry Huang Date: Fri, 18 Aug 2023 20:11:50 +0800 Subject: [PATCH 019/159] Ford: Kuga 2022 fingerprint (#29449) Ford: Kuga 2022 fingerprint --- selfdrive/car/ford/values.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/selfdrive/car/ford/values.py b/selfdrive/car/ford/values.py index 6687204b46..01d1ae7b8a 100644 --- a/selfdrive/car/ford/values.py +++ b/selfdrive/car/ford/values.py @@ -156,6 +156,7 @@ FW_VERSIONS = { b'LX6C-2D053-NT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'LX6C-2D053-NY\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'LX6C-2D053-SA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'LX6C-2D053-SD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x764, None): [ b'LB5T-14D049-AB\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', @@ -163,11 +164,13 @@ FW_VERSIONS = { (Ecu.fwdCamera, 0x706, None): [ b'LJ6T-14F397-AD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'LJ6T-14F397-AE\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'LV4T-14F397-GG\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7E0, None): [ b'LX6A-14C204-BJV\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'LX6A-14C204-BJX\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'LX6A-14C204-CNG\x00\x00\x00\x00\x00\x00\x00\x00\x00', + b'LX6A-14C204-DPK\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'LX6A-14C204-ESG\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'MX6A-14C204-BEF\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'MX6A-14C204-BEJ\x00\x00\x00\x00\x00\x00\x00\x00\x00', From 6253dca9eb2e936c5828de5cf96e6c988d1349a7 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 18 Aug 2023 14:33:13 -0700 Subject: [PATCH 020/159] CAN fingerprint: timing test (#29461) * test fingerprint frames (timing) * guess not needed * it checks both buses * use case list * this is safe since we call current test only in the current loop, never after * prof * test this too --- selfdrive/car/tests/test_can_fingerprint.py | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/tests/test_can_fingerprint.py b/selfdrive/car/tests/test_can_fingerprint.py index 9f3f232980..7189ff542b 100755 --- a/selfdrive/car/tests/test_can_fingerprint.py +++ b/selfdrive/car/tests/test_can_fingerprint.py @@ -3,7 +3,7 @@ from parameterized import parameterized import unittest from cereal import log, messaging -from selfdrive.car.car_helpers import can_fingerprint +from selfdrive.car.car_helpers import FRAME_FINGERPRINT, can_fingerprint from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS @@ -24,6 +24,43 @@ class TestCanFingerprint(unittest.TestCase): self.assertEqual(car_fingerprint, car_model) self.assertEqual(finger[0], fingerprint) self.assertEqual(finger[1], fingerprint) + self.assertEqual(finger[2], {}) + + def test_timing(self): + # just pick any CAN fingerprinting car + car_model = 'CHEVROLET BOLT EUV 2022' + fingerprint = FINGERPRINTS[car_model][0] + + cases = [] + + # case 1 - one match, make sure we keep going for 100 frames + can = messaging.new_message('can', 1) + can.can = [log.CanData(address=address, dat=b'\x00' * length, src=src) + for address, length in fingerprint.items() for src in (0, 1)] + cases.append((FRAME_FINGERPRINT, car_model, can)) + + # case 2 - no matches, make sure we keep going for 100 frames + can = messaging.new_message('can', 1) + can.can = [log.CanData(address=1, dat=b'\x00' * 1, src=src) for src in (0, 1)] # uncommon address + cases.append((FRAME_FINGERPRINT, None, can)) + + # case 3 - multiple matches, make sure we keep going for 200 frames to try to eliminate some + can = messaging.new_message('can', 1) + can.can = [log.CanData(address=2016, dat=b'\x00' * 8, src=src) for src in (0, 1)] # common address + cases.append((FRAME_FINGERPRINT * 2, None, can)) + + for expected_frames, car_model, can in cases: + with self.subTest(expected_frames=expected_frames, car_model=car_model): + frames = 0 + + def test(): + nonlocal frames + frames += 1 + return can # noqa: B023 + + car_fingerprint, _ = can_fingerprint(test) + self.assertEqual(car_fingerprint, car_model) + self.assertEqual(frames, expected_frames + 2) # TODO: fix extra frames if __name__ == "__main__": From 38f15237420e911294ff12f541529d21242e51aa Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 18 Aug 2023 20:57:42 -0700 Subject: [PATCH 021/159] add Kia Niro Hybrid 2019 to legacy safety mode list (#29472) * add Kia Niro Hybrid 2019 to legacy safety mode list * list * test * update docs * space --- docs/CARS.md | 4 ++-- selfdrive/car/hyundai/interface.py | 5 +++-- selfdrive/car/hyundai/tests/test_hyundai.py | 4 ++-- selfdrive/car/hyundai/values.py | 3 +++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/CARS.md b/docs/CARS.md index 9ec07a3e22..a502cde3ac 100644 --- a/docs/CARS.md +++ b/docs/CARS.md @@ -124,8 +124,8 @@ A supported vehicle is one that just works when you install a comma three. All s |Kia|Niro EV 2023[6](#footnotes)|All|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Niro Hybrid 2021-22|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai F connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Niro Hybrid 2023[6](#footnotes)|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| -|Kia|Niro Plug-in Hybrid 2018-19|All|openpilot available[1](#footnotes)|10 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| -|Kia|Niro Plug-in Hybrid 2020|All|openpilot available[1](#footnotes)|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai D connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| +|Kia|Niro Plug-in Hybrid 2018-19|All|Stock|10 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| +|Kia|Niro Plug-in Hybrid 2020|All|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai D connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Optima 2017|Advanced Smart Cruise Control|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai B connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Optima 2019-20|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai G connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Seltos 2021|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index ed0dab54fc..3e25863f46 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -4,7 +4,8 @@ from panda import Panda from common.conversions import Conversions as CV from selfdrive.car.hyundai.hyundaicanfd import CanBus from selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \ - EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, Buttons + EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, UNSUPPORTED_LONGITUDINAL_CAR, \ + Buttons from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR from selfdrive.car import create_button_event, get_safety_config from selfdrive.car.interfaces import CarInterfaceBase @@ -247,7 +248,7 @@ class CarInterface(CarInterfaceBase): else: ret.longitudinalTuning.kpV = [0.5] ret.longitudinalTuning.kiV = [0.0] - ret.experimentalLongitudinalAvailable = candidate not in (LEGACY_SAFETY_MODE_CAR | CAMERA_SCC_CAR) + ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | CAMERA_SCC_CAR) ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable ret.pcmCruise = not ret.openpilotLongitudinalControl diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 3d2b704e55..68a7603ec4 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -5,7 +5,7 @@ from cereal import car from selfdrive.car.fw_versions import build_fw_dict from selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ EV_CAR, FW_QUERY_CONFIG, FW_VERSIONS, LEGACY_SAFETY_MODE_CAR, \ - PLATFORM_CODE_ECUS, get_platform_codes + UNSUPPORTED_LONGITUDINAL_CAR, PLATFORM_CODE_ECUS, get_platform_codes Ecu = car.CarParams.Ecu ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} @@ -37,7 +37,7 @@ NO_DATES_PLATFORMS = { class TestHyundaiFingerprint(unittest.TestCase): def test_canfd_not_in_can_features(self): - can_specific_feature_list = set.union(*CAN_GEARS.values(), *CHECKSUM.values(), LEGACY_SAFETY_MODE_CAR, CAMERA_SCC_CAR) + can_specific_feature_list = set.union(*CAN_GEARS.values(), *CHECKSUM.values(), LEGACY_SAFETY_MODE_CAR, UNSUPPORTED_LONGITUDINAL_CAR, CAMERA_SCC_CAR) for car_model in CANFD_CAR: self.assertNotIn(car_model, can_specific_feature_list, "CAN FD car unexpectedly found in a CAN feature list") diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 72408a6006..5a137267ad 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1942,6 +1942,9 @@ LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_L CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022} +# these cars have not been verified to work with longitudinal yet - radar disable, sending correct messages, etc +UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV} + # If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points. # If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py DBC = { From 1a08c2986e5600dd4e84bfeaed26c74e679085de Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 18 Aug 2023 22:56:43 -0700 Subject: [PATCH 022/159] Revert "radard: tie radard frequency to modelV2 vol. 2 (#29240)" (#29474) * Revert "static analysis fixes" This reverts commit a1e85f3661d2a464ec452294a57e7c0462044a28. * Revert "radard: tie radard frequency to modelV2 vol. 2 (#29240)" This reverts commit 460f5c8e0b2fd2c420e211b09b70d1d79834a929. * update refs --- selfdrive/car/chrysler/radar_interface.py | 2 +- selfdrive/car/ford/radar_interface.py | 2 +- selfdrive/car/gm/radar_interface.py | 2 +- selfdrive/car/honda/radar_interface.py | 73 ++++++-------- selfdrive/car/hyundai/radar_interface.py | 2 +- selfdrive/car/interfaces.py | 8 +- selfdrive/car/tesla/radar_interface.py | 2 +- selfdrive/car/toyota/radar_interface.py | 51 +++------- selfdrive/controls/radard.py | 99 ++++++++----------- .../test/process_replay/process_replay.py | 4 +- selfdrive/test/process_replay/ref_commit | 2 +- 11 files changed, 103 insertions(+), 144 deletions(-) diff --git a/selfdrive/car/chrysler/radar_interface.py b/selfdrive/car/chrysler/radar_interface.py index fc795a36ca..1d0661778a 100755 --- a/selfdrive/car/chrysler/radar_interface.py +++ b/selfdrive/car/chrysler/radar_interface.py @@ -46,7 +46,7 @@ class RadarInterface(RadarInterfaceBase): def update(self, can_strings): if self.rcp is None or self.CP.radarUnavailable: - return None + return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) diff --git a/selfdrive/car/ford/radar_interface.py b/selfdrive/car/ford/radar_interface.py index 39a62b9e43..78dd594627 100644 --- a/selfdrive/car/ford/radar_interface.py +++ b/selfdrive/car/ford/radar_interface.py @@ -51,7 +51,7 @@ class RadarInterface(RadarInterfaceBase): def update(self, can_strings): if self.rcp is None: - return None + return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) diff --git a/selfdrive/car/gm/radar_interface.py b/selfdrive/car/gm/radar_interface.py index 0424b95a77..99fb89ceb3 100755 --- a/selfdrive/car/gm/radar_interface.py +++ b/selfdrive/car/gm/radar_interface.py @@ -44,7 +44,7 @@ class RadarInterface(RadarInterfaceBase): def update(self, can_strings): if self.rcp is None: - return None + return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) diff --git a/selfdrive/car/honda/radar_interface.py b/selfdrive/car/honda/radar_interface.py index 43fe422026..58f665233b 100755 --- a/selfdrive/car/honda/radar_interface.py +++ b/selfdrive/car/honda/radar_interface.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from collections import defaultdict - from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.interfaces import RadarInterfaceBase @@ -30,61 +28,50 @@ class RadarInterface(RadarInterfaceBase): else: self.rcp = _create_nidec_can_parser(CP.carFingerprint) self.trigger_msg = 0x445 - self.updated_values = defaultdict(lambda: defaultdict(list)) + self.updated_messages = set() def update(self, can_strings): # in Bosch radar and we are only steering for now, so sleep 0.05s to keep # radard at 20Hz and return no points if self.radar_off_can: - return None + return super().update(None) - addresses = self.rcp.update_strings(can_strings) - for addr in addresses: - vals_dict = self.rcp.vl_all[addr] - for sig_name, vals in vals_dict.items(): - self.updated_values[addr][sig_name].extend(vals) + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - if self.trigger_msg not in self.updated_values: + if self.trigger_msg not in self.updated_messages: return None - radar_data = self._radar_msg_from_buffer(self.updated_values, self.rcp.can_valid) - self.updated_values.clear() + rr = self._update(self.updated_messages) + self.updated_messages.clear() + return rr - return radar_data - - def _radar_msg_from_buffer(self, updated_values, can_valid): + def _update(self, updated_messages): ret = car.RadarData.new_message() - for ii in sorted(updated_values): - msgs = updated_values[ii] - n_vals_per_addr = len(list(msgs.values())[0]) - cpts = [ - {k: v[i] for k, v in msgs.items()} - for i in range(n_vals_per_addr) - ] - - for cpt in cpts: - if ii == 0x400: - # check for radar faults - self.radar_fault = cpt['RADAR_STATE'] != 0x79 - self.radar_wrong_config = cpt['RADAR_STATE'] == 0x69 - elif cpt['LONG_DIST'] < 255: - if ii not in self.pts or cpt['NEW_TRACK']: - self.pts[ii] = car.RadarData.RadarPoint.new_message() - self.pts[ii].trackId = self.track_id - self.track_id += 1 - self.pts[ii].dRel = cpt['LONG_DIST'] # from front of car - self.pts[ii].yRel = -cpt['LAT_DIST'] # in car frame's y axis, left is positive - self.pts[ii].vRel = cpt['REL_SPEED'] - self.pts[ii].aRel = float('nan') - self.pts[ii].yvRel = float('nan') - self.pts[ii].measured = True - else: - if ii in self.pts: - del self.pts[ii] + for ii in sorted(updated_messages): + cpt = self.rcp.vl[ii] + if ii == 0x400: + # check for radar faults + self.radar_fault = cpt['RADAR_STATE'] != 0x79 + self.radar_wrong_config = cpt['RADAR_STATE'] == 0x69 + elif cpt['LONG_DIST'] < 255: + if ii not in self.pts or cpt['NEW_TRACK']: + self.pts[ii] = car.RadarData.RadarPoint.new_message() + self.pts[ii].trackId = self.track_id + self.track_id += 1 + self.pts[ii].dRel = cpt['LONG_DIST'] # from front of car + self.pts[ii].yRel = -cpt['LAT_DIST'] # in car frame's y axis, left is positive + self.pts[ii].vRel = cpt['REL_SPEED'] + self.pts[ii].aRel = float('nan') + self.pts[ii].yvRel = float('nan') + self.pts[ii].measured = True + else: + if ii in self.pts: + del self.pts[ii] errors = [] - if not can_valid: + if not self.rcp.can_valid: errors.append("canError") if self.radar_fault: errors.append("fault") diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index 7301ad18ce..3b74a03d4b 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -30,7 +30,7 @@ class RadarInterface(RadarInterfaceBase): def update(self, can_strings): if self.radar_off_can or (self.rcp is None): - return None + return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index a9966c2bb7..f30683d9a3 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -1,5 +1,6 @@ import yaml import os +import time from abc import abstractmethod, ABC from typing import Any, Dict, Optional, Tuple, List, Callable @@ -309,9 +310,14 @@ class RadarInterfaceBase(ABC): self.rcp = None self.pts = {} self.delay = 0 + self.radar_ts = CP.radarTimeStep + self.no_radar_sleep = 'NO_RADAR_SLEEP' in os.environ def update(self, can_strings): - pass + ret = car.RadarData.new_message() + if not self.no_radar_sleep: + time.sleep(self.radar_ts) # radard runs on RI updates + return ret class CarStateBase(ABC): diff --git a/selfdrive/car/tesla/radar_interface.py b/selfdrive/car/tesla/radar_interface.py index cf76e213e0..c368c794b0 100755 --- a/selfdrive/car/tesla/radar_interface.py +++ b/selfdrive/car/tesla/radar_interface.py @@ -36,7 +36,7 @@ class RadarInterface(RadarInterfaceBase): def update(self, can_strings): if self.rcp is None: - return None + return super().update(None) values = self.rcp.update_strings(can_strings) self.updated_messages.update(values) diff --git a/selfdrive/car/toyota/radar_interface.py b/selfdrive/car/toyota/radar_interface.py index 378178f5c8..56473b06a4 100755 --- a/selfdrive/car/toyota/radar_interface.py +++ b/selfdrive/car/toyota/radar_interface.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from collections import defaultdict - from opendbc.can.parser import CANParser from cereal import car from selfdrive.car.toyota.values import DBC, TSS2_CAR @@ -38,47 +36,34 @@ class RadarInterface(RadarInterfaceBase): self.rcp = None if CP.radarUnavailable else _create_radar_can_parser(CP.carFingerprint) self.trigger_msg = self.RADAR_B_MSGS[-1] - self.updated_values = defaultdict(lambda: defaultdict(list)) + self.updated_messages = set() def update(self, can_strings): if self.rcp is None: - return None + return super().update(None) - addresses = self.rcp.update_strings(can_strings) - for addr in addresses: - vals_dict = self.rcp.vl_all[addr] - for sig_name, vals in vals_dict.items(): - self.updated_values[addr][sig_name].extend(vals) + vls = self.rcp.update_strings(can_strings) + self.updated_messages.update(vls) - if self.trigger_msg not in self.updated_values: + if self.trigger_msg not in self.updated_messages: return None - radar_data = self._radar_msg_from_buffer(self.updated_values, self.rcp.can_valid) - self.updated_values.clear() + rr = self._update(self.updated_messages) + self.updated_messages.clear() - return radar_data + return rr - def _radar_msg_from_buffer(self, updated_values, can_valid): + def _update(self, updated_messages): ret = car.RadarData.new_message() errors = [] - if not can_valid: + if not self.rcp.can_valid: errors.append("canError") ret.errors = errors - for ii in sorted(updated_values): - if ii not in self.RADAR_A_MSGS: - continue - - radar_a_msgs = updated_values[ii] - radar_b_msgs = updated_values[ii+16] + for ii in sorted(updated_messages): + if ii in self.RADAR_A_MSGS: + cpt = self.rcp.vl[ii] - n_vals_per_addr = len(list(radar_a_msgs.values())[0]) - cpts = [ - {k: v[i] for k, v in radar_a_msgs.items()} - for i in range(n_vals_per_addr) - ] - - for index, cpt in enumerate(cpts): if cpt['LONG_DIST'] >= 255 or cpt['NEW_TRACK']: self.valid_cnt[ii] = 0 # reset counter if cpt['VALID'] and cpt['LONG_DIST'] < 255: @@ -86,15 +71,11 @@ class RadarInterface(RadarInterfaceBase): else: self.valid_cnt[ii] = max(self.valid_cnt[ii] - 1, 0) - n_b_scores = len(radar_b_msgs['SCORE']) - if n_b_scores > 0: - score_index = min(index, n_b_scores - 1) - score = radar_b_msgs['SCORE'][score_index] - else: - score = None + score = self.rcp.vl[ii+16]['SCORE'] + # print ii, self.valid_cnt[ii], score, cpt['VALID'], cpt['LONG_DIST'], cpt['LAT_DIST'] # radar point only valid if it's a valid measurement and score is above 50 - if cpt['VALID'] or (score and score > 50 and cpt['LONG_DIST'] < 255 and self.valid_cnt[ii] > 0): + if cpt['VALID'] or (score > 50 and cpt['LONG_DIST'] < 255 and self.valid_cnt[ii] > 0): if ii not in self.pts or cpt['NEW_TRACK']: self.pts[ii] = car.RadarData.RadarPoint.new_message() self.pts[ii].trackId = self.track_id diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index 303bbaaafe..cce866a093 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -8,7 +8,7 @@ import capnp from cereal import messaging, log, car from common.numpy_fast import interp from common.params import Params -from common.realtime import Ratekeeper, Priority, config_realtime_process, DT_MDL +from common.realtime import Ratekeeper, Priority, config_realtime_process from system.swaglog import cloudlog from common.kalman.simple_kalman import KF1D @@ -50,8 +50,7 @@ class KalmanParams: class Track: - def __init__(self, identifier: int, v_lead: float, kalman_params: KalmanParams): - self.identifier = identifier + def __init__(self, v_lead: float, kalman_params: KalmanParams): self.cnt = 0 self.aLeadTau = _LEAD_ACCEL_TAU self.K_A = kalman_params.A @@ -64,12 +63,8 @@ class Track: self.dRel = d_rel # LONG_DIST self.yRel = y_rel # -LAT_DIST self.vRel = v_rel # REL_SPEED - self.measured = measured # measured or estimate - - self.update_vlead(v_lead) - - def update_vlead(self, v_lead: float): self.vLead = v_lead + self.measured = measured # measured or estimate # computed velocity and accelerations if self.cnt > 0: @@ -103,12 +98,11 @@ class Track: "vLead": float(self.vLead), "vLeadK": float(self.vLeadK), "aLeadK": float(self.aLeadK), - "aLeadTau": float(self.aLeadTau), "status": True, "fcw": self.is_potential_fcw(model_prob), "modelProb": model_prob, "radar": True, - "radarTrackId": self.identifier, + "aLeadTau": float(self.aLeadTau) } def potential_low_speed_lead(self, v_ego: float): @@ -164,17 +158,15 @@ def get_RadarState_from_vision(lead_msg: capnp._DynamicStructReader, v_ego: floa "aLeadTau": 0.3, "fcw": False, "modelProb": float(lead_msg.prob), - "status": True, "radar": False, - "radarTrackId": -1, + "status": True } def get_lead(v_ego: float, ready: bool, tracks: Dict[int, Track], lead_msg: capnp._DynamicStructReader, model_v_ego: float, low_speed_override: bool = True) -> Dict[str, Any]: # Determine leads, this is where the essential logic happens - lead_msg_empty = any(len(c) == 0 for c in [lead_msg.x, lead_msg.y, lead_msg.v]) - if len(tracks) > 0 and ready and not lead_msg_empty and lead_msg.prob > .5: + if len(tracks) > 0 and ready and lead_msg.prob > .5: track = match_vision_to_track(v_ego, lead_msg, tracks) else: track = None @@ -182,7 +174,7 @@ def get_lead(v_ego: float, ready: bool, tracks: Dict[int, Track], lead_msg: capn lead_dict = {'status': False} if track is not None: lead_dict = track.get_RadarState(lead_msg.prob) - elif track is None and ready and not lead_msg_empty and lead_msg.prob > .5: + elif (track is None) and ready and (lead_msg.prob > .5): lead_dict = get_RadarState_from_vision(lead_msg, v_ego, model_v_ego) if low_speed_override: @@ -212,14 +204,14 @@ class RadarD: self.ready = False - def update(self, sm: messaging.SubMaster, radar_data: Optional[car.RadarData]): + def update(self, sm: messaging.SubMaster, rr: Optional[car.RadarData]): self.current_time = 1e-9*max(sm.logMonoTime.values()) radar_points = [] radar_errors = [] - if radar_data is not None: - radar_points = radar_data.points - radar_errors = radar_data.errors + if rr is not None: + radar_points = rr.points + radar_errors = rr.errors if sm.updated['carState']: self.v_ego = sm['carState'].vEgo @@ -227,32 +219,26 @@ class RadarD: if sm.updated['modelV2']: self.ready = True - if radar_data is not None: - ar_pts = {} - for pt in radar_points: - ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured] + ar_pts = {} + for pt in radar_points: + ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured] - # *** remove missing points from meta data *** - for ids in list(self.tracks.keys()): - if ids not in ar_pts: - self.tracks.pop(ids, None) + # *** remove missing points from meta data *** + for ids in list(self.tracks.keys()): + if ids not in ar_pts: + self.tracks.pop(ids, None) - # *** compute the tracks *** - for ids in ar_pts: - rpt = ar_pts[ids] + # *** compute the tracks *** + for ids in ar_pts: + rpt = ar_pts[ids] - # align v_ego by a fixed time to align it with the radar measurement - v_lead = rpt[2] + self.v_ego_hist[0] + # align v_ego by a fixed time to align it with the radar measurement + v_lead = rpt[2] + self.v_ego_hist[0] - # create the track if it doesn't exist or it's a new track - if ids not in self.tracks: - self.tracks[ids] = Track(ids, v_lead, self.kalman_params) - self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead, rpt[3]) - else: - # *** no radar points, keep existing tracks, update v_lead - for track in self.tracks.values(): - v_lead = track.vRel + self.v_ego_hist[0] - track.update_vlead(v_lead) + # create the track if it doesn't exist or it's a new track + if ids not in self.tracks: + self.tracks[ids] = Track(v_lead, self.kalman_params) + self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead, rpt[3]) # *** publish radarState *** self.radar_state_valid = sm.all_checks() and len(radar_errors) == 0 @@ -305,33 +291,32 @@ def radard_thread(sm: Optional[messaging.SubMaster] = None, pm: Optional[messagi cloudlog.info("radard is importing %s", CP.carName) RadarInterface = importlib.import_module(f'selfdrive.car.{CP.carName}.radar_interface').RadarInterface - # setup messaging + # *** setup messaging if can_sock is None: can_sock = messaging.sub_sock('can') if sm is None: - sm = messaging.SubMaster(['modelV2', 'carState'], poll=["modelV2"]) + sm = messaging.SubMaster(['modelV2', 'carState'], ignore_avg_freq=['modelV2', 'carState']) # Can't check average frequency, since radar determines timing if pm is None: pm = messaging.PubMaster(['radarState', 'liveTracks']) - interface = RadarInterface(CP) + RI = RadarInterface(CP) - rk = Ratekeeper(1 / DT_MDL, print_delay_threshold=None) - radar = RadarD(DT_MDL, interface.delay) + rk = Ratekeeper(1.0 / CP.radarTimeStep, print_delay_threshold=None) + RD = RadarD(CP.radarTimeStep, RI.delay) - while True: - sm.update() + while 1: + can_strings = messaging.drain_sock_raw(can_sock, wait_for_one=True) + rr = RI.update(can_strings) - if sm.updated['modelV2']: - can_strings = messaging.drain_sock_raw(can_sock) - if len(can_strings) == 0: - radar_data = None - else: - radar_data = interface.update(can_strings) + if rr is None: + continue + + sm.update(0) - radar.update(sm, radar_data) - radar.publish(pm, -rk.remaining*1000.0) + RD.update(sm, rr) + RD.publish(pm, -rk.remaining*1000.0) - rk.monitor_time() + rk.monitor_time() def main(sm: Optional[messaging.SubMaster] = None, pm: Optional[messaging.PubMaster] = None, can_sock: messaging.SubSocket = None): diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 08e497e72d..623478c555 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -465,8 +465,8 @@ CONFIGS = [ subs=["radarState", "liveTracks"], ignore=["logMonoTime", "valid", "radarState.cumLagMs"], init_callback=get_car_params_callback, - should_recv_callback=MessageBasedRcvCallback("modelV2"), - unlocked_pubs=["can"], + should_recv_callback=MessageBasedRcvCallback("can"), + main_pub="can", ), ProcessConfig( proc_name="plannerd", diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index ce6c513c10..8aec881aa5 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -ac3f87bad519df408a295d2e007e0de58b11690c \ No newline at end of file +72e3d7b660ee92f5adcc249112cf04c703f4bf9e \ No newline at end of file From 2bd4e71b243e8c07a8698ae91174cf269983a20b Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 19 Aug 2023 02:38:36 -0400 Subject: [PATCH 023/159] Hyundai longitudinal (CAN): don't send FCA11 on non-FCA cars (#28479) * Hyundai longitudinal (CAN): don't send FCA messages to non-FCA cars * Update comments * outside * change to FCA11 only * move down * add todos * Apply suggestions from code review * add todo --------- Co-authored-by: Shane Smiskol --- selfdrive/car/hyundai/carcontroller.py | 4 +++- selfdrive/car/hyundai/hyundaican.py | 27 ++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 8c734583e4..6af5f572da 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -171,8 +171,10 @@ class CarController: if self.frame % 2 == 0 and self.CP.openpilotLongitudinalControl: # TODO: unclear if this is needed jerk = 3.0 if actuators.longControlState == LongCtrlState.pid else 1.0 + use_fca = self.CP.flags & HyundaiFlags.USE_FCA.value can_sends.extend(hyundaican.create_acc_commands(self.packer, CC.enabled, accel, jerk, int(self.frame / 2), - hud_control.leadVisible, set_speed_in_units, stopping, CC.cruiseControl.override)) + hud_control.leadVisible, set_speed_in_units, stopping, + CC.cruiseControl.override, use_fca)) # 20 Hz LFA MFA message if self.frame % 5 == 0 and self.CP.flags & HyundaiFlags.SEND_LFA.value: diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index dc5a5b6286..c0c60fba03 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -125,7 +125,7 @@ def create_lfahda_mfc(packer, enabled, hda_set_speed=0): } return packer.make_can_msg("LFAHDA_MFC", 0, values) -def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, set_speed, stopping, long_override): +def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, set_speed, stopping, long_override, use_fca): commands = [] scc11_values = { @@ -163,17 +163,19 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, s } commands.append(packer.make_can_msg("SCC14", 0, scc14_values)) - # note that some vehicles most likely have an alternate checksum/counter definition - # https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602 - fca11_values = { - "CR_FCA_Alive": idx % 0xF, - "PAINT1_Status": 1, - "FCA_DrvSetStatus": 1, - "FCA_Status": 1, # AEB disabled - } - fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2] - fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7]) - commands.append(packer.make_can_msg("FCA11", 0, fca11_values)) + # Only send FCA11 on cars where it exists on the bus + if use_fca: + # note that some vehicles most likely have an alternate checksum/counter definition + # https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602 + fca11_values = { + "CR_FCA_Alive": idx % 0xF, + "PAINT1_Status": 1, + "FCA_DrvSetStatus": 1, + "FCA_Status": 1, # AEB disabled + } + fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2] + fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7]) + commands.append(packer.make_can_msg("FCA11", 0, fca11_values)) return commands @@ -187,6 +189,7 @@ def create_acc_opt(packer): } commands.append(packer.make_can_msg("SCC13", 0, scc13_values)) + # TODO: this needs to be detected and conditionally sent on unsupported long cars fca12_values = { "FCA_DrvSetState": 2, "FCA_USM": 1, # AEB disabled From ac07c205ed70745da1400b69afb38c5ee81d1241 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 18 Aug 2023 23:47:58 -0700 Subject: [PATCH 024/159] Nissan: add alt request for engine on Rogue (#29477) * get engine * \xda should work * fix issue * Update selfdrive/car/nissan/values.py * bump ref * other ref --- selfdrive/car/nissan/values.py | 10 ++++++++++ selfdrive/car/tests/test_fw_fingerprint.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/nissan/values.py b/selfdrive/car/nissan/values.py index e1970ded48..17df968094 100644 --- a/selfdrive/car/nissan/values.py +++ b/selfdrive/car/nissan/values.py @@ -80,9 +80,14 @@ FINGERPRINTS = { ] } +# Default diagnostic session NISSAN_DIAGNOSTIC_REQUEST_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0x81]) NISSAN_DIAGNOSTIC_RESPONSE_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0x81]) +# Manufacturer specific +NISSAN_DIAGNOSTIC_REQUEST_KWP_2 = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0xda]) +NISSAN_DIAGNOSTIC_RESPONSE_KWP_2 = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0xda]) + NISSAN_VERSION_REQUEST_KWP = b'\x21\x83' NISSAN_VERSION_RESPONSE_KWP = b'\x61\x83' @@ -99,6 +104,11 @@ FW_QUERY_CONFIG = FwQueryConfig( [NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP], rx_offset=NISSAN_RX_OFFSET, ), + # Rogue's engine solely responds to this + Request( + [NISSAN_DIAGNOSTIC_REQUEST_KWP_2, NISSAN_VERSION_REQUEST_KWP], + [NISSAN_DIAGNOSTIC_RESPONSE_KWP_2, NISSAN_VERSION_RESPONSE_KWP], + ), Request( [StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST], [StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE], diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 3feb595219..6825bb3717 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -220,7 +220,7 @@ class TestFwFingerprintTiming(unittest.TestCase): print(f'get_vin, query time={vin_time / self.N} seconds') def test_fw_query_timing(self): - total_ref_time = 6.1 + total_ref_time = 6.2 brand_ref_times = { 1: { 'body': 0.1, @@ -229,7 +229,7 @@ class TestFwFingerprintTiming(unittest.TestCase): 'honda': 0.5, 'hyundai': 0.7, 'mazda': 0.2, - 'nissan': 0.3, + 'nissan': 0.4, 'subaru': 0.2, 'tesla': 0.2, 'toyota': 1.6, From f2d22075ebd3f5e17628d1cf1ea102c7ce0bbb09 Mon Sep 17 00:00:00 2001 From: pencilpusher <83676301+jakethesnake420@users.noreply.github.com> Date: Sat, 19 Aug 2023 02:07:52 -0500 Subject: [PATCH 025/159] ui/map: interactive counter fix (#29470) * use interactive_counter instead of separate zoom and pan counters * use interaction_counter instead of separate zoom and pan counters * same styling --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/maps/map.cc | 20 +++++++------------- selfdrive/ui/qt/maps/map.h | 3 +-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index b596b11260..d756a777c4 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -10,7 +10,7 @@ #include "selfdrive/ui/ui.h" -const int PAN_TIMEOUT = 100; +const int INTERACTION_TIMEOUT = 100; const float MAX_ZOOM = 17; const float MIN_ZOOM = 14; @@ -193,17 +193,12 @@ void MapWindow::updateState(const UIState &s) { m_map->updateSource("carPosSource", carPosSource); } - if (pan_counter == 0) { + if (interaction_counter == 0) { if (last_position) m_map->setCoordinate(*last_position); if (last_bearing) m_map->setBearing(*last_bearing); - } else { - pan_counter--; - } - - if (zoom_counter == 0) { m_map->setZoom(util::map_val(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM)); } else { - zoom_counter--; + interaction_counter--; } if (sm.updated("navInstruction")) { @@ -307,15 +302,14 @@ void MapWindow::mouseDoubleClickEvent(QMouseEvent *ev) { m_map->setZoom(util::map_val(velocity_filter.x(), 0, 30, MAX_ZOOM, MIN_ZOOM)); update(); - pan_counter = 0; - zoom_counter = 0; + interaction_counter = 0; } void MapWindow::mouseMoveEvent(QMouseEvent *ev) { QPointF delta = ev->localPos() - m_lastPos; if (!delta.isNull()) { - pan_counter = PAN_TIMEOUT; + interaction_counter = INTERACTION_TIMEOUT; m_map->moveBy(delta / MAP_SCALE); update(); } @@ -337,7 +331,7 @@ void MapWindow::wheelEvent(QWheelEvent *ev) { m_map->scaleBy(1 + factor, ev->pos() / MAP_SCALE); update(); - zoom_counter = PAN_TIMEOUT; + interaction_counter = INTERACTION_TIMEOUT; ev->accept(); } @@ -362,7 +356,7 @@ void MapWindow::pinchTriggered(QPinchGesture *gesture) { // TODO: figure out why gesture centerPoint doesn't work m_map->scaleBy(gesture->scaleFactor(), {width() / 2.0 / MAP_SCALE, height() / 2.0 / MAP_SCALE}); update(); - zoom_counter = PAN_TIMEOUT; + interaction_counter = INTERACTION_TIMEOUT; } } diff --git a/selfdrive/ui/qt/maps/map.h b/selfdrive/ui/qt/maps/map.h index 66d10a00a0..5fe79f8b15 100644 --- a/selfdrive/ui/qt/maps/map.h +++ b/selfdrive/ui/qt/maps/map.h @@ -53,8 +53,7 @@ private: // Panning QPointF m_lastPos; - int pan_counter = 0; - int zoom_counter = 0; + int interaction_counter = 0; // Position std::optional last_valid_nav_dest; From 9ea2cd8d0b5b697ffe7ae38a318ef44e5233ea44 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Sat, 19 Aug 2023 16:23:42 +0800 Subject: [PATCH 026/159] ui/map_instructions: center lanes (#29465) * center lanes * test * similar spacing and no need for stretchj --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/maps/map_instructions.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/selfdrive/ui/qt/maps/map_instructions.cc b/selfdrive/ui/qt/maps/map_instructions.cc index 0901213c76..277e8915cd 100644 --- a/selfdrive/ui/qt/maps/map_instructions.cc +++ b/selfdrive/ui/qt/maps/map_instructions.cc @@ -10,27 +10,30 @@ const QString ICON_SUFFIX = ".png"; MapInstructions::MapInstructions(QWidget *parent) : QWidget(parent) { is_rhd = Params().getBool("IsRhdDetected"); - QHBoxLayout *main_layout = new QHBoxLayout(this); + QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(11, UI_BORDER_SIZE, 11, 11); - main_layout->addWidget(icon_01 = new QLabel, 0, Qt::AlignTop); - QWidget *right_container = new QWidget(this); - right_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - QVBoxLayout *layout = new QVBoxLayout(right_container); + QHBoxLayout *top_layout = new QHBoxLayout; + top_layout->addWidget(icon_01 = new QLabel, 0, Qt::AlignTop); - layout->addWidget(distance = new QLabel); + QVBoxLayout *right_layout = new QVBoxLayout; + right_layout->addWidget(distance = new QLabel); distance->setStyleSheet(R"(font-size: 90px;)"); - layout->addWidget(primary = new QLabel); + right_layout->addWidget(primary = new QLabel); primary->setStyleSheet(R"(font-size: 60px;)"); primary->setWordWrap(true); - layout->addWidget(secondary = new QLabel); + right_layout->addWidget(secondary = new QLabel); secondary->setStyleSheet(R"(font-size: 50px;)"); secondary->setWordWrap(true); - layout->addLayout(lane_layout = new QHBoxLayout); - main_layout->addWidget(right_container); + top_layout->addLayout(right_layout); + + main_layout->addLayout(top_layout); + main_layout->addLayout(lane_layout = new QHBoxLayout); + lane_layout->setAlignment(Qt::AlignHCenter); + lane_layout->setSpacing(10); setStyleSheet("color:white"); QPalette pal = palette(); From 012060ba328da69e7fd62531bd65e8d064b3f6c0 Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Sat, 19 Aug 2023 08:49:16 +0000 Subject: [PATCH 027/159] fast clone instructions (#29455) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fast clone instructions * Support default ubuntu 20.04 git --------- Co-authored-by: Harald Schäfer --- tools/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/README.md b/tools/README.md index 28c819c28b..7e229d3eaa 100644 --- a/tools/README.md +++ b/tools/README.md @@ -9,10 +9,9 @@ openpilot is developed and tested on **Ubuntu 20.04**, which is the primary deve First, clone openpilot: ``` bash cd ~ -git clone https://github.com/commaai/openpilot.git +git clone --filter=blob:none --recurse-submodules https://github.com/commaai/openpilot.git cd openpilot -git submodule update --init ``` Then, run the setup script: From 3972c85e9711c8bf5e6231e80ee7d01f99384e83 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Sun, 20 Aug 2023 11:50:08 +0100 Subject: [PATCH 028/159] agnos manifest: add alt system image (#29468) --- system/hardware/tici/agnos.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/hardware/tici/agnos.json b/system/hardware/tici/agnos.json index 90933e8fef..dcbba3cf92 100644 --- a/system/hardware/tici/agnos.json +++ b/system/hardware/tici/agnos.json @@ -67,6 +67,10 @@ "size": 10737418240, "sparse": true, "full_check": false, - "has_ab": true + "has_ab": true, + "alt": { + "hash": "256442a55fcb9e8f72969f003a4db91598dee1136f8dda85b553a557d36b93d8", + "url": "https://commadist.azureedge.net/agnosupdate/system-e1fa3018bce9bad01c6967e5e21f1141cf5c8f02d2edfaed51c738f74a32a432-skip-chunks.img.xz" + } } ] From 3861fca9409d3b4950367d32fad2a0da5da816fd Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Sun, 20 Aug 2023 20:18:52 +0100 Subject: [PATCH 029/159] agnos: alt system image --- system/hardware/tici/agnos.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/hardware/tici/agnos.json b/system/hardware/tici/agnos.json index dcbba3cf92..7e8cd480be 100644 --- a/system/hardware/tici/agnos.json +++ b/system/hardware/tici/agnos.json @@ -70,7 +70,7 @@ "has_ab": true, "alt": { "hash": "256442a55fcb9e8f72969f003a4db91598dee1136f8dda85b553a557d36b93d8", - "url": "https://commadist.azureedge.net/agnosupdate/system-e1fa3018bce9bad01c6967e5e21f1141cf5c8f02d2edfaed51c738f74a32a432-skip-chunks.img.xz" + "url": "https://commadist.azureedge.net/agnosupdate/system-skip-chunks-e1fa3018bce9bad01c6967e5e21f1141cf5c8f02d2edfaed51c738f74a32a432.img.xz" } } ] From 1dea20e57485a79ff4e1515d892e589ed4a4c65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Sun, 20 Aug 2023 13:05:18 -0700 Subject: [PATCH 030/159] Proc replay: field tolerance unused (#29479) field tolerance unused --- selfdrive/test/process_replay/compare_logs.py | 22 +++---------------- .../test/process_replay/process_replay.py | 1 - .../test/process_replay/test_processes.py | 2 +- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/selfdrive/test/process_replay/compare_logs.py b/selfdrive/test/process_replay/compare_logs.py index a929fae6ed..a2a355805b 100755 --- a/selfdrive/test/process_replay/compare_logs.py +++ b/selfdrive/test/process_replay/compare_logs.py @@ -39,25 +39,12 @@ def remove_ignored_fields(msg, ignore): return msg -def get_field_tolerance(diff_field, field_tolerances): - diff_field_str = diff_field[0] - for s in diff_field[1:]: - # loop until number in field - if not isinstance(s, str): - break - diff_field_str += '.'+s - if diff_field_str in field_tolerances: - return field_tolerances[diff_field_str] - - -def compare_logs(log1, log2, ignore_fields=None, ignore_msgs=None, tolerance=None, field_tolerances=None): +def compare_logs(log1, log2, ignore_fields=None, ignore_msgs=None, tolerance=None,): if ignore_fields is None: ignore_fields = [] if ignore_msgs is None: ignore_msgs = [] - if field_tolerances is None: - field_tolerances = {} - default_tolerance = EPSILON if tolerance is None else tolerance + tolerance = EPSILON if tolerance is None else tolerance log1, log2 = ( [m for m in log if m.which() not in ignore_msgs] @@ -88,13 +75,10 @@ def compare_logs(log1, log2, ignore_fields=None, ignore_msgs=None, tolerance=Non def outside_tolerance(diff): try: if diff[0] == "change": - field_tolerance = default_tolerance - if (tol := get_field_tolerance(diff[1], field_tolerances)) is not None: - field_tolerance = tol a, b = diff[2] finite = math.isfinite(a) and math.isfinite(b) if finite and isinstance(a, numbers.Number) and isinstance(b, numbers.Number): - return abs(a - b) > max(field_tolerance, field_tolerance * max(abs(a), abs(b))) + return abs(a - b) > max(tolerance, tolerance * max(abs(a), abs(b))) except TypeError: pass return True diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 623478c555..eb2c7dad47 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -123,7 +123,6 @@ class ProcessConfig: should_recv_callback: Optional[Callable] = None tolerance: Optional[float] = None processing_time: float = 0.001 - field_tolerances: Dict[str, float] = field(default_factory=dict) timeout: int = 30 simulation: bool = True main_pub: Optional[str] = None diff --git a/selfdrive/test/process_replay/test_processes.py b/selfdrive/test/process_replay/test_processes.py index 0e099d83e2..fe80bc17a5 100755 --- a/selfdrive/test/process_replay/test_processes.py +++ b/selfdrive/test/process_replay/test_processes.py @@ -110,7 +110,7 @@ def test_process(cfg, lr, segment, ref_log_path, new_log_path, ignore_fields=Non return f"Route did not enable at all or for long enough: {new_log_path}", log_msgs try: - return compare_logs(ref_log_msgs, log_msgs, ignore_fields + cfg.ignore, ignore_msgs, cfg.tolerance, cfg.field_tolerances), log_msgs + return compare_logs(ref_log_msgs, log_msgs, ignore_fields + cfg.ignore, ignore_msgs, cfg.tolerance), log_msgs except Exception as e: return str(e), log_msgs From 1f056f3217c431eeda73f00e7d1ec506e103e201 Mon Sep 17 00:00:00 2001 From: Lee Jong Mun <43285072+crwusiz@users.noreply.github.com> Date: Mon, 21 Aug 2023 07:05:25 +0900 Subject: [PATCH 031/159] kor translation update (#29493) --- selfdrive/ui/translations/main_ko.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/translations/main_ko.ts b/selfdrive/ui/translations/main_ko.ts index 851c306a47..31190c25b9 100644 --- a/selfdrive/ui/translations/main_ko.ts +++ b/selfdrive/ui/translations/main_ko.ts @@ -1120,11 +1120,11 @@ This may take up to a minute. When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right appropriately at forks/exits. Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around exits and forks. These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc. - + 내비게이션에 목적지가 있으면 openpilot이 지도 정보를 모델에 입력합니다. 이는 모델에 유용한 컨텍스트를 제공하고 openpilot이 분기점에서 적절하게 왼쪽 또는 오른쪽을 유지할 수 있도록 합니다. 차선 변경 기능은 여전히 운전자의 조작에 의해 활성화됩니다. 이것은 알파 상태의 기능입니다. 특히 출구 분기점 주변에서 실수가 발생될수 있으며 이러한 실수에는 의도하지 않은 차선 이탈, 늦은 출구 이용, 도로 가장자리의 분리대 또는 경계석을 향해 운전하는 등이 포함될 수 있습니다. The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner. When a navigation destination is set and the driving model is using it as input, the driving path on the map will turn green. - + 주행 시각화는 저속으로 주행시 도로를 향한 광각 카메라로 전환되어 일부 회전을 더 잘 보여줍니다. 실험적 모드 로고도 우측 상단에 표시됩니다. 내비게이션 목적지가 설정되고 주행 모델에 입력되면 지도의 주행 경로가 녹색으로 바뀝니다.
From 5690386d8d731c9bebda536a5c71c890f6dfe98c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 20 Aug 2023 15:13:24 -0700 Subject: [PATCH 032/159] update clone instructions (#29490) * both * Update README.md * Update README.md --- tools/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/README.md b/tools/README.md index 7e229d3eaa..fd03a5d77e 100644 --- a/tools/README.md +++ b/tools/README.md @@ -9,7 +9,10 @@ openpilot is developed and tested on **Ubuntu 20.04**, which is the primary deve First, clone openpilot: ``` bash cd ~ -git clone --filter=blob:none --recurse-submodules https://github.com/commaai/openpilot.git +git clone --recurse-submodules https://github.com/commaai/openpilot.git + +# or do a partial clone instead for a faster clone and smaller repo size +git clone --filter=blob:none --recurse-submodules --also-filter-submodules https://github.com/commaai/openpilot.git cd openpilot ``` From bc4b75822a609e6897058bc83688c84004f29093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Sun, 20 Aug 2023 17:24:33 -0700 Subject: [PATCH 033/159] update process replay timeout (#29478) * Always dict differ * Update selfdrive_tests.yaml * bump up more --------- Co-authored-by: Adeeb Shihadeh --- .github/workflows/selfdrive_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 65e10e61ed..0aad8ba0bb 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -306,7 +306,7 @@ jobs: run: | ${{ env.RUN }} "scons -j$(nproc)" - name: Run replay - timeout-minutes: 20 + timeout-minutes: 30 run: | ${{ env.RUN }} "CI=1 coverage run selfdrive/test/process_replay/test_processes.py -j$(nproc) && \ coverage xml" From d61f86d3398900ef01423d24cfdf897392a8efbb Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 20 Aug 2023 18:50:58 -0700 Subject: [PATCH 034/159] replace custom clock helpers with time module (#29499) * replace custom clock stuff wtih time module * fix double * fix release * bump cereal * update type * fix one more --- cereal | 2 +- common/SConscript | 1 - common/clock.pyx | 24 ------------------- common/realtime.py | 11 ++++----- release/files_common | 1 - scripts/waste.py | 6 ++--- selfdrive/athena/athenad.py | 16 ++++++------- selfdrive/controls/controlsd.py | 7 +++--- .../controls/lib/lateral_mpc_lib/lat_mpc.py | 6 ++--- selfdrive/controls/lib/lateral_planner.py | 5 ++-- .../lib/longitudinal_mpc_lib/long_mpc.py | 8 +++---- selfdrive/debug/can_printer.py | 14 +++++------ selfdrive/debug/check_freq.py | 6 ++--- selfdrive/manager/process.py | 3 +-- selfdrive/thermald/power_monitoring.py | 6 ++--- selfdrive/thermald/thermald.py | 14 +++++------ 16 files changed, 52 insertions(+), 78 deletions(-) delete mode 100644 common/clock.pyx diff --git a/cereal b/cereal index 1ee48e0110..3cac040c5b 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 1ee48e0110a46fbdd9db50ed89a38bb5a748cfcb +Subproject commit 3cac040c5b219402cb9b234d53c78a6007298534 diff --git a/common/SConscript b/common/SConscript index 5d6170611f..71894923a6 100644 --- a/common/SConscript +++ b/common/SConscript @@ -31,5 +31,4 @@ if GetOption('test'): env.Program('tests/test_swaglog', ['tests/test_swaglog.cc'], LIBS=[_common, 'json11', 'zmq', 'pthread']) # Cython -envCython.Program('clock.so', 'clock.pyx') envCython.Program('params_pyx.so', 'params_pyx.pyx', LIBS=envCython['LIBS'] + [_common, 'zmq', 'json11']) diff --git a/common/clock.pyx b/common/clock.pyx deleted file mode 100644 index 81333565c5..0000000000 --- a/common/clock.pyx +++ /dev/null @@ -1,24 +0,0 @@ -# distutils: language = c++ -# cython: language_level = 3 -from posix.time cimport clock_gettime, timespec, CLOCK_MONOTONIC_RAW, clockid_t - -IF UNAME_SYSNAME == "Darwin": - # Darwin doesn't have a CLOCK_BOOTTIME - CLOCK_BOOTTIME = CLOCK_MONOTONIC_RAW -ELSE: - from posix.time cimport CLOCK_BOOTTIME - -cdef double readclock(clockid_t clock_id): - cdef timespec ts - cdef double current - - clock_gettime(clock_id, &ts) - current = ts.tv_sec + (ts.tv_nsec / 1000000000.) - return current - -def monotonic_time(): - return readclock(CLOCK_MONOTONIC_RAW) - -def sec_since_boot(): - return readclock(CLOCK_BOOTTIME) - diff --git a/common/realtime.py b/common/realtime.py index 7dd2eb98a6..dd3a5fdf8f 100644 --- a/common/realtime.py +++ b/common/realtime.py @@ -5,9 +5,8 @@ import time from collections import deque from typing import Optional, List, Union -from setproctitle import getproctitle # pylint: disable=no-name-in-module +from setproctitle import getproctitle -from common.clock import sec_since_boot # pylint: disable=no-name-in-module, import-error from system.hardware import PC @@ -50,13 +49,13 @@ class Ratekeeper: def __init__(self, rate: float, print_delay_threshold: Optional[float] = 0.0) -> None: """Rate in Hz for ratekeeping. print_delay_threshold must be nonnegative.""" self._interval = 1. / rate - self._next_frame_time = sec_since_boot() + self._interval + self._next_frame_time = time.monotonic() + self._interval self._print_delay_threshold = print_delay_threshold self._frame = 0 self._remaining = 0.0 self._process_name = getproctitle() self._dts = deque([self._interval], maxlen=100) - self._last_monitor_time = sec_since_boot() + self._last_monitor_time = time.monotonic() @property def frame(self) -> int: @@ -82,11 +81,11 @@ class Ratekeeper: # this only monitor the cumulative lag, but does not enforce a rate def monitor_time(self) -> bool: prev = self._last_monitor_time - self._last_monitor_time = sec_since_boot() + self._last_monitor_time = time.monotonic() self._dts.append(self._last_monitor_time - prev) lagged = False - remaining = self._next_frame_time - sec_since_boot() + remaining = self._next_frame_time - time.monotonic() self._next_frame_time += self._interval if self._print_delay_threshold is not None and remaining < -self._print_delay_threshold: print(f"{self._process_name} lagging by {-remaining * 1000:.2f} ms") diff --git a/release/files_common b/release/files_common index 8381546b03..0f43daa4a0 100644 --- a/release/files_common +++ b/release/files_common @@ -20,7 +20,6 @@ common/__init__.py common/conversions.py common/gpio.py common/realtime.py -common/clock.pyx common/timeout.py common/ffi_wrapper.py common/file_helpers.py diff --git a/scripts/waste.py b/scripts/waste.py index d3c96bf198..e72b367063 100755 --- a/scripts/waste.py +++ b/scripts/waste.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import os +import time import numpy as np -from common.realtime import sec_since_boot from multiprocessing import Process from setproctitle import setproctitle # pylint: disable=no-name-in-module @@ -12,12 +12,12 @@ def waste(core): m2 = np.zeros((200, 200)) + 1.2 i = 1 - st = sec_since_boot() + st = time.monotonic() j = 0 while 1: if (i % 100) == 0: setproctitle("%3d: %8d" % (core, i)) - lt = sec_since_boot() + lt = time.monotonic() print("%3d: %8d %f %.2f" % (core, i, lt-st, j)) st = lt i += 1 diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index d7ef064072..b3a13d2279 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -34,7 +34,7 @@ from common.api import Api from common.basedir import PERSIST from common.file_helpers import CallbackReader from common.params import Params -from common.realtime import sec_since_boot, set_core_affinity +from common.realtime import set_core_affinity from system.hardware import HARDWARE, PC, AGNOS from system.loggerd.config import ROOT from system.loggerd.xattr_cache import getxattr, setxattr @@ -593,10 +593,10 @@ def log_handler(end_event: threading.Event) -> None: return log_files = [] - last_scan = 0 + last_scan = 0. while not end_event.is_set(): try: - curr_scan = sec_since_boot() + curr_scan = time.monotonic() if curr_scan - last_scan > 10: log_files = get_logs_to_send_sorted() last_scan = curr_scan @@ -652,8 +652,8 @@ def log_handler(end_event: threading.Event) -> None: def stat_handler(end_event: threading.Event) -> None: while not end_event.is_set(): - last_scan = 0 - curr_scan = sec_since_boot() + last_scan = 0. + curr_scan = time.monotonic() try: if curr_scan - last_scan > 10: stat_filenames = list(filter(lambda name: not name.startswith(tempfile.gettempprefix()), os.listdir(STATS_DIR))) @@ -721,7 +721,7 @@ def ws_proxy_send(ws: WebSocket, local_sock: socket.socket, signal_sock: socket. def ws_recv(ws: WebSocket, end_event: threading.Event) -> None: - last_ping = int(sec_since_boot() * 1e9) + last_ping = int(time.monotonic() * 1e9) while not end_event.is_set(): try: opcode, data = ws.recv_data(control_frame=True) @@ -730,10 +730,10 @@ def ws_recv(ws: WebSocket, end_event: threading.Event) -> None: data = data.decode("utf-8") recv_queue.put_nowait(data) elif opcode == ABNF.OPCODE_PING: - last_ping = int(sec_since_boot() * 1e9) + last_ping = int(time.monotonic() * 1e9) Params().put("LastAthenaPingTime", str(last_ping)) except WebSocketTimeoutException: - ns_since_last_ping = int(sec_since_boot() * 1e9) - last_ping + ns_since_last_ping = int(time.monotonic() * 1e9) - last_ping if ns_since_last_ping > RECONNECT_TIMEOUT_S * 1e9: cloudlog.exception("athenad.ws_recv.timeout") end_event.set() diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 8084b18ff6..564a0aa6ac 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 import os import math +import time from typing import SupportsFloat from cereal import car, log from common.numpy_fast import clip -from common.realtime import sec_since_boot, config_realtime_process, Priority, Ratekeeper, DT_CTRL from common.profiler import Profiler from common.params import Params, put_nonblocking, put_bool_nonblocking +from common.realtime import DT_CTRL, Priority, Ratekeeper, config_realtime_process import cereal.messaging as messaging from cereal.visionipc import VisionIpcClient, VisionStreamType from common.conversions import Conversions as CV @@ -743,7 +744,7 @@ class Controls: if not self.read_only and self.initialized: # send car controls over can - now_nanos = self.can_log_mono_time if REPLAY else int(sec_since_boot() * 1e9) + now_nanos = self.can_log_mono_time if REPLAY else int(time.monotonic() * 1e9) self.last_actuators, can_sends = self.CI.apply(CC, now_nanos) self.pm.send('sendcan', can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) CC.actuatorsOutput = self.last_actuators @@ -842,7 +843,7 @@ class Controls: self.CC = CC def step(self): - start_time = sec_since_boot() + start_time = time.monotonic() self.prof.checkpoint("Ratekeeper", ignore=True) self.is_metric = self.params.get_bool("IsMetric") diff --git a/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py b/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py index 6afcb99dab..506b03031b 100755 --- a/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py +++ b/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 import os +import time import numpy as np from casadi import SX, vertcat, sin, cos -from common.realtime import sec_since_boot # WARNING: imports outside of constants will not trigger a rebuild from selfdrive.modeld.constants import T_IDXS @@ -182,9 +182,9 @@ class LateralMpc(): self.solver.set(N, "p", p_cp[N]) self.solver.cost_set(N, "yref", self.yref[N][:COST_E_DIM]) - t = sec_since_boot() + t = time.monotonic() self.solution_status = self.solver.solve() - self.solve_time = sec_since_boot() - t + self.solve_time = time.monotonic() - t for i in range(N+1): self.x_sol[i] = self.solver.get(i, 'x') diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py index 38258b4b5d..41aa95223e 100644 --- a/selfdrive/controls/lib/lateral_planner.py +++ b/selfdrive/controls/lib/lateral_planner.py @@ -1,6 +1,7 @@ +import time import numpy as np -from common.realtime import sec_since_boot, DT_MDL from common.numpy_fast import interp +from common.realtime import DT_MDL from system.swaglog import cloudlog from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import N as LAT_MPC_N @@ -108,7 +109,7 @@ class LateralPlanner: # Check for infeasible MPC solution mpc_nans = np.isnan(self.lat_mpc.x_sol[:, 3]).any() - t = sec_since_boot() + t = time.monotonic() if mpc_nans or self.lat_mpc.solution_status != 0: self.reset_mpc() self.x0[3] = measured_curvature * self.v_ego diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py b/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py index dadf6cba28..19cb2bac04 100644 --- a/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 import os +import time import numpy as np from cereal import log -from common.realtime import sec_since_boot from common.numpy_fast import clip from system.swaglog import cloudlog # WARNING: imports outside of constants will not trigger a rebuild @@ -411,7 +411,7 @@ class LongitudinalMpc: self.source = 'lead1' def run(self): - # t0 = sec_since_boot() + # t0 = time.monotonic() # reset = 0 for i in range(N+1): self.solver.set(i, 'p', self.params[i]) @@ -442,14 +442,14 @@ class LongitudinalMpc: self.prev_a = np.interp(T_IDXS + 0.05, T_IDXS, self.a_solution) - t = sec_since_boot() + t = time.monotonic() if self.solution_status != 0: if t > self.last_cloudlog_t + 5.0: self.last_cloudlog_t = t cloudlog.warning(f"Long mpc reset, solution_status: {self.solution_status}") self.reset() # reset = 1 - # print(f"long_mpc timings: total internal {self.solve_time:.2e}, external: {(sec_since_boot() - t0):.2e} qp {self.time_qp_solution:.2e}, \ + # print(f"long_mpc timings: total internal {self.solve_time:.2e}, external: {(time.monotonic() - t0):.2e} qp {self.time_qp_solution:.2e}, \ # lin {self.time_linearization:.2e} qp_iter {qp_iter}, reset {reset}") diff --git a/selfdrive/debug/can_printer.py b/selfdrive/debug/can_printer.py index 3f991d4e6c..220008979d 100755 --- a/selfdrive/debug/can_printer.py +++ b/selfdrive/debug/can_printer.py @@ -1,17 +1,17 @@ #!/usr/bin/env python3 import argparse import binascii +import time from collections import defaultdict import cereal.messaging as messaging -from common.realtime import sec_since_boot def can_printer(bus, max_msg, addr, ascii_decode): logcan = messaging.sub_sock('can', addr=addr) - start = sec_since_boot() - lp = sec_since_boot() + start = time.monotonic() + lp = time.monotonic() msgs = defaultdict(list) while 1: can_recv = messaging.drain_sock(logcan, wait_for_one=True) @@ -20,17 +20,17 @@ def can_printer(bus, max_msg, addr, ascii_decode): if y.src == bus: msgs[y.address].append(y.dat) - if sec_since_boot() - lp > 0.1: + if time.monotonic() - lp > 0.1: dd = chr(27) + "[2J" - dd += f"{sec_since_boot() - start:5.2f}\n" + dd += f"{time.monotonic() - start:5.2f}\n" for addr in sorted(msgs.keys()): a = f"\"{msgs[addr][-1].decode('ascii', 'backslashreplace')}\"" if ascii_decode else "" x = binascii.hexlify(msgs[addr][-1]).decode('ascii') - freq = len(msgs[addr]) / (sec_since_boot() - start) + freq = len(msgs[addr]) / (time.monotonic() - start) if max_msg is None or addr < max_msg: dd += "%04X(%4d)(%6d)(%3dHz) %s %s\n" % (addr, addr, len(msgs[addr]), freq, x.ljust(20), a) print(dd) - lp = sec_since_boot() + lp = time.monotonic() if __name__ == "__main__": parser = argparse.ArgumentParser(description="simple CAN data viewer", diff --git a/selfdrive/debug/check_freq.py b/selfdrive/debug/check_freq.py index 6436abb4f1..7e7b05e950 100755 --- a/selfdrive/debug/check_freq.py +++ b/selfdrive/debug/check_freq.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 import argparse import numpy as np +import time from collections import defaultdict, deque from typing import DefaultDict, Deque, MutableSequence -from common.realtime import sec_since_boot import cereal.messaging as messaging @@ -22,7 +22,7 @@ if __name__ == "__main__": rcv_times: DefaultDict[str, MutableSequence[float]] = defaultdict(lambda: deque(maxlen=100)) valids: DefaultDict[str, Deque[bool]] = defaultdict(lambda: deque(maxlen=100)) - t = sec_since_boot() + t = time.monotonic() for name in socket_names: sock = messaging.sub_sock(name, poller=poller) sockets[sock] = name @@ -36,7 +36,7 @@ if __name__ == "__main__": name = msg.which() - t = sec_since_boot() + t = time.monotonic() rcv_times[name].append(msg.logMonoTime / 1e9) valids[name].append(msg.valid) diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index 0acb23857a..e6c2c52bec 100644 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -15,7 +15,6 @@ import selfdrive.sentry as sentry from cereal import car from common.basedir import BASEDIR from common.params import Params -from common.realtime import sec_since_boot from system.swaglog import cloudlog from cereal import log @@ -104,7 +103,7 @@ class ManagerProcess(ABC): except Exception: pass - dt = sec_since_boot() - self.last_watchdog_time / 1e9 + dt = time.monotonic() - self.last_watchdog_time / 1e9 if dt > self.watchdog_max_dt: if self.watchdog_seen and ENABLE_WATCHDOG: diff --git a/selfdrive/thermald/power_monitoring.py b/selfdrive/thermald/power_monitoring.py index 06e2b5e8f9..e9b07da1f6 100644 --- a/selfdrive/thermald/power_monitoring.py +++ b/selfdrive/thermald/power_monitoring.py @@ -1,8 +1,8 @@ +import time import threading from typing import Optional from common.params import Params, put_nonblocking -from common.realtime import sec_since_boot from system.hardware import HARDWARE from system.swaglog import cloudlog from selfdrive.statsd import statlog @@ -41,7 +41,7 @@ class PowerMonitoring: # Calculation tick def calculate(self, voltage: Optional[int], ignition: bool): try: - now = sec_since_boot() + now = time.monotonic() # If peripheralState is None, we're probably not in a car, so we don't care if voltage is None: @@ -113,7 +113,7 @@ class PowerMonitoring: if offroad_timestamp is None: return False - now = sec_since_boot() + now = time.monotonic() should_shutdown = False offroad_time = (now - offroad_timestamp) low_voltage_shutdown = (self.car_voltage_mV < (VBATT_PAUSE_CHARGING * 1e3) and diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 931f9be88f..d2ab8ff733 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -17,7 +17,7 @@ from common.dict_helpers import strip_deprecated_keys from common.time import MIN_DATE from common.filter_simple import FirstOrderFilter from common.params import Params -from common.realtime import DT_TRML, sec_since_boot +from common.realtime import DT_TRML from selfdrive.controls.lib.alertmanager import set_offroad_alert from system.hardware import HARDWARE, TICI, AGNOS from system.loggerd.config import get_available_percent @@ -230,7 +230,7 @@ def thermald_thread(end_event, hw_queue): if TICI: fan_controller = TiciFanController() - elif (sec_since_boot() - sm.rcv_time['pandaStates']) > DISCONNECT_TIMEOUT: + elif (time.monotonic() - sm.rcv_time['pandaStates']) > DISCONNECT_TIMEOUT: if onroad_conditions["ignition"]: onroad_conditions["ignition"] = False cloudlog.error("panda timed out onroad") @@ -273,7 +273,7 @@ def thermald_thread(end_event, hw_queue): if fan_controller is not None: msg.deviceState.fanSpeedPercentDesired = fan_controller.update(all_comp_temp, onroad_conditions["ignition"]) - is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (sec_since_boot() - off_ts > 60 * 5)) + is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (time.monotonic() - off_ts > 60 * 5)) if is_offroad_for_5_min and offroad_comp_temp > OFFROAD_DANGER_TEMP: # if device is offroad and already hot without the extra onroad load, # we want to cool down first before increasing load @@ -354,10 +354,10 @@ def thermald_thread(end_event, hw_queue): if should_start: off_ts = None if started_ts is None: - started_ts = sec_since_boot() + started_ts = time.monotonic() started_seen = True if startup_blocked_ts is not None: - cloudlog.event("Startup after block", block_duration=(sec_since_boot() - startup_blocked_ts), + cloudlog.event("Startup after block", block_duration=(time.monotonic() - startup_blocked_ts), startup_conditions=startup_conditions, onroad_conditions=onroad_conditions, startup_conditions_prev=startup_conditions_prev, error=True) startup_blocked_ts = None @@ -365,11 +365,11 @@ def thermald_thread(end_event, hw_queue): if onroad_conditions["ignition"] and (startup_conditions != startup_conditions_prev): cloudlog.event("Startup blocked", startup_conditions=startup_conditions, onroad_conditions=onroad_conditions, error=True) startup_conditions_prev = startup_conditions.copy() - startup_blocked_ts = sec_since_boot() + startup_blocked_ts = time.monotonic() started_ts = None if off_ts is None: - off_ts = sec_since_boot() + off_ts = time.monotonic() # Offroad power monitoring voltage = None if peripheralState.pandaType == log.PandaState.PandaType.unknown else peripheralState.voltage From a9626f95b69af19306143fc4def02fb5769405d2 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 20 Aug 2023 20:49:55 -0700 Subject: [PATCH 035/159] add openpilot prefix to imports (#29498) * add openpilot prefix to imports * more * more * fix docs * fix linter * bump submodules * fix patched tests * update dynamic imports * debug * Revert "debug" This reverts commit db5e13b9911cc74438bee123bc3430da6c31b24b. * fix pm test --- Dockerfile.openpilot | 1 + common/api/__init__.py | 4 +- common/basedir.py | 2 +- common/kalman/simple_kalman.py | 2 +- common/kalman/tests/test_simple_kalman.py | 8 ++-- common/params.py | 3 +- common/realtime.py | 2 +- common/spinner.py | 2 +- common/tests/test_file_helpers.py | 4 +- common/tests/test_numpy_fast.py | 2 +- common/tests/test_params.py | 2 +- common/text_window.py | 2 +- common/transformations/camera.py | 2 +- common/transformations/coordinates.py | 6 +-- common/transformations/model.py | 10 ++--- common/transformations/orientation.py | 2 +- .../transformations/tests/test_coordinates.py | 2 +- .../transformations/tests/test_orientation.py | 2 +- common/transformations/transformations.pyx | 30 +++++++------- docs/conf.py | 4 +- docs/docker/Dockerfile | 1 + laika_repo | 2 +- panda | 2 +- release/files_common | 3 ++ scripts/count_cars.py | 2 +- scripts/disable-powersave.py | 2 +- scripts/pyqt_demo.py | 2 +- scripts/waste.py | 4 +- selfdrive/athena/athenad.py | 24 +++++------ selfdrive/athena/manage_athenad.py | 8 ++-- selfdrive/athena/registration.py | 14 +++---- selfdrive/athena/tests/helpers.py | 2 +- selfdrive/athena/tests/test_athenad.py | 10 ++--- selfdrive/athena/tests/test_athenad_ping.py | 10 ++--- selfdrive/athena/tests/test_registration.py | 16 ++++---- selfdrive/boardd/boardd.py | 2 +- selfdrive/boardd/pandad.py | 10 ++--- selfdrive/boardd/set_time.py | 2 +- .../boardd/tests/test_boardd_loopback.py | 12 +++--- selfdrive/boardd/tests/test_pandad.py | 12 +++--- selfdrive/car/__init__.py | 2 +- selfdrive/car/body/carcontroller.py | 10 ++--- selfdrive/car/body/carstate.py | 4 +- selfdrive/car/body/interface.py | 8 ++-- selfdrive/car/body/radar_interface.py | 2 +- selfdrive/car/body/values.py | 6 +-- selfdrive/car/car_helpers.py | 20 +++++----- selfdrive/car/chrysler/carcontroller.py | 8 ++-- selfdrive/car/chrysler/carstate.py | 6 +-- selfdrive/car/chrysler/chryslercan.py | 2 +- selfdrive/car/chrysler/interface.py | 6 +-- selfdrive/car/chrysler/radar_interface.py | 4 +- selfdrive/car/chrysler/values.py | 6 +-- selfdrive/car/disable_ecu.py | 4 +- selfdrive/car/docs.py | 8 ++-- selfdrive/car/docs_definitions.py | 2 +- selfdrive/car/ecu_addrs.py | 8 ++-- selfdrive/car/fingerprints.py | 2 +- selfdrive/car/ford/carcontroller.py | 8 ++-- selfdrive/car/ford/carstate.py | 8 ++-- selfdrive/car/ford/fordcan.py | 2 +- selfdrive/car/ford/interface.py | 10 ++--- selfdrive/car/ford/radar_interface.py | 8 ++-- selfdrive/car/ford/values.py | 6 +-- selfdrive/car/fw_versions.py | 16 ++++---- selfdrive/car/gm/carcontroller.py | 12 +++--- selfdrive/car/gm/carstate.py | 8 ++-- selfdrive/car/gm/gmcan.py | 4 +- selfdrive/car/gm/interface.py | 12 +++--- selfdrive/car/gm/radar_interface.py | 6 +-- selfdrive/car/gm/tests/test_gm.py | 2 +- selfdrive/car/gm/values.py | 4 +- selfdrive/car/honda/carcontroller.py | 12 +++--- selfdrive/car/honda/carstate.py | 12 +++--- selfdrive/car/honda/hondacan.py | 4 +- selfdrive/car/honda/interface.py | 12 +++--- selfdrive/car/honda/radar_interface.py | 4 +- selfdrive/car/honda/tests/test_honda.py | 2 +- selfdrive/car/honda/values.py | 8 ++-- selfdrive/car/hyundai/carcontroller.py | 14 +++---- selfdrive/car/hyundai/carstate.py | 9 +++-- selfdrive/car/hyundai/hyundaican.py | 2 +- selfdrive/car/hyundai/hyundaicanfd.py | 6 +-- selfdrive/car/hyundai/interface.py | 14 +++---- selfdrive/car/hyundai/radar_interface.py | 4 +- .../car/hyundai/tests/print_platform_codes.py | 2 +- selfdrive/car/hyundai/tests/test_hyundai.py | 4 +- selfdrive/car/hyundai/values.py | 8 ++-- selfdrive/car/interfaces.py | 20 +++++----- selfdrive/car/isotp_parallel_query.py | 4 +- selfdrive/car/mazda/carcontroller.py | 6 +-- selfdrive/car/mazda/carstate.py | 6 +-- selfdrive/car/mazda/interface.py | 8 ++-- selfdrive/car/mazda/mazdacan.py | 2 +- selfdrive/car/mazda/radar_interface.py | 2 +- selfdrive/car/mazda/values.py | 6 +-- selfdrive/car/mock/interface.py | 6 +-- selfdrive/car/mock/radar_interface.py | 2 +- selfdrive/car/mock/values.py | 2 +- selfdrive/car/nissan/carcontroller.py | 6 +-- selfdrive/car/nissan/carstate.py | 6 +-- selfdrive/car/nissan/interface.py | 6 +-- selfdrive/car/nissan/nissancan.py | 2 +- selfdrive/car/nissan/radar_interface.py | 2 +- selfdrive/car/nissan/values.py | 6 +-- selfdrive/car/subaru/carcontroller.py | 8 ++-- selfdrive/car/subaru/carstate.py | 8 ++-- selfdrive/car/subaru/interface.py | 6 +-- selfdrive/car/subaru/radar_interface.py | 2 +- selfdrive/car/subaru/subarucan.py | 2 +- selfdrive/car/subaru/values.py | 6 +-- selfdrive/car/tesla/carcontroller.py | 8 ++-- selfdrive/car/tesla/carstate.py | 6 +-- selfdrive/car/tesla/interface.py | 6 +-- selfdrive/car/tesla/radar_interface.py | 4 +- selfdrive/car/tesla/teslacan.py | 4 +- selfdrive/car/tesla/values.py | 6 +-- selfdrive/car/tests/routes.py | 24 +++++------ selfdrive/car/tests/test_can_fingerprint.py | 4 +- selfdrive/car/tests/test_car_interfaces.py | 12 +++--- selfdrive/car/tests/test_docs.py | 14 +++---- selfdrive/car/tests/test_fingerprints.py | 2 +- selfdrive/car/tests/test_fw_fingerprint.py | 11 ++--- selfdrive/car/tests/test_lateral_limits.py | 10 ++--- selfdrive/car/tests/test_models.py | 22 +++++----- selfdrive/car/toyota/carcontroller.py | 8 ++-- selfdrive/car/toyota/carstate.py | 13 +++--- selfdrive/car/toyota/interface.py | 8 ++-- selfdrive/car/toyota/radar_interface.py | 4 +- selfdrive/car/toyota/tests/test_toyota.py | 2 +- selfdrive/car/toyota/values.py | 8 ++-- selfdrive/car/vin.py | 6 +-- selfdrive/car/volkswagen/carcontroller.py | 12 +++--- selfdrive/car/volkswagen/carstate.py | 6 +-- selfdrive/car/volkswagen/interface.py | 8 ++-- selfdrive/car/volkswagen/radar_interface.py | 2 +- selfdrive/car/volkswagen/values.py | 6 +-- selfdrive/controls/controlsd.py | 40 +++++++++---------- selfdrive/controls/lib/alertmanager.py | 6 +-- selfdrive/controls/lib/desire_helper.py | 4 +- selfdrive/controls/lib/drive_helpers.py | 8 ++-- selfdrive/controls/lib/events.py | 8 ++-- selfdrive/controls/lib/latcontrol.py | 4 +- selfdrive/controls/lib/latcontrol_angle.py | 2 +- selfdrive/controls/lib/latcontrol_pid.py | 4 +- selfdrive/controls/lib/latcontrol_torque.py | 8 ++-- .../controls/lib/lateral_mpc_lib/lat_mpc.py | 6 +-- selfdrive/controls/lib/lateral_planner.py | 14 +++---- selfdrive/controls/lib/longcontrol.py | 10 ++--- .../lib/longitudinal_mpc_lib/long_mpc.py | 14 +++---- .../controls/lib/longitudinal_planner.py | 24 +++++------ selfdrive/controls/lib/pid.py | 2 +- .../controls/lib/tests/test_alertmanager.py | 4 +- .../controls/lib/tests/test_latcontrol.py | 16 ++++---- .../controls/lib/tests/test_vehicle_model.py | 6 +-- selfdrive/controls/plannerd.py | 12 +++--- selfdrive/controls/radard.py | 10 ++--- selfdrive/controls/tests/test_alerts.py | 10 ++--- selfdrive/controls/tests/test_cruise_speed.py | 8 ++-- .../controls/tests/test_following_distance.py | 6 +-- selfdrive/controls/tests/test_lateral_mpc.py | 6 +-- selfdrive/controls/tests/test_startup.py | 14 +++---- .../controls/tests/test_state_machine.py | 8 ++-- selfdrive/debug/can_print_changes.py | 4 +- .../debug/check_can_parser_performance.py | 6 +-- selfdrive/debug/count_events.py | 4 +- selfdrive/debug/cpu_usage_stat.py | 2 +- selfdrive/debug/cycle_alerts.py | 10 ++--- selfdrive/debug/dump_car_info.py | 2 +- selfdrive/debug/filter_log_message.py | 4 +- selfdrive/debug/fingerprint_from_route.py | 4 +- .../debug/internal/fuzz_fw_fingerprint.py | 10 ++--- selfdrive/debug/internal/qlog_size.py | 4 +- selfdrive/debug/live_cpu_and_temp.py | 2 +- selfdrive/debug/print_docs_diff.py | 4 +- selfdrive/debug/run_process_on_route.py | 8 ++-- selfdrive/debug/sensor_data_to_hist.py | 4 +- selfdrive/debug/set_car_params.py | 6 +-- selfdrive/debug/show_matching_cars.py | 2 +- selfdrive/debug/test_car_model.py | 6 +-- selfdrive/debug/test_fw_query_on_routes.py | 8 ++-- selfdrive/debug/toyota_eps_factor.py | 6 +-- selfdrive/debug/uiview.py | 4 +- selfdrive/locationd/calibrationd.py | 10 ++--- selfdrive/locationd/laikad.py | 10 ++--- selfdrive/locationd/models/car_kf.py | 6 +-- selfdrive/locationd/models/gnss_kf.py | 4 +- selfdrive/locationd/models/lane_kf.py | 2 +- selfdrive/locationd/models/live_kf.py | 2 +- selfdrive/locationd/models/loc_kf.py | 4 +- selfdrive/locationd/paramsd.py | 12 +++--- .../locationd/test/_test_locationd_lib.py | 2 +- selfdrive/locationd/test/test_calibrationd.py | 4 +- selfdrive/locationd/test/test_laikad.py | 10 ++--- selfdrive/locationd/test/test_locationd.py | 6 +-- selfdrive/locationd/torqued.py | 10 ++--- selfdrive/manager/build.py | 12 +++--- selfdrive/manager/manager.py | 24 +++++------ selfdrive/manager/process.py | 11 +++-- selfdrive/manager/process_config.py | 6 +-- selfdrive/manager/test/test_manager.py | 10 ++--- selfdrive/modeld/modeld.cc | 2 +- selfdrive/modeld/tests/test_modeld.py | 8 ++-- selfdrive/modeld/tests/timing/benchmark.py | 2 +- selfdrive/monitoring/dmonitoringd.py | 8 ++-- selfdrive/monitoring/driver_monitor.py | 10 ++--- selfdrive/monitoring/test_monitoring.py | 6 +-- selfdrive/navd/helpers.py | 6 +-- selfdrive/navd/map_renderer.py | 4 +- selfdrive/navd/navd.py | 12 +++--- selfdrive/navd/set_destination.py | 2 +- selfdrive/navd/tests/test_map_renderer.py | 2 +- selfdrive/rtshield.py | 2 +- selfdrive/sentry.py | 10 ++--- selfdrive/statsd.py | 12 +++--- selfdrive/test/ciui.py | 2 +- selfdrive/test/helpers.py | 8 ++-- .../test/longitudinal_maneuvers/maneuver.py | 2 +- .../test/longitudinal_maneuvers/plant.py | 14 +++---- .../test_longitudinal.py | 6 +-- selfdrive/test/process_replay/README.md | 10 ++--- selfdrive/test/process_replay/__init__.py | 2 +- selfdrive/test/process_replay/compare_logs.py | 2 +- selfdrive/test/process_replay/helpers.py | 2 +- selfdrive/test/process_replay/migration.py | 2 +- selfdrive/test/process_replay/model_replay.py | 28 ++++++------- .../test/process_replay/process_replay.py | 20 +++++----- selfdrive/test/process_replay/regen.py | 12 +++--- selfdrive/test/process_replay/regen_all.py | 8 ++-- selfdrive/test/process_replay/test_debayer.py | 16 ++++---- selfdrive/test/process_replay/test_fuzzy.py | 6 +-- .../test/process_replay/test_processes.py | 16 ++++---- selfdrive/test/process_replay/vision_meta.py | 4 +- selfdrive/test/profiling/profiler.py | 24 +++++------ selfdrive/test/test_onroad.py | 16 ++++---- selfdrive/test/test_time_to_onroad.py | 6 +-- selfdrive/test/test_updated.py | 4 +- selfdrive/test/test_valgrind_replay.py | 6 +-- selfdrive/test/update_ci_routes.py | 6 +-- selfdrive/thermald/fan_controller.py | 8 ++-- selfdrive/thermald/power_monitoring.py | 8 ++-- .../thermald/tests/test_fan_controller.py | 2 +- .../thermald/tests/test_power_monitoring.py | 32 +++++++-------- selfdrive/thermald/thermald.py | 26 ++++++------ selfdrive/tombstoned.py | 10 ++--- selfdrive/ui/qt/python_helpers.py | 4 +- selfdrive/ui/tests/cycle_offroad_alerts.py | 6 +-- selfdrive/ui/tests/test_soundd.py | 6 +-- selfdrive/ui/tests/test_translations.py | 2 +- selfdrive/ui/translations/create_badges.py | 6 +-- selfdrive/ui/update_translations.py | 4 +- selfdrive/updated.py | 16 ++++---- system/camerad/snapshot/snapshot.py | 10 ++--- .../test/get_thumbnails_for_segment.py | 6 +-- system/camerad/test/test_camerad.py | 4 +- system/camerad/test/test_exposure.py | 4 +- system/hardware/__init__.py | 6 +-- system/hardware/pc/hardware.py | 2 +- system/hardware/tici/agnos.py | 2 +- system/hardware/tici/hardware.py | 10 ++--- system/hardware/tici/power_draw_test.py | 6 +-- system/hardware/tici/power_monitor.py | 4 +- system/hardware/tici/precise_power_measure.py | 2 +- .../tici/tests/compare_casync_manifest.py | 2 +- system/hardware/tici/tests/test_amplifier.py | 6 +-- system/hardware/tici/tests/test_casync.py | 2 +- system/hardware/tici/tests/test_hardware.py | 4 +- system/hardware/tici/tests/test_power_draw.py | 10 ++--- system/loggerd/config.py | 2 +- system/loggerd/deleter.py | 8 ++-- system/loggerd/tests/fill.py | 4 +- system/loggerd/tests/loggerd_tests_common.py | 6 +-- system/loggerd/tests/test_deleter.py | 6 +-- system/loggerd/tests/test_encoder.py | 12 +++--- system/loggerd/tests/test_loggerd.py | 20 +++++----- system/loggerd/tests/test_uploader.py | 6 +-- system/loggerd/tools/mark_all_uploaded.py | 4 +- system/loggerd/tools/mark_unuploaded.py | 2 +- system/loggerd/uploader.py | 14 +++---- system/logmessaged.py | 4 +- system/micd.py | 6 +-- system/sensord/pigeond.py | 10 ++--- system/sensord/rawgps/rawgpsd.py | 10 ++--- system/sensord/rawgps/test_rawgps.py | 8 ++-- system/sensord/tests/test_pigeond.py | 10 ++--- system/sensord/tests/test_sensord.py | 6 +-- system/sensord/tests/ttff_test.py | 2 +- system/swaglog.py | 4 +- system/tests/test_logmessaged.py | 4 +- system/timezoned.py | 6 +-- system/ubloxd/tests/test_ublox_processing.py | 6 +-- system/ubloxd/tests/ubloxd.py | 2 +- system/version.py | 6 +-- tools/bodyteleop/web.py | 4 +- tools/cabana/dbc/generate_dbc_json.py | 2 +- tools/camerastream/receive.py | 2 +- tools/gpstest/rpc_server.py | 4 +- tools/gpstest/test_gps.py | 8 ++-- tools/gpstest/test_gps_qcom.py | 6 +-- tools/gpstest/test_laikad.py | 10 ++--- tools/joystick/joystickd.py | 8 ++-- tools/latencylogger/latency_logger.py | 2 +- tools/lib/README.md | 8 ++-- tools/lib/auth.py | 4 +- tools/lib/auth_config.py | 4 +- tools/lib/bootlog.py | 6 +-- tools/lib/cache.py | 2 +- tools/lib/filereader.py | 2 +- tools/lib/framereader.py | 8 ++-- tools/lib/logreader.py | 4 +- tools/lib/route.py | 6 +-- tools/lib/tests/test_caching.py | 2 +- tools/lib/tests/test_readers.py | 4 +- tools/lib/tests/test_route_library.py | 2 +- tools/lib/url_file.py | 2 +- tools/plotjuggler/juggle.py | 12 +++--- tools/plotjuggler/test_plotjuggler.py | 6 +-- tools/replay/can_replay.py | 8 ++-- tools/replay/lib/ui_helpers.py | 4 +- tools/replay/ui.py | 6 +-- tools/replay/unlog_ci_segment.py | 6 +-- tools/scripts/fetch_image_from_route.py | 4 +- tools/scripts/save_ubloxraw_stream.py | 6 +-- tools/scripts/setup_ssh_keys.py | 2 +- tools/sim/Dockerfile.sim | 3 +- tools/sim/bridge.py | 18 ++++----- tools/sim/lib/can.py | 4 +- tools/sim/tests/test_carla_integration.py | 8 ++-- tools/tuning/measure_steering_accuracy.py | 2 +- tools/webcam/front_mount_helper.py | 2 +- tools/webcam/warp_vis.py | 2 +- tools/zookeeper/check_consumption.py | 2 +- tools/zookeeper/disable.py | 2 +- tools/zookeeper/enable_and_wait.py | 2 +- tools/zookeeper/ignition.py | 2 +- tools/zookeeper/power_monitor.py | 6 +-- tools/zookeeper/test_zookeeper.py | 2 +- 337 files changed, 1154 insertions(+), 1143 deletions(-) diff --git a/Dockerfile.openpilot b/Dockerfile.openpilot index 51907b7a44..3541be92b0 100644 --- a/Dockerfile.openpilot +++ b/Dockerfile.openpilot @@ -10,6 +10,7 @@ WORKDIR ${OPENPILOT_PATH} COPY SConstruct ${OPENPILOT_PATH} +COPY ./openpilot ${OPENPILOT_PATH}/openpilot COPY ./third_party ${OPENPILOT_PATH}/third_party COPY ./site_scons ${OPENPILOT_PATH}/site_scons COPY ./laika ${OPENPILOT_PATH}/laika diff --git a/common/api/__init__.py b/common/api/__init__.py index c1fa635bd6..0eb8aa7627 100644 --- a/common/api/__init__.py +++ b/common/api/__init__.py @@ -2,8 +2,8 @@ import jwt import os import requests from datetime import datetime, timedelta -from common.basedir import PERSIST -from system.version import get_version +from openpilot.common.basedir import PERSIST +from openpilot.system.version import get_version API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com') diff --git a/common/basedir.py b/common/basedir.py index 371b54d3ef..b4486f9f08 100644 --- a/common/basedir.py +++ b/common/basedir.py @@ -1,7 +1,7 @@ import os from pathlib import Path -from system.hardware import PC +from openpilot.system.hardware import PC BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) diff --git a/common/kalman/simple_kalman.py b/common/kalman/simple_kalman.py index 33289e4f50..31ad76c5b2 100644 --- a/common/kalman/simple_kalman.py +++ b/common/kalman/simple_kalman.py @@ -1,3 +1,3 @@ # pylint: skip-file -from common.kalman.simple_kalman_impl import KF1D as KF1D +from openpilot.common.kalman.simple_kalman_impl import KF1D as KF1D assert KF1D diff --git a/common/kalman/tests/test_simple_kalman.py b/common/kalman/tests/test_simple_kalman.py index 96b2527655..32cc79fc3d 100644 --- a/common/kalman/tests/test_simple_kalman.py +++ b/common/kalman/tests/test_simple_kalman.py @@ -3,8 +3,8 @@ import random import timeit import numpy as np -from common.kalman.simple_kalman import KF1D -from common.kalman.simple_kalman_old import KF1D as KF1D_old +from openpilot.common.kalman.simple_kalman import KF1D +from openpilot.common.kalman.simple_kalman_old import KF1D as KF1D_old class TestSimpleKalman(unittest.TestCase): @@ -54,8 +54,8 @@ class TestSimpleKalman(unittest.TestCase): setup = """ import numpy as np -from common.kalman.simple_kalman import KF1D -from common.kalman.simple_kalman_old import KF1D as KF1D_old +from openpilot.common.kalman.simple_kalman import KF1D +from openpilot.common.kalman.simple_kalman_old import KF1D as KF1D_old dt = 0.01 x0_0 = 0.0 diff --git a/common/params.py b/common/params.py index b6be424d41..bc1422dd81 100644 --- a/common/params.py +++ b/common/params.py @@ -1,4 +1,5 @@ -from common.params_pyx import Params, ParamKeyType, UnknownKeyName, put_nonblocking, put_bool_nonblocking # pylint: disable=no-name-in-module, import-error +from openpilot.common.params_pyx import Params, ParamKeyType, UnknownKeyName, put_nonblocking, \ + put_bool_nonblocking # pylint: disable=no-name-in-module, import-error assert Params assert ParamKeyType assert UnknownKeyName diff --git a/common/realtime.py b/common/realtime.py index dd3a5fdf8f..7549a7ef52 100644 --- a/common/realtime.py +++ b/common/realtime.py @@ -7,7 +7,7 @@ from typing import Optional, List, Union from setproctitle import getproctitle -from system.hardware import PC +from openpilot.system.hardware import PC # time step for each process diff --git a/common/spinner.py b/common/spinner.py index 34fd720ee9..43d4bb2cc2 100644 --- a/common/spinner.py +++ b/common/spinner.py @@ -1,6 +1,6 @@ import os import subprocess -from common.basedir import BASEDIR +from openpilot.common.basedir import BASEDIR class Spinner(): diff --git a/common/tests/test_file_helpers.py b/common/tests/test_file_helpers.py index d39e66de13..e36df57a32 100644 --- a/common/tests/test_file_helpers.py +++ b/common/tests/test_file_helpers.py @@ -2,8 +2,8 @@ import os import unittest from uuid import uuid4 -from common.file_helpers import atomic_write_on_fs_tmp -from common.file_helpers import atomic_write_in_dir +from openpilot.common.file_helpers import atomic_write_on_fs_tmp +from openpilot.common.file_helpers import atomic_write_in_dir class TestFileHelpers(unittest.TestCase): diff --git a/common/tests/test_numpy_fast.py b/common/tests/test_numpy_fast.py index 2fb8a1cef3..de7bb972e7 100644 --- a/common/tests/test_numpy_fast.py +++ b/common/tests/test_numpy_fast.py @@ -1,7 +1,7 @@ import numpy as np import unittest -from common.numpy_fast import interp +from openpilot.common.numpy_fast import interp class InterpTest(unittest.TestCase): diff --git a/common/tests/test_params.py b/common/tests/test_params.py index d432218c8a..72fa4e3f72 100644 --- a/common/tests/test_params.py +++ b/common/tests/test_params.py @@ -6,7 +6,7 @@ import shutil import uuid import unittest -from common.params import Params, ParamKeyType, UnknownKeyName, put_nonblocking, put_bool_nonblocking +from openpilot.common.params import Params, ParamKeyType, UnknownKeyName, put_nonblocking, put_bool_nonblocking class TestParams(unittest.TestCase): def setUp(self): diff --git a/common/text_window.py b/common/text_window.py index bea3a149f8..d2762ebf7d 100755 --- a/common/text_window.py +++ b/common/text_window.py @@ -2,7 +2,7 @@ import os import time import subprocess -from common.basedir import BASEDIR +from openpilot.common.basedir import BASEDIR class TextWindow: diff --git a/common/transformations/camera.py b/common/transformations/camera.py index eaed0e7afe..c643cb5702 100644 --- a/common/transformations/camera.py +++ b/common/transformations/camera.py @@ -1,6 +1,6 @@ import numpy as np -import common.transformations.orientation as orient +import openpilot.common.transformations.orientation as orient ## -- hardcoded hardware params -- eon_f_focal_length = 910.0 diff --git a/common/transformations/coordinates.py b/common/transformations/coordinates.py index 46cc0ded0d..7e7b56522a 100644 --- a/common/transformations/coordinates.py +++ b/common/transformations/coordinates.py @@ -1,8 +1,8 @@ # pylint: skip-file -from common.transformations.orientation import numpy_wrap -from common.transformations.transformations import (ecef2geodetic_single, +from openpilot.common.transformations.orientation import numpy_wrap +from openpilot.common.transformations.transformations import (ecef2geodetic_single, geodetic2ecef_single) -from common.transformations.transformations import LocalCoord as LocalCoord_single +from openpilot.common.transformations.transformations import LocalCoord as LocalCoord_single class LocalCoord(LocalCoord_single): diff --git a/common/transformations/model.py b/common/transformations/model.py index 811a17eafe..114f8eae38 100644 --- a/common/transformations/model.py +++ b/common/transformations/model.py @@ -1,6 +1,6 @@ import numpy as np -from common.transformations.camera import (FULL_FRAME_SIZE, +from openpilot.common.transformations.camera import (FULL_FRAME_SIZE, get_view_frame_from_calib_frame) # segnet @@ -61,8 +61,8 @@ medmodel_frame_from_bigmodel_frame = np.dot(medmodel_intrinsics, np.linalg.inv(b ### This function mimics the update_calibration logic in modeld.cc ### Manually verified to give similar results to xx.uncommon.utils.transform_img def get_warp_matrix(rpy_calib, wide_cam=False, big_model=False, tici=True): - from common.transformations.orientation import rot_from_euler - from common.transformations.camera import view_frame_from_device_frame, eon_fcam_intrinsics, tici_ecam_intrinsics, tici_fcam_intrinsics + from openpilot.common.transformations.orientation import rot_from_euler + from openpilot.common.transformations.camera import view_frame_from_device_frame, eon_fcam_intrinsics, tici_ecam_intrinsics, tici_fcam_intrinsics if tici and wide_cam: intrinsics = tici_ecam_intrinsics @@ -85,8 +85,8 @@ def get_warp_matrix(rpy_calib, wide_cam=False, big_model=False, tici=True): ### This is old, just for debugging def get_warp_matrix_old(rpy_calib, wide_cam=False, big_model=False, tici=True): - from common.transformations.orientation import rot_from_euler - from common.transformations.camera import view_frame_from_device_frame, eon_fcam_intrinsics, tici_ecam_intrinsics, tici_fcam_intrinsics + from openpilot.common.transformations.orientation import rot_from_euler + from openpilot.common.transformations.camera import view_frame_from_device_frame, eon_fcam_intrinsics, tici_ecam_intrinsics, tici_fcam_intrinsics def get_view_frame_from_road_frame(roll, pitch, yaw, height): diff --git a/common/transformations/orientation.py b/common/transformations/orientation.py index 134442b624..657a86a574 100644 --- a/common/transformations/orientation.py +++ b/common/transformations/orientation.py @@ -2,7 +2,7 @@ import numpy as np from typing import Callable -from common.transformations.transformations import (ecef_euler_from_ned_single, +from openpilot.common.transformations.transformations import (ecef_euler_from_ned_single, euler2quat_single, euler2rot_single, ned_euler_from_ecef_single, diff --git a/common/transformations/tests/test_coordinates.py b/common/transformations/tests/test_coordinates.py index dc70faed0b..7ae79403bd 100755 --- a/common/transformations/tests/test_coordinates.py +++ b/common/transformations/tests/test_coordinates.py @@ -3,7 +3,7 @@ import numpy as np import unittest -import common.transformations.coordinates as coord +import openpilot.common.transformations.coordinates as coord geodetic_positions = np.array([[37.7610403, -122.4778699, 115], [27.4840915, -68.5867592, 2380], diff --git a/common/transformations/tests/test_orientation.py b/common/transformations/tests/test_orientation.py index 50978e1a63..f77827d2f9 100755 --- a/common/transformations/tests/test_orientation.py +++ b/common/transformations/tests/test_orientation.py @@ -3,7 +3,7 @@ import numpy as np import unittest -from common.transformations.orientation import euler2quat, quat2euler, euler2rot, rot2euler, \ +from openpilot.common.transformations.orientation import euler2quat, quat2euler, euler2rot, rot2euler, \ rot2quat, quat2rot, \ ned_euler_from_ecef diff --git a/common/transformations/transformations.pyx b/common/transformations/transformations.pyx index ce80d90d29..c5cb9e0056 100644 --- a/common/transformations/transformations.pyx +++ b/common/transformations/transformations.pyx @@ -1,20 +1,20 @@ # distutils: language = c++ # cython: language_level = 3 -from common.transformations.transformations cimport Matrix3, Vector3, Quaternion -from common.transformations.transformations cimport ECEF, NED, Geodetic - -from common.transformations.transformations cimport euler2quat as euler2quat_c -from common.transformations.transformations cimport quat2euler as quat2euler_c -from common.transformations.transformations cimport quat2rot as quat2rot_c -from common.transformations.transformations cimport rot2quat as rot2quat_c -from common.transformations.transformations cimport euler2rot as euler2rot_c -from common.transformations.transformations cimport rot2euler as rot2euler_c -from common.transformations.transformations cimport rot_matrix as rot_matrix_c -from common.transformations.transformations cimport ecef_euler_from_ned as ecef_euler_from_ned_c -from common.transformations.transformations cimport ned_euler_from_ecef as ned_euler_from_ecef_c -from common.transformations.transformations cimport geodetic2ecef as geodetic2ecef_c -from common.transformations.transformations cimport ecef2geodetic as ecef2geodetic_c -from common.transformations.transformations cimport LocalCoord_c +from openpilot.common.transformations.transformations cimport Matrix3, Vector3, Quaternion +from openpilot.common.transformations.transformations cimport ECEF, NED, Geodetic + +from openpilot.common.transformations.transformations cimport euler2quat as euler2quat_c +from openpilot.common.transformations.transformations cimport quat2euler as quat2euler_c +from openpilot.common.transformations.transformations cimport quat2rot as quat2rot_c +from openpilot.common.transformations.transformations cimport rot2quat as rot2quat_c +from openpilot.common.transformations.transformations cimport euler2rot as euler2rot_c +from openpilot.common.transformations.transformations cimport rot2euler as rot2euler_c +from openpilot.common.transformations.transformations cimport rot_matrix as rot_matrix_c +from openpilot.common.transformations.transformations cimport ecef_euler_from_ned as ecef_euler_from_ned_c +from openpilot.common.transformations.transformations cimport ned_euler_from_ecef as ned_euler_from_ecef_c +from openpilot.common.transformations.transformations cimport geodetic2ecef as geodetic2ecef_c +from openpilot.common.transformations.transformations cimport ecef2geodetic as ecef2geodetic_c +from openpilot.common.transformations.transformations cimport LocalCoord_c import cython diff --git a/docs/conf.py b/docs/conf.py index beb5924496..a4ed00c919 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,8 +17,8 @@ import os import sys from os.path import exists -from common.basedir import BASEDIR -from system.version import get_version +from openpilot.common.basedir import BASEDIR +from openpilot.system.version import get_version sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('..')) diff --git a/docs/docker/Dockerfile b/docs/docker/Dockerfile index 63564a6fff..209fba010f 100644 --- a/docs/docker/Dockerfile +++ b/docs/docker/Dockerfile @@ -11,6 +11,7 @@ WORKDIR ${OPENPILOT_PATH} COPY SConstruct ${OPENPILOT_PATH} +COPY ./openpilot ${OPENPILOT_PATH}/openpilot COPY ./body ${OPENPILOT_PATH}/body COPY ./third_party ${OPENPILOT_PATH}/third_party COPY ./site_scons ${OPENPILOT_PATH}/site_scons diff --git a/laika_repo b/laika_repo index ef21c612f4..65901a1e6c 160000 --- a/laika_repo +++ b/laika_repo @@ -1 +1 @@ -Subproject commit ef21c612f4b0d68c790b4b1a6d637cd5fce7732e +Subproject commit 65901a1e6c7c7940d8c97027d3edaca7d0132253 diff --git a/panda b/panda index aed103d537..57ec466a91 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit aed103d5372d1e5b3fb686d2aa8f111081b37fd0 +Subproject commit 57ec466a91d1e2d51b43d54417091a50f0c9dc78 diff --git a/release/files_common b/release/files_common index 0f43daa4a0..023fd9e3af 100644 --- a/release/files_common +++ b/release/files_common @@ -15,6 +15,9 @@ docs/INTEGRATION.md docs/LIMITATIONS.md site_scons/site_tools/cython.py +openpilot/__init__.py +openpilot/** + common/.gitignore common/__init__.py common/conversions.py diff --git a/scripts/count_cars.py b/scripts/count_cars.py index 25bad2c9b4..8c0892bb82 100755 --- a/scripts/count_cars.py +++ b/scripts/count_cars.py @@ -2,7 +2,7 @@ from collections import Counter from pprint import pprint -from selfdrive.car.docs import get_all_car_info +from openpilot.selfdrive.car.docs import get_all_car_info if __name__ == "__main__": cars = get_all_car_info() diff --git a/scripts/disable-powersave.py b/scripts/disable-powersave.py index 93688504f3..367b4108b0 100755 --- a/scripts/disable-powersave.py +++ b/scripts/disable-powersave.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from system.hardware import HARDWARE +from openpilot.system.hardware import HARDWARE if __name__ == "__main__": HARDWARE.set_power_save(False) diff --git a/scripts/pyqt_demo.py b/scripts/pyqt_demo.py index 43716fbeb2..b73d7dfad7 100755 --- a/scripts/pyqt_demo.py +++ b/scripts/pyqt_demo.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from PyQt5.QtWidgets import QApplication, QLabel # pylint: disable=no-name-in-module, import-error -from selfdrive.ui.qt.python_helpers import set_main_window +from openpilot.selfdrive.ui.qt.python_helpers import set_main_window if __name__ == "__main__": diff --git a/scripts/waste.py b/scripts/waste.py index e72b367063..0764ff77c3 100755 --- a/scripts/waste.py +++ b/scripts/waste.py @@ -3,10 +3,10 @@ import os import time import numpy as np from multiprocessing import Process -from setproctitle import setproctitle # pylint: disable=no-name-in-module +from setproctitle import setproctitle def waste(core): - os.sched_setaffinity(0, [core,]) # pylint: disable=no-member + os.sched_setaffinity(0, [core,]) m1 = np.zeros((200, 200)) + 0.8 m2 = np.zeros((200, 200)) + 1.2 diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index b3a13d2279..15088f69b1 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -30,17 +30,17 @@ from websocket import (ABNF, WebSocket, WebSocketException, WebSocketTimeoutExce import cereal.messaging as messaging from cereal import log from cereal.services import service_list -from common.api import Api -from common.basedir import PERSIST -from common.file_helpers import CallbackReader -from common.params import Params -from common.realtime import set_core_affinity -from system.hardware import HARDWARE, PC, AGNOS -from system.loggerd.config import ROOT -from system.loggerd.xattr_cache import getxattr, setxattr -from selfdrive.statsd import STATS_DIR -from system.swaglog import SWAGLOG_DIR, cloudlog -from system.version import get_commit, get_origin, get_short_branch, get_version +from openpilot.common.api import Api +from openpilot.common.basedir import PERSIST +from openpilot.common.file_helpers import CallbackReader +from openpilot.common.params import Params +from openpilot.common.realtime import set_core_affinity +from openpilot.system.hardware import HARDWARE, PC, AGNOS +from openpilot.system.loggerd.config import ROOT +from openpilot.system.loggerd.xattr_cache import getxattr, setxattr +from openpilot.selfdrive.statsd import STATS_DIR +from openpilot.system.swaglog import SWAGLOG_DIR, cloudlog +from openpilot.system.version import get_commit, get_origin, get_short_branch, get_version # TODO: use socket constant when mypy recognizes this as a valid attribute @@ -552,7 +552,7 @@ def getNetworks(): @dispatcher.add_method def takeSnapshot() -> Optional[Union[str, Dict[str, str]]]: - from system.camerad.snapshot.snapshot import jpeg_write, snapshot + from openpilot.system.camerad.snapshot.snapshot import jpeg_write, snapshot ret = snapshot() if ret is not None: def b64jpeg(x): diff --git a/selfdrive/athena/manage_athenad.py b/selfdrive/athena/manage_athenad.py index 59ca2430ce..877d8aca03 100755 --- a/selfdrive/athena/manage_athenad.py +++ b/selfdrive/athena/manage_athenad.py @@ -3,10 +3,10 @@ import time from multiprocessing import Process -from common.params import Params -from selfdrive.manager.process import launcher -from system.swaglog import cloudlog -from system.version import get_version, is_dirty +from openpilot.common.params import Params +from openpilot.selfdrive.manager.process import launcher +from openpilot.system.swaglog import cloudlog +from openpilot.system.version import get_version, is_dirty ATHENA_MGR_PID_PARAM = "AthenadPid" diff --git a/selfdrive/athena/registration.py b/selfdrive/athena/registration.py index 32bc92059c..0ab69371c2 100755 --- a/selfdrive/athena/registration.py +++ b/selfdrive/athena/registration.py @@ -6,13 +6,13 @@ from pathlib import Path from typing import Optional from datetime import datetime, timedelta -from common.api import api_get -from common.params import Params -from common.spinner import Spinner -from common.basedir import PERSIST -from selfdrive.controls.lib.alertmanager import set_offroad_alert -from system.hardware import HARDWARE, PC -from system.swaglog import cloudlog +from openpilot.common.api import api_get +from openpilot.common.params import Params +from openpilot.common.spinner import Spinner +from openpilot.common.basedir import PERSIST +from openpilot.selfdrive.controls.lib.alertmanager import set_offroad_alert +from openpilot.system.hardware import HARDWARE, PC +from openpilot.system.swaglog import cloudlog UNREGISTERED_DONGLE_ID = "UnregisteredDevice" diff --git a/selfdrive/athena/tests/helpers.py b/selfdrive/athena/tests/helpers.py index 5087012bcd..34edeb2de5 100644 --- a/selfdrive/athena/tests/helpers.py +++ b/selfdrive/athena/tests/helpers.py @@ -6,7 +6,7 @@ import time from functools import wraps from multiprocessing import Process -from common.timeout import Timeout +from openpilot.common.timeout import Timeout class MockResponse: diff --git a/selfdrive/athena/tests/test_athenad.py b/selfdrive/athena/tests/test_athenad.py index 7ce6932f2a..f32df74217 100755 --- a/selfdrive/athena/tests/test_athenad.py +++ b/selfdrive/athena/tests/test_athenad.py @@ -18,10 +18,10 @@ from unittest import mock from websocket import ABNF from websocket._exceptions import WebSocketConnectionClosedException -from system import swaglog -from selfdrive.athena import athenad -from selfdrive.athena.athenad import MAX_RETRY_COUNT, dispatcher -from selfdrive.athena.tests.helpers import MockWebsocket, MockParams, MockApi, EchoSocket, with_http_server +from openpilot.system import swaglog +from openpilot.selfdrive.athena import athenad +from openpilot.selfdrive.athena.athenad import MAX_RETRY_COUNT, dispatcher +from openpilot.selfdrive.athena.tests.helpers import MockWebsocket, MockParams, MockApi, EchoSocket, with_http_server from cereal import messaging @@ -351,7 +351,7 @@ class TestAthenadMethods(unittest.TestCase): self.assertEqual(athenad.upload_queue.qsize(), 1) self.assertDictEqual(asdict(athenad.upload_queue.queue[-1]), asdict(item1)) - @mock.patch('selfdrive.athena.athenad.create_connection') + @mock.patch('openpilot.selfdrive.athena.athenad.create_connection') def test_startLocalProxy(self, mock_create_connection): end_event = threading.Event() diff --git a/selfdrive/athena/tests/test_athenad_ping.py b/selfdrive/athena/tests/test_athenad_ping.py index e1fa00a76f..3ec7cb115c 100755 --- a/selfdrive/athena/tests/test_athenad_ping.py +++ b/selfdrive/athena/tests/test_athenad_ping.py @@ -6,11 +6,11 @@ import unittest from typing import Callable, cast, Optional from unittest.mock import MagicMock -from common.params import Params -from common.timeout import Timeout -from selfdrive.athena import athenad -from selfdrive.manager.helpers import write_onroad_params -from system.hardware import TICI +from openpilot.common.params import Params +from openpilot.common.timeout import Timeout +from openpilot.selfdrive.athena import athenad +from openpilot.selfdrive.manager.helpers import write_onroad_params +from openpilot.system.hardware import TICI def wifi_radio(on: bool) -> None: diff --git a/selfdrive/athena/tests/test_registration.py b/selfdrive/athena/tests/test_registration.py index 7a38477305..195fca2df9 100755 --- a/selfdrive/athena/tests/test_registration.py +++ b/selfdrive/athena/tests/test_registration.py @@ -7,9 +7,9 @@ from Crypto.PublicKey import RSA from pathlib import Path from unittest import mock -from common.params import Params -from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID -from selfdrive.athena.tests.helpers import MockResponse +from openpilot.common.params import Params +from openpilot.selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID +from openpilot.selfdrive.athena.tests.helpers import MockResponse class TestRegistration(unittest.TestCase): @@ -23,7 +23,7 @@ class TestRegistration(unittest.TestCase): os.mkdir(os.path.join(self.persist.name, "comma")) self.priv_key = Path(os.path.join(self.persist.name, "comma/id_rsa")) self.pub_key = Path(os.path.join(self.persist.name, "comma/id_rsa.pub")) - self.persist_patcher = mock.patch("selfdrive.athena.registration.PERSIST", self.persist.name) + self.persist_patcher = mock.patch("openpilot.selfdrive.athena.registration.PERSIST", self.persist.name) self.persist_patcher.start() def tearDown(self): @@ -44,7 +44,7 @@ class TestRegistration(unittest.TestCase): self.params.put("HardwareSerial", "serial") self._generate_keys() - with mock.patch("selfdrive.athena.registration.api_get", autospec=True) as m: + with mock.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) as m: dongle = "DONGLE_ID_123" self.params.put("DongleId", dongle) self.assertEqual(register(), dongle) @@ -52,7 +52,7 @@ class TestRegistration(unittest.TestCase): def test_no_keys(self): # missing pubkey - with mock.patch("selfdrive.athena.registration.api_get", autospec=True) as m: + with mock.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) as m: dongle = register() self.assertEqual(m.call_count, 0) self.assertEqual(dongle, UNREGISTERED_DONGLE_ID) @@ -61,7 +61,7 @@ class TestRegistration(unittest.TestCase): def test_missing_cache(self): # keys exist but no dongle id self._generate_keys() - with mock.patch("selfdrive.athena.registration.api_get", autospec=True) as m: + with mock.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) as m: dongle = "DONGLE_ID_123" m.return_value = MockResponse(json.dumps({'dongle_id': dongle}), 200) self.assertEqual(register(), dongle) @@ -75,7 +75,7 @@ class TestRegistration(unittest.TestCase): def test_unregistered(self): # keys exist, but unregistered self._generate_keys() - with mock.patch("selfdrive.athena.registration.api_get", autospec=True) as m: + with mock.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) as m: m.return_value = MockResponse(None, 402) dongle = register() self.assertEqual(m.call_count, 1) diff --git a/selfdrive/boardd/boardd.py b/selfdrive/boardd/boardd.py index 527f1f4f52..702c46565f 100644 --- a/selfdrive/boardd/boardd.py +++ b/selfdrive/boardd/boardd.py @@ -1,7 +1,7 @@ # pylint: skip-file # Cython, now uses scons to build -from selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp +from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp assert can_list_to_can_capnp def can_capnp_to_can_list(can, src_filter=None): diff --git a/selfdrive/boardd/pandad.py b/selfdrive/boardd/pandad.py index be2ed3c4cc..ce9137a30b 100755 --- a/selfdrive/boardd/pandad.py +++ b/selfdrive/boardd/pandad.py @@ -9,11 +9,11 @@ from typing import List, NoReturn from functools import cmp_to_key from panda import Panda, PandaDFU, PandaProtocolMismatch, FW_PATH -from common.basedir import BASEDIR -from common.params import Params -from selfdrive.boardd.set_time import set_time -from system.hardware import HARDWARE -from system.swaglog import cloudlog +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params +from openpilot.selfdrive.boardd.set_time import set_time +from openpilot.system.hardware import HARDWARE +from openpilot.system.swaglog import cloudlog def get_expected_signature(panda: Panda) -> bytes: diff --git a/selfdrive/boardd/set_time.py b/selfdrive/boardd/set_time.py index 93453dcd97..fe17f64e82 100755 --- a/selfdrive/boardd/set_time.py +++ b/selfdrive/boardd/set_time.py @@ -3,7 +3,7 @@ import os import datetime from panda import Panda -from common.time import MIN_DATE +from openpilot.common.time import MIN_DATE def set_time(logger): sys_time = datetime.datetime.today() diff --git a/selfdrive/boardd/tests/test_boardd_loopback.py b/selfdrive/boardd/tests/test_boardd_loopback.py index 74393c6eb1..dfce0e3710 100755 --- a/selfdrive/boardd/tests/test_boardd_loopback.py +++ b/selfdrive/boardd/tests/test_boardd_loopback.py @@ -9,12 +9,12 @@ from pprint import pprint import cereal.messaging as messaging from cereal import car, log -from common.params import Params -from common.timeout import Timeout -from selfdrive.boardd.boardd import can_list_to_can_capnp -from selfdrive.car import make_can_msg -from system.hardware import TICI -from selfdrive.test.helpers import phone_only, with_processes +from openpilot.common.params import Params +from openpilot.common.timeout import Timeout +from openpilot.selfdrive.boardd.boardd import can_list_to_can_capnp +from openpilot.selfdrive.car import make_can_msg +from openpilot.system.hardware import TICI +from openpilot.selfdrive.test.helpers import phone_only, with_processes class TestBoardd(unittest.TestCase): diff --git a/selfdrive/boardd/tests/test_pandad.py b/selfdrive/boardd/tests/test_pandad.py index 1d49446bf5..970af385d8 100755 --- a/selfdrive/boardd/tests/test_pandad.py +++ b/selfdrive/boardd/tests/test_pandad.py @@ -5,13 +5,13 @@ import unittest import cereal.messaging as messaging from cereal import log -from common.gpio import gpio_set, gpio_init -from common.params import Params +from openpilot.common.gpio import gpio_set, gpio_init +from openpilot.common.params import Params from panda import Panda, PandaDFU, PandaProtocolMismatch -from selfdrive.test.helpers import phone_only -from selfdrive.manager.process_config import managed_processes -from system.hardware import HARDWARE -from system.hardware.tici.pins import GPIO +from openpilot.selfdrive.test.helpers import phone_only +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.hardware import HARDWARE +from openpilot.system.hardware.tici.pins import GPIO HERE = os.path.dirname(os.path.realpath(__file__)) diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py index 156161c796..c5f4a41520 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -5,7 +5,7 @@ from typing import Dict, Optional import capnp from cereal import car -from common.numpy_fast import clip, interp +from openpilot.common.numpy_fast import clip, interp # kg of standard extra cargo to count for drive, gas, etc... diff --git a/selfdrive/car/body/carcontroller.py b/selfdrive/car/body/carcontroller.py index 4993b1865f..1dad8e796a 100644 --- a/selfdrive/car/body/carcontroller.py +++ b/selfdrive/car/body/carcontroller.py @@ -1,11 +1,11 @@ import numpy as np -from common.params import Params -from common.realtime import DT_CTRL +from openpilot.common.params import Params +from openpilot.common.realtime import DT_CTRL from opendbc.can.packer import CANPacker -from selfdrive.car.body import bodycan -from selfdrive.car.body.values import SPEED_FROM_RPM -from selfdrive.controls.lib.pid import PIDController +from openpilot.selfdrive.car.body import bodycan +from openpilot.selfdrive.car.body.values import SPEED_FROM_RPM +from openpilot.selfdrive.controls.lib.pid import PIDController MAX_TORQUE = 500 diff --git a/selfdrive/car/body/carstate.py b/selfdrive/car/body/carstate.py index a1ef17360f..fca9bcc627 100644 --- a/selfdrive/car/body/carstate.py +++ b/selfdrive/car/body/carstate.py @@ -1,7 +1,7 @@ from cereal import car from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import CarStateBase -from selfdrive.car.body.values import DBC +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.body.values import DBC STARTUP_TICKS = 100 diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index 4d583badae..bf33eea38f 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 import math from cereal import car -from common.realtime import DT_CTRL -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase -from selfdrive.car.body.values import SPEED_FROM_RPM +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.body.values import SPEED_FROM_RPM class CarInterface(CarInterfaceBase): @staticmethod diff --git a/selfdrive/car/body/radar_interface.py b/selfdrive/car/body/radar_interface.py index b2f7651136..b461fcd5f8 100644 --- a/selfdrive/car/body/radar_interface.py +++ b/selfdrive/car/body/radar_interface.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass diff --git a/selfdrive/car/body/values.py b/selfdrive/car/body/values.py index 4fef966374..56d9723818 100644 --- a/selfdrive/car/body/values.py +++ b/selfdrive/car/body/values.py @@ -1,9 +1,9 @@ from typing import Dict from cereal import car -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarInfo -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarInfo +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 652862de47..81a8c7eacd 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -2,16 +2,16 @@ import os from typing import Callable, Dict, List, Optional, Tuple from cereal import car -from common.params import Params -from common.basedir import BASEDIR -from system.version import is_comma_remote, is_tested_branch -from selfdrive.car.interfaces import get_interface_attr -from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars -from selfdrive.car.vin import get_vin, is_valid_vin, VIN_UNKNOWN -from selfdrive.car.fw_versions import get_fw_versions_ordered, get_present_ecus, match_fw_to_car, set_obd_multiplexing -from system.swaglog import cloudlog +from openpilot.common.params import Params +from openpilot.common.basedir import BASEDIR +from openpilot.system.version import is_comma_remote, is_tested_branch +from openpilot.selfdrive.car.interfaces import get_interface_attr +from openpilot.selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars +from openpilot.selfdrive.car.vin import get_vin, is_valid_vin, VIN_UNKNOWN +from openpilot.selfdrive.car.fw_versions import get_fw_versions_ordered, get_present_ecus, match_fw_to_car, set_obd_multiplexing +from openpilot.system.swaglog import cloudlog import cereal.messaging as messaging -from selfdrive.car import gen_empty_fingerprint +from openpilot.selfdrive.car import gen_empty_fingerprint FRAME_FINGERPRINT = 100 # 1s @@ -44,7 +44,7 @@ def get_one_can(logcan): def load_interfaces(brand_names): ret = {} for brand_name in brand_names: - path = f'selfdrive.car.{brand_name}' + path = f'openpilot.selfdrive.car.{brand_name}' CarInterface = __import__(path + '.interface', fromlist=['CarInterface']).CarInterface if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carstate.py'): diff --git a/selfdrive/car/chrysler/carcontroller.py b/selfdrive/car/chrysler/carcontroller.py index b418179e0e..a568f927b8 100644 --- a/selfdrive/car/chrysler/carcontroller.py +++ b/selfdrive/car/chrysler/carcontroller.py @@ -1,8 +1,8 @@ from opendbc.can.packer import CANPacker -from common.realtime import DT_CTRL -from selfdrive.car import apply_meas_steer_torque_limits -from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, create_cruise_buttons -from selfdrive.car.chrysler.values import RAM_CARS, CarControllerParams, ChryslerFlags +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car import apply_meas_steer_torque_limits +from openpilot.selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, create_cruise_buttons +from openpilot.selfdrive.car.chrysler.values import RAM_CARS, CarControllerParams, ChryslerFlags class CarController: diff --git a/selfdrive/car/chrysler/carstate.py b/selfdrive/car/chrysler/carstate.py index 7b250ddf9b..eb1cf7e7d5 100644 --- a/selfdrive/car/chrysler/carstate.py +++ b/selfdrive/car/chrysler/carstate.py @@ -1,9 +1,9 @@ from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine -from selfdrive.car.interfaces import CarStateBase -from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD, RAM_CARS +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD, RAM_CARS class CarState(CarStateBase): diff --git a/selfdrive/car/chrysler/chryslercan.py b/selfdrive/car/chrysler/chryslercan.py index 10ed73e9f2..96439f35d8 100644 --- a/selfdrive/car/chrysler/chryslercan.py +++ b/selfdrive/car/chrysler/chryslercan.py @@ -1,5 +1,5 @@ from cereal import car -from selfdrive.car.chrysler.values import RAM_CARS +from openpilot.selfdrive.car.chrysler.values import RAM_CARS GearShifter = car.CarState.GearShifter VisualAlert = car.CarControl.HUDControl.VisualAlert diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index a3c0b0c7a1..a87759910b 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from selfdrive.car import get_safety_config -from selfdrive.car.chrysler.values import CAR, RAM_HD, RAM_DT, RAM_CARS, ChryslerFlags -from selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.chrysler.values import CAR, RAM_HD, RAM_DT, RAM_CARS, ChryslerFlags +from openpilot.selfdrive.car.interfaces import CarInterfaceBase class CarInterface(CarInterfaceBase): diff --git a/selfdrive/car/chrysler/radar_interface.py b/selfdrive/car/chrysler/radar_interface.py index 1d0661778a..d982958422 100755 --- a/selfdrive/car/chrysler/radar_interface.py +++ b/selfdrive/car/chrysler/radar_interface.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from opendbc.can.parser import CANParser from cereal import car -from selfdrive.car.interfaces import RadarInterfaceBase -from selfdrive.car.chrysler.values import DBC +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.chrysler.values import DBC RADAR_MSGS_C = list(range(0x2c2, 0x2d4+2, 2)) # c_ messages 706,...,724 RADAR_MSGS_D = list(range(0x2a2, 0x2b4+2, 2)) # d_ messages diff --git a/selfdrive/car/chrysler/values.py b/selfdrive/car/chrysler/values.py index 172d3a08cc..657ada2706 100644 --- a/selfdrive/car/chrysler/values.py +++ b/selfdrive/car/chrysler/values.py @@ -5,9 +5,9 @@ from typing import Dict, List, Optional, Union from cereal import car from panda.python import uds -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarHarness, CarInfo, CarParts -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16 +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarHarness, CarInfo, CarParts +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16 Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/disable_ecu.py b/selfdrive/car/disable_ecu.py index 36ebe12fa8..1a1252327f 100755 --- a/selfdrive/car/disable_ecu.py +++ b/selfdrive/car/disable_ecu.py @@ -1,5 +1,5 @@ -from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery -from system.swaglog import cloudlog +from openpilot.selfdrive.car.isotp_parallel_query import IsoTpParallelQuery +from openpilot.system.swaglog import cloudlog EXT_DIAG_REQUEST = b'\x10\x03' EXT_DIAG_RESPONSE = b'\x50\x03' diff --git a/selfdrive/car/docs.py b/selfdrive/car/docs.py index 02075a5e11..8475a69d8a 100755 --- a/selfdrive/car/docs.py +++ b/selfdrive/car/docs.py @@ -8,10 +8,10 @@ from natsort import natsorted from typing import Dict, List from cereal import car -from common.basedir import BASEDIR -from selfdrive.car import gen_empty_fingerprint -from selfdrive.car.docs_definitions import CarInfo, Column, CommonFootnote, PartType -from selfdrive.car.car_helpers import interfaces, get_interface_attr +from openpilot.common.basedir import BASEDIR +from openpilot.selfdrive.car import gen_empty_fingerprint +from openpilot.selfdrive.car.docs_definitions import CarInfo, Column, CommonFootnote, PartType +from openpilot.selfdrive.car.car_helpers import interfaces, get_interface_attr def get_all_footnotes() -> Dict[Enum, int]: diff --git a/selfdrive/car/docs_definitions.py b/selfdrive/car/docs_definitions.py index 2220205e8f..3319ba31c8 100644 --- a/selfdrive/car/docs_definitions.py +++ b/selfdrive/car/docs_definitions.py @@ -6,7 +6,7 @@ from enum import Enum from typing import Dict, List, Optional, Tuple, Union from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV GOOD_TORQUE_THRESHOLD = 1.0 # m/s^2 MODEL_YEARS_RE = r"(?<= )((\d{4}-\d{2})|(\d{4}))(,|$)" diff --git a/selfdrive/car/ecu_addrs.py b/selfdrive/car/ecu_addrs.py index 25938f0d3c..cff1df79a5 100755 --- a/selfdrive/car/ecu_addrs.py +++ b/selfdrive/car/ecu_addrs.py @@ -5,10 +5,10 @@ from typing import Optional, Set import cereal.messaging as messaging from panda.python.uds import SERVICE_TYPE -from selfdrive.car import make_can_msg -from selfdrive.car.fw_query_definitions import EcuAddrBusType -from selfdrive.boardd.boardd import can_list_to_can_capnp -from system.swaglog import cloudlog +from openpilot.selfdrive.car import make_can_msg +from openpilot.selfdrive.car.fw_query_definitions import EcuAddrBusType +from openpilot.selfdrive.boardd.boardd import can_list_to_can_capnp +from openpilot.system.swaglog import cloudlog def make_tester_present_msg(addr, bus, subaddr=None): diff --git a/selfdrive/car/fingerprints.py b/selfdrive/car/fingerprints.py index 09ed30cc19..1d627e4b37 100644 --- a/selfdrive/car/fingerprints.py +++ b/selfdrive/car/fingerprints.py @@ -1,4 +1,4 @@ -from selfdrive.car.interfaces import get_interface_attr +from openpilot.selfdrive.car.interfaces import get_interface_attr FW_VERSIONS = get_interface_attr('FW_VERSIONS', combine_brands=True, ignore_none=True) diff --git a/selfdrive/car/ford/carcontroller.py b/selfdrive/car/ford/carcontroller.py index dd30bc57e1..86008c6352 100644 --- a/selfdrive/car/ford/carcontroller.py +++ b/selfdrive/car/ford/carcontroller.py @@ -1,10 +1,10 @@ from cereal import car -from common.numpy_fast import clip +from openpilot.common.numpy_fast import clip from opendbc.can.packer import CANPacker -from selfdrive.car import apply_std_steer_angle_limits -from selfdrive.car.ford.fordcan import CanBus, create_acc_msg, create_acc_ui_msg, create_button_msg, \ +from openpilot.selfdrive.car import apply_std_steer_angle_limits +from openpilot.selfdrive.car.ford.fordcan import CanBus, create_acc_msg, create_acc_ui_msg, create_button_msg, \ create_lat_ctl_msg, create_lat_ctl2_msg, create_lka_msg, create_lkas_ui_msg -from selfdrive.car.ford.values import CANFD_CAR, CarControllerParams +from openpilot.selfdrive.car.ford.values import CANFD_CAR, CarControllerParams LongCtrlState = car.CarControl.Actuators.LongControlState VisualAlert = car.CarControl.HUDControl.VisualAlert diff --git a/selfdrive/car/ford/carstate.py b/selfdrive/car/ford/carstate.py index 824d929930..5c787b787a 100644 --- a/selfdrive/car/ford/carstate.py +++ b/selfdrive/car/ford/carstate.py @@ -1,10 +1,10 @@ from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import CarStateBase -from selfdrive.car.ford.fordcan import CanBus -from selfdrive.car.ford.values import CANFD_CAR, CarControllerParams, DBC +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.ford.fordcan import CanBus +from openpilot.selfdrive.car.ford.values import CANFD_CAR, CarControllerParams, DBC GearShifter = car.CarState.GearShifter TransmissionType = car.CarParams.TransmissionType diff --git a/selfdrive/car/ford/fordcan.py b/selfdrive/car/ford/fordcan.py index a49d7ad85d..e0086ecbb5 100644 --- a/selfdrive/car/ford/fordcan.py +++ b/selfdrive/car/ford/fordcan.py @@ -1,5 +1,5 @@ from cereal import car -from selfdrive.car import CanBusBase +from openpilot.selfdrive.car import CanBusBase HUDControl = car.CarControl.HUDControl diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 990d14de93..755d7d1d00 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from common.conversions import Conversions as CV -from selfdrive.car import get_safety_config -from selfdrive.car.ford.fordcan import CanBus -from selfdrive.car.ford.values import CANFD_CAR, CAR, Ecu -from selfdrive.car.interfaces import CarInterfaceBase +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.ford.fordcan import CanBus +from openpilot.selfdrive.car.ford.values import CANFD_CAR, CAR, Ecu +from openpilot.selfdrive.car.interfaces import CarInterfaceBase TransmissionType = car.CarParams.TransmissionType GearShifter = car.CarState.GearShifter diff --git a/selfdrive/car/ford/radar_interface.py b/selfdrive/car/ford/radar_interface.py index 78dd594627..a166fc20dd 100644 --- a/selfdrive/car/ford/radar_interface.py +++ b/selfdrive/car/ford/radar_interface.py @@ -2,10 +2,10 @@ from math import cos, sin from cereal import car from opendbc.can.parser import CANParser -from common.conversions import Conversions as CV -from selfdrive.car.ford.fordcan import CanBus -from selfdrive.car.ford.values import DBC, RADAR -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.ford.fordcan import CanBus +from openpilot.selfdrive.car.ford.values import DBC, RADAR +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase DELPHI_ESR_RADAR_MSGS = list(range(0x500, 0x540)) diff --git a/selfdrive/car/ford/values.py b/selfdrive/car/ford/values.py index 01d1ae7b8a..5d99db945e 100644 --- a/selfdrive/car/ford/values.py +++ b/selfdrive/car/ford/values.py @@ -4,10 +4,10 @@ from enum import Enum from typing import Dict, List, Union from cereal import car -from selfdrive.car import AngleRateLimit, dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column, \ +from openpilot.selfdrive.car import AngleRateLimit, dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column, \ Device -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 7fa47da998..45c4967cb8 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -6,13 +6,13 @@ import capnp import panda.python.uds as uds from cereal import car -from common.params import Params -from selfdrive.car.ecu_addrs import get_ecu_addrs -from selfdrive.car.fw_query_definitions import AddrType, EcuAddrBusType -from selfdrive.car.interfaces import get_interface_attr -from selfdrive.car.fingerprints import FW_VERSIONS -from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery -from system.swaglog import cloudlog +from openpilot.common.params import Params +from openpilot.selfdrive.car.ecu_addrs import get_ecu_addrs +from openpilot.selfdrive.car.fw_query_definitions import AddrType, EcuAddrBusType +from openpilot.selfdrive.car.interfaces import get_interface_attr +from openpilot.selfdrive.car.fingerprints import FW_VERSIONS +from openpilot.selfdrive.car.isotp_parallel_query import IsoTpParallelQuery +from openpilot.system.swaglog import cloudlog Ecu = car.CarParams.Ecu ESSENTIAL_ECUS = [Ecu.engine, Ecu.eps, Ecu.abs, Ecu.fwdRadar, Ecu.fwdCamera, Ecu.vsa] @@ -338,7 +338,7 @@ if __name__ == "__main__": import time import argparse import cereal.messaging as messaging - from selfdrive.car.vin import get_vin + from openpilot.selfdrive.car.vin import get_vin parser = argparse.ArgumentParser(description='Get firmware version of ECUs') parser.add_argument('--scan', action='store_true') diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index 1b2424afaf..f51cb75372 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -1,11 +1,11 @@ from cereal import car -from common.conversions import Conversions as CV -from common.numpy_fast import interp -from common.realtime import DT_CTRL +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import interp +from openpilot.common.realtime import DT_CTRL from opendbc.can.packer import CANPacker -from selfdrive.car import apply_driver_steer_torque_limits -from selfdrive.car.gm import gmcan -from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams, CruiseButtons +from openpilot.selfdrive.car import apply_driver_steer_torque_limits +from openpilot.selfdrive.car.gm import gmcan +from openpilot.selfdrive.car.gm.values import DBC, CanBus, CarControllerParams, CruiseButtons VisualAlert = car.CarControl.HUDControl.VisualAlert NetworkLocation = car.CarParams.NetworkLocation diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index 43cdee18d4..8585e9f205 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -1,11 +1,11 @@ import copy from cereal import car -from common.conversions import Conversions as CV -from common.numpy_fast import mean +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import mean from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import CarStateBase -from selfdrive.car.gm.values import DBC, AccState, CanBus, STEER_THRESHOLD +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.gm.values import DBC, AccState, CanBus, STEER_THRESHOLD TransmissionType = car.CarParams.TransmissionType NetworkLocation = car.CarParams.NetworkLocation diff --git a/selfdrive/car/gm/gmcan.py b/selfdrive/car/gm/gmcan.py index 0de2066678..bd1e29ce3b 100644 --- a/selfdrive/car/gm/gmcan.py +++ b/selfdrive/car/gm/gmcan.py @@ -1,5 +1,5 @@ -from selfdrive.car import make_can_msg -from selfdrive.car.gm.values import CAR +from openpilot.selfdrive.car import make_can_msg +from openpilot.selfdrive.car.gm.values import CAR def create_buttons(packer, bus, idx, button): diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 8e139947a6..511da405d8 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -3,12 +3,12 @@ from cereal import car from math import fabs, exp from panda import Panda -from common.conversions import Conversions as CV -from selfdrive.car import create_button_event, get_safety_config -from selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG -from selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus -from selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD -from selfdrive.controls.lib.drive_helpers import get_friction +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car import create_button_event, get_safety_config +from openpilot.selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG +from openpilot.selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus +from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD +from openpilot.selfdrive.controls.lib.drive_helpers import get_friction ButtonType = car.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName diff --git a/selfdrive/car/gm/radar_interface.py b/selfdrive/car/gm/radar_interface.py index 99fb89ceb3..b893babd31 100755 --- a/selfdrive/car/gm/radar_interface.py +++ b/selfdrive/car/gm/radar_interface.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 import math from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from opendbc.can.parser import CANParser -from selfdrive.car.gm.values import DBC, CanBus -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.gm.values import DBC, CanBus +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase RADAR_HEADER_MSG = 1120 SLOT_1_MSG = RADAR_HEADER_MSG + 1 diff --git a/selfdrive/car/gm/tests/test_gm.py b/selfdrive/car/gm/tests/test_gm.py index 1fc8a25611..fce5fea720 100755 --- a/selfdrive/car/gm/tests/test_gm.py +++ b/selfdrive/car/gm/tests/test_gm.py @@ -2,7 +2,7 @@ from parameterized import parameterized import unittest -from selfdrive.car.gm.values import CAMERA_ACC_CAR, CAR, FINGERPRINTS, GM_RX_OFFSET +from openpilot.selfdrive.car.gm.values import CAMERA_ACC_CAR, CAR, FINGERPRINTS, GM_RX_OFFSET CAMERA_DIAGNOSTIC_ADDRESS = 0x24b diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index cfe518650a..d12c21dc23 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -5,8 +5,8 @@ from enum import Enum from typing import Dict, List, Union from cereal import car -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index 347c16c86f..056b47c4b3 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -1,13 +1,13 @@ from collections import namedtuple from cereal import car -from common.numpy_fast import clip, interp -from common.realtime import DT_CTRL +from openpilot.common.numpy_fast import clip, interp +from openpilot.common.realtime import DT_CTRL from opendbc.can.packer import CANPacker -from selfdrive.car import create_gas_interceptor_command -from selfdrive.car.honda import hondacan -from selfdrive.car.honda.values import CruiseButtons, VISUAL_HUD, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams -from selfdrive.controls.lib.drive_helpers import rate_limit +from openpilot.selfdrive.car import create_gas_interceptor_command +from openpilot.selfdrive.car.honda import hondacan +from openpilot.selfdrive.car.honda.values import CruiseButtons, VISUAL_HUD, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams +from openpilot.selfdrive.controls.lib.drive_helpers import rate_limit VisualAlert = car.CarControl.HUDControl.VisualAlert LongCtrlState = car.CarControl.Actuators.LongControlState diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index d6d2b18a0a..03aedb31d2 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -1,13 +1,15 @@ from collections import defaultdict from cereal import car -from common.conversions import Conversions as CV -from common.numpy_fast import interp +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import interp from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser -from selfdrive.car.honda.hondacan import get_cruise_speed_conversion, get_pt_bus -from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_ALT_BRAKE_SIGNAL, HONDA_BOSCH_RADARLESS -from selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.honda.hondacan import get_cruise_speed_conversion, get_pt_bus +from openpilot.selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, HONDA_BOSCH, \ + HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_ALT_BRAKE_SIGNAL, \ + HONDA_BOSCH_RADARLESS +from openpilot.selfdrive.car.interfaces import CarStateBase TransmissionType = car.CarParams.TransmissionType diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index 1fe0a13767..a8cbad78ce 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -1,5 +1,5 @@ -from common.conversions import Conversions as CV -from selfdrive.car.honda.values import HondaFlags, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, CAR, CarControllerParams +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.honda.values import HondaFlags, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, CAR, CarControllerParams # CAN bus layout with relay # 0 = ACC-CAN - radar side diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 1025eb6212..3b87009a24 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from common.conversions import Conversions as CV -from common.numpy_fast import interp -from selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, \ +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import interp +from openpilot.selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, \ HONDA_BOSCH_ALT_BRAKE_SIGNAL, HONDA_BOSCH_RADARLESS -from selfdrive.car import create_button_event, get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase -from selfdrive.car.disable_ecu import disable_ecu +from openpilot.selfdrive.car import create_button_event, get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.disable_ecu import disable_ecu ButtonType = car.CarState.ButtonEvent.Type diff --git a/selfdrive/car/honda/radar_interface.py b/selfdrive/car/honda/radar_interface.py index 58f665233b..8090f8e03e 100755 --- a/selfdrive/car/honda/radar_interface.py +++ b/selfdrive/car/honda/radar_interface.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from cereal import car from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import RadarInterfaceBase -from selfdrive.car.honda.values import DBC +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.honda.values import DBC def _create_nidec_can_parser(car_fingerprint): diff --git a/selfdrive/car/honda/tests/test_honda.py b/selfdrive/car/honda/tests/test_honda.py index 7a8c86fb0a..da64b8f70b 100755 --- a/selfdrive/car/honda/tests/test_honda.py +++ b/selfdrive/car/honda/tests/test_honda.py @@ -2,7 +2,7 @@ import re import unittest -from selfdrive.car.honda.values import FW_VERSIONS +from openpilot.selfdrive.car.honda.values import FW_VERSIONS HONDA_FW_VERSION_RE = br"\d{5}-[A-Z0-9]{3}(-|,)[A-Z0-9]{4}(\x00){2}$" diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py index b149fd2a02..403745bd42 100644 --- a/selfdrive/car/honda/values.py +++ b/selfdrive/car/honda/values.py @@ -3,11 +3,11 @@ from enum import Enum, IntFlag from typing import Dict, List, Optional, Union from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from panda.python import uds -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries, p16 +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries, p16 Ecu = car.CarParams.Ecu VisualAlert = car.CarControl.HUDControl.VisualAlert diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 6af5f572da..1ff211e860 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -1,12 +1,12 @@ from cereal import car -from common.conversions import Conversions as CV -from common.numpy_fast import clip -from common.realtime import DT_CTRL +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import clip +from openpilot.common.realtime import DT_CTRL from opendbc.can.packer import CANPacker -from selfdrive.car import apply_driver_steer_torque_limits, common_fault_avoidance -from selfdrive.car.hyundai import hyundaicanfd, hyundaican -from selfdrive.car.hyundai.hyundaicanfd import CanBus -from selfdrive.car.hyundai.values import HyundaiFlags, Buttons, CarControllerParams, CANFD_CAR, CAR +from openpilot.selfdrive.car import apply_driver_steer_torque_limits, common_fault_avoidance +from openpilot.selfdrive.car.hyundai import hyundaicanfd, hyundaican +from openpilot.selfdrive.car.hyundai.hyundaicanfd import CanBus +from openpilot.selfdrive.car.hyundai.values import HyundaiFlags, Buttons, CarControllerParams, CANFD_CAR, CAR VisualAlert = car.CarControl.HUDControl.VisualAlert LongCtrlState = car.CarControl.Actuators.LongControlState diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 2e3801c319..ee35bf6663 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -3,12 +3,13 @@ import copy import math from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine -from selfdrive.car.hyundai.hyundaicanfd import CanBus -from selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CAN_GEARS, CAMERA_SCC_CAR, CANFD_CAR, EV_CAR, HYBRID_CAR, Buttons, CarControllerParams -from selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.hyundai.hyundaicanfd import CanBus +from openpilot.selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CAN_GEARS, CAMERA_SCC_CAR, \ + CANFD_CAR, EV_CAR, HYBRID_CAR, Buttons, CarControllerParams +from openpilot.selfdrive.car.interfaces import CarStateBase PREV_BUTTON_SAMPLES = 8 CLUSTER_SAMPLE_RATE = 20 # frames diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index c0c60fba03..64fc241273 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -1,5 +1,5 @@ import crcmod -from selfdrive.car.hyundai.values import CAR, CHECKSUM, CAMERA_SCC_CAR +from openpilot.selfdrive.car.hyundai.values import CAR, CHECKSUM, CAMERA_SCC_CAR hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) diff --git a/selfdrive/car/hyundai/hyundaicanfd.py b/selfdrive/car/hyundai/hyundaicanfd.py index e78e02ae50..7aca5b850c 100644 --- a/selfdrive/car/hyundai/hyundaicanfd.py +++ b/selfdrive/car/hyundai/hyundaicanfd.py @@ -1,6 +1,6 @@ -from common.numpy_fast import clip -from selfdrive.car import CanBusBase -from selfdrive.car.hyundai.values import HyundaiFlags +from openpilot.common.numpy_fast import clip +from openpilot.selfdrive.car import CanBusBase +from openpilot.selfdrive.car.hyundai.values import HyundaiFlags class CanBus(CanBusBase): diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 3e25863f46..b4cf10d0ed 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from common.conversions import Conversions as CV -from selfdrive.car.hyundai.hyundaicanfd import CanBus -from selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \ +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.hyundai.hyundaicanfd import CanBus +from openpilot.selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \ EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, UNSUPPORTED_LONGITUDINAL_CAR, \ Buttons -from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR -from selfdrive.car import create_button_event, get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase -from selfdrive.car.disable_ecu import disable_ecu +from openpilot.selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR +from openpilot.selfdrive.car import create_button_event, get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.disable_ecu import disable_ecu Ecu = car.CarParams.Ecu ButtonType = car.CarState.ButtonEvent.Type diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index 3b74a03d4b..e1cae9ffaf 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -3,8 +3,8 @@ import math from cereal import car from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import RadarInterfaceBase -from selfdrive.car.hyundai.values import DBC +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.hyundai.values import DBC RADAR_START_ADDR = 0x500 RADAR_MSG_COUNT = 32 diff --git a/selfdrive/car/hyundai/tests/print_platform_codes.py b/selfdrive/car/hyundai/tests/print_platform_codes.py index 1bc8a4e366..6fe4582f54 100755 --- a/selfdrive/car/hyundai/tests/print_platform_codes.py +++ b/selfdrive/car/hyundai/tests/print_platform_codes.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 from cereal import car -from selfdrive.car.hyundai.values import FW_VERSIONS, PLATFORM_CODE_ECUS, get_platform_codes +from openpilot.selfdrive.car.hyundai.values import FW_VERSIONS, PLATFORM_CODE_ECUS, get_platform_codes Ecu = car.CarParams.Ecu ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 68a7603ec4..b61b09a897 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -2,8 +2,8 @@ import unittest from cereal import car -from selfdrive.car.fw_versions import build_fw_dict -from selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ +from openpilot.selfdrive.car.fw_versions import build_fw_dict +from openpilot.selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ EV_CAR, FW_QUERY_CONFIG, FW_VERSIONS, LEGACY_SAFETY_MODE_CAR, \ UNSUPPORTED_LONGITUDINAL_CAR, PLATFORM_CODE_ECUS, get_platform_codes diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 5a137267ad..dc90fbfba7 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -6,10 +6,10 @@ from typing import Dict, List, Optional, Set, Tuple, Union from cereal import car from panda.python import uds -from common.conversions import Conversions as CV -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16 +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16 Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index f30683d9a3..53b3e381f6 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -5,15 +5,15 @@ from abc import abstractmethod, ABC from typing import Any, Dict, Optional, Tuple, List, Callable from cereal import car -from common.basedir import BASEDIR -from common.conversions import Conversions as CV -from common.kalman.simple_kalman import KF1D -from common.numpy_fast import clip -from common.realtime import DT_CTRL -from selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG -from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction -from selfdrive.controls.lib.events import Events -from selfdrive.controls.lib.vehicle_model import VehicleModel +from openpilot.common.basedir import BASEDIR +from openpilot.common.conversions import Conversions as CV +from openpilot.common.kalman.simple_kalman import KF1D +from openpilot.common.numpy_fast import clip +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG +from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction +from openpilot.selfdrive.controls.lib.events import Events +from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel ButtonType = car.CarState.ButtonEvent.Type GearShifter = car.CarState.GearShifter @@ -441,7 +441,7 @@ def get_interface_attr(attr: str, combine_brands: bool = False, ignore_none: boo for car_folder in sorted([x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]): try: brand_name = car_folder.split('/')[-1] - brand_values = __import__(f'selfdrive.car.{brand_name}.values', fromlist=[attr]) + brand_values = __import__(f'openpilot.selfdrive.car.{brand_name}.values', fromlist=[attr]) if hasattr(brand_values, attr) or not ignore_none: attr_data = getattr(brand_values, attr, None) else: diff --git a/selfdrive/car/isotp_parallel_query.py b/selfdrive/car/isotp_parallel_query.py index 93033126a0..adbc598ea6 100644 --- a/selfdrive/car/isotp_parallel_query.py +++ b/selfdrive/car/isotp_parallel_query.py @@ -3,8 +3,8 @@ from collections import defaultdict from functools import partial import cereal.messaging as messaging -from system.swaglog import cloudlog -from selfdrive.boardd.boardd import can_list_to_can_capnp +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.boardd.boardd import can_list_to_can_capnp from panda.python.uds import CanClient, IsoTpMessage, FUNCTIONAL_ADDRS, get_rx_addr_for_tx_addr diff --git a/selfdrive/car/mazda/carcontroller.py b/selfdrive/car/mazda/carcontroller.py index cb401a8abd..320ad19bb4 100644 --- a/selfdrive/car/mazda/carcontroller.py +++ b/selfdrive/car/mazda/carcontroller.py @@ -1,8 +1,8 @@ from cereal import car from opendbc.can.packer import CANPacker -from selfdrive.car import apply_driver_steer_torque_limits -from selfdrive.car.mazda import mazdacan -from selfdrive.car.mazda.values import CarControllerParams, Buttons +from openpilot.selfdrive.car import apply_driver_steer_torque_limits +from openpilot.selfdrive.car.mazda import mazdacan +from openpilot.selfdrive.car.mazda.values import CarControllerParams, Buttons VisualAlert = car.CarControl.HUDControl.VisualAlert diff --git a/selfdrive/car/mazda/carstate.py b/selfdrive/car/mazda/carstate.py index d782e59dee..1f7846ca06 100644 --- a/selfdrive/car/mazda/carstate.py +++ b/selfdrive/car/mazda/carstate.py @@ -1,9 +1,9 @@ from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import CarStateBase -from selfdrive.car.mazda.values import DBC, LKAS_LIMITS, GEN1 +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.mazda.values import DBC, LKAS_LIMITS, GEN1 class CarState(CarStateBase): def __init__(self, CP): diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index cb89c4c448..7ac93d9dee 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from cereal import car -from common.conversions import Conversions as CV -from selfdrive.car.mazda.values import CAR, LKAS_LIMITS -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.mazda.values import CAR, LKAS_LIMITS +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase ButtonType = car.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName diff --git a/selfdrive/car/mazda/mazdacan.py b/selfdrive/car/mazda/mazdacan.py index 58a505f917..e350c5587f 100644 --- a/selfdrive/car/mazda/mazdacan.py +++ b/selfdrive/car/mazda/mazdacan.py @@ -1,4 +1,4 @@ -from selfdrive.car.mazda.values import GEN1, Buttons +from openpilot.selfdrive.car.mazda.values import GEN1, Buttons def create_steering_control(packer, car_fingerprint, frame, apply_steer, lkas): diff --git a/selfdrive/car/mazda/radar_interface.py b/selfdrive/car/mazda/radar_interface.py index b2f7651136..b461fcd5f8 100755 --- a/selfdrive/car/mazda/radar_interface.py +++ b/selfdrive/car/mazda/radar_interface.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass diff --git a/selfdrive/car/mazda/values.py b/selfdrive/car/mazda/values.py index fbdf8961af..0230be2297 100644 --- a/selfdrive/car/mazda/values.py +++ b/selfdrive/car/mazda/values.py @@ -2,9 +2,9 @@ from dataclasses import dataclass, field from typing import Dict, List, Union from cereal import car -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarHarness, CarInfo, CarParts -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarHarness, CarInfo, CarParts +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index 7986adb8f1..d36f972a87 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from cereal import car -from system.swaglog import cloudlog +from openpilot.system.swaglog import cloudlog import cereal.messaging as messaging -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase # mocked car interface to work with chffrplus diff --git a/selfdrive/car/mock/radar_interface.py b/selfdrive/car/mock/radar_interface.py index b2f7651136..b461fcd5f8 100755 --- a/selfdrive/car/mock/radar_interface.py +++ b/selfdrive/car/mock/radar_interface.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass diff --git a/selfdrive/car/mock/values.py b/selfdrive/car/mock/values.py index dfc7902e41..8426041b32 100644 --- a/selfdrive/car/mock/values.py +++ b/selfdrive/car/mock/values.py @@ -1,6 +1,6 @@ from typing import Dict, List, Optional, Union -from selfdrive.car.docs_definitions import CarInfo +from openpilot.selfdrive.car.docs_definitions import CarInfo class CAR: diff --git a/selfdrive/car/nissan/carcontroller.py b/selfdrive/car/nissan/carcontroller.py index 2c628b102d..2da518bbf1 100644 --- a/selfdrive/car/nissan/carcontroller.py +++ b/selfdrive/car/nissan/carcontroller.py @@ -1,8 +1,8 @@ from cereal import car from opendbc.can.packer import CANPacker -from selfdrive.car import apply_std_steer_angle_limits -from selfdrive.car.nissan import nissancan -from selfdrive.car.nissan.values import CAR, CarControllerParams +from openpilot.selfdrive.car import apply_std_steer_angle_limits +from openpilot.selfdrive.car.nissan import nissancan +from openpilot.selfdrive.car.nissan.values import CAR, CarControllerParams VisualAlert = car.CarControl.HUDControl.VisualAlert diff --git a/selfdrive/car/nissan/carstate.py b/selfdrive/car/nissan/carstate.py index f17e2d8dc4..b2ba9ce290 100644 --- a/selfdrive/car/nissan/carstate.py +++ b/selfdrive/car/nissan/carstate.py @@ -2,10 +2,10 @@ import copy from collections import deque from cereal import car from opendbc.can.can_define import CANDefine -from selfdrive.car.interfaces import CarStateBase -from common.conversions import Conversions as CV +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.common.conversions import Conversions as CV from opendbc.can.parser import CANParser -from selfdrive.car.nissan.values import CAR, DBC, CarControllerParams +from openpilot.selfdrive.car.nissan.values import CAR, DBC, CarControllerParams TORQUE_SAMPLES = 12 diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 423a1bf8de..3d6b6cb70c 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from cereal import car -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase -from selfdrive.car.nissan.values import CAR +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.nissan.values import CAR class CarInterface(CarInterfaceBase): diff --git a/selfdrive/car/nissan/nissancan.py b/selfdrive/car/nissan/nissancan.py index 89754775b1..49dcd6fe93 100644 --- a/selfdrive/car/nissan/nissancan.py +++ b/selfdrive/car/nissan/nissancan.py @@ -1,5 +1,5 @@ import crcmod -from selfdrive.car.nissan.values import CAR +from openpilot.selfdrive.car.nissan.values import CAR # TODO: add this checksum to the CANPacker nissan_checksum = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) diff --git a/selfdrive/car/nissan/radar_interface.py b/selfdrive/car/nissan/radar_interface.py index b2f7651136..b461fcd5f8 100644 --- a/selfdrive/car/nissan/radar_interface.py +++ b/selfdrive/car/nissan/radar_interface.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass diff --git a/selfdrive/car/nissan/values.py b/selfdrive/car/nissan/values.py index 17df968094..db69132a76 100644 --- a/selfdrive/car/nissan/values.py +++ b/selfdrive/car/nissan/values.py @@ -4,9 +4,9 @@ from typing import Dict, List, Optional, Union from cereal import car from panda.python import uds -from selfdrive.car import AngleRateLimit, dbc_dict -from selfdrive.car.docs_definitions import CarInfo, CarHarness, CarParts -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries +from openpilot.selfdrive.car import AngleRateLimit, dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarInfo, CarHarness, CarParts +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index 80634bf261..3aba25fe8d 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -1,8 +1,8 @@ -from common.numpy_fast import clip, interp +from openpilot.common.numpy_fast import clip, interp from opendbc.can.packer import CANPacker -from selfdrive.car import apply_driver_steer_torque_limits -from selfdrive.car.subaru import subarucan -from selfdrive.car.subaru.values import DBC, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, CarControllerParams, SubaruFlags +from openpilot.selfdrive.car import apply_driver_steer_torque_limits +from openpilot.selfdrive.car.subaru import subarucan +from openpilot.selfdrive.car.subaru.values import DBC, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, CarControllerParams, SubaruFlags class CarController: diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py index 84c1285af1..66c4c6386e 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -1,11 +1,11 @@ import copy from cereal import car from opendbc.can.can_define import CANDefine -from common.conversions import Conversions as CV -from selfdrive.car.interfaces import CarStateBase +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser -from selfdrive.car.subaru.values import DBC, CAR, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, SubaruFlags -from selfdrive.car import CanSignalRateCalculator +from openpilot.selfdrive.car.subaru.values import DBC, CAR, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, SubaruFlags +from openpilot.selfdrive.car import CanSignalRateCalculator class CarState(CarStateBase): diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index eab39420cc..b206a816ac 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase -from selfdrive.car.subaru.values import CAR, LKAS_ANGLE, GLOBAL_GEN2, PREGLOBAL_CARS, SubaruFlags +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.subaru.values import CAR, LKAS_ANGLE, GLOBAL_GEN2, PREGLOBAL_CARS, SubaruFlags class CarInterface(CarInterfaceBase): diff --git a/selfdrive/car/subaru/radar_interface.py b/selfdrive/car/subaru/radar_interface.py index b2f7651136..b461fcd5f8 100644 --- a/selfdrive/car/subaru/radar_interface.py +++ b/selfdrive/car/subaru/radar_interface.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass diff --git a/selfdrive/car/subaru/subarucan.py b/selfdrive/car/subaru/subarucan.py index df2718c764..caa1451842 100644 --- a/selfdrive/car/subaru/subarucan.py +++ b/selfdrive/car/subaru/subarucan.py @@ -1,5 +1,5 @@ from cereal import car -from selfdrive.car.subaru.values import CanBus +from openpilot.selfdrive.car.subaru.values import CanBus VisualAlert = car.CarControl.HUDControl.VisualAlert diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index dc25f31f73..8cb3a904b2 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -4,9 +4,9 @@ from typing import Dict, List, Union from cereal import car from panda.python import uds -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Tool, Column -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries, p16 +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Tool, Column +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries, p16 Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/tesla/carcontroller.py b/selfdrive/car/tesla/carcontroller.py index aeaaba88e7..95a248a614 100644 --- a/selfdrive/car/tesla/carcontroller.py +++ b/selfdrive/car/tesla/carcontroller.py @@ -1,8 +1,8 @@ -from common.numpy_fast import clip +from openpilot.common.numpy_fast import clip from opendbc.can.packer import CANPacker -from selfdrive.car import apply_std_steer_angle_limits -from selfdrive.car.tesla.teslacan import TeslaCAN -from selfdrive.car.tesla.values import DBC, CANBUS, CarControllerParams +from openpilot.selfdrive.car import apply_std_steer_angle_limits +from openpilot.selfdrive.car.tesla.teslacan import TeslaCAN +from openpilot.selfdrive.car.tesla.values import DBC, CANBUS, CarControllerParams class CarController: diff --git a/selfdrive/car/tesla/carstate.py b/selfdrive/car/tesla/carstate.py index 61a6526f07..2cb4f09d79 100644 --- a/selfdrive/car/tesla/carstate.py +++ b/selfdrive/car/tesla/carstate.py @@ -1,9 +1,9 @@ import copy from collections import deque from cereal import car -from common.conversions import Conversions as CV -from selfdrive.car.tesla.values import DBC, CANBUS, GEAR_MAP, DOORS, BUTTONS -from selfdrive.car.interfaces import CarStateBase +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.tesla.values import DBC, CANBUS, GEAR_MAP, DOORS, BUTTONS +from openpilot.selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index 209f00873a..e06139729c 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from selfdrive.car.tesla.values import CANBUS, CAR -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.tesla.values import CANBUS, CAR +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase class CarInterface(CarInterfaceBase): diff --git a/selfdrive/car/tesla/radar_interface.py b/selfdrive/car/tesla/radar_interface.py index c368c794b0..b3e7c7fcb1 100755 --- a/selfdrive/car/tesla/radar_interface.py +++ b/selfdrive/car/tesla/radar_interface.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from cereal import car from opendbc.can.parser import CANParser -from selfdrive.car.tesla.values import DBC, CANBUS -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.tesla.values import DBC, CANBUS +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase RADAR_MSGS_A = list(range(0x310, 0x36E, 3)) RADAR_MSGS_B = list(range(0x311, 0x36F, 3)) diff --git a/selfdrive/car/tesla/teslacan.py b/selfdrive/car/tesla/teslacan.py index a491c030f8..6bb27b995f 100644 --- a/selfdrive/car/tesla/teslacan.py +++ b/selfdrive/car/tesla/teslacan.py @@ -1,7 +1,7 @@ import crcmod -from common.conversions import Conversions as CV -from selfdrive.car.tesla.values import CANBUS, CarControllerParams +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.tesla.values import CANBUS, CarControllerParams class TeslaCAN: diff --git a/selfdrive/car/tesla/values.py b/selfdrive/car/tesla/values.py index 3333455d1b..15283ae4b2 100644 --- a/selfdrive/car/tesla/values.py +++ b/selfdrive/car/tesla/values.py @@ -3,9 +3,9 @@ from collections import namedtuple from typing import Dict, List, Union from cereal import car -from selfdrive.car import AngleRateLimit, dbc_dict -from selfdrive.car.docs_definitions import CarInfo -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries +from openpilot.selfdrive.car import AngleRateLimit, dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarInfo +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/tests/routes.py b/selfdrive/car/tests/routes.py index 857ba8e4f4..9c56f578b9 100644 --- a/selfdrive/car/tests/routes.py +++ b/selfdrive/car/tests/routes.py @@ -1,18 +1,18 @@ #!/usr/bin/env python3 from typing import NamedTuple, Optional -from selfdrive.car.chrysler.values import CAR as CHRYSLER -from selfdrive.car.gm.values import CAR as GM -from selfdrive.car.ford.values import CAR as FORD -from selfdrive.car.honda.values import CAR as HONDA -from selfdrive.car.hyundai.values import CAR as HYUNDAI -from selfdrive.car.nissan.values import CAR as NISSAN -from selfdrive.car.mazda.values import CAR as MAZDA -from selfdrive.car.subaru.values import CAR as SUBARU -from selfdrive.car.toyota.values import CAR as TOYOTA -from selfdrive.car.volkswagen.values import CAR as VOLKSWAGEN -from selfdrive.car.tesla.values import CAR as TESLA -from selfdrive.car.body.values import CAR as COMMA +from openpilot.selfdrive.car.chrysler.values import CAR as CHRYSLER +from openpilot.selfdrive.car.gm.values import CAR as GM +from openpilot.selfdrive.car.ford.values import CAR as FORD +from openpilot.selfdrive.car.honda.values import CAR as HONDA +from openpilot.selfdrive.car.hyundai.values import CAR as HYUNDAI +from openpilot.selfdrive.car.nissan.values import CAR as NISSAN +from openpilot.selfdrive.car.mazda.values import CAR as MAZDA +from openpilot.selfdrive.car.subaru.values import CAR as SUBARU +from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA +from openpilot.selfdrive.car.volkswagen.values import CAR as VOLKSWAGEN +from openpilot.selfdrive.car.tesla.values import CAR as TESLA +from openpilot.selfdrive.car.body.values import CAR as COMMA # TODO: add routes for these cars non_tested_cars = [ diff --git a/selfdrive/car/tests/test_can_fingerprint.py b/selfdrive/car/tests/test_can_fingerprint.py index 7189ff542b..406ccd07f0 100755 --- a/selfdrive/car/tests/test_can_fingerprint.py +++ b/selfdrive/car/tests/test_can_fingerprint.py @@ -3,8 +3,8 @@ from parameterized import parameterized import unittest from cereal import log, messaging -from selfdrive.car.car_helpers import FRAME_FINGERPRINT, can_fingerprint -from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS +from openpilot.selfdrive.car.car_helpers import FRAME_FINGERPRINT, can_fingerprint +from openpilot.selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS class TestCanFingerprint(unittest.TestCase): diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index 3945fbb987..a447fc21b6 100755 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -7,12 +7,12 @@ import importlib from parameterized import parameterized from cereal import car -from common.realtime import DT_CTRL -from selfdrive.car import gen_empty_fingerprint -from selfdrive.car.car_helpers import interfaces -from selfdrive.car.fingerprints import all_known_cars -from selfdrive.car.interfaces import get_interface_attr -from selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car import gen_empty_fingerprint +from openpilot.selfdrive.car.car_helpers import interfaces +from openpilot.selfdrive.car.fingerprints import all_known_cars +from openpilot.selfdrive.car.interfaces import get_interface_attr +from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator def get_fuzzy_car_interface_args(draw: DrawType) -> dict: diff --git a/selfdrive/car/tests/test_docs.py b/selfdrive/car/tests/test_docs.py index 6e4a58149c..d9d67fe87d 100755 --- a/selfdrive/car/tests/test_docs.py +++ b/selfdrive/car/tests/test_docs.py @@ -4,13 +4,13 @@ import os import re import unittest -from common.basedir import BASEDIR -from selfdrive.car.car_helpers import interfaces, get_interface_attr -from selfdrive.car.docs import CARS_MD_OUT, CARS_MD_TEMPLATE, generate_cars_md, get_all_car_info -from selfdrive.car.docs_definitions import Cable, Column, PartType, Star -from selfdrive.car.honda.values import CAR as HONDA -from selfdrive.debug.dump_car_info import dump_car_info -from selfdrive.debug.print_docs_diff import print_car_info_diff +from openpilot.common.basedir import BASEDIR +from openpilot.selfdrive.car.car_helpers import interfaces, get_interface_attr +from openpilot.selfdrive.car.docs import CARS_MD_OUT, CARS_MD_TEMPLATE, generate_cars_md, get_all_car_info +from openpilot.selfdrive.car.docs_definitions import Cable, Column, PartType, Star +from openpilot.selfdrive.car.honda.values import CAR as HONDA +from openpilot.selfdrive.debug.dump_car_info import dump_car_info +from openpilot.selfdrive.debug.print_docs_diff import print_car_info_diff class TestCarDocs(unittest.TestCase): diff --git a/selfdrive/car/tests/test_fingerprints.py b/selfdrive/car/tests/test_fingerprints.py index a0baec68d6..61e9a4d165 100755 --- a/selfdrive/car/tests/test_fingerprints.py +++ b/selfdrive/car/tests/test_fingerprints.py @@ -3,7 +3,7 @@ import os import sys from typing import Dict, List -from common.basedir import BASEDIR +from openpilot.common.basedir import BASEDIR # messages reserved for CAN based ignition (see can_ignition_hook function in panda/board/drivers/can) # (addr, len) diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 6825bb3717..3280dea7dc 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -7,11 +7,12 @@ from parameterized import parameterized import threading from cereal import car -from common.params import Params -from selfdrive.car.car_helpers import interfaces -from selfdrive.car.fingerprints import FW_VERSIONS -from selfdrive.car.fw_versions import FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, match_fw_to_car, get_fw_versions, get_present_ecus -from selfdrive.car.vin import get_vin +from openpilot.common.params import Params +from openpilot.selfdrive.car.car_helpers import interfaces +from openpilot.selfdrive.car.fingerprints import FW_VERSIONS +from openpilot.selfdrive.car.fw_versions import FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \ + match_fw_to_car, get_fw_versions, get_present_ecus +from openpilot.selfdrive.car.vin import get_vin CarFw = car.CarParams.CarFw Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/tests/test_lateral_limits.py b/selfdrive/car/tests/test_lateral_limits.py index 9e9043d236..9de6063f3d 100755 --- a/selfdrive/car/tests/test_lateral_limits.py +++ b/selfdrive/car/tests/test_lateral_limits.py @@ -6,11 +6,11 @@ import sys from typing import DefaultDict, Dict import unittest -from common.realtime import DT_CTRL -from selfdrive.car.car_helpers import interfaces -from selfdrive.car.fingerprints import all_known_cars -from selfdrive.car.interfaces import get_torque_params -from selfdrive.car.subaru.values import CAR as SUBARU +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car.car_helpers import interfaces +from openpilot.selfdrive.car.fingerprints import all_known_cars +from openpilot.selfdrive.car.interfaces import get_torque_params +from openpilot.selfdrive.car.subaru.values import CAR as SUBARU CAR_MODELS = all_known_cars() diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py index c40d8bb505..0147725291 100755 --- a/selfdrive/car/tests/test_models.py +++ b/selfdrive/car/tests/test_models.py @@ -9,17 +9,17 @@ from typing import List, Optional, Tuple from parameterized import parameterized_class from cereal import log, car -from common.basedir import BASEDIR -from common.realtime import DT_CTRL -from selfdrive.car.fingerprints import all_known_cars -from selfdrive.car.car_helpers import FRAME_FINGERPRINT, interfaces -from selfdrive.car.gm.values import CAR as GM -from selfdrive.car.honda.values import CAR as HONDA, HONDA_BOSCH -from selfdrive.car.hyundai.values import CAR as HYUNDAI -from selfdrive.car.tests.routes import non_tested_cars, routes, CarTestRoute -from selfdrive.test.openpilotci import get_url -from tools.lib.logreader import LogReader -from tools.lib.route import Route, SegmentName, RouteName +from openpilot.common.basedir import BASEDIR +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car.fingerprints import all_known_cars +from openpilot.selfdrive.car.car_helpers import FRAME_FINGERPRINT, interfaces +from openpilot.selfdrive.car.gm.values import CAR as GM +from openpilot.selfdrive.car.honda.values import CAR as HONDA, HONDA_BOSCH +from openpilot.selfdrive.car.hyundai.values import CAR as HYUNDAI +from openpilot.selfdrive.car.tests.routes import non_tested_cars, routes, CarTestRoute +from openpilot.selfdrive.test.openpilotci import get_url +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route, SegmentName, RouteName from panda.tests.libpanda import libpanda_py diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index d2558b5b29..c625c2e493 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -1,11 +1,11 @@ from cereal import car -from common.numpy_fast import clip, interp -from selfdrive.car import apply_meas_steer_torque_limits, apply_std_steer_angle_limits, common_fault_avoidance, \ +from openpilot.common.numpy_fast import clip, interp +from openpilot.selfdrive.car import apply_meas_steer_torque_limits, apply_std_steer_angle_limits, common_fault_avoidance, \ create_gas_interceptor_command, make_can_msg -from selfdrive.car.toyota.toyotacan import create_steer_command, create_ui_command, \ +from openpilot.selfdrive.car.toyota.toyotacan import create_steer_command, create_ui_command, \ create_accel_command, create_acc_cancel_command, \ create_fcw_command, create_lta_steer_command -from selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \ +from openpilot.selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \ MIN_ACC_SPEED, PEDAL_TRANSITION, CarControllerParams, \ UNSUPPORTED_DSU_CAR from opendbc.can.packer import CANPacker diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 8a75ab4277..7eefe43dd9 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -1,14 +1,15 @@ import copy from cereal import car -from common.conversions import Conversions as CV -from common.numpy_fast import mean -from common.filter_simple import FirstOrderFilter -from common.realtime import DT_CTRL +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import mean +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.common.realtime import DT_CTRL from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser -from selfdrive.car.interfaces import CarStateBase -from selfdrive.car.toyota.values import ToyotaFlags, CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR, RADAR_ACC_CAR, EPS_SCALE, UNSUPPORTED_DSU_CAR +from openpilot.selfdrive.car.interfaces import CarStateBase +from openpilot.selfdrive.car.toyota.values import ToyotaFlags, CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, \ + TSS2_CAR, RADAR_ACC_CAR, EPS_SCALE, UNSUPPORTED_DSU_CAR SteerControlType = car.CarParams.SteerControlType diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 6be01c1c0e..c78479a97e 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 from cereal import car -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from panda import Panda -from selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \ +from openpilot.selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \ MIN_ACC_SPEED, EPS_SCALE, EV_HYBRID_CAR, UNSUPPORTED_DSU_CAR, NO_STOP_TIMER_CAR, ANGLE_CONTROL_CAR -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase EventName = car.CarEvent.EventName SteerControlType = car.CarParams.SteerControlType diff --git a/selfdrive/car/toyota/radar_interface.py b/selfdrive/car/toyota/radar_interface.py index 56473b06a4..fae6eecaf6 100755 --- a/selfdrive/car/toyota/radar_interface.py +++ b/selfdrive/car/toyota/radar_interface.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from opendbc.can.parser import CANParser from cereal import car -from selfdrive.car.toyota.values import DBC, TSS2_CAR -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.toyota.values import DBC, TSS2_CAR +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase def _create_radar_can_parser(car_fingerprint): diff --git a/selfdrive/car/toyota/tests/test_toyota.py b/selfdrive/car/toyota/tests/test_toyota.py index 46e3fc2d27..e877db3eb8 100755 --- a/selfdrive/car/toyota/tests/test_toyota.py +++ b/selfdrive/car/toyota/tests/test_toyota.py @@ -2,7 +2,7 @@ from cereal import car import unittest -from selfdrive.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, FW_VERSIONS +from openpilot.selfdrive.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, FW_VERSIONS Ecu = car.CarParams.Ecu diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index ad6a2c639c..7d62528748 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -4,10 +4,10 @@ from enum import Enum, IntFlag from typing import Dict, List, Union from cereal import car -from common.conversions import Conversions as CV -from selfdrive.car import AngleRateLimit, dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarInfo, Column, CarParts, CarHarness -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car import AngleRateLimit, dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarInfo, Column, CarParts, CarHarness +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries Ecu = car.CarParams.Ecu MIN_ACC_SPEED = 19. * CV.MPH_TO_MS diff --git a/selfdrive/car/vin.py b/selfdrive/car/vin.py index cf1c25e851..28edf157ae 100755 --- a/selfdrive/car/vin.py +++ b/selfdrive/car/vin.py @@ -3,9 +3,9 @@ import re import cereal.messaging as messaging from panda.python.uds import get_rx_addr_for_tx_addr, FUNCTIONAL_ADDRS -from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery -from selfdrive.car.fw_query_definitions import StdQueries -from system.swaglog import cloudlog +from openpilot.selfdrive.car.isotp_parallel_query import IsoTpParallelQuery +from openpilot.selfdrive.car.fw_query_definitions import StdQueries +from openpilot.system.swaglog import cloudlog VIN_UNKNOWN = "0" * 17 VIN_RE = "[A-HJ-NPR-Z0-9]{17}" diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py index ddcf80f006..e7a7f2a998 100644 --- a/selfdrive/car/volkswagen/carcontroller.py +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -1,11 +1,11 @@ from cereal import car from opendbc.can.packer import CANPacker -from common.numpy_fast import clip -from common.conversions import Conversions as CV -from common.realtime import DT_CTRL -from selfdrive.car import apply_driver_steer_torque_limits -from selfdrive.car.volkswagen import mqbcan, pqcan -from selfdrive.car.volkswagen.values import CANBUS, PQ_CARS, CarControllerParams +from openpilot.common.numpy_fast import clip +from openpilot.common.conversions import Conversions as CV +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car import apply_driver_steer_torque_limits +from openpilot.selfdrive.car.volkswagen import mqbcan, pqcan +from openpilot.selfdrive.car.volkswagen.values import CANBUS, PQ_CARS, CarControllerParams VisualAlert = car.CarControl.HUDControl.VisualAlert LongCtrlState = car.CarControl.Actuators.LongControlState diff --git a/selfdrive/car/volkswagen/carstate.py b/selfdrive/car/volkswagen/carstate.py index 35f7e8bf67..cbe8918d48 100644 --- a/selfdrive/car/volkswagen/carstate.py +++ b/selfdrive/car/volkswagen/carstate.py @@ -1,9 +1,9 @@ import numpy as np from cereal import car -from common.conversions import Conversions as CV -from selfdrive.car.interfaces import CarStateBase +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser -from selfdrive.car.volkswagen.values import DBC, CANBUS, PQ_CARS, NetworkLocation, TransmissionType, GearShifter, \ +from openpilot.selfdrive.car.volkswagen.values import DBC, CANBUS, PQ_CARS, NetworkLocation, TransmissionType, GearShifter, \ CarControllerParams diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index 66b6239cb3..d5377453c1 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -1,9 +1,9 @@ from cereal import car from panda import Panda -from common.conversions import Conversions as CV -from selfdrive.car import get_safety_config -from selfdrive.car.interfaces import CarInterfaceBase -from selfdrive.car.volkswagen.values import CAR, PQ_CARS, CANBUS, NetworkLocation, TransmissionType, GearShifter +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.volkswagen.values import CAR, PQ_CARS, CANBUS, NetworkLocation, TransmissionType, GearShifter ButtonType = car.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName diff --git a/selfdrive/car/volkswagen/radar_interface.py b/selfdrive/car/volkswagen/radar_interface.py index b2f7651136..b461fcd5f8 100644 --- a/selfdrive/car/volkswagen/radar_interface.py +++ b/selfdrive/car/volkswagen/radar_interface.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.interfaces import RadarInterfaceBase +from openpilot.selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass diff --git a/selfdrive/car/volkswagen/values.py b/selfdrive/car/volkswagen/values.py index bc129f79cc..3ffc09a43d 100755 --- a/selfdrive/car/volkswagen/values.py +++ b/selfdrive/car/volkswagen/values.py @@ -6,10 +6,10 @@ from typing import Dict, List, Union from cereal import car from panda.python import uds from opendbc.can.can_define import CANDefine -from selfdrive.car import dbc_dict -from selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column, \ +from openpilot.selfdrive.car import dbc_dict +from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column, \ Device -from selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16 +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16 Ecu = car.CarParams.Ecu NetworkLocation = car.CarParams.NetworkLocation diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 564a0aa6ac..8094030731 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -5,29 +5,29 @@ import time from typing import SupportsFloat from cereal import car, log -from common.numpy_fast import clip -from common.profiler import Profiler -from common.params import Params, put_nonblocking, put_bool_nonblocking -from common.realtime import DT_CTRL, Priority, Ratekeeper, config_realtime_process +from openpilot.common.numpy_fast import clip +from openpilot.common.realtime import config_realtime_process, Priority, Ratekeeper, DT_CTRL +from openpilot.common.profiler import Profiler +from openpilot.common.params import Params, put_nonblocking, put_bool_nonblocking import cereal.messaging as messaging from cereal.visionipc import VisionIpcClient, VisionStreamType -from common.conversions import Conversions as CV +from openpilot.common.conversions import Conversions as CV from panda import ALTERNATIVE_EXPERIENCE -from system.swaglog import cloudlog -from system.version import is_release_branch, get_short_branch -from selfdrive.boardd.boardd import can_list_to_can_capnp -from selfdrive.car.car_helpers import get_car, get_startup_event, get_one_can -from selfdrive.controls.lib.lateral_planner import CAMERA_OFFSET -from selfdrive.controls.lib.drive_helpers import VCruiseHelper, get_lag_adjusted_curvature -from selfdrive.controls.lib.latcontrol import LatControl, MIN_LATERAL_CONTROL_SPEED -from selfdrive.controls.lib.longcontrol import LongControl -from selfdrive.controls.lib.latcontrol_pid import LatControlPID -from selfdrive.controls.lib.latcontrol_angle import LatControlAngle, STEER_ANGLE_SATURATION_THRESHOLD -from selfdrive.controls.lib.latcontrol_torque import LatControlTorque -from selfdrive.controls.lib.events import Events, ET -from selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert -from selfdrive.controls.lib.vehicle_model import VehicleModel -from system.hardware import HARDWARE +from openpilot.system.swaglog import cloudlog +from openpilot.system.version import is_release_branch, get_short_branch +from openpilot.selfdrive.boardd.boardd import can_list_to_can_capnp +from openpilot.selfdrive.car.car_helpers import get_car, get_startup_event, get_one_can +from openpilot.selfdrive.controls.lib.lateral_planner import CAMERA_OFFSET +from openpilot.selfdrive.controls.lib.drive_helpers import VCruiseHelper, get_lag_adjusted_curvature +from openpilot.selfdrive.controls.lib.latcontrol import LatControl, MIN_LATERAL_CONTROL_SPEED +from openpilot.selfdrive.controls.lib.longcontrol import LongControl +from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID +from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle, STEER_ANGLE_SATURATION_THRESHOLD +from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque +from openpilot.selfdrive.controls.lib.events import Events, ET +from openpilot.selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert +from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel +from openpilot.system.hardware import HARDWARE SOFT_DISABLE_TIME = 3 # seconds LDW_MIN_SPEED = 31 * CV.MPH_TO_MS diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index f32e838333..6abcf4cbba 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -5,9 +5,9 @@ from collections import defaultdict from dataclasses import dataclass from typing import List, Dict, Optional -from common.basedir import BASEDIR -from common.params import Params -from selfdrive.controls.lib.events import Alert +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params +from openpilot.selfdrive.controls.lib.events import Alert with open(os.path.join(BASEDIR, "selfdrive/controls/lib/alerts_offroad.json")) as f: diff --git a/selfdrive/controls/lib/desire_helper.py b/selfdrive/controls/lib/desire_helper.py index 4652b41c1c..d538035070 100644 --- a/selfdrive/controls/lib/desire_helper.py +++ b/selfdrive/controls/lib/desire_helper.py @@ -1,6 +1,6 @@ from cereal import log -from common.conversions import Conversions as CV -from common.realtime import DT_MDL +from openpilot.common.conversions import Conversions as CV +from openpilot.common.realtime import DT_MDL LaneChangeState = log.LateralPlan.LaneChangeState LaneChangeDirection = log.LateralPlan.LaneChangeDirection diff --git a/selfdrive/controls/lib/drive_helpers.py b/selfdrive/controls/lib/drive_helpers.py index ab65da2e1d..00916ddf78 100644 --- a/selfdrive/controls/lib/drive_helpers.py +++ b/selfdrive/controls/lib/drive_helpers.py @@ -1,10 +1,10 @@ import math from cereal import car, log -from common.conversions import Conversions as CV -from common.numpy_fast import clip, interp -from common.realtime import DT_MDL -from selfdrive.modeld.constants import T_IDXS +from openpilot.common.conversions import Conversions as CV +from openpilot.common.numpy_fast import clip, interp +from openpilot.common.realtime import DT_MDL +from openpilot.selfdrive.modeld.constants import T_IDXS # WARNING: this value was determined based on the model's training distribution, # model predictions above this speed can be unpredictable diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 0230a5775c..7c30effce5 100755 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -5,10 +5,10 @@ from typing import Dict, Union, Callable, List, Optional from cereal import log, car import cereal.messaging as messaging -from common.conversions import Conversions as CV -from common.realtime import DT_CTRL -from selfdrive.locationd.calibrationd import MIN_SPEED_FILTER -from system.version import get_short_branch +from openpilot.common.conversions import Conversions as CV +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.locationd.calibrationd import MIN_SPEED_FILTER +from openpilot.system.version import get_short_branch AlertSize = log.ControlsState.AlertSize AlertStatus = log.ControlsState.AlertStatus diff --git a/selfdrive/controls/lib/latcontrol.py b/selfdrive/controls/lib/latcontrol.py index d38959c560..30e1918442 100644 --- a/selfdrive/controls/lib/latcontrol.py +++ b/selfdrive/controls/lib/latcontrol.py @@ -1,7 +1,7 @@ from abc import abstractmethod, ABC -from common.numpy_fast import clip -from common.realtime import DT_CTRL +from openpilot.common.numpy_fast import clip +from openpilot.common.realtime import DT_CTRL MIN_LATERAL_CONTROL_SPEED = 0.3 # m/s diff --git a/selfdrive/controls/lib/latcontrol_angle.py b/selfdrive/controls/lib/latcontrol_angle.py index 9ed140d38e..b13d41e51c 100644 --- a/selfdrive/controls/lib/latcontrol_angle.py +++ b/selfdrive/controls/lib/latcontrol_angle.py @@ -1,7 +1,7 @@ import math from cereal import log -from selfdrive.controls.lib.latcontrol import LatControl +from openpilot.selfdrive.controls.lib.latcontrol import LatControl STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees diff --git a/selfdrive/controls/lib/latcontrol_pid.py b/selfdrive/controls/lib/latcontrol_pid.py index 6696d2e304..c41130af95 100644 --- a/selfdrive/controls/lib/latcontrol_pid.py +++ b/selfdrive/controls/lib/latcontrol_pid.py @@ -1,8 +1,8 @@ import math from cereal import log -from selfdrive.controls.lib.latcontrol import LatControl -from selfdrive.controls.lib.pid import PIDController +from openpilot.selfdrive.controls.lib.latcontrol import LatControl +from openpilot.selfdrive.controls.lib.pid import PIDController class LatControlPID(LatControl): diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index 6550b19227..2c77630632 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -1,10 +1,10 @@ import math from cereal import log -from common.numpy_fast import interp -from selfdrive.controls.lib.latcontrol import LatControl -from selfdrive.controls.lib.pid import PIDController -from selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY +from openpilot.common.numpy_fast import interp +from openpilot.selfdrive.controls.lib.latcontrol import LatControl +from openpilot.selfdrive.controls.lib.pid import PIDController +from openpilot.selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY # At higher speeds (25+mph) we can assume: # Lateral acceleration achieved by a specific car correlates to diff --git a/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py b/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py index 506b03031b..5e6f884df4 100755 --- a/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py +++ b/selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py @@ -5,12 +5,12 @@ import numpy as np from casadi import SX, vertcat, sin, cos # WARNING: imports outside of constants will not trigger a rebuild -from selfdrive.modeld.constants import T_IDXS +from openpilot.selfdrive.modeld.constants import T_IDXS if __name__ == '__main__': # generating code - from third_party.acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver + from openpilot.third_party.acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver else: - from selfdrive.controls.lib.lateral_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython + from openpilot.selfdrive.controls.lib.lateral_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython LAT_MPC_DIR = os.path.dirname(os.path.abspath(__file__)) EXPORT_DIR = os.path.join(LAT_MPC_DIR, "c_generated_code") diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py index 41aa95223e..92786f73d8 100644 --- a/selfdrive/controls/lib/lateral_planner.py +++ b/selfdrive/controls/lib/lateral_planner.py @@ -1,12 +1,12 @@ import time import numpy as np -from common.numpy_fast import interp -from common.realtime import DT_MDL -from system.swaglog import cloudlog -from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc -from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import N as LAT_MPC_N -from selfdrive.controls.lib.drive_helpers import CONTROL_N, MIN_SPEED, get_speed_error -from selfdrive.controls.lib.desire_helper import DesireHelper +from openpilot.common.realtime import DT_MDL +from openpilot.common.numpy_fast import interp +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc +from openpilot.selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import N as LAT_MPC_N +from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, MIN_SPEED, get_speed_error +from openpilot.selfdrive.controls.lib.desire_helper import DesireHelper import cereal.messaging as messaging from cereal import log diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index e8095813f2..61c150aadc 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -1,9 +1,9 @@ from cereal import car -from common.numpy_fast import clip, interp -from common.realtime import DT_CTRL -from selfdrive.controls.lib.drive_helpers import CONTROL_N, apply_deadzone -from selfdrive.controls.lib.pid import PIDController -from selfdrive.modeld.constants import T_IDXS +from openpilot.common.numpy_fast import clip, interp +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, apply_deadzone +from openpilot.selfdrive.controls.lib.pid import PIDController +from openpilot.selfdrive.modeld.constants import T_IDXS LongCtrlState = car.CarControl.Actuators.LongControlState diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py b/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py index 19cb2bac04..eaa782efee 100644 --- a/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py @@ -3,17 +3,17 @@ import os import time import numpy as np from cereal import log -from common.numpy_fast import clip -from system.swaglog import cloudlog +from openpilot.common.numpy_fast import clip +from openpilot.system.swaglog import cloudlog # WARNING: imports outside of constants will not trigger a rebuild -from selfdrive.modeld.constants import index_function -from selfdrive.car.interfaces import ACCEL_MIN -from selfdrive.controls.radard import _LEAD_ACCEL_TAU +from openpilot.selfdrive.modeld.constants import index_function +from openpilot.selfdrive.car.interfaces import ACCEL_MIN +from openpilot.selfdrive.controls.radard import _LEAD_ACCEL_TAU if __name__ == '__main__': # generating code - from third_party.acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver + from openpilot.third_party.acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver else: - from selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython + from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython from casadi import SX, vertcat diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 5765272928..c1e782fa5c 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -1,21 +1,21 @@ #!/usr/bin/env python3 import math import numpy as np -from common.numpy_fast import clip, interp -from common.params import Params +from openpilot.common.numpy_fast import clip, interp +from openpilot.common.params import Params from cereal import log import cereal.messaging as messaging -from common.conversions import Conversions as CV -from common.filter_simple import FirstOrderFilter -from common.realtime import DT_MDL -from selfdrive.modeld.constants import T_IDXS -from selfdrive.car.interfaces import ACCEL_MIN, ACCEL_MAX -from selfdrive.controls.lib.longcontrol import LongCtrlState -from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import LongitudinalMpc -from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import T_IDXS as T_IDXS_MPC -from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N, get_speed_error -from system.swaglog import cloudlog +from openpilot.common.conversions import Conversions as CV +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.common.realtime import DT_MDL +from openpilot.selfdrive.modeld.constants import T_IDXS +from openpilot.selfdrive.car.interfaces import ACCEL_MIN, ACCEL_MAX +from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState +from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import LongitudinalMpc +from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import T_IDXS as T_IDXS_MPC +from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N, get_speed_error +from openpilot.system.swaglog import cloudlog LON_MPC_STEP = 0.2 # first step is 0.2s A_CRUISE_MIN = -1.2 diff --git a/selfdrive/controls/lib/pid.py b/selfdrive/controls/lib/pid.py index 965158131b..f4ec7e5996 100644 --- a/selfdrive/controls/lib/pid.py +++ b/selfdrive/controls/lib/pid.py @@ -1,7 +1,7 @@ import numpy as np from numbers import Number -from common.numpy_fast import clip, interp +from openpilot.common.numpy_fast import clip, interp class PIDController(): diff --git a/selfdrive/controls/lib/tests/test_alertmanager.py b/selfdrive/controls/lib/tests/test_alertmanager.py index 6c1b6fc4a2..dbd42858a0 100755 --- a/selfdrive/controls/lib/tests/test_alertmanager.py +++ b/selfdrive/controls/lib/tests/test_alertmanager.py @@ -2,8 +2,8 @@ import random import unittest -from selfdrive.controls.lib.events import Alert, EVENTS -from selfdrive.controls.lib.alertmanager import AlertManager +from openpilot.selfdrive.controls.lib.events import Alert, EVENTS +from openpilot.selfdrive.controls.lib.alertmanager import AlertManager class TestAlertManager(unittest.TestCase): diff --git a/selfdrive/controls/lib/tests/test_latcontrol.py b/selfdrive/controls/lib/tests/test_latcontrol.py index b504b3d125..4ff7ef7c93 100755 --- a/selfdrive/controls/lib/tests/test_latcontrol.py +++ b/selfdrive/controls/lib/tests/test_latcontrol.py @@ -4,14 +4,14 @@ import unittest from parameterized import parameterized from cereal import car, log -from selfdrive.car.car_helpers import interfaces -from selfdrive.car.honda.values import CAR as HONDA -from selfdrive.car.toyota.values import CAR as TOYOTA -from selfdrive.car.nissan.values import CAR as NISSAN -from selfdrive.controls.lib.latcontrol_pid import LatControlPID -from selfdrive.controls.lib.latcontrol_torque import LatControlTorque -from selfdrive.controls.lib.latcontrol_angle import LatControlAngle -from selfdrive.controls.lib.vehicle_model import VehicleModel +from openpilot.selfdrive.car.car_helpers import interfaces +from openpilot.selfdrive.car.honda.values import CAR as HONDA +from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA +from openpilot.selfdrive.car.nissan.values import CAR as NISSAN +from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID +from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque +from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle +from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel class TestLatControl(unittest.TestCase): diff --git a/selfdrive/controls/lib/tests/test_vehicle_model.py b/selfdrive/controls/lib/tests/test_vehicle_model.py index 03d97a7e3f..fc8ef2fb56 100755 --- a/selfdrive/controls/lib/tests/test_vehicle_model.py +++ b/selfdrive/controls/lib/tests/test_vehicle_model.py @@ -5,9 +5,9 @@ import unittest import numpy as np from control import StateSpace -from selfdrive.car.honda.interface import CarInterface -from selfdrive.car.honda.values import CAR -from selfdrive.controls.lib.vehicle_model import VehicleModel, dyn_ss_sol, create_dyn_state_matrices +from openpilot.selfdrive.car.honda.interface import CarInterface +from openpilot.selfdrive.car.honda.values import CAR +from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel, dyn_ss_sol, create_dyn_state_matrices class TestVehicleModel(unittest.TestCase): diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index 7e61efcf45..2b23a0440e 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -2,12 +2,12 @@ import os import numpy as np from cereal import car -from common.params import Params -from common.realtime import Priority, config_realtime_process -from system.swaglog import cloudlog -from selfdrive.modeld.constants import T_IDXS -from selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner -from selfdrive.controls.lib.lateral_planner import LateralPlanner +from openpilot.common.params import Params +from openpilot.common.realtime import Priority, config_realtime_process +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.modeld.constants import T_IDXS +from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner +from openpilot.selfdrive.controls.lib.lateral_planner import LateralPlanner import cereal.messaging as messaging def cumtrapz(x, t): diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index cce866a093..8a21fdd8ab 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -6,12 +6,12 @@ from typing import Optional, Dict, Any import capnp from cereal import messaging, log, car -from common.numpy_fast import interp -from common.params import Params -from common.realtime import Ratekeeper, Priority, config_realtime_process -from system.swaglog import cloudlog +from openpilot.common.numpy_fast import interp +from openpilot.common.params import Params +from openpilot.common.realtime import Ratekeeper, Priority, config_realtime_process +from openpilot.system.swaglog import cloudlog -from common.kalman.simple_kalman import KF1D +from openpilot.common.kalman.simple_kalman import KF1D # Default lead acceleration decay set to 50% at 1s diff --git a/selfdrive/controls/tests/test_alerts.py b/selfdrive/controls/tests/test_alerts.py index c0d70b3b6f..7b4fba0dce 100755 --- a/selfdrive/controls/tests/test_alerts.py +++ b/selfdrive/controls/tests/test_alerts.py @@ -8,11 +8,11 @@ from PIL import Image, ImageDraw, ImageFont from cereal import log, car from cereal.messaging import SubMaster -from common.basedir import BASEDIR -from common.params import Params -from selfdrive.controls.lib.events import Alert, EVENTS, ET -from selfdrive.controls.lib.alertmanager import set_offroad_alert -from selfdrive.test.process_replay.process_replay import CONFIGS +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params +from openpilot.selfdrive.controls.lib.events import Alert, EVENTS, ET +from openpilot.selfdrive.controls.lib.alertmanager import set_offroad_alert +from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS AlertSize = log.ControlsState.AlertSize diff --git a/selfdrive/controls/tests/test_cruise_speed.py b/selfdrive/controls/tests/test_cruise_speed.py index 6d11c30ab2..c7221cfcfa 100755 --- a/selfdrive/controls/tests/test_cruise_speed.py +++ b/selfdrive/controls/tests/test_cruise_speed.py @@ -4,11 +4,11 @@ import unittest from parameterized import parameterized_class from cereal import log -from common.params import Params -from selfdrive.controls.lib.drive_helpers import VCruiseHelper, V_CRUISE_MIN, V_CRUISE_MAX, V_CRUISE_INITIAL, IMPERIAL_INCREMENT +from openpilot.common.params import Params +from openpilot.selfdrive.controls.lib.drive_helpers import VCruiseHelper, V_CRUISE_MIN, V_CRUISE_MAX, V_CRUISE_INITIAL, IMPERIAL_INCREMENT from cereal import car -from common.conversions import Conversions as CV -from selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver +from openpilot.common.conversions import Conversions as CV +from openpilot.selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver ButtonEvent = car.CarState.ButtonEvent ButtonType = car.CarState.ButtonEvent.Type diff --git a/selfdrive/controls/tests/test_following_distance.py b/selfdrive/controls/tests/test_following_distance.py index 9ee7bdfb3b..be949764c5 100644 --- a/selfdrive/controls/tests/test_following_distance.py +++ b/selfdrive/controls/tests/test_following_distance.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 import unittest -from common.params import Params +from openpilot.common.params import Params from cereal import log -from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import desired_follow_distance, get_T_FOLLOW -from selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver +from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import desired_follow_distance, get_T_FOLLOW +from openpilot.selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver def run_following_distance_simulation(v_lead, t_end=100.0, e2e=False): diff --git a/selfdrive/controls/tests/test_lateral_mpc.py b/selfdrive/controls/tests/test_lateral_mpc.py index b569da09b4..8c09f46b60 100644 --- a/selfdrive/controls/tests/test_lateral_mpc.py +++ b/selfdrive/controls/tests/test_lateral_mpc.py @@ -1,8 +1,8 @@ import unittest import numpy as np -from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc -from selfdrive.controls.lib.drive_helpers import CAR_ROTATION_RADIUS -from selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import N as LAT_MPC_N +from openpilot.selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import LateralMpc +from openpilot.selfdrive.controls.lib.drive_helpers import CAR_ROTATION_RADIUS +from openpilot.selfdrive.controls.lib.lateral_mpc_lib.lat_mpc import N as LAT_MPC_N def run_mpc(lat_mpc=None, v_ref=30., x_init=0., y_init=0., psi_init=0., curvature_init=0., diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py index 18c8e79026..72a5b4b48f 100755 --- a/selfdrive/controls/tests/test_startup.py +++ b/selfdrive/controls/tests/test_startup.py @@ -5,13 +5,13 @@ from parameterized import parameterized from cereal import log, car import cereal.messaging as messaging -from common.params import Params -from selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error -from selfdrive.car.fingerprints import _FINGERPRINTS -from selfdrive.car.toyota.values import CAR as TOYOTA -from selfdrive.car.mazda.values import CAR as MAZDA -from selfdrive.controls.lib.events import EVENT_NAME -from selfdrive.test.helpers import with_processes +from openpilot.common.params import Params +from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error +from openpilot.selfdrive.car.fingerprints import _FINGERPRINTS +from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA +from openpilot.selfdrive.car.mazda.values import CAR as MAZDA +from openpilot.selfdrive.controls.lib.events import EVENT_NAME +from openpilot.selfdrive.test.helpers import with_processes EventName = car.CarEvent.EventName Ecu = car.CarParams.Ecu diff --git a/selfdrive/controls/tests/test_state_machine.py b/selfdrive/controls/tests/test_state_machine.py index d5f468f214..bdeed9fb7a 100755 --- a/selfdrive/controls/tests/test_state_machine.py +++ b/selfdrive/controls/tests/test_state_machine.py @@ -2,10 +2,10 @@ import unittest from cereal import car, log -from common.realtime import DT_CTRL -from selfdrive.car.car_helpers import interfaces -from selfdrive.controls.controlsd import Controls, SOFT_DISABLE_TIME -from selfdrive.controls.lib.events import Events, ET, Alert, Priority, AlertSize, AlertStatus, VisualAlert, \ +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car.car_helpers import interfaces +from openpilot.selfdrive.controls.controlsd import Controls, SOFT_DISABLE_TIME +from openpilot.selfdrive.controls.lib.events import Events, ET, Alert, Priority, AlertSize, AlertStatus, VisualAlert, \ AudibleAlert, EVENTS State = log.ControlsState.OpenpilotState diff --git a/selfdrive/debug/can_print_changes.py b/selfdrive/debug/can_print_changes.py index ff98c20e60..ea1160d60b 100755 --- a/selfdrive/debug/can_print_changes.py +++ b/selfdrive/debug/can_print_changes.py @@ -5,8 +5,8 @@ import time from collections import defaultdict import cereal.messaging as messaging -from selfdrive.debug.can_table import can_table -from tools.lib.logreader import logreader_from_route_or_segment +from openpilot.selfdrive.debug.can_table import can_table +from openpilot.tools.lib.logreader import logreader_from_route_or_segment RED = '\033[91m' CLEAR = '\033[0m' diff --git a/selfdrive/debug/check_can_parser_performance.py b/selfdrive/debug/check_can_parser_performance.py index 4b430e013f..c4b688ce29 100755 --- a/selfdrive/debug/check_can_parser_performance.py +++ b/selfdrive/debug/check_can_parser_performance.py @@ -4,9 +4,9 @@ import time from tqdm import tqdm from cereal import car -from selfdrive.car.tests.routes import CarTestRoute -from selfdrive.car.tests.test_models import TestCarModelBase -from tools.plotjuggler.juggle import DEMO_ROUTE +from openpilot.selfdrive.car.tests.routes import CarTestRoute +from openpilot.selfdrive.car.tests.test_models import TestCarModelBase +from openpilot.tools.plotjuggler.juggle import DEMO_ROUTE N_RUNS = 10 diff --git a/selfdrive/debug/count_events.py b/selfdrive/debug/count_events.py index a81d797b89..a8af5e6fe9 100755 --- a/selfdrive/debug/count_events.py +++ b/selfdrive/debug/count_events.py @@ -8,8 +8,8 @@ from tqdm import tqdm from typing import List, Tuple, cast from cereal.services import service_list -from tools.lib.route import Route -from tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.logreader import LogReader if __name__ == "__main__": r = Route(sys.argv[1]) diff --git a/selfdrive/debug/cpu_usage_stat.py b/selfdrive/debug/cpu_usage_stat.py index b3294c8728..9050fbb064 100755 --- a/selfdrive/debug/cpu_usage_stat.py +++ b/selfdrive/debug/cpu_usage_stat.py @@ -24,7 +24,7 @@ import argparse import re from collections import defaultdict -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes # Do statistics every 5 seconds PRINT_INTERVAL = 5 diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py index 71c7b34be5..5037208643 100755 --- a/selfdrive/debug/cycle_alerts.py +++ b/selfdrive/debug/cycle_alerts.py @@ -4,11 +4,11 @@ import random from cereal import car, log import cereal.messaging as messaging -from common.realtime import DT_CTRL -from selfdrive.car.honda.interface import CarInterface -from selfdrive.controls.lib.events import ET, Events -from selfdrive.controls.lib.alertmanager import AlertManager -from selfdrive.manager.process_config import managed_processes +from openpilot.common.realtime import DT_CTRL +from openpilot.selfdrive.car.honda.interface import CarInterface +from openpilot.selfdrive.controls.lib.events import ET, Events +from openpilot.selfdrive.controls.lib.alertmanager import AlertManager +from openpilot.selfdrive.manager.process_config import managed_processes EventName = car.CarEvent.EventName diff --git a/selfdrive/debug/dump_car_info.py b/selfdrive/debug/dump_car_info.py index c9a21c2848..6af328926b 100755 --- a/selfdrive/debug/dump_car_info.py +++ b/selfdrive/debug/dump_car_info.py @@ -2,7 +2,7 @@ import argparse import pickle -from selfdrive.car.docs import get_all_car_info +from openpilot.selfdrive.car.docs import get_all_car_info def dump_car_info(path): diff --git a/selfdrive/debug/filter_log_message.py b/selfdrive/debug/filter_log_message.py index 8d9ce8e6a2..20cef0fcc0 100755 --- a/selfdrive/debug/filter_log_message.py +++ b/selfdrive/debug/filter_log_message.py @@ -4,8 +4,8 @@ import argparse import json import cereal.messaging as messaging -from tools.lib.logreader import LogReader -from tools.lib.route import Route +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route LEVELS = { "DEBUG": 10, diff --git a/selfdrive/debug/fingerprint_from_route.py b/selfdrive/debug/fingerprint_from_route.py index b3598b105c..c2bff7c638 100755 --- a/selfdrive/debug/fingerprint_from_route.py +++ b/selfdrive/debug/fingerprint_from_route.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 import sys -from tools.lib.route import Route -from tools.lib.logreader import MultiLogIterator +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.logreader import MultiLogIterator def get_fingerprint(lr): diff --git a/selfdrive/debug/internal/fuzz_fw_fingerprint.py b/selfdrive/debug/internal/fuzz_fw_fingerprint.py index 8209bbf4ce..aedb3ada1d 100755 --- a/selfdrive/debug/internal/fuzz_fw_fingerprint.py +++ b/selfdrive/debug/internal/fuzz_fw_fingerprint.py @@ -5,11 +5,11 @@ from collections import defaultdict from tqdm import tqdm -from selfdrive.car.fw_versions import match_fw_to_car_fuzzy -from selfdrive.car.toyota.values import FW_VERSIONS as TOYOTA_FW_VERSIONS -from selfdrive.car.honda.values import FW_VERSIONS as HONDA_FW_VERSIONS -from selfdrive.car.hyundai.values import FW_VERSIONS as HYUNDAI_FW_VERSIONS -from selfdrive.car.volkswagen.values import FW_VERSIONS as VW_FW_VERSIONS +from openpilot.selfdrive.car.fw_versions import match_fw_to_car_fuzzy +from openpilot.selfdrive.car.toyota.values import FW_VERSIONS as TOYOTA_FW_VERSIONS +from openpilot.selfdrive.car.honda.values import FW_VERSIONS as HONDA_FW_VERSIONS +from openpilot.selfdrive.car.hyundai.values import FW_VERSIONS as HYUNDAI_FW_VERSIONS +from openpilot.selfdrive.car.volkswagen.values import FW_VERSIONS as VW_FW_VERSIONS FWS = {} diff --git a/selfdrive/debug/internal/qlog_size.py b/selfdrive/debug/internal/qlog_size.py index be9ab5b17e..9b7f369525 100755 --- a/selfdrive/debug/internal/qlog_size.py +++ b/selfdrive/debug/internal/qlog_size.py @@ -6,8 +6,8 @@ from collections import defaultdict import matplotlib.pyplot as plt from cereal.services import service_list -from tools.lib.logreader import LogReader -from tools.lib.route import Route +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route MIN_SIZE = 0.5 # Percent size of total to show as separate entry diff --git a/selfdrive/debug/live_cpu_and_temp.py b/selfdrive/debug/live_cpu_and_temp.py index c35afc474b..06f1be0b00 100755 --- a/selfdrive/debug/live_cpu_and_temp.py +++ b/selfdrive/debug/live_cpu_and_temp.py @@ -4,7 +4,7 @@ import capnp from collections import defaultdict from cereal.messaging import SubMaster -from common.numpy_fast import mean +from openpilot.common.numpy_fast import mean from typing import Optional, Dict def cputime_total(ct): diff --git a/selfdrive/debug/print_docs_diff.py b/selfdrive/debug/print_docs_diff.py index 1cb6c3cdda..8fb6277d3b 100755 --- a/selfdrive/debug/print_docs_diff.py +++ b/selfdrive/debug/print_docs_diff.py @@ -4,8 +4,8 @@ from collections import defaultdict import difflib import pickle -from selfdrive.car.docs import get_all_car_info -from selfdrive.car.docs_definitions import Column +from openpilot.selfdrive.car.docs import get_all_car_info +from openpilot.selfdrive.car.docs_definitions import Column FOOTNOTE_TAG = "{}" STAR_ICON = '' diff --git a/selfdrive/debug/run_process_on_route.py b/selfdrive/debug/run_process_on_route.py index c7a1434975..c7b6250d3f 100755 --- a/selfdrive/debug/run_process_on_route.py +++ b/selfdrive/debug/run_process_on_route.py @@ -2,10 +2,10 @@ import argparse -from selfdrive.test.process_replay.process_replay import CONFIGS, replay_process -from tools.lib.logreader import MultiLogIterator -from tools.lib.route import Route -from tools.lib.helpers import save_log +from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, replay_process +from openpilot.tools.lib.logreader import MultiLogIterator +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.helpers import save_log if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run process on route and create new logs", diff --git a/selfdrive/debug/sensor_data_to_hist.py b/selfdrive/debug/sensor_data_to_hist.py index ceed4b0ec3..73f98b285c 100755 --- a/selfdrive/debug/sensor_data_to_hist.py +++ b/selfdrive/debug/sensor_data_to_hist.py @@ -10,8 +10,8 @@ import sys import numpy as np from collections import defaultdict -from tools.lib.logreader import LogReader -from tools.lib.route import Route +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route import matplotlib.pyplot as plt diff --git a/selfdrive/debug/set_car_params.py b/selfdrive/debug/set_car_params.py index 24258db9f2..6060dfbc36 100755 --- a/selfdrive/debug/set_car_params.py +++ b/selfdrive/debug/set_car_params.py @@ -2,9 +2,9 @@ import sys from cereal import car -from common.params import Params -from tools.lib.route import Route -from tools.lib.logreader import LogReader +from openpilot.common.params import Params +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.logreader import LogReader if __name__ == "__main__": CP = None diff --git a/selfdrive/debug/show_matching_cars.py b/selfdrive/debug/show_matching_cars.py index a97c41f128..19144ead7e 100755 --- a/selfdrive/debug/show_matching_cars.py +++ b/selfdrive/debug/show_matching_cars.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars +from openpilot.selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars import cereal.messaging as messaging diff --git a/selfdrive/debug/test_car_model.py b/selfdrive/debug/test_car_model.py index 3f7a1a167b..66fe2ea65f 100755 --- a/selfdrive/debug/test_car_model.py +++ b/selfdrive/debug/test_car_model.py @@ -4,9 +4,9 @@ import sys from typing import List import unittest -from selfdrive.car.tests.routes import CarTestRoute -from selfdrive.car.tests.test_models import TestCarModel -from tools.lib.route import SegmentName +from openpilot.selfdrive.car.tests.routes import CarTestRoute +from openpilot.selfdrive.car.tests.test_models import TestCarModel +from openpilot.tools.lib.route import SegmentName def create_test_models_suite(routes: List[CarTestRoute], ci=False) -> unittest.TestSuite: diff --git a/selfdrive/debug/test_fw_query_on_routes.py b/selfdrive/debug/test_fw_query_on_routes.py index 51cd426315..83e173244e 100755 --- a/selfdrive/debug/test_fw_query_on_routes.py +++ b/selfdrive/debug/test_fw_query_on_routes.py @@ -6,10 +6,10 @@ import argparse import os import traceback from tqdm import tqdm -from tools.lib.logreader import LogReader -from tools.lib.route import Route -from selfdrive.car.car_helpers import interface_names -from selfdrive.car.fw_versions import VERSIONS, match_fw_to_car +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route +from openpilot.selfdrive.car.car_helpers import interface_names +from openpilot.selfdrive.car.fw_versions import VERSIONS, match_fw_to_car NO_API = "NO_API" in os.environ diff --git a/selfdrive/debug/toyota_eps_factor.py b/selfdrive/debug/toyota_eps_factor.py index 0a459bb719..e1156c05aa 100755 --- a/selfdrive/debug/toyota_eps_factor.py +++ b/selfdrive/debug/toyota_eps_factor.py @@ -3,10 +3,10 @@ import sys import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model # pylint: disable=import-error -from selfdrive.car.toyota.values import STEER_THRESHOLD +from openpilot.selfdrive.car.toyota.values import STEER_THRESHOLD -from tools.lib.route import Route -from tools.lib.logreader import MultiLogIterator +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.logreader import MultiLogIterator MIN_SAMPLES = 30 * 100 diff --git a/selfdrive/debug/uiview.py b/selfdrive/debug/uiview.py index 93d901f7c9..f4440a912c 100755 --- a/selfdrive/debug/uiview.py +++ b/selfdrive/debug/uiview.py @@ -2,8 +2,8 @@ import time from cereal import car, log, messaging -from common.params import Params -from selfdrive.manager.process_config import managed_processes +from openpilot.common.params import Params +from openpilot.selfdrive.manager.process_config import managed_processes if __name__ == "__main__": CP = car.CarParams(notCar=True) diff --git a/selfdrive/locationd/calibrationd.py b/selfdrive/locationd/calibrationd.py index 7f8fd03b98..6469ece402 100755 --- a/selfdrive/locationd/calibrationd.py +++ b/selfdrive/locationd/calibrationd.py @@ -14,11 +14,11 @@ from typing import List, NoReturn, Optional from cereal import log import cereal.messaging as messaging -from common.conversions import Conversions as CV -from common.params import Params, put_nonblocking -from common.realtime import set_realtime_priority -from common.transformations.orientation import rot_from_euler, euler_from_rot -from system.swaglog import cloudlog +from openpilot.common.conversions import Conversions as CV +from openpilot.common.params import Params, put_nonblocking +from openpilot.common.realtime import set_realtime_priority +from openpilot.common.transformations.orientation import rot_from_euler, euler_from_rot +from openpilot.system.swaglog import cloudlog MIN_SPEED_FILTER = 15 * CV.MPH_TO_MS MAX_VEL_ANGLE_STD = np.radians(0.25) diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index e4a408d130..2073813363 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -11,7 +11,7 @@ from typing import List, Optional, Dict, Any import numpy as np from cereal import log, messaging -from common.params import Params, put_nonblocking +from openpilot.common.params import Params, put_nonblocking from laika import AstroDog from laika.constants import SECS_IN_HR, SECS_IN_MIN from laika.downloader import DownloadFailed @@ -20,10 +20,10 @@ from laika.gps_time import GPSTime from laika.helpers import ConstellationId, get_sv_id from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox, read_raw_qcom from laika.opt import calc_pos_fix, get_posfix_sympy_fun, calc_vel_fix, get_velfix_sympy_func -from selfdrive.locationd.models.constants import GENERATED_DIR, ObservationKind -from selfdrive.locationd.models.gnss_kf import GNSSKalman -from selfdrive.locationd.models.gnss_kf import States as GStates -from system.swaglog import cloudlog +from openpilot.selfdrive.locationd.models.constants import GENERATED_DIR, ObservationKind +from openpilot.selfdrive.locationd.models.gnss_kf import GNSSKalman +from openpilot.selfdrive.locationd.models.gnss_kf import States as GStates +from openpilot.system.swaglog import cloudlog MAX_TIME_GAP = 10 EPHEMERIS_CACHE = 'LaikadEphemerisV3' diff --git a/selfdrive/locationd/models/car_kf.py b/selfdrive/locationd/models/car_kf.py index a5abf8514a..6c02257a1f 100755 --- a/selfdrive/locationd/models/car_kf.py +++ b/selfdrive/locationd/models/car_kf.py @@ -5,9 +5,9 @@ from typing import Any, Dict import numpy as np -from selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY -from selfdrive.locationd.models.constants import ObservationKind -from system.swaglog import cloudlog +from openpilot.selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY +from openpilot.selfdrive.locationd.models.constants import ObservationKind +from openpilot.system.swaglog import cloudlog from rednose.helpers.kalmanfilter import KalmanFilter diff --git a/selfdrive/locationd/models/gnss_kf.py b/selfdrive/locationd/models/gnss_kf.py index 0d661dc321..f98434c909 100755 --- a/selfdrive/locationd/models/gnss_kf.py +++ b/selfdrive/locationd/models/gnss_kf.py @@ -4,8 +4,8 @@ from typing import List import numpy as np -from selfdrive.locationd.models.constants import ObservationKind -from selfdrive.locationd.models.gnss_helpers import parse_pr, parse_prr +from openpilot.selfdrive.locationd.models.constants import ObservationKind +from openpilot.selfdrive.locationd.models.gnss_helpers import parse_pr, parse_prr if __name__ == '__main__': # Generating sympy import sympy as sp diff --git a/selfdrive/locationd/models/lane_kf.py b/selfdrive/locationd/models/lane_kf.py index 4d38fa8e09..e8fa999956 100755 --- a/selfdrive/locationd/models/lane_kf.py +++ b/selfdrive/locationd/models/lane_kf.py @@ -3,7 +3,7 @@ import sys import numpy as np import sympy as sp -from selfdrive.locationd.models.constants import ObservationKind +from openpilot.selfdrive.locationd.models.constants import ObservationKind from rednose.helpers.ekf_sym import gen_code, EKF_sym diff --git a/selfdrive/locationd/models/live_kf.py b/selfdrive/locationd/models/live_kf.py index dc439c23f6..c4933a6129 100755 --- a/selfdrive/locationd/models/live_kf.py +++ b/selfdrive/locationd/models/live_kf.py @@ -4,7 +4,7 @@ import sys import os import numpy as np -from selfdrive.locationd.models.constants import ObservationKind +from openpilot.selfdrive.locationd.models.constants import ObservationKind import sympy as sp import inspect diff --git a/selfdrive/locationd/models/loc_kf.py b/selfdrive/locationd/models/loc_kf.py index d865509e95..8bd317bd58 100755 --- a/selfdrive/locationd/models/loc_kf.py +++ b/selfdrive/locationd/models/loc_kf.py @@ -9,8 +9,8 @@ from rednose.helpers.ekf_sym import EKF_sym, gen_code from rednose.helpers.lst_sq_computer import LstSqComputer from rednose.helpers.sympy_helpers import euler_rotate, quat_matrix_r, quat_rotate -from selfdrive.locationd.models.constants import ObservationKind -from selfdrive.locationd.models.gnss_helpers import parse_pr, parse_prr +from openpilot.selfdrive.locationd.models.constants import ObservationKind +from openpilot.selfdrive.locationd.models.gnss_helpers import parse_pr, parse_prr EARTH_GM = 3.986005e14 # m^3/s^2 (gravitational constant * mass of earth) diff --git a/selfdrive/locationd/paramsd.py b/selfdrive/locationd/paramsd.py index 1644ceaf92..55ad62145e 100755 --- a/selfdrive/locationd/paramsd.py +++ b/selfdrive/locationd/paramsd.py @@ -7,12 +7,12 @@ import numpy as np import cereal.messaging as messaging from cereal import car from cereal import log -from common.params import Params, put_nonblocking -from common.realtime import config_realtime_process, DT_MDL -from common.numpy_fast import clip -from selfdrive.locationd.models.car_kf import CarKalman, ObservationKind, States -from selfdrive.locationd.models.constants import GENERATED_DIR -from system.swaglog import cloudlog +from openpilot.common.params import Params, put_nonblocking +from openpilot.common.realtime import config_realtime_process, DT_MDL +from openpilot.common.numpy_fast import clip +from openpilot.selfdrive.locationd.models.car_kf import CarKalman, ObservationKind, States +from openpilot.selfdrive.locationd.models.constants import GENERATED_DIR +from openpilot.system.swaglog import cloudlog MAX_ANGLE_OFFSET_DELTA = 20 * DT_MDL # Max 20 deg/s diff --git a/selfdrive/locationd/test/_test_locationd_lib.py b/selfdrive/locationd/test/_test_locationd_lib.py index 97207908e7..bf4fcbdbe9 100755 --- a/selfdrive/locationd/test/_test_locationd_lib.py +++ b/selfdrive/locationd/test/_test_locationd_lib.py @@ -10,7 +10,7 @@ from cffi import FFI import cereal.messaging as messaging from cereal import log -from common.ffi_wrapper import suffix +from openpilot.common.ffi_wrapper import suffix SENSOR_DECIMATION = 1 VISION_DECIMATION = 1 diff --git a/selfdrive/locationd/test/test_calibrationd.py b/selfdrive/locationd/test/test_calibrationd.py index e3e8c3ca7c..a5eedaf99a 100755 --- a/selfdrive/locationd/test/test_calibrationd.py +++ b/selfdrive/locationd/test/test_calibrationd.py @@ -6,8 +6,8 @@ import numpy as np import cereal.messaging as messaging from cereal import log -from common.params import Params -from selfdrive.locationd.calibrationd import Calibrator, INPUTS_NEEDED, INPUTS_WANTED, BLOCK_SIZE, MIN_SPEED_FILTER, \ +from openpilot.common.params import Params +from openpilot.selfdrive.locationd.calibrationd import Calibrator, INPUTS_NEEDED, INPUTS_WANTED, BLOCK_SIZE, MIN_SPEED_FILTER, \ MAX_YAW_RATE_FILTER, SMOOTH_CYCLES, HEIGHT_INIT diff --git a/selfdrive/locationd/test/test_laikad.py b/selfdrive/locationd/test/test_laikad.py index c90095cdca..58c650e26c 100755 --- a/selfdrive/locationd/test/test_laikad.py +++ b/selfdrive/locationd/test/test_laikad.py @@ -2,7 +2,7 @@ import time import unittest from cereal import log -from common.params import Params +from openpilot.common.params import Params from datetime import datetime from unittest import mock @@ -13,11 +13,11 @@ from laika.ephemeris import EphemerisType from laika.gps_time import GPSTime from laika.helpers import ConstellationId from laika.raw_gnss import GNSSMeasurement, read_raw_ublox, read_raw_qcom -from selfdrive.locationd.laikad import EPHEMERIS_CACHE, Laikad -from selfdrive.test.openpilotci import get_url -from tools.lib.logreader import LogReader +from openpilot.selfdrive.locationd.laikad import EPHEMERIS_CACHE, Laikad +from openpilot.selfdrive.test.openpilotci import get_url +from openpilot.tools.lib.logreader import LogReader -from selfdrive.test.process_replay.process_replay import get_process_config, replay_process +from openpilot.selfdrive.test.process_replay.process_replay import get_process_config, replay_process GPS_TIME_PREDICTION_ORBITS_RUSSIAN_SRC = GPSTime.from_datetime(datetime(2022, month=1, day=29, hour=12)) UBLOX_TEST_ROUTE = "4cf7a6ad03080c90|2021-09-29--13-46-36" diff --git a/selfdrive/locationd/test/test_locationd.py b/selfdrive/locationd/test/test_locationd.py index 96233f5320..6c6ac33431 100755 --- a/selfdrive/locationd/test/test_locationd.py +++ b/selfdrive/locationd/test/test_locationd.py @@ -7,10 +7,10 @@ import capnp import cereal.messaging as messaging from cereal.services import service_list -from common.params import Params -from common.transformations.coordinates import ecef2geodetic +from openpilot.common.params import Params +from openpilot.common.transformations.coordinates import ecef2geodetic -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes class TestLocationdProc(unittest.TestCase): diff --git a/selfdrive/locationd/torqued.py b/selfdrive/locationd/torqued.py index 2bac2a8988..ddb95e944c 100755 --- a/selfdrive/locationd/torqued.py +++ b/selfdrive/locationd/torqued.py @@ -7,11 +7,11 @@ from collections import deque, defaultdict import cereal.messaging as messaging from cereal import car, log -from common.params import Params -from common.realtime import config_realtime_process, DT_MDL -from common.filter_simple import FirstOrderFilter -from system.swaglog import cloudlog -from selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY +from openpilot.common.params import Params +from openpilot.common.realtime import config_realtime_process, DT_MDL +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY HISTORY = 5 # secs POINTS_PER_BUCKET = 1500 diff --git a/selfdrive/manager/build.py b/selfdrive/manager/build.py index 26003cd1de..c877e6ed97 100755 --- a/selfdrive/manager/build.py +++ b/selfdrive/manager/build.py @@ -5,12 +5,12 @@ import textwrap from pathlib import Path # NOTE: Do NOT import anything here that needs be built (e.g. params) -from common.basedir import BASEDIR -from common.spinner import Spinner -from common.text_window import TextWindow -from system.hardware import AGNOS -from system.swaglog import cloudlog, add_file_handler -from system.version import is_dirty +from openpilot.common.basedir import BASEDIR +from openpilot.common.spinner import Spinner +from openpilot.common.text_window import TextWindow +from openpilot.system.hardware import AGNOS +from openpilot.system.swaglog import cloudlog, add_file_handler +from openpilot.system.version import is_dirty MAX_CACHE_SIZE = 4e9 if "CI" in os.environ else 2e9 CACHE_DIR = Path("/data/scons_cache" if AGNOS else "/tmp/scons_cache") diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index e9a1b2cb5b..a739437de7 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -9,18 +9,18 @@ from typing import List, Tuple, Union from cereal import log import cereal.messaging as messaging -import selfdrive.sentry as sentry -from common.basedir import BASEDIR -from common.params import Params, ParamKeyType -from common.text_window import TextWindow -from selfdrive.boardd.set_time import set_time -from system.hardware import HARDWARE, PC -from selfdrive.manager.helpers import unblock_stdout, write_onroad_params -from selfdrive.manager.process import ensure_running -from selfdrive.manager.process_config import managed_processes -from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID -from system.swaglog import cloudlog, add_file_handler -from system.version import is_dirty, get_commit, get_version, get_origin, get_short_branch, \ +import openpilot.selfdrive.sentry as sentry +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params, ParamKeyType +from openpilot.common.text_window import TextWindow +from openpilot.selfdrive.boardd.set_time import set_time +from openpilot.system.hardware import HARDWARE, PC +from openpilot.selfdrive.manager.helpers import unblock_stdout, write_onroad_params +from openpilot.selfdrive.manager.process import ensure_running +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID +from openpilot.system.swaglog import cloudlog, add_file_handler +from openpilot.system.version import is_dirty, get_commit, get_version, get_origin, get_short_branch, \ get_normalized_origin, terms_version, training_version, \ is_tested_branch, is_release_branch diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index e6c2c52bec..8328f1cee9 100644 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -10,13 +10,12 @@ from multiprocessing import Process from setproctitle import setproctitle # pylint: disable=no-name-in-module +from cereal import car, log import cereal.messaging as messaging -import selfdrive.sentry as sentry -from cereal import car -from common.basedir import BASEDIR -from common.params import Params -from system.swaglog import cloudlog -from cereal import log +import openpilot.selfdrive.sentry as sentry +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params +from openpilot.system.swaglog import cloudlog WATCHDOG_FN = "/dev/shm/wd_" ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py index 7cd1ed9489..936dff883b 100644 --- a/selfdrive/manager/process_config.py +++ b/selfdrive/manager/process_config.py @@ -1,9 +1,9 @@ import os from cereal import car -from common.params import Params -from system.hardware import PC, TICI -from selfdrive.manager.process import PythonProcess, NativeProcess, DaemonProcess +from openpilot.common.params import Params +from openpilot.system.hardware import PC, TICI +from openpilot.selfdrive.manager.process import PythonProcess, NativeProcess, DaemonProcess WEBCAM = os.getenv("USE_WEBCAM") is not None diff --git a/selfdrive/manager/test/test_manager.py b/selfdrive/manager/test/test_manager.py index 39bda1e156..8ae872d3df 100755 --- a/selfdrive/manager/test/test_manager.py +++ b/selfdrive/manager/test/test_manager.py @@ -5,11 +5,11 @@ import time import unittest from cereal import car -from common.params import Params -import selfdrive.manager.manager as manager -from selfdrive.manager.process import ensure_running -from selfdrive.manager.process_config import managed_processes -from system.hardware import HARDWARE +from openpilot.common.params import Params +import openpilot.selfdrive.manager.manager as manager +from openpilot.selfdrive.manager.process import ensure_running +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.hardware import HARDWARE os.environ['FAKEUPLOAD'] = "1" diff --git a/selfdrive/modeld/modeld.cc b/selfdrive/modeld/modeld.cc index f19138b179..d1769c4bec 100644 --- a/selfdrive/modeld/modeld.cc +++ b/selfdrive/modeld/modeld.cc @@ -23,7 +23,7 @@ ExitHandler do_exit; mat3 update_calibration(Eigen::Vector3d device_from_calib_euler, bool wide_camera, bool bigmodel_frame) { /* import numpy as np - from common.transformations.model import medmodel_frame_from_calib_frame + from openpilot.common.transformations.model import medmodel_frame_from_calib_frame medmodel_frame_from_calib_frame = medmodel_frame_from_calib_frame[:, :3] calib_from_smedmodel_frame = np.linalg.inv(medmodel_frame_from_calib_frame) */ diff --git a/selfdrive/modeld/tests/test_modeld.py b/selfdrive/modeld/tests/test_modeld.py index 758948811e..c3d3b3daa1 100755 --- a/selfdrive/modeld/tests/test_modeld.py +++ b/selfdrive/modeld/tests/test_modeld.py @@ -6,10 +6,10 @@ import random import cereal.messaging as messaging from cereal.visionipc import VisionIpcServer, VisionStreamType -from common.transformations.camera import tici_f_frame_size -from common.realtime import DT_MDL -from selfdrive.manager.process_config import managed_processes -from selfdrive.test.process_replay.vision_meta import meta_from_camera_state +from openpilot.common.transformations.camera import tici_f_frame_size +from openpilot.common.realtime import DT_MDL +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.test.process_replay.vision_meta import meta_from_camera_state IMG = np.zeros(int(tici_f_frame_size[0]*tici_f_frame_size[1]*(3/2)), dtype=np.uint8) IMG_BYTES = IMG.flatten().tobytes() diff --git a/selfdrive/modeld/tests/timing/benchmark.py b/selfdrive/modeld/tests/timing/benchmark.py index f4fddaab40..1463342a6a 100755 --- a/selfdrive/modeld/tests/timing/benchmark.py +++ b/selfdrive/modeld/tests/timing/benchmark.py @@ -7,7 +7,7 @@ import time import numpy as np import cereal.messaging as messaging -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes N = int(os.getenv("N", "5")) diff --git a/selfdrive/monitoring/dmonitoringd.py b/selfdrive/monitoring/dmonitoringd.py index 836ed9cc4f..c7cff88f3e 100755 --- a/selfdrive/monitoring/dmonitoringd.py +++ b/selfdrive/monitoring/dmonitoringd.py @@ -4,10 +4,10 @@ import gc import cereal.messaging as messaging from cereal import car from cereal import log -from common.params import Params, put_bool_nonblocking -from common.realtime import set_realtime_priority -from selfdrive.controls.lib.events import Events -from selfdrive.monitoring.driver_monitor import DriverStatus +from openpilot.common.params import Params, put_bool_nonblocking +from openpilot.common.realtime import set_realtime_priority +from openpilot.selfdrive.controls.lib.events import Events +from openpilot.selfdrive.monitoring.driver_monitor import DriverStatus def dmonitoringd_thread(sm=None, pm=None): diff --git a/selfdrive/monitoring/driver_monitor.py b/selfdrive/monitoring/driver_monitor.py index 97407e25eb..ab82da301f 100644 --- a/selfdrive/monitoring/driver_monitor.py +++ b/selfdrive/monitoring/driver_monitor.py @@ -1,11 +1,11 @@ from math import atan2 from cereal import car -from common.numpy_fast import interp -from common.realtime import DT_DMON -from common.filter_simple import FirstOrderFilter -from common.stat_live import RunningStatFilter -from common.transformations.camera import tici_d_frame_size +from openpilot.common.numpy_fast import interp +from openpilot.common.realtime import DT_DMON +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.common.stat_live import RunningStatFilter +from openpilot.common.transformations.camera import tici_d_frame_size EventName = car.CarEvent.EventName diff --git a/selfdrive/monitoring/test_monitoring.py b/selfdrive/monitoring/test_monitoring.py index 98d3f43f12..b1011fb306 100755 --- a/selfdrive/monitoring/test_monitoring.py +++ b/selfdrive/monitoring/test_monitoring.py @@ -3,9 +3,9 @@ import unittest import numpy as np from cereal import car, log -from common.realtime import DT_DMON -from selfdrive.controls.lib.events import Events -from selfdrive.monitoring.driver_monitor import DriverStatus, DRIVER_MONITOR_SETTINGS +from openpilot.common.realtime import DT_DMON +from openpilot.selfdrive.controls.lib.events import Events +from openpilot.selfdrive.monitoring.driver_monitor import DriverStatus, DRIVER_MONITOR_SETTINGS EventName = car.CarEvent.EventName dm_settings = DRIVER_MONITOR_SETTINGS() diff --git a/selfdrive/navd/helpers.py b/selfdrive/navd/helpers.py index 5957816334..55c3f88a9a 100644 --- a/selfdrive/navd/helpers.py +++ b/selfdrive/navd/helpers.py @@ -4,9 +4,9 @@ import json import math from typing import Any, Dict, List, Optional, Tuple, Union, cast -from common.conversions import Conversions -from common.numpy_fast import clip -from common.params import Params +from openpilot.common.conversions import Conversions +from openpilot.common.numpy_fast import clip +from openpilot.common.params import Params DIRECTIONS = ('left', 'right', 'straight') MODIFIABLE_DIRECTIONS = ('left', 'right') diff --git a/selfdrive/navd/map_renderer.py b/selfdrive/navd/map_renderer.py index 57d5e0593c..8d525ac73e 100755 --- a/selfdrive/navd/map_renderer.py +++ b/selfdrive/navd/map_renderer.py @@ -7,8 +7,8 @@ import numpy as np import polyline from cffi import FFI -from common.ffi_wrapper import suffix -from common.basedir import BASEDIR +from openpilot.common.ffi_wrapper import suffix +from openpilot.common.basedir import BASEDIR HEIGHT = WIDTH = SIZE = 256 METERS_PER_PIXEL = 2 diff --git a/selfdrive/navd/navd.py b/selfdrive/navd/navd.py index 3a8897e8e2..6a6a0846b7 100755 --- a/selfdrive/navd/navd.py +++ b/selfdrive/navd/navd.py @@ -9,15 +9,15 @@ import numpy as np import cereal.messaging as messaging from cereal import log -from common.api import Api -from common.params import Params -from common.realtime import Ratekeeper -from common.transformations.coordinates import ecef2geodetic -from selfdrive.navd.helpers import (Coordinate, coordinate_from_param, +from openpilot.common.api import Api +from openpilot.common.params import Params +from openpilot.common.realtime import Ratekeeper +from openpilot.common.transformations.coordinates import ecef2geodetic +from openpilot.selfdrive.navd.helpers import (Coordinate, coordinate_from_param, distance_along_geometry, maxspeed_to_ms, minimum_distance, parse_banner_instructions) -from system.swaglog import cloudlog +from openpilot.system.swaglog import cloudlog REROUTE_DISTANCE = 25 MANEUVER_TRANSITION_THRESHOLD = 10 diff --git a/selfdrive/navd/set_destination.py b/selfdrive/navd/set_destination.py index e6158dbdee..811aa576d1 100755 --- a/selfdrive/navd/set_destination.py +++ b/selfdrive/navd/set_destination.py @@ -2,7 +2,7 @@ import json import sys -from common.params import Params +from openpilot.common.params import Params if __name__ == "__main__": params = Params() diff --git a/selfdrive/navd/tests/test_map_renderer.py b/selfdrive/navd/tests/test_map_renderer.py index e3eda8bdef..1c3d8acd7f 100755 --- a/selfdrive/navd/tests/test_map_renderer.py +++ b/selfdrive/navd/tests/test_map_renderer.py @@ -8,7 +8,7 @@ import cereal.messaging as messaging from typing import Any from cereal.visionipc import VisionIpcClient, VisionStreamType -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes LLK_DECIMATION = 10 CACHE_PATH = "/data/mbgl-cache-navd.db" diff --git a/selfdrive/rtshield.py b/selfdrive/rtshield.py index 45571fe2db..68dc4989cd 100755 --- a/selfdrive/rtshield.py +++ b/selfdrive/rtshield.py @@ -3,7 +3,7 @@ import os import time from typing import NoReturn -from common.realtime import set_core_affinity, set_realtime_priority +from openpilot.common.realtime import set_core_affinity, set_realtime_priority # RT shield - ensure CPU 3 always remains available for RT processes # runs as SCHED_FIFO with minimum priority to ensure kthreads don't diff --git a/selfdrive/sentry.py b/selfdrive/sentry.py index aa409ea394..02d9d17550 100644 --- a/selfdrive/sentry.py +++ b/selfdrive/sentry.py @@ -3,11 +3,11 @@ import sentry_sdk from enum import Enum from sentry_sdk.integrations.threading import ThreadingIntegration -from common.params import Params -from selfdrive.athena.registration import is_registered_device -from system.hardware import HARDWARE, PC -from system.swaglog import cloudlog -from system.version import get_branch, get_commit, get_origin, get_version, \ +from openpilot.common.params import Params +from openpilot.selfdrive.athena.registration import is_registered_device +from openpilot.system.hardware import HARDWARE, PC +from openpilot.system.swaglog import cloudlog +from openpilot.system.version import get_branch, get_commit, get_origin, get_version, \ is_comma_remote, is_dirty, is_tested_branch diff --git a/selfdrive/statsd.py b/selfdrive/statsd.py index a444a62312..8acf406515 100755 --- a/selfdrive/statsd.py +++ b/selfdrive/statsd.py @@ -7,13 +7,13 @@ from collections import defaultdict from datetime import datetime, timezone from typing import NoReturn, Union, List, Dict -from common.params import Params +from openpilot.common.params import Params from cereal.messaging import SubMaster -from system.swaglog import cloudlog -from system.hardware import HARDWARE -from common.file_helpers import atomic_write_in_dir -from system.version import get_normalized_origin, get_short_branch, get_short_version, is_dirty -from system.loggerd.config import STATS_DIR, STATS_DIR_FILE_LIMIT, STATS_SOCKET, STATS_FLUSH_TIME_S +from openpilot.system.swaglog import cloudlog +from openpilot.system.hardware import HARDWARE +from openpilot.common.file_helpers import atomic_write_in_dir +from openpilot.system.version import get_normalized_origin, get_short_branch, get_short_version, is_dirty +from openpilot.system.loggerd.config import STATS_DIR, STATS_DIR_FILE_LIMIT, STATS_SOCKET, STATS_FLUSH_TIME_S class METRIC_TYPE: diff --git a/selfdrive/test/ciui.py b/selfdrive/test/ciui.py index 291f9f6e44..ba55f3af24 100755 --- a/selfdrive/test/ciui.py +++ b/selfdrive/test/ciui.py @@ -7,7 +7,7 @@ signal.signal(signal.SIGTERM, signal.SIG_DFL) from PyQt5.QtCore import QTimer # pylint: disable=no-name-in-module, import-error from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel # pylint: disable=no-name-in-module, import-error -from selfdrive.ui.qt.python_helpers import set_main_window +from openpilot.selfdrive.ui.qt.python_helpers import set_main_window class Window(QWidget): def __init__(self, parent=None): diff --git a/selfdrive/test/helpers.py b/selfdrive/test/helpers.py index f7dab576f3..f5ba67b407 100644 --- a/selfdrive/test/helpers.py +++ b/selfdrive/test/helpers.py @@ -3,10 +3,10 @@ import time from functools import wraps import cereal.messaging as messaging -from common.params import Params -from selfdrive.manager.process_config import managed_processes -from system.hardware import PC -from system.version import training_version, terms_version +from openpilot.common.params import Params +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.hardware import PC +from openpilot.system.version import training_version, terms_version def set_params_enabled(): diff --git a/selfdrive/test/longitudinal_maneuvers/maneuver.py b/selfdrive/test/longitudinal_maneuvers/maneuver.py index 00ddfe627e..000225ab77 100644 --- a/selfdrive/test/longitudinal_maneuvers/maneuver.py +++ b/selfdrive/test/longitudinal_maneuvers/maneuver.py @@ -1,5 +1,5 @@ import numpy as np -from selfdrive.test.longitudinal_maneuvers.plant import Plant +from openpilot.selfdrive.test.longitudinal_maneuvers.plant import Plant class Maneuver: diff --git a/selfdrive/test/longitudinal_maneuvers/plant.py b/selfdrive/test/longitudinal_maneuvers/plant.py index 541f7d8747..9373eb6d89 100755 --- a/selfdrive/test/longitudinal_maneuvers/plant.py +++ b/selfdrive/test/longitudinal_maneuvers/plant.py @@ -4,11 +4,11 @@ import numpy as np from cereal import log import cereal.messaging as messaging -from common.realtime import Ratekeeper, DT_MDL -from selfdrive.controls.lib.longcontrol import LongCtrlState -from selfdrive.modeld.constants import T_IDXS -from selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner -from selfdrive.controls.radard import _LEAD_ACCEL_TAU +from openpilot.common.realtime import Ratekeeper, DT_MDL +from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState +from openpilot.selfdrive.modeld.constants import T_IDXS +from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner +from openpilot.selfdrive.controls.radard import _LEAD_ACCEL_TAU class Plant: @@ -46,8 +46,8 @@ class Plant: time.sleep(1) self.sm = messaging.SubMaster(['longitudinalPlan']) - from selfdrive.car.honda.values import CAR - from selfdrive.car.honda.interface import CarInterface + from openpilot.selfdrive.car.honda.values import CAR + from openpilot.selfdrive.car.honda.interface import CarInterface self.planner = LongitudinalPlanner(CarInterface.get_non_essential_params(CAR.CIVIC), init_v=self.speed) diff --git a/selfdrive/test/longitudinal_maneuvers/test_longitudinal.py b/selfdrive/test/longitudinal_maneuvers/test_longitudinal.py index bc477ca9fe..a3b307ccba 100755 --- a/selfdrive/test/longitudinal_maneuvers/test_longitudinal.py +++ b/selfdrive/test/longitudinal_maneuvers/test_longitudinal.py @@ -4,9 +4,9 @@ import os from parameterized import parameterized_class import unittest -from common.params import Params -from selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import STOP_DISTANCE -from selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver +from openpilot.common.params import Params +from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import STOP_DISTANCE +from openpilot.selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver # TODO: make new FCW tests diff --git a/selfdrive/test/process_replay/README.md b/selfdrive/test/process_replay/README.md index d1743ac539..1174dbab83 100644 --- a/selfdrive/test/process_replay/README.md +++ b/selfdrive/test/process_replay/README.md @@ -62,8 +62,8 @@ def replay_process( Example usage: ```py -from selfdrive.test.process_replay import replay_process_with_name -from tools.lib.logreader import LogReader +from openpilot.selfdrive.test.process_replay import replay_process_with_name +from openpilot.tools.lib.logreader import LogReader lr = LogReader(...) @@ -91,7 +91,7 @@ Supported processes: Certain processes may require an initial state, which is usually supplied within `Params` and persisting from segment to segment (e.g CalibrationParams, LiveParameters). The `custom_params` is dictionary used to prepopulate `Params` with arbitrary values. The `get_custom_params_from_lr` helper is provided to fetch meaningful values from log files. ```py -from selfdrive.test.process_replay import get_custom_params_from_lr +from openpilot.selfdrive.test.process_replay import get_custom_params_from_lr previous_segment_lr = LogReader(...) current_segment_lr = LogReader(...) @@ -104,7 +104,7 @@ output_logs = replay_process_with_name('calibrationd', lr, custom_params=custom_ Replaying processes that use VisionIPC (e.g. modeld, dmonitoringmodeld) require additional `frs` dictionary with camera states as keys and `FrameReader` objects as values. ```py -from tools.lib.framereader import FrameReader +from openpilot.tools.lib.framereader import FrameReader frs = { 'roadCameraState': FrameReader(...), @@ -125,4 +125,4 @@ output_logs = replay_process_with_name(['radard', 'plannerd'], lr, captured_outp # entries with captured output in format { 'out': '...', 'err': '...' } will be added to provided dictionary for each replayed process print(output_store['radard']['out']) # radard stdout print(output_store['radard']['err']) # radard stderr -``` \ No newline at end of file +``` diff --git a/selfdrive/test/process_replay/__init__.py b/selfdrive/test/process_replay/__init__.py index a872c310d7..b994277186 100644 --- a/selfdrive/test/process_replay/__init__.py +++ b/selfdrive/test/process_replay/__init__.py @@ -1,2 +1,2 @@ -from selfdrive.test.process_replay.process_replay import CONFIGS, get_process_config, get_custom_params_from_lr, \ +from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, get_process_config, get_custom_params_from_lr, \ replay_process, replay_process_with_name # noqa: F401 diff --git a/selfdrive/test/process_replay/compare_logs.py b/selfdrive/test/process_replay/compare_logs.py index a2a355805b..7de0a25761 100755 --- a/selfdrive/test/process_replay/compare_logs.py +++ b/selfdrive/test/process_replay/compare_logs.py @@ -6,7 +6,7 @@ import numbers import dictdiffer from collections import Counter -from tools.lib.logreader import LogReader +from openpilot.tools.lib.logreader import LogReader EPSILON = sys.float_info.epsilon diff --git a/selfdrive/test/process_replay/helpers.py b/selfdrive/test/process_replay/helpers.py index 5cf1acfa59..0af8ff6c76 100644 --- a/selfdrive/test/process_replay/helpers.py +++ b/selfdrive/test/process_replay/helpers.py @@ -4,7 +4,7 @@ import uuid from typing import List, Optional -from common.params import Params +from openpilot.common.params import Params class OpenpilotPrefix(object): def __init__(self, prefix: Optional[str] = None, clean_dirs_on_exit: bool = True): diff --git a/selfdrive/test/process_replay/migration.py b/selfdrive/test/process_replay/migration.py index eb2aba8799..4560a66b97 100644 --- a/selfdrive/test/process_replay/migration.py +++ b/selfdrive/test/process_replay/migration.py @@ -1,7 +1,7 @@ from collections import defaultdict from cereal import messaging -from selfdrive.test.process_replay.vision_meta import meta_from_encode_index +from openpilot.selfdrive.test.process_replay.vision_meta import meta_from_encode_index def migrate_all(lr, old_logtime=False, camera_states=False): diff --git a/selfdrive/test/process_replay/model_replay.py b/selfdrive/test/process_replay/model_replay.py index 56bb3e1b3e..f576e07a40 100755 --- a/selfdrive/test/process_replay/model_replay.py +++ b/selfdrive/test/process_replay/model_replay.py @@ -6,18 +6,18 @@ from collections import defaultdict from typing import Any import cereal.messaging as messaging -from common.params import Params -from common.spinner import Spinner -from system.hardware import PC -from selfdrive.manager.process_config import managed_processes -from selfdrive.test.openpilotci import BASE_URL, get_url -from selfdrive.test.process_replay.compare_logs import compare_logs -from selfdrive.test.process_replay.test_processes import format_diff -from selfdrive.test.process_replay.process_replay import get_process_config, replay_process -from system.version import get_commit -from tools.lib.framereader import FrameReader -from tools.lib.logreader import LogReader -from tools.lib.helpers import save_log +from openpilot.common.params import Params +from openpilot.common.spinner import Spinner +from openpilot.system.hardware import PC +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.test.openpilotci import BASE_URL, get_url +from openpilot.selfdrive.test.process_replay.compare_logs import compare_logs +from openpilot.selfdrive.test.process_replay.test_processes import format_diff +from openpilot.selfdrive.test.process_replay.process_replay import get_process_config, replay_process +from openpilot.system.version import get_commit +from openpilot.tools.lib.framereader import FrameReader +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.helpers import save_log TEST_ROUTE = "2f4452b03ccb98f0|2022-12-03--13-45-30" SEGMENT = 6 @@ -161,7 +161,7 @@ if __name__ == "__main__": import requests import threading import http.server - from selfdrive.test.openpilotci import upload_bytes + from openpilot.selfdrive.test.openpilotci import upload_bytes os.environ['MAPS_HOST'] = 'http://localhost:5000' class HTTPRequestHandler(http.server.BaseHTTPRequestHandler): @@ -244,7 +244,7 @@ if __name__ == "__main__": # upload new refs if (update or failed) and not PC: - from selfdrive.test.openpilotci import upload_file + from openpilot.selfdrive.test.openpilotci import upload_file print("Uploading new refs") diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index eb2c7dad47..9256b6015c 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -16,17 +16,17 @@ import cereal.messaging as messaging from cereal import car from cereal.services import service_list from cereal.visionipc import VisionIpcServer, get_endpoint_name as vipc_get_endpoint_name -from common.params import Params -from common.timeout import Timeout -from common.realtime import DT_CTRL +from openpilot.common.params import Params +from openpilot.common.timeout import Timeout +from openpilot.common.realtime import DT_CTRL from panda.python import ALTERNATIVE_EXPERIENCE -from selfdrive.car.car_helpers import get_car, interfaces -from selfdrive.manager.process_config import managed_processes -from selfdrive.test.process_replay.helpers import OpenpilotPrefix, DummySocket -from selfdrive.test.process_replay.vision_meta import meta_from_camera_state, available_streams -from selfdrive.test.process_replay.migration import migrate_all -from selfdrive.test.process_replay.capture import ProcessOutputCapture -from tools.lib.logreader import LogReader +from openpilot.selfdrive.car.car_helpers import get_car, interfaces +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.test.process_replay.helpers import OpenpilotPrefix, DummySocket +from openpilot.selfdrive.test.process_replay.vision_meta import meta_from_camera_state, available_streams +from openpilot.selfdrive.test.process_replay.migration import migrate_all +from openpilot.selfdrive.test.process_replay.capture import ProcessOutputCapture +from openpilot.tools.lib.logreader import LogReader # Numpy gives different results based on CPU features after version 19 NUMPY_TOLERANCE = 1e-7 diff --git a/selfdrive/test/process_replay/regen.py b/selfdrive/test/process_replay/regen.py index 07d3c04e37..81f27b7d0e 100755 --- a/selfdrive/test/process_replay/regen.py +++ b/selfdrive/test/process_replay/regen.py @@ -6,13 +6,13 @@ import capnp from typing import Union, Iterable, Optional, List, Any, Dict, Tuple -from selfdrive.test.process_replay.process_replay import CONFIGS, FAKEDATA, replay_process, get_process_config, \ +from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, FAKEDATA, replay_process, get_process_config, \ check_openpilot_enabled, get_custom_params_from_lr -from selfdrive.test.update_ci_routes import upload_route -from tools.lib.route import Route -from tools.lib.framereader import FrameReader -from tools.lib.logreader import LogReader -from tools.lib.helpers import save_log +from openpilot.selfdrive.test.update_ci_routes import upload_route +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.framereader import FrameReader +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.helpers import save_log def regen_segment( diff --git a/selfdrive/test/process_replay/regen_all.py b/selfdrive/test/process_replay/regen_all.py index f69d07eb69..f42686ac6a 100755 --- a/selfdrive/test/process_replay/regen_all.py +++ b/selfdrive/test/process_replay/regen_all.py @@ -6,10 +6,10 @@ import random import traceback from tqdm import tqdm -from selfdrive.test.process_replay.helpers import OpenpilotPrefix -from selfdrive.test.process_replay.regen import regen_and_save -from selfdrive.test.process_replay.test_processes import FAKEDATA, source_segments as segments -from tools.lib.route import SegmentName +from openpilot.selfdrive.test.process_replay.helpers import OpenpilotPrefix +from openpilot.selfdrive.test.process_replay.regen import regen_and_save +from openpilot.selfdrive.test.process_replay.test_processes import FAKEDATA, source_segments as segments +from openpilot.tools.lib.route import SegmentName def regen_job(segment, upload, disable_tqdm): diff --git a/selfdrive/test/process_replay/test_debayer.py b/selfdrive/test/process_replay/test_debayer.py index 2ed2be61ac..a6e6955dbf 100755 --- a/selfdrive/test/process_replay/test_debayer.py +++ b/selfdrive/test/process_replay/test_debayer.py @@ -6,13 +6,13 @@ import numpy as np import pyopencl as cl # install with `PYOPENCL_CL_PRETEND_VERSION=2.0 pip install pyopencl` -from system.hardware import PC, TICI -from common.basedir import BASEDIR -from selfdrive.test.openpilotci import BASE_URL, get_url -from system.version import get_commit -from system.camerad.snapshot.snapshot import yuv_to_rgb -from tools.lib.logreader import LogReader -from tools.lib.filereader import FileReader +from openpilot.system.hardware import PC, TICI +from openpilot.common.basedir import BASEDIR +from openpilot.selfdrive.test.openpilotci import BASE_URL, get_url +from openpilot.system.version import get_commit +from openpilot.system.camerad.snapshot.snapshot import yuv_to_rgb +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.filereader import FileReader TEST_ROUTE = "8345e3b82948d454|2022-05-04--13-45-33" SEGMENT = 0 @@ -172,7 +172,7 @@ if __name__ == "__main__": # upload new refs if update or (failed and TICI): - from selfdrive.test.openpilotci import upload_file + from openpilot.selfdrive.test.openpilotci import upload_file print("Uploading new refs") diff --git a/selfdrive/test/process_replay/test_fuzzy.py b/selfdrive/test/process_replay/test_fuzzy.py index c58599caee..f3f48d0159 100755 --- a/selfdrive/test/process_replay/test_fuzzy.py +++ b/selfdrive/test/process_replay/test_fuzzy.py @@ -6,9 +6,9 @@ from parameterized import parameterized import unittest from cereal import log -from selfdrive.car.toyota.values import CAR as TOYOTA -from selfdrive.test.fuzzy_generation import FuzzyGenerator -import selfdrive.test.process_replay.process_replay as pr +from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA +from openpilot.selfdrive.test.fuzzy_generation import FuzzyGenerator +import openpilot.selfdrive.test.process_replay.process_replay as pr # These processes currently fail because of unrealistic data breaking assumptions # that openpilot makes causing error with NaN, inf, int size, array indexing ... diff --git a/selfdrive/test/process_replay/test_processes.py b/selfdrive/test/process_replay/test_processes.py index fe80bc17a5..9c8b5bfcd8 100755 --- a/selfdrive/test/process_replay/test_processes.py +++ b/selfdrive/test/process_replay/test_processes.py @@ -7,14 +7,14 @@ from collections import defaultdict from tqdm import tqdm from typing import Any, DefaultDict, Dict -from selfdrive.car.car_helpers import interface_names -from selfdrive.test.openpilotci import get_url, upload_file -from selfdrive.test.process_replay.compare_logs import compare_logs -from selfdrive.test.process_replay.process_replay import CONFIGS, PROC_REPLAY_DIR, FAKEDATA, check_openpilot_enabled, replay_process -from system.version import get_commit -from tools.lib.filereader import FileReader -from tools.lib.logreader import LogReader -from tools.lib.helpers import save_log +from openpilot.selfdrive.car.car_helpers import interface_names +from openpilot.selfdrive.test.openpilotci import get_url, upload_file +from openpilot.selfdrive.test.process_replay.compare_logs import compare_logs +from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, PROC_REPLAY_DIR, FAKEDATA, check_openpilot_enabled, replay_process +from openpilot.system.version import get_commit +from openpilot.tools.lib.filereader import FileReader +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.helpers import save_log source_segments = [ ("BODY", "937ccb7243511b65|2022-05-24--16-03-09--1"), # COMMA.BODY diff --git a/selfdrive/test/process_replay/vision_meta.py b/selfdrive/test/process_replay/vision_meta.py index 77c6b0345d..2994b77452 100644 --- a/selfdrive/test/process_replay/vision_meta.py +++ b/selfdrive/test/process_replay/vision_meta.py @@ -1,7 +1,7 @@ from collections import namedtuple from cereal.visionipc import VisionStreamType -from common.realtime import DT_MDL, DT_DMON -from common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size, eon_f_frame_size, eon_d_frame_size +from openpilot.common.realtime import DT_MDL, DT_DMON +from openpilot.common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size, eon_f_frame_size, eon_d_frame_size VideoStreamMeta = namedtuple("VideoStreamMeta", ["camera_state", "encode_index", "stream", "dt", "frame_sizes"]) ROAD_CAMERA_FRAME_SIZES = {"tici": tici_f_frame_size, "tizi": tici_f_frame_size, "eon": eon_f_frame_size} diff --git a/selfdrive/test/profiling/profiler.py b/selfdrive/test/profiling/profiler.py index 28e3b34e40..984907b870 100755 --- a/selfdrive/test/profiling/profiler.py +++ b/selfdrive/test/profiling/profiler.py @@ -5,13 +5,13 @@ import cProfile # pylint: disable=import-error import pprofile import pyprof2calltree -from common.params import Params -from tools.lib.logreader import LogReader -from selfdrive.test.profiling.lib import SubMaster, PubMaster, SubSocket, ReplayDone -from selfdrive.test.process_replay.process_replay import CONFIGS -from selfdrive.car.toyota.values import CAR as TOYOTA -from selfdrive.car.honda.values import CAR as HONDA -from selfdrive.car.volkswagen.values import CAR as VW +from openpilot.common.params import Params +from openpilot.tools.lib.logreader import LogReader +from openpilot.selfdrive.test.profiling.lib import SubMaster, PubMaster, SubSocket, ReplayDone +from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS +from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA +from openpilot.selfdrive.car.honda.values import CAR as HONDA +from openpilot.selfdrive.car.volkswagen.values import CAR as VW BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/" @@ -79,11 +79,11 @@ def profile(proc, func, car='toyota'): if __name__ == '__main__': - from selfdrive.controls.controlsd import main as controlsd_thread - from selfdrive.controls.radard import radard_thread - from selfdrive.locationd.paramsd import main as paramsd_thread - from selfdrive.controls.plannerd import main as plannerd_thread - from selfdrive.locationd.laikad import main as laikad_thread + from openpilot.selfdrive.controls.controlsd import main as controlsd_thread + from openpilot.selfdrive.controls.radard import radard_thread + from openpilot.selfdrive.locationd.paramsd import main as paramsd_thread + from openpilot.selfdrive.controls.plannerd import main as plannerd_thread + from openpilot.selfdrive.locationd.laikad import main as laikad_thread procs = { 'radard': radard_thread, diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index d71f49dc3a..0fa9d9c711 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -14,14 +14,14 @@ from pathlib import Path from cereal import car import cereal.messaging as messaging from cereal.services import service_list -from common.basedir import BASEDIR -from common.timeout import Timeout -from common.params import Params -from selfdrive.controls.lib.events import EVENTS, ET -from system.hardware import HARDWARE -from system.loggerd.config import ROOT -from selfdrive.test.helpers import set_params_enabled, release_only -from tools.lib.logreader import LogReader +from openpilot.common.basedir import BASEDIR +from openpilot.common.timeout import Timeout +from openpilot.common.params import Params +from openpilot.selfdrive.controls.lib.events import EVENTS, ET +from openpilot.system.hardware import HARDWARE +from openpilot.system.loggerd.config import ROOT +from openpilot.selfdrive.test.helpers import set_params_enabled, release_only +from openpilot.tools.lib.logreader import LogReader # Baseline CPU usage by process PROCS = { diff --git a/selfdrive/test/test_time_to_onroad.py b/selfdrive/test/test_time_to_onroad.py index 5991250945..429feca344 100755 --- a/selfdrive/test/test_time_to_onroad.py +++ b/selfdrive/test/test_time_to_onroad.py @@ -4,9 +4,9 @@ import time import subprocess import cereal.messaging as messaging -from common.basedir import BASEDIR -from common.timeout import Timeout -from selfdrive.test.helpers import set_params_enabled +from openpilot.common.basedir import BASEDIR +from openpilot.common.timeout import Timeout +from openpilot.selfdrive.test.helpers import set_params_enabled def test_time_to_onroad(): diff --git a/selfdrive/test/test_updated.py b/selfdrive/test/test_updated.py index aab8b256ac..e679cd2c3b 100755 --- a/selfdrive/test/test_updated.py +++ b/selfdrive/test/test_updated.py @@ -9,8 +9,8 @@ import signal import subprocess import random -from common.basedir import BASEDIR -from common.params import Params +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params class TestUpdated(unittest.TestCase): diff --git a/selfdrive/test/test_valgrind_replay.py b/selfdrive/test/test_valgrind_replay.py index a831ad6e2e..dbcf3b18d4 100755 --- a/selfdrive/test/test_valgrind_replay.py +++ b/selfdrive/test/test_valgrind_replay.py @@ -14,9 +14,9 @@ else: import cereal.messaging as messaging from collections import namedtuple -from tools.lib.logreader import LogReader -from selfdrive.test.openpilotci import get_url -from common.basedir import BASEDIR +from openpilot.tools.lib.logreader import LogReader +from openpilot.selfdrive.test.openpilotci import get_url +from openpilot.common.basedir import BASEDIR ProcessConfig = namedtuple('ProcessConfig', ['proc_name', 'pub_sub', 'ignore', 'command', 'path', 'segment', 'wait_for_response']) diff --git a/selfdrive/test/update_ci_routes.py b/selfdrive/test/update_ci_routes.py index cee2f49e56..a69eb80cef 100755 --- a/selfdrive/test/update_ci_routes.py +++ b/selfdrive/test/update_ci_routes.py @@ -5,9 +5,9 @@ import subprocess from tqdm import tqdm from azure.storage.blob import BlockBlobService # pylint: disable=import-error -from selfdrive.car.tests.routes import routes as test_car_models_routes -from selfdrive.locationd.test.test_laikad import UBLOX_TEST_ROUTE, QCOM_TEST_ROUTE -from selfdrive.test.process_replay.test_processes import source_segments as replay_segments +from openpilot.selfdrive.car.tests.routes import routes as test_car_models_routes +from openpilot.selfdrive.locationd.test.test_laikad import UBLOX_TEST_ROUTE, QCOM_TEST_ROUTE +from openpilot.selfdrive.test.process_replay.test_processes import source_segments as replay_segments from xx.chffr.lib import azureutil # pylint: disable=import-error from xx.chffr.lib.storage import _DATA_ACCOUNT_PRODUCTION, _DATA_ACCOUNT_CI, _DATA_BUCKET_PRODUCTION # pylint: disable=import-error diff --git a/selfdrive/thermald/fan_controller.py b/selfdrive/thermald/fan_controller.py index f3e822da51..64cd4c78ee 100644 --- a/selfdrive/thermald/fan_controller.py +++ b/selfdrive/thermald/fan_controller.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 from abc import ABC, abstractmethod -from common.realtime import DT_TRML -from common.numpy_fast import interp -from system.swaglog import cloudlog -from selfdrive.controls.lib.pid import PIDController +from openpilot.common.realtime import DT_TRML +from openpilot.common.numpy_fast import interp +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.controls.lib.pid import PIDController class BaseFanController(ABC): @abstractmethod diff --git a/selfdrive/thermald/power_monitoring.py b/selfdrive/thermald/power_monitoring.py index e9b07da1f6..0b3c73a1c0 100644 --- a/selfdrive/thermald/power_monitoring.py +++ b/selfdrive/thermald/power_monitoring.py @@ -2,10 +2,10 @@ import time import threading from typing import Optional -from common.params import Params, put_nonblocking -from system.hardware import HARDWARE -from system.swaglog import cloudlog -from selfdrive.statsd import statlog +from openpilot.common.params import Params, put_nonblocking +from openpilot.system.hardware import HARDWARE +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.statsd import statlog CAR_VOLTAGE_LOW_PASS_K = 0.011 # LPF gain for 45s tau (dt/tau / (dt/tau + 1)) diff --git a/selfdrive/thermald/tests/test_fan_controller.py b/selfdrive/thermald/tests/test_fan_controller.py index 22d618485c..7081e1353e 100755 --- a/selfdrive/thermald/tests/test_fan_controller.py +++ b/selfdrive/thermald/tests/test_fan_controller.py @@ -3,7 +3,7 @@ import unittest from unittest.mock import Mock, patch from parameterized import parameterized -from selfdrive.thermald.fan_controller import TiciFanController +from openpilot.selfdrive.thermald.fan_controller import TiciFanController ALL_CONTROLLERS = [(TiciFanController,)] diff --git a/selfdrive/thermald/tests/test_power_monitoring.py b/selfdrive/thermald/tests/test_power_monitoring.py index 57b16accff..5d6531ff49 100755 --- a/selfdrive/thermald/tests/test_power_monitoring.py +++ b/selfdrive/thermald/tests/test_power_monitoring.py @@ -2,35 +2,35 @@ import unittest from unittest.mock import patch -from common.params import Params -params = Params() +from openpilot.common.params import Params +from openpilot.selfdrive.thermald.power_monitoring import PowerMonitoring, CAR_BATTERY_CAPACITY_uWh, \ + CAR_CHARGING_RATE_W, VBATT_PAUSE_CHARGING, DELAY_SHUTDOWN_TIME_S + # Create fake time -ssb = 0 -def mock_sec_since_boot(): +ssb = 0. +def mock_time_monotonic(): global ssb - ssb += 1 + ssb += 1. return ssb -with patch("common.realtime.sec_since_boot", new=mock_sec_since_boot): - with patch("common.params.put_nonblocking", new=params.put): - from selfdrive.thermald.power_monitoring import PowerMonitoring, CAR_BATTERY_CAPACITY_uWh, \ - CAR_CHARGING_RATE_W, VBATT_PAUSE_CHARGING, DELAY_SHUTDOWN_TIME_S - TEST_DURATION_S = 50 GOOD_VOLTAGE = 12 * 1e3 VOLTAGE_BELOW_PAUSE_CHARGING = (VBATT_PAUSE_CHARGING - 1) * 1e3 def pm_patch(name, value, constant=False): if constant: - return patch(f"selfdrive.thermald.power_monitoring.{name}", value) - return patch(f"selfdrive.thermald.power_monitoring.{name}", return_value=value) + return patch(f"openpilot.selfdrive.thermald.power_monitoring.{name}", value) + return patch(f"openpilot.selfdrive.thermald.power_monitoring.{name}", return_value=value) + +@patch("time.monotonic", new=mock_time_monotonic) +@patch("openpilot.selfdrive.thermald.power_monitoring.put_nonblocking", new=lambda x, y: Params().put(x, y)) class TestPowerMonitoring(unittest.TestCase): def setUp(self): - # Clear stored capacity before each test - params.remove("CarBatteryCapacity") - params.remove("DisablePowerDown") + self.params = Params() + self.params.remove("CarBatteryCapacity") + self.params.remove("DisablePowerDown") # Test to see that it doesn't do anything when pandaState is None def test_pandaState_present(self): @@ -139,7 +139,7 @@ class TestPowerMonitoring(unittest.TestCase): def test_disable_power_down(self): POWER_DRAW = 0 # To stop shutting down for other reasons TEST_TIME = 100 - params.put_bool("DisablePowerDown", True) + self.params.put_bool("DisablePowerDown", True) with pm_patch("HARDWARE.get_current_power_draw", POWER_DRAW): pm = PowerMonitoring() pm.car_battery_capacity_uWh = CAR_BATTERY_CAPACITY_uWh diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index d2ab8ff733..b80ce71aea 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -13,19 +13,19 @@ import psutil import cereal.messaging as messaging from cereal import log -from common.dict_helpers import strip_deprecated_keys -from common.time import MIN_DATE -from common.filter_simple import FirstOrderFilter -from common.params import Params -from common.realtime import DT_TRML -from selfdrive.controls.lib.alertmanager import set_offroad_alert -from system.hardware import HARDWARE, TICI, AGNOS -from system.loggerd.config import get_available_percent -from selfdrive.statsd import statlog -from system.swaglog import cloudlog -from selfdrive.thermald.power_monitoring import PowerMonitoring -from selfdrive.thermald.fan_controller import TiciFanController -from system.version import terms_version, training_version +from openpilot.common.dict_helpers import strip_deprecated_keys +from openpilot.common.time import MIN_DATE +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.common.params import Params +from openpilot.common.realtime import DT_TRML +from openpilot.selfdrive.controls.lib.alertmanager import set_offroad_alert +from openpilot.system.hardware import HARDWARE, TICI, AGNOS +from openpilot.system.loggerd.config import get_available_percent +from openpilot.selfdrive.statsd import statlog +from openpilot.system.swaglog import cloudlog +from openpilot.selfdrive.thermald.power_monitoring import PowerMonitoring +from openpilot.selfdrive.thermald.fan_controller import TiciFanController +from openpilot.system.version import terms_version, training_version ThermalStatus = log.DeviceState.ThermalStatus NetworkType = log.DeviceState.NetworkType diff --git a/selfdrive/tombstoned.py b/selfdrive/tombstoned.py index b1086305b7..25f2a61f98 100755 --- a/selfdrive/tombstoned.py +++ b/selfdrive/tombstoned.py @@ -9,11 +9,11 @@ import time import glob from typing import NoReturn -from common.file_helpers import mkdirs_exists_ok -from system.loggerd.config import ROOT -import selfdrive.sentry as sentry -from system.swaglog import cloudlog -from system.version import get_commit +from openpilot.common.file_helpers import mkdirs_exists_ok +from openpilot.system.loggerd.config import ROOT +import openpilot.selfdrive.sentry as sentry +from openpilot.system.swaglog import cloudlog +from openpilot.system.version import get_commit MAX_SIZE = 1_000_000 * 100 # allow up to 100M MAX_TOMBSTONE_FN_LEN = 62 # 85 - 23 ("/crash/") diff --git a/selfdrive/ui/qt/python_helpers.py b/selfdrive/ui/qt/python_helpers.py index 905d41a634..59e51a5517 100644 --- a/selfdrive/ui/qt/python_helpers.py +++ b/selfdrive/ui/qt/python_helpers.py @@ -3,8 +3,8 @@ from cffi import FFI import sip # pylint: disable=import-error -from common.ffi_wrapper import suffix -from common.basedir import BASEDIR +from openpilot.common.ffi_wrapper import suffix +from openpilot.common.basedir import BASEDIR def get_ffi(): diff --git a/selfdrive/ui/tests/cycle_offroad_alerts.py b/selfdrive/ui/tests/cycle_offroad_alerts.py index 8a3d9ec45a..75b19ceb90 100755 --- a/selfdrive/ui/tests/cycle_offroad_alerts.py +++ b/selfdrive/ui/tests/cycle_offroad_alerts.py @@ -4,9 +4,9 @@ import sys import time import json -from common.basedir import BASEDIR -from common.params import Params -from selfdrive.controls.lib.alertmanager import set_offroad_alert +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params +from openpilot.selfdrive.controls.lib.alertmanager import set_offroad_alert if __name__ == "__main__": params = Params() diff --git a/selfdrive/ui/tests/test_soundd.py b/selfdrive/ui/tests/test_soundd.py index 8cc9215b74..80a261e6d9 100755 --- a/selfdrive/ui/tests/test_soundd.py +++ b/selfdrive/ui/tests/test_soundd.py @@ -5,10 +5,10 @@ import unittest from cereal import log, car import cereal.messaging as messaging -from selfdrive.test.helpers import phone_only, with_processes +from openpilot.selfdrive.test.helpers import phone_only, with_processes # TODO: rewrite for unittest -from common.realtime import DT_CTRL -from system.hardware import HARDWARE +from openpilot.common.realtime import DT_CTRL +from openpilot.system.hardware import HARDWARE AudibleAlert = car.CarControl.HUDControl.AudibleAlert diff --git a/selfdrive/ui/tests/test_translations.py b/selfdrive/ui/tests/test_translations.py index 8321e2e4c0..1ff203b97d 100755 --- a/selfdrive/ui/tests/test_translations.py +++ b/selfdrive/ui/tests/test_translations.py @@ -6,7 +6,7 @@ import shutil import unittest import xml.etree.ElementTree as ET -from selfdrive.ui.update_translations import TRANSLATIONS_DIR, LANGUAGES_FILE, update_translations +from openpilot.selfdrive.ui.update_translations import TRANSLATIONS_DIR, LANGUAGES_FILE, update_translations TMP_TRANSLATIONS_DIR = os.path.join(TRANSLATIONS_DIR, "tmp") UNFINISHED_TRANSLATION_TAG = " None: def handle_agnos_update() -> None: - from system.hardware.tici.agnos import flash_agnos_update, get_target_slot_number + from openpilot.system.hardware.tici.agnos import flash_agnos_update, get_target_slot_number cur_version = HARDWARE.get_os_version() updated_version = run(["bash", "-c", r"unset AGNOS_VERSION && source launch_env.sh && \ diff --git a/system/camerad/snapshot/snapshot.py b/system/camerad/snapshot/snapshot.py index 447062fb2e..ede97d1a79 100755 --- a/system/camerad/snapshot/snapshot.py +++ b/system/camerad/snapshot/snapshot.py @@ -7,11 +7,11 @@ from PIL import Image import cereal.messaging as messaging from cereal.visionipc import VisionIpcClient, VisionStreamType -from common.params import Params -from common.realtime import DT_MDL -from system.hardware import PC -from selfdrive.controls.lib.alertmanager import set_offroad_alert -from selfdrive.manager.process_config import managed_processes +from openpilot.common.params import Params +from openpilot.common.realtime import DT_MDL +from openpilot.system.hardware import PC +from openpilot.selfdrive.controls.lib.alertmanager import set_offroad_alert +from openpilot.selfdrive.manager.process_config import managed_processes LM_THRESH = 120 # defined in system/camerad/imgproc/utils.h diff --git a/system/camerad/test/get_thumbnails_for_segment.py b/system/camerad/test/get_thumbnails_for_segment.py index 898377b111..97667ede86 100755 --- a/system/camerad/test/get_thumbnails_for_segment.py +++ b/system/camerad/test/get_thumbnails_for_segment.py @@ -4,9 +4,9 @@ import os from tqdm import tqdm -from common.file_helpers import mkdirs_exists_ok -from tools.lib.logreader import LogReader -from tools.lib.route import Route +from openpilot.common.file_helpers import mkdirs_exists_ok +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route import argparse diff --git a/system/camerad/test/test_camerad.py b/system/camerad/test/test_camerad.py index f03c531b20..6669df301c 100755 --- a/system/camerad/test/test_camerad.py +++ b/system/camerad/test/test_camerad.py @@ -7,8 +7,8 @@ from collections import defaultdict import cereal.messaging as messaging from cereal import log from cereal.services import service_list -from selfdrive.manager.process_config import managed_processes -from system.hardware import TICI +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.hardware import TICI TEST_TIMESPAN = 30 LAG_FRAME_TOLERANCE = {log.FrameData.ImageSensor.ar0231: 0.5, # ARs use synced pulses for frame starts diff --git a/system/camerad/test/test_exposure.py b/system/camerad/test/test_exposure.py index 8f65744da3..50467f9db4 100755 --- a/system/camerad/test/test_exposure.py +++ b/system/camerad/test/test_exposure.py @@ -3,8 +3,8 @@ import time import unittest import numpy as np -from selfdrive.test.helpers import with_processes, phone_only -from system.camerad.snapshot.snapshot import get_snapshots +from openpilot.selfdrive.test.helpers import with_processes, phone_only +from openpilot.system.camerad.snapshot.snapshot import get_snapshots TEST_TIME = 45 REPEAT = 5 diff --git a/system/hardware/__init__.py b/system/hardware/__init__.py index 77bb0e5e2a..99079b5ef3 100644 --- a/system/hardware/__init__.py +++ b/system/hardware/__init__.py @@ -1,9 +1,9 @@ import os from typing import cast -from system.hardware.base import HardwareBase -from system.hardware.tici.hardware import Tici -from system.hardware.pc.hardware import Pc +from openpilot.system.hardware.base import HardwareBase +from openpilot.system.hardware.tici.hardware import Tici +from openpilot.system.hardware.pc.hardware import Pc TICI = os.path.isfile('/TICI') AGNOS = os.path.isfile('/AGNOS') diff --git a/system/hardware/pc/hardware.py b/system/hardware/pc/hardware.py index 564f9e483a..27c05f5904 100644 --- a/system/hardware/pc/hardware.py +++ b/system/hardware/pc/hardware.py @@ -1,7 +1,7 @@ import random from cereal import log -from system.hardware.base import HardwareBase, ThermalConfig +from openpilot.system.hardware.base import HardwareBase, ThermalConfig NetworkType = log.DeviceState.NetworkType NetworkStrength = log.DeviceState.NetworkStrength diff --git a/system/hardware/tici/agnos.py b/system/hardware/tici/agnos.py index 5f446a8e90..ef7d9adb79 100755 --- a/system/hardware/tici/agnos.py +++ b/system/hardware/tici/agnos.py @@ -10,7 +10,7 @@ from typing import Dict, Generator, List, Tuple, Union import requests -import system.hardware.tici.casync as casync +import openpilot.system.hardware.tici.casync as casync SPARSE_CHUNK_FMT = struct.Struct('H2xI4x') CAIBX_URL = "https://commadist.azureedge.net/agnosupdate/" diff --git a/system/hardware/tici/hardware.py b/system/hardware/tici/hardware.py index 6932ea08b6..3cd3427842 100644 --- a/system/hardware/tici/hardware.py +++ b/system/hardware/tici/hardware.py @@ -8,11 +8,11 @@ from functools import cached_property, lru_cache from pathlib import Path from cereal import log -from common.gpio import gpio_set, gpio_init, get_irqs_for_action -from system.hardware.base import HardwareBase, ThermalConfig -from system.hardware.tici import iwlist -from system.hardware.tici.pins import GPIO -from system.hardware.tici.amplifier import Amplifier +from openpilot.common.gpio import gpio_set, gpio_init, get_irqs_for_action +from openpilot.system.hardware.base import HardwareBase, ThermalConfig +from openpilot.system.hardware.tici import iwlist +from openpilot.system.hardware.tici.pins import GPIO +from openpilot.system.hardware.tici.amplifier import Amplifier NM = 'org.freedesktop.NetworkManager' NM_CON_ACT = NM + '.Connection.Active' diff --git a/system/hardware/tici/power_draw_test.py b/system/hardware/tici/power_draw_test.py index 3c303ff61f..28113ad073 100755 --- a/system/hardware/tici/power_draw_test.py +++ b/system/hardware/tici/power_draw_test.py @@ -2,9 +2,9 @@ import os import time import numpy as np -from system.hardware.tici.hardware import Tici -from system.hardware.tici.pins import GPIO -from common.gpio import gpio_init, gpio_set, gpio_export +from openpilot.system.hardware.tici.hardware import Tici +from openpilot.system.hardware.tici.pins import GPIO +from openpilot.common.gpio import gpio_init, gpio_set, gpio_export def read_power(): with open("/sys/bus/i2c/devices/0-0040/hwmon/hwmon1/in1_input") as f: diff --git a/system/hardware/tici/power_monitor.py b/system/hardware/tici/power_monitor.py index f9d1e3cc41..0a54319398 100755 --- a/system/hardware/tici/power_monitor.py +++ b/system/hardware/tici/power_monitor.py @@ -5,8 +5,8 @@ import datetime import numpy as np from typing import List -from common.realtime import Ratekeeper -from common.filter_simple import FirstOrderFilter +from openpilot.common.realtime import Ratekeeper +from openpilot.common.filter_simple import FirstOrderFilter def read_power(): diff --git a/system/hardware/tici/precise_power_measure.py b/system/hardware/tici/precise_power_measure.py index 5d68851367..e186ba4aea 100755 --- a/system/hardware/tici/precise_power_measure.py +++ b/system/hardware/tici/precise_power_measure.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import numpy as np -from system.hardware.tici.power_monitor import sample_power +from openpilot.system.hardware.tici.power_monitor import sample_power if __name__ == '__main__': print("measuring for 5 seconds") diff --git a/system/hardware/tici/tests/compare_casync_manifest.py b/system/hardware/tici/tests/compare_casync_manifest.py index 6d7232bd64..835985b0b5 100755 --- a/system/hardware/tici/tests/compare_casync_manifest.py +++ b/system/hardware/tici/tests/compare_casync_manifest.py @@ -8,7 +8,7 @@ from typing import Dict, List import requests from tqdm import tqdm -import system.hardware.tici.casync as casync +import openpilot.system.hardware.tici.casync as casync def get_chunk_download_size(chunk): diff --git a/system/hardware/tici/tests/test_amplifier.py b/system/hardware/tici/tests/test_amplifier.py index 6019495449..cd3b0f90fe 100755 --- a/system/hardware/tici/tests/test_amplifier.py +++ b/system/hardware/tici/tests/test_amplifier.py @@ -5,9 +5,9 @@ import unittest import subprocess from panda import Panda -from system.hardware import TICI, HARDWARE -from system.hardware.tici.hardware import Tici -from system.hardware.tici.amplifier import Amplifier +from openpilot.system.hardware import TICI, HARDWARE +from openpilot.system.hardware.tici.hardware import Tici +from openpilot.system.hardware.tici.amplifier import Amplifier class TestAmplifier(unittest.TestCase): diff --git a/system/hardware/tici/tests/test_casync.py b/system/hardware/tici/tests/test_casync.py index 8724575ad6..94b32a9f76 100755 --- a/system/hardware/tici/tests/test_casync.py +++ b/system/hardware/tici/tests/test_casync.py @@ -4,7 +4,7 @@ import unittest import tempfile import subprocess -import system.hardware.tici.casync as casync +import openpilot.system.hardware.tici.casync as casync # dd if=/dev/zero of=/tmp/img.raw bs=1M count=2 # sudo losetup -f /tmp/img.raw diff --git a/system/hardware/tici/tests/test_hardware.py b/system/hardware/tici/tests/test_hardware.py index bb22cb1594..7d377ac3fb 100755 --- a/system/hardware/tici/tests/test_hardware.py +++ b/system/hardware/tici/tests/test_hardware.py @@ -3,8 +3,8 @@ import time import unittest import numpy as np -from system.hardware import TICI -from system.hardware.tici.hardware import Tici +from openpilot.system.hardware import TICI +from openpilot.system.hardware.tici.hardware import Tici HARDWARE = Tici() diff --git a/system/hardware/tici/tests/test_power_draw.py b/system/hardware/tici/tests/test_power_draw.py index a35f231c4e..fbca95f6f6 100755 --- a/system/hardware/tici/tests/test_power_draw.py +++ b/system/hardware/tici/tests/test_power_draw.py @@ -9,11 +9,11 @@ from typing import List import cereal.messaging as messaging from cereal.services import service_list -from system.hardware import HARDWARE, TICI -from system.hardware.tici.power_monitor import get_power -from selfdrive.manager.process_config import managed_processes -from selfdrive.manager.manager import manager_cleanup -from selfdrive.navd.tests.test_map_renderer import gen_llk +from openpilot.system.hardware import HARDWARE, TICI +from openpilot.system.hardware.tici.power_monitor import get_power +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.manager import manager_cleanup +from openpilot.selfdrive.navd.tests.test_map_renderer import gen_llk SAMPLE_TIME = 8 # seconds to sample power diff --git a/system/loggerd/config.py b/system/loggerd/config.py index df187a48c0..dfc117f2c1 100644 --- a/system/loggerd/config.py +++ b/system/loggerd/config.py @@ -1,6 +1,6 @@ import os from pathlib import Path -from system.hardware import PC +from openpilot.system.hardware import PC if os.environ.get('LOG_ROOT', False): ROOT = os.environ['LOG_ROOT'] diff --git a/system/loggerd/deleter.py b/system/loggerd/deleter.py index 5e7b31f583..ab4a0b97c1 100644 --- a/system/loggerd/deleter.py +++ b/system/loggerd/deleter.py @@ -4,10 +4,10 @@ import shutil import threading from typing import List -from system.swaglog import cloudlog -from system.loggerd.config import ROOT, get_available_bytes, get_available_percent -from system.loggerd.uploader import listdir_by_creation -from system.loggerd.xattr_cache import getxattr +from openpilot.system.swaglog import cloudlog +from openpilot.system.loggerd.config import ROOT, get_available_bytes, get_available_percent +from openpilot.system.loggerd.uploader import listdir_by_creation +from openpilot.system.loggerd.xattr_cache import getxattr MIN_BYTES = 5 * 1024 * 1024 * 1024 MIN_PERCENT = 10 diff --git a/system/loggerd/tests/fill.py b/system/loggerd/tests/fill.py index 4bf4f73604..c749f42b97 100755 --- a/system/loggerd/tests/fill.py +++ b/system/loggerd/tests/fill.py @@ -3,8 +3,8 @@ from pathlib import Path -from system.loggerd.config import ROOT, get_available_percent -from system.loggerd.tests.loggerd_tests_common import create_random_file +from openpilot.system.loggerd.config import ROOT, get_available_percent +from openpilot.system.loggerd.tests.loggerd_tests_common import create_random_file if __name__ == "__main__": diff --git a/system/loggerd/tests/loggerd_tests_common.py b/system/loggerd/tests/loggerd_tests_common.py index 7d71516dfe..89ddbd658c 100644 --- a/system/loggerd/tests/loggerd_tests_common.py +++ b/system/loggerd/tests/loggerd_tests_common.py @@ -7,9 +7,9 @@ import unittest from pathlib import Path from typing import Optional -import system.loggerd.deleter as deleter -import system.loggerd.uploader as uploader -from system.loggerd.xattr_cache import setxattr +import openpilot.system.loggerd.deleter as deleter +import openpilot.system.loggerd.uploader as uploader +from openpilot.system.loggerd.xattr_cache import setxattr def create_random_file(file_path: Path, size_mb: float, lock: bool = False, upload_xattr: Optional[bytes] = None) -> None: diff --git a/system/loggerd/tests/test_deleter.py b/system/loggerd/tests/test_deleter.py index 9474b30f82..86152b05f8 100755 --- a/system/loggerd/tests/test_deleter.py +++ b/system/loggerd/tests/test_deleter.py @@ -6,9 +6,9 @@ from collections import namedtuple from pathlib import Path from typing import Sequence -import system.loggerd.deleter as deleter -from common.timeout import Timeout, TimeoutException -from system.loggerd.tests.loggerd_tests_common import UploaderTestCase +import openpilot.system.loggerd.deleter as deleter +from openpilot.common.timeout import Timeout, TimeoutException +from openpilot.system.loggerd.tests.loggerd_tests_common import UploaderTestCase Stats = namedtuple("Stats", ['f_bavail', 'f_blocks', 'f_frsize']) diff --git a/system/loggerd/tests/test_encoder.py b/system/loggerd/tests/test_encoder.py index 81f4e9fb9d..41b83c0821 100755 --- a/system/loggerd/tests/test_encoder.py +++ b/system/loggerd/tests/test_encoder.py @@ -11,12 +11,12 @@ from pathlib import Path from parameterized import parameterized from tqdm import trange -from common.params import Params -from common.timeout import Timeout -from system.hardware import TICI -from system.loggerd.config import ROOT -from selfdrive.manager.process_config import managed_processes -from tools.lib.logreader import LogReader +from openpilot.common.params import Params +from openpilot.common.timeout import Timeout +from openpilot.system.hardware import TICI +from openpilot.system.loggerd.config import ROOT +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.tools.lib.logreader import LogReader SEGMENT_LENGTH = 2 FULL_SIZE = 2507572 diff --git a/system/loggerd/tests/test_loggerd.py b/system/loggerd/tests/test_loggerd.py index c151afb24f..b43f597c25 100755 --- a/system/loggerd/tests/test_loggerd.py +++ b/system/loggerd/tests/test_loggerd.py @@ -13,17 +13,17 @@ from typing import Dict, List import cereal.messaging as messaging from cereal import log from cereal.services import service_list -from common.basedir import BASEDIR -from common.params import Params -from common.timeout import Timeout -from system.loggerd.config import ROOT -from system.loggerd.xattr_cache import getxattr -from system.loggerd.deleter import PRESERVE_ATTR_NAME, PRESERVE_ATTR_VALUE -from selfdrive.manager.process_config import managed_processes -from system.version import get_version -from tools.lib.logreader import LogReader +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params +from openpilot.common.timeout import Timeout +from openpilot.system.loggerd.config import ROOT +from openpilot.system.loggerd.xattr_cache import getxattr +from openpilot.system.loggerd.deleter import PRESERVE_ATTR_NAME, PRESERVE_ATTR_VALUE +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.version import get_version +from openpilot.tools.lib.logreader import LogReader from cereal.visionipc import VisionIpcServer, VisionStreamType -from common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size +from openpilot.common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size SentinelType = log.Sentinel.SentinelType diff --git a/system/loggerd/tests/test_uploader.py b/system/loggerd/tests/test_uploader.py index 580d1efae2..bf21d8d7a9 100755 --- a/system/loggerd/tests/test_uploader.py +++ b/system/loggerd/tests/test_uploader.py @@ -8,10 +8,10 @@ import json from pathlib import Path from typing import List, Optional -from system.swaglog import cloudlog -from system.loggerd.uploader import uploader_fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE +from openpilot.system.swaglog import cloudlog +from openpilot.system.loggerd.uploader import uploader_fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE -from system.loggerd.tests.loggerd_tests_common import UploaderTestCase +from openpilot.system.loggerd.tests.loggerd_tests_common import UploaderTestCase class TestLogHandler(logging.Handler): diff --git a/system/loggerd/tools/mark_all_uploaded.py b/system/loggerd/tools/mark_all_uploaded.py index c963014748..84b9c20d78 100644 --- a/system/loggerd/tools/mark_all_uploaded.py +++ b/system/loggerd/tools/mark_all_uploaded.py @@ -1,7 +1,7 @@ import os -from system.loggerd.uploader import UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE +from openpilot.system.loggerd.uploader import UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE -from system.loggerd.config import ROOT +from openpilot.system.loggerd.config import ROOT for folder in os.walk(ROOT): for file1 in folder[2]: full_path = os.path.join(folder[0], file1) diff --git a/system/loggerd/tools/mark_unuploaded.py b/system/loggerd/tools/mark_unuploaded.py index 3d1d4472b0..ef50280441 100755 --- a/system/loggerd/tools/mark_unuploaded.py +++ b/system/loggerd/tools/mark_unuploaded.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import os import sys -from system.loggerd.uploader import UPLOAD_ATTR_NAME +from openpilot.system.loggerd.uploader import UPLOAD_ATTR_NAME for fn in sys.argv[1:]: print(f"unmarking {fn}") diff --git a/system/loggerd/uploader.py b/system/loggerd/uploader.py index 196e5b3c2b..8ed60dac56 100644 --- a/system/loggerd/uploader.py +++ b/system/loggerd/uploader.py @@ -13,13 +13,13 @@ from typing import BinaryIO, Iterator, List, Optional, Tuple, Union from cereal import log import cereal.messaging as messaging -from common.api import Api -from common.params import Params -from common.realtime import set_core_affinity -from system.hardware import TICI -from system.loggerd.xattr_cache import getxattr, setxattr -from system.loggerd.config import ROOT -from system.swaglog import cloudlog +from openpilot.common.api import Api +from openpilot.common.params import Params +from openpilot.common.realtime import set_core_affinity +from openpilot.system.hardware import TICI +from openpilot.system.loggerd.xattr_cache import getxattr, setxattr +from openpilot.system.loggerd.config import ROOT +from openpilot.system.swaglog import cloudlog NetworkType = log.DeviceState.NetworkType UPLOAD_ATTR_NAME = 'user.upload' diff --git a/system/logmessaged.py b/system/logmessaged.py index 04101d042b..cab8cdd80d 100755 --- a/system/logmessaged.py +++ b/system/logmessaged.py @@ -3,8 +3,8 @@ import zmq from typing import NoReturn import cereal.messaging as messaging -from common.logging_extra import SwagLogFileFormatter -from system.swaglog import get_file_handler +from openpilot.common.logging_extra import SwagLogFileFormatter +from openpilot.system.swaglog import get_file_handler def main() -> NoReturn: diff --git a/system/micd.py b/system/micd.py index 97ba0c262e..ae2bf86730 100755 --- a/system/micd.py +++ b/system/micd.py @@ -2,9 +2,9 @@ import numpy as np from cereal import messaging -from common.filter_simple import FirstOrderFilter -from common.realtime import Ratekeeper -from system.swaglog import cloudlog +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.common.realtime import Ratekeeper +from openpilot.system.swaglog import cloudlog RATE = 10 FFT_SAMPLES = 4096 diff --git a/system/sensord/pigeond.py b/system/sensord/pigeond.py index f9ac2eaf95..a2b6b08de0 100755 --- a/system/sensord/pigeond.py +++ b/system/sensord/pigeond.py @@ -10,11 +10,11 @@ from datetime import datetime from typing import List, Optional, Tuple from cereal import messaging -from common.params import Params -from system.swaglog import cloudlog -from system.hardware import TICI -from common.gpio import gpio_init, gpio_set -from system.hardware.tici.pins import GPIO +from openpilot.common.params import Params +from openpilot.system.swaglog import cloudlog +from openpilot.system.hardware import TICI +from openpilot.common.gpio import gpio_init, gpio_set +from openpilot.system.hardware.tici.pins import GPIO UBLOX_TTY = "/dev/ttyHS0" diff --git a/system/sensord/rawgps/rawgpsd.py b/system/sensord/rawgps/rawgpsd.py index d9b2c37731..bb228812dc 100755 --- a/system/sensord/rawgps/rawgpsd.py +++ b/system/sensord/rawgps/rawgpsd.py @@ -15,14 +15,14 @@ from struct import unpack_from, calcsize, pack from cereal import log import cereal.messaging as messaging -from common.gpio import gpio_init, gpio_set +from openpilot.common.gpio import gpio_init, gpio_set from laika.gps_time import GPSTime, utc_to_gpst, get_leap_seconds from laika.helpers import get_prn_from_nmea_id from laika.constants import SECS_IN_HR, SECS_IN_DAY, SECS_IN_WEEK -from system.hardware.tici.pins import GPIO -from system.swaglog import cloudlog -from system.sensord.rawgps.modemdiag import ModemDiag, DIAG_LOG_F, setup_logs, send_recv -from system.sensord.rawgps.structs import (dict_unpacker, position_report, relist, +from openpilot.system.hardware.tici.pins import GPIO +from openpilot.system.swaglog import cloudlog +from openpilot.system.sensord.rawgps.modemdiag import ModemDiag, DIAG_LOG_F, setup_logs, send_recv +from openpilot.system.sensord.rawgps.structs import (dict_unpacker, position_report, relist, gps_measurement_report, gps_measurement_report_sv, glonass_measurement_report, glonass_measurement_report_sv, oemdre_measurement_report, oemdre_measurement_report_sv, oemdre_svpoly_report, diff --git a/system/sensord/rawgps/test_rawgps.py b/system/sensord/rawgps/test_rawgps.py index 8c2e246764..02777d5a1d 100755 --- a/system/sensord/rawgps/test_rawgps.py +++ b/system/sensord/rawgps/test_rawgps.py @@ -8,10 +8,10 @@ import subprocess import numpy as np import cereal.messaging as messaging -from system.hardware import TICI -from system.sensord.rawgps.rawgpsd import at_cmd, wait_for_modem -from selfdrive.manager.process_config import managed_processes -from common.transformations.coordinates import ecef_from_geodetic +from openpilot.system.hardware import TICI +from openpilot.system.sensord.rawgps.rawgpsd import at_cmd, wait_for_modem +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.common.transformations.coordinates import ecef_from_geodetic GOOD_SIGNAL = bool(int(os.getenv("GOOD_SIGNAL", '0'))) diff --git a/system/sensord/tests/test_pigeond.py b/system/sensord/tests/test_pigeond.py index 9519183aac..d7c7567e4f 100755 --- a/system/sensord/tests/test_pigeond.py +++ b/system/sensord/tests/test_pigeond.py @@ -4,11 +4,11 @@ import unittest import cereal.messaging as messaging from cereal.services import service_list -from common.gpio import gpio_read -from selfdrive.test.helpers import with_processes -from selfdrive.manager.process_config import managed_processes -from system.hardware import TICI -from system.hardware.tici.pins import GPIO +from openpilot.common.gpio import gpio_read +from openpilot.selfdrive.test.helpers import with_processes +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.hardware import TICI +from openpilot.system.hardware.tici.pins import GPIO # TODO: test TTFF when we have good A-GNSS diff --git a/system/sensord/tests/test_sensord.py b/system/sensord/tests/test_sensord.py index eea527ed63..b394a86b59 100755 --- a/system/sensord/tests/test_sensord.py +++ b/system/sensord/tests/test_sensord.py @@ -7,9 +7,9 @@ from collections import namedtuple, defaultdict import cereal.messaging as messaging from cereal import log -from common.gpio import get_irqs_for_action -from system.hardware import TICI -from selfdrive.manager.process_config import managed_processes +from openpilot.common.gpio import get_irqs_for_action +from openpilot.system.hardware import TICI +from openpilot.selfdrive.manager.process_config import managed_processes BMX = { ('bmx055', 'acceleration'), diff --git a/system/sensord/tests/ttff_test.py b/system/sensord/tests/ttff_test.py index e2cbc6d144..e023489ed5 100755 --- a/system/sensord/tests/ttff_test.py +++ b/system/sensord/tests/ttff_test.py @@ -4,7 +4,7 @@ import time import atexit from cereal import messaging -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes TIMEOUT = 10*60 diff --git a/system/swaglog.py b/system/swaglog.py index 28beb5a4d1..5fe1c2f27f 100644 --- a/system/swaglog.py +++ b/system/swaglog.py @@ -7,8 +7,8 @@ from logging.handlers import BaseRotatingHandler import zmq -from common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter -from system.hardware import PC +from openpilot.common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter +from openpilot.system.hardware import PC if PC: SWAGLOG_DIR = os.path.join(str(Path.home()), ".comma", "log") diff --git a/system/tests/test_logmessaged.py b/system/tests/test_logmessaged.py index 08335517ae..955272d403 100755 --- a/system/tests/test_logmessaged.py +++ b/system/tests/test_logmessaged.py @@ -6,8 +6,8 @@ import time import unittest import cereal.messaging as messaging -from selfdrive.manager.process_config import managed_processes -from system.swaglog import cloudlog, SWAGLOG_DIR +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.system.swaglog import cloudlog, SWAGLOG_DIR class TestLogmessaged(unittest.TestCase): diff --git a/system/timezoned.py b/system/timezoned.py index 884a5c3812..37e813c561 100755 --- a/system/timezoned.py +++ b/system/timezoned.py @@ -8,9 +8,9 @@ from typing import NoReturn import requests from timezonefinder import TimezoneFinder -from common.params import Params -from system.hardware import AGNOS -from system.swaglog import cloudlog +from openpilot.common.params import Params +from openpilot.system.hardware import AGNOS +from openpilot.system.swaglog import cloudlog def set_timezone(valid_timezones, timezone): diff --git a/system/ubloxd/tests/test_ublox_processing.py b/system/ubloxd/tests/test_ublox_processing.py index cd4ce0de04..b1709cd9bb 100755 --- a/system/ubloxd/tests/test_ublox_processing.py +++ b/system/ubloxd/tests/test_ublox_processing.py @@ -6,9 +6,9 @@ from laika import AstroDog from laika.helpers import ConstellationId from laika.raw_gnss import correct_measurements, process_measurements, read_raw_ublox from laika.opt import calc_pos_fix -from selfdrive.test.openpilotci import get_url -from tools.lib.logreader import LogReader -from selfdrive.test.helpers import with_processes +from openpilot.selfdrive.test.openpilotci import get_url +from openpilot.tools.lib.logreader import LogReader +from openpilot.selfdrive.test.helpers import with_processes import cereal.messaging as messaging def get_gnss_measurements(log_reader): diff --git a/system/ubloxd/tests/ubloxd.py b/system/ubloxd/tests/ubloxd.py index 7c7e68b23b..783eb1eb0d 100755 --- a/system/ubloxd/tests/ubloxd.py +++ b/system/ubloxd/tests/ubloxd.py @@ -2,7 +2,7 @@ # type: ignore # pylint: skip-file -from selfdrive.locationd.test import ublox +from openpilot.selfdrive.locationd.test import ublox import struct baudrate = 460800 diff --git a/system/version.py b/system/version.py index c9ab443694..82e99fd416 100644 --- a/system/version.py +++ b/system/version.py @@ -4,8 +4,8 @@ import subprocess from typing import List, Optional from functools import lru_cache -from common.basedir import BASEDIR -from system.swaglog import cloudlog +from openpilot.common.basedir import BASEDIR +from openpilot.system.swaglog import cloudlog RELEASE_BRANCHES = ['release3-staging', 'dashcam3-staging', 'release3', 'dashcam3', 'nightly'] TESTED_BRANCHES = RELEASE_BRANCHES + ['devel', 'devel-staging'] @@ -127,7 +127,7 @@ def is_dirty() -> bool: if __name__ == "__main__": - from common.params import Params + from openpilot.common.params import Params params = Params() params.put("TermsVersion", terms_version) diff --git a/tools/bodyteleop/web.py b/tools/bodyteleop/web.py index ed94cb6d83..717afdeaf8 100644 --- a/tools/bodyteleop/web.py +++ b/tools/bodyteleop/web.py @@ -15,8 +15,8 @@ from aiohttp import web from aiortc import RTCPeerConnection, RTCSessionDescription import cereal.messaging as messaging -from common.basedir import BASEDIR -from tools.bodyteleop.bodyav import BodyMic, WebClientSpeaker, force_codec, play_sound, MediaBlackhole, EncodedBodyVideo +from openpilot.common.basedir import BASEDIR +from openpilot.tools.bodyteleop.bodyav import BodyMic, WebClientSpeaker, force_codec, play_sound, MediaBlackhole, EncodedBodyVideo logger = logging.getLogger("pc") logging.basicConfig(level=logging.INFO) diff --git a/tools/cabana/dbc/generate_dbc_json.py b/tools/cabana/dbc/generate_dbc_json.py index cb122e2eb2..da19e27b77 100755 --- a/tools/cabana/dbc/generate_dbc_json.py +++ b/tools/cabana/dbc/generate_dbc_json.py @@ -2,7 +2,7 @@ import argparse import json -from selfdrive.car.car_helpers import get_interface_attr +from openpilot.selfdrive.car.car_helpers import get_interface_attr def generate_dbc_json() -> str: diff --git a/tools/camerastream/receive.py b/tools/camerastream/receive.py index 6f8d67c78f..bf6929c039 100755 --- a/tools/camerastream/receive.py +++ b/tools/camerastream/receive.py @@ -4,7 +4,7 @@ import sys import numpy as np os.environ['ZMQ'] = '1' -from common.window import Window +from openpilot.common.window import Window import cereal.messaging as messaging # start camerad with 'SEND_ROAD=1 SEND_DRIVER=1 SEND_WIDE_ROAD=1 XMIN=771 XMAX=1156 YMIN=483 YMAX=724 ./camerad' diff --git a/tools/gpstest/rpc_server.py b/tools/gpstest/rpc_server.py index be8dbb61b8..060446370b 100644 --- a/tools/gpstest/rpc_server.py +++ b/tools/gpstest/rpc_server.py @@ -7,9 +7,9 @@ from collections import defaultdict import rpyc # pylint: disable=import-error from rpyc.utils.server import ThreadedServer # pylint: disable=import-error -#from common.params import Params +#from openpilot.common.params import Params import cereal.messaging as messaging -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes from laika.lib.coordinates import ecef2geodetic DELTA = 0.001 diff --git a/tools/gpstest/test_gps.py b/tools/gpstest/test_gps.py index 5043e484fd..98f1ad84b8 100644 --- a/tools/gpstest/test_gps.py +++ b/tools/gpstest/test_gps.py @@ -3,11 +3,11 @@ import time import unittest import struct -from common.params import Params +from openpilot.common.params import Params import cereal.messaging as messaging -import system.sensord.pigeond as pd -from system.hardware import TICI -from selfdrive.test.helpers import with_processes +import openpilot.system.sensord.pigeond as pd +from openpilot.system.hardware import TICI +from openpilot.selfdrive.test.helpers import with_processes def read_events(service, duration_sec): diff --git a/tools/gpstest/test_gps_qcom.py b/tools/gpstest/test_gps_qcom.py index b3ce93fc81..c399671715 100644 --- a/tools/gpstest/test_gps_qcom.py +++ b/tools/gpstest/test_gps_qcom.py @@ -3,10 +3,10 @@ import time import unittest import subprocess as sp -from common.params import Params -from system.hardware import TICI +from openpilot.common.params import Params +from openpilot.system.hardware import TICI import cereal.messaging as messaging -from selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.manager.process_config import managed_processes def exec_mmcli(cmd): diff --git a/tools/gpstest/test_laikad.py b/tools/gpstest/test_laikad.py index 689b0f0b9f..abb47d4bfc 100644 --- a/tools/gpstest/test_laikad.py +++ b/tools/gpstest/test_laikad.py @@ -4,12 +4,12 @@ import time import unittest import cereal.messaging as messaging -import system.sensord.pigeond as pd +import openpilot.system.sensord.pigeond as pd -from common.params import Params -from system.hardware import TICI -from selfdrive.manager.process_config import managed_processes -from selfdrive.test.helpers import with_processes +from openpilot.common.params import Params +from openpilot.system.hardware import TICI +from openpilot.selfdrive.manager.process_config import managed_processes +from openpilot.selfdrive.test.helpers import with_processes def wait_for_location(sm, timeout, con=10): diff --git a/tools/joystick/joystickd.py b/tools/joystick/joystickd.py index b31dab83fe..82847e3fa1 100755 --- a/tools/joystick/joystickd.py +++ b/tools/joystick/joystickd.py @@ -5,10 +5,10 @@ import threading from inputs import get_gamepad import cereal.messaging as messaging -from common.realtime import Ratekeeper -from common.numpy_fast import interp, clip -from common.params import Params -from tools.lib.kbhit import KBHit +from openpilot.common.realtime import Ratekeeper +from openpilot.common.numpy_fast import interp, clip +from openpilot.common.params import Params +from openpilot.tools.lib.kbhit import KBHit class Keyboard: diff --git a/tools/latencylogger/latency_logger.py b/tools/latencylogger/latency_logger.py index 81a4790dea..f2adc97e01 100755 --- a/tools/latencylogger/latency_logger.py +++ b/tools/latencylogger/latency_logger.py @@ -8,7 +8,7 @@ import sys from bisect import bisect_left, bisect_right from collections import defaultdict -from tools.lib.logreader import logreader_from_route_or_segment +from openpilot.tools.lib.logreader import logreader_from_route_or_segment DEMO_ROUTE = "9f583b1d93915c31|2022-05-18--10-49-51--0" diff --git a/tools/lib/README.md b/tools/lib/README.md index 8f540a5c82..daf74aaf40 100644 --- a/tools/lib/README.md +++ b/tools/lib/README.md @@ -3,8 +3,8 @@ Route is a class for conveniently accessing all the [logs](/system/loggerd/) from your routes. The LogReader class reads the non-video logs, i.e. rlog.bz2 and qlog.bz2. There's also a matching FrameReader class for reading the videos. ```python -from tools.lib.route import Route -from tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.logreader import LogReader r = Route("a2a0ccea32023010|2023-07-27--13-01-19") @@ -37,8 +37,8 @@ for msg in lr: `MultiLogIterator` is similar to `LogReader`, but reads multiple logs. ```python -from tools.lib.route import Route -from tools.lib.logreader import MultiLogIterator +from openpilot.tools.lib.route import Route +from openpilot.tools.lib.logreader import MultiLogIterator # setup a MultiLogIterator to read all the logs in the route r = Route("a2a0ccea32023010|2023-07-27--13-01-19") diff --git a/tools/lib/auth.py b/tools/lib/auth.py index a1bcdb1c58..7fc71b6895 100755 --- a/tools/lib/auth.py +++ b/tools/lib/auth.py @@ -29,8 +29,8 @@ from http.server import BaseHTTPRequestHandler, HTTPServer from typing import Any, Dict from urllib.parse import parse_qs, urlencode -from tools.lib.api import APIError, CommaApi, UnauthorizedError -from tools.lib.auth_config import set_token, get_token +from openpilot.tools.lib.api import APIError, CommaApi, UnauthorizedError +from openpilot.tools.lib.auth_config import set_token, get_token PORT = 3000 diff --git a/tools/lib/auth_config.py b/tools/lib/auth_config.py index 7952fee495..8863dd57a2 100644 --- a/tools/lib/auth_config.py +++ b/tools/lib/auth_config.py @@ -1,7 +1,7 @@ import json import os -from common.file_helpers import mkdirs_exists_ok -from system.hardware import PC +from openpilot.common.file_helpers import mkdirs_exists_ok +from openpilot.system.hardware import PC class MissingAuthConfigError(Exception): diff --git a/tools/lib/bootlog.py b/tools/lib/bootlog.py index 1e474e5dde..01756bb5e9 100644 --- a/tools/lib/bootlog.py +++ b/tools/lib/bootlog.py @@ -3,9 +3,9 @@ import functools import re from typing import List, Optional -from tools.lib.auth_config import get_token -from tools.lib.api import CommaApi -from tools.lib.helpers import RE, timestamp_to_datetime +from openpilot.tools.lib.auth_config import get_token +from openpilot.tools.lib.api import CommaApi +from openpilot.tools.lib.helpers import RE, timestamp_to_datetime @functools.total_ordering diff --git a/tools/lib/cache.py b/tools/lib/cache.py index 82b2298730..d142955e59 100644 --- a/tools/lib/cache.py +++ b/tools/lib/cache.py @@ -1,6 +1,6 @@ import os import urllib.parse -from common.file_helpers import mkdirs_exists_ok +from openpilot.common.file_helpers import mkdirs_exists_ok DEFAULT_CACHE_DIR = os.path.expanduser("~/.commacache") diff --git a/tools/lib/filereader.py b/tools/lib/filereader.py index 718b853b1a..5ac23d57ec 100644 --- a/tools/lib/filereader.py +++ b/tools/lib/filereader.py @@ -1,5 +1,5 @@ import os -from tools.lib.url_file import URLFile +from openpilot.tools.lib.url_file import URLFile DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/") diff --git a/tools/lib/framereader.py b/tools/lib/framereader.py index b4845b9f0d..27984514e9 100644 --- a/tools/lib/framereader.py +++ b/tools/lib/framereader.py @@ -13,11 +13,11 @@ import numpy as np from lru import LRU import _io -from tools.lib.cache import cache_path_for_file_path -from tools.lib.exceptions import DataUnreadableError -from common.file_helpers import atomic_write_in_dir +from openpilot.tools.lib.cache import cache_path_for_file_path +from openpilot.tools.lib.exceptions import DataUnreadableError +from openpilot.common.file_helpers import atomic_write_in_dir -from tools.lib.filereader import FileReader +from openpilot.tools.lib.filereader import FileReader HEVC_SLICE_B = 0 HEVC_SLICE_P = 1 diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index 8f1e5b9f80..e528996f32 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -8,8 +8,8 @@ import warnings from cereal import log as capnp_log -from tools.lib.filereader import FileReader -from tools.lib.route import Route, SegmentName +from openpilot.tools.lib.filereader import FileReader +from openpilot.tools.lib.route import Route, SegmentName # this is an iterator itself, and uses private variables from LogReader class MultiLogIterator: diff --git a/tools/lib/route.py b/tools/lib/route.py index 388cb003e6..e37b7d4434 100644 --- a/tools/lib/route.py +++ b/tools/lib/route.py @@ -5,9 +5,9 @@ from collections import defaultdict from itertools import chain from typing import Optional -from tools.lib.auth_config import get_token -from tools.lib.api import CommaApi -from tools.lib.helpers import RE +from openpilot.tools.lib.auth_config import get_token +from openpilot.tools.lib.api import CommaApi +from openpilot.tools.lib.helpers import RE QLOG_FILENAMES = ['qlog', 'qlog.bz2'] QCAMERA_FILENAMES = ['qcamera.ts'] diff --git a/tools/lib/tests/test_caching.py b/tools/lib/tests/test_caching.py index d2a2a6872f..1e44b96489 100644 --- a/tools/lib/tests/test_caching.py +++ b/tools/lib/tests/test_caching.py @@ -4,7 +4,7 @@ import shutil import unittest os.environ["COMMA_CACHE"] = "/tmp/__test_cache__" -from tools.lib.url_file import URLFile, CACHE_DIR +from openpilot.tools.lib.url_file import URLFile, CACHE_DIR class TestFileDownload(unittest.TestCase): diff --git a/tools/lib/tests/test_readers.py b/tools/lib/tests/test_readers.py index 6efa0dc351..1f24ae5c8e 100755 --- a/tools/lib/tests/test_readers.py +++ b/tools/lib/tests/test_readers.py @@ -5,8 +5,8 @@ import tempfile from collections import defaultdict import numpy as np -from tools.lib.framereader import FrameReader -from tools.lib.logreader import LogReader +from openpilot.tools.lib.framereader import FrameReader +from openpilot.tools.lib.logreader import LogReader class TestReaders(unittest.TestCase): diff --git a/tools/lib/tests/test_route_library.py b/tools/lib/tests/test_route_library.py index 814017c9cc..7977f17be2 100755 --- a/tools/lib/tests/test_route_library.py +++ b/tools/lib/tests/test_route_library.py @@ -2,7 +2,7 @@ import unittest from collections import namedtuple -from tools.lib.route import SegmentName +from openpilot.tools.lib.route import SegmentName class TestRouteLibrary(unittest.TestCase): def test_segment_name_formats(self): diff --git a/tools/lib/url_file.py b/tools/lib/url_file.py index 1e94a588f1..c2c7fc9d38 100644 --- a/tools/lib/url_file.py +++ b/tools/lib/url_file.py @@ -9,7 +9,7 @@ import pycurl from hashlib import sha256 from io import BytesIO from tenacity import retry, wait_random_exponential, stop_after_attempt -from common.file_helpers import mkdirs_exists_ok, atomic_write_in_dir +from openpilot.common.file_helpers import mkdirs_exists_ok, atomic_write_in_dir # Cache chunk size K = 1000 CHUNK_SIZE = 1000 * K diff --git a/tools/plotjuggler/juggle.py b/tools/plotjuggler/juggle.py index a5d6974f9c..02858b1edf 100755 --- a/tools/plotjuggler/juggle.py +++ b/tools/plotjuggler/juggle.py @@ -10,11 +10,11 @@ import tempfile import requests import argparse -from common.basedir import BASEDIR -from selfdrive.test.openpilotci import get_url -from tools.lib.logreader import LogReader -from tools.lib.route import Route, SegmentName -from tools.lib.helpers import save_log +from openpilot.common.basedir import BASEDIR +from openpilot.selfdrive.test.openpilotci import get_url +from openpilot.tools.lib.logreader import LogReader +from openpilot.tools.lib.route import Route, SegmentName +from openpilot.tools.lib.helpers import save_log from urllib.parse import urlparse, parse_qs juggle_dir = os.path.dirname(os.path.realpath(__file__)) @@ -129,7 +129,7 @@ def juggle_route(route_or_segment_name, segment_count, qlog, can, layout, dbc=No if dbc is None: for cp in [m for m in all_data if m.which() == 'carParams']: try: - DBC = __import__(f"selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC + DBC = __import__(f"openpilot.selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC dbc = DBC[cp.carParams.carFingerprint]['pt'] except Exception: pass diff --git a/tools/plotjuggler/test_plotjuggler.py b/tools/plotjuggler/test_plotjuggler.py index 8fc032042a..e29e33f921 100755 --- a/tools/plotjuggler/test_plotjuggler.py +++ b/tools/plotjuggler/test_plotjuggler.py @@ -6,9 +6,9 @@ import subprocess import time import unittest -from common.basedir import BASEDIR -from common.timeout import Timeout -from tools.plotjuggler.juggle import install +from openpilot.common.basedir import BASEDIR +from openpilot.common.timeout import Timeout +from openpilot.tools.plotjuggler.juggle import install PJ_DIR = os.path.join(BASEDIR, "tools/plotjuggler") diff --git a/tools/replay/can_replay.py b/tools/replay/can_replay.py index 44b109514f..032c29824a 100755 --- a/tools/replay/can_replay.py +++ b/tools/replay/can_replay.py @@ -8,10 +8,10 @@ from tqdm import tqdm os.environ['FILEREADER_CACHE'] = '1' -from common.realtime import config_realtime_process, Ratekeeper, DT_CTRL -from selfdrive.boardd.boardd import can_capnp_to_can_list -from tools.plotjuggler.juggle import load_segment -from tools.lib.logreader import logreader_from_route_or_segment +from openpilot.common.realtime import config_realtime_process, Ratekeeper, DT_CTRL +from openpilot.selfdrive.boardd.boardd import can_capnp_to_can_list +from openpilot.tools.plotjuggler.juggle import load_segment +from openpilot.tools.lib.logreader import logreader_from_route_or_segment from panda import Panda, PandaJungle def send_thread(s, flock): diff --git a/tools/replay/lib/ui_helpers.py b/tools/replay/lib/ui_helpers.py index 4ab8efab61..aa13502143 100644 --- a/tools/replay/lib/ui_helpers.py +++ b/tools/replay/lib/ui_helpers.py @@ -7,10 +7,10 @@ import pygame # pylint: disable=import-error from matplotlib.backends.backend_agg import FigureCanvasAgg -from common.transformations.camera import (eon_f_frame_size, eon_f_focal_length, +from openpilot.common.transformations.camera import (eon_f_frame_size, eon_f_focal_length, tici_f_frame_size, tici_f_focal_length, get_view_frame_from_calib_frame) -from selfdrive.controls.radard import RADAR_TO_CAMERA +from openpilot.selfdrive.controls.radard import RADAR_TO_CAMERA RED = (255, 0, 0) diff --git a/tools/replay/ui.py b/tools/replay/ui.py index a222e8e5b6..1659a024a4 100755 --- a/tools/replay/ui.py +++ b/tools/replay/ui.py @@ -8,9 +8,9 @@ import numpy as np import pygame # pylint: disable=import-error import cereal.messaging as messaging -from common.numpy_fast import clip -from common.basedir import BASEDIR -from tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, UP, +from openpilot.common.numpy_fast import clip +from openpilot.common.basedir import BASEDIR +from openpilot.tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, UP, _INTRINSICS, BLACK, GREEN, YELLOW, Calibration, get_blank_lid_overlay, init_plots, diff --git a/tools/replay/unlog_ci_segment.py b/tools/replay/unlog_ci_segment.py index c008a7aeff..8d69ae954b 100755 --- a/tools/replay/unlog_ci_segment.py +++ b/tools/replay/unlog_ci_segment.py @@ -11,9 +11,9 @@ import tty from collections import defaultdict import cereal.messaging as messaging -from tools.lib.framereader import FrameReader -from tools.lib.logreader import LogReader -from selfdrive.test.openpilotci import get_url +from openpilot.tools.lib.framereader import FrameReader +from openpilot.tools.lib.logreader import LogReader +from openpilot.selfdrive.test.openpilotci import get_url IGNORE = ['initData', 'sentinel'] diff --git a/tools/scripts/fetch_image_from_route.py b/tools/scripts/fetch_image_from_route.py index 139373f665..471db7ee3e 100755 --- a/tools/scripts/fetch_image_from_route.py +++ b/tools/scripts/fetch_image_from_route.py @@ -8,8 +8,8 @@ if len(sys.argv) < 4: import requests from PIL import Image -from tools.lib.auth_config import get_token -from tools.lib.framereader import FrameReader +from openpilot.tools.lib.auth_config import get_token +from openpilot.tools.lib.framereader import FrameReader jwt = get_token() diff --git a/tools/scripts/save_ubloxraw_stream.py b/tools/scripts/save_ubloxraw_stream.py index 3fefd45ba8..541252d270 100644 --- a/tools/scripts/save_ubloxraw_stream.py +++ b/tools/scripts/save_ubloxraw_stream.py @@ -2,9 +2,9 @@ import argparse import os import sys -from common.basedir import BASEDIR -from tools.lib.logreader import MultiLogIterator -from tools.lib.route import Route +from openpilot.common.basedir import BASEDIR +from openpilot.tools.lib.logreader import MultiLogIterator +from openpilot.tools.lib.route import Route os.environ['BASEDIR'] = BASEDIR diff --git a/tools/scripts/setup_ssh_keys.py b/tools/scripts/setup_ssh_keys.py index 8f03303b59..699765eee1 100755 --- a/tools/scripts/setup_ssh_keys.py +++ b/tools/scripts/setup_ssh_keys.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import requests -from common.params import Params +from openpilot.common.params import Params import sys diff --git a/tools/sim/Dockerfile.sim b/tools/sim/Dockerfile.sim index 48aa12ebc6..d312f34ecd 100644 --- a/tools/sim/Dockerfile.sim +++ b/tools/sim/Dockerfile.sim @@ -14,6 +14,7 @@ RUN mkdir -p $HOME/openpilot COPY SConstruct $HOME/openpilot/ +COPY ./openpilot $HOME/openpilot/openpilot COPY ./body $HOME/openpilot/body COPY ./third_party $HOME/openpilot/third_party COPY ./site_scons $HOME/openpilot/site_scons @@ -30,4 +31,4 @@ COPY ./tools $HOME/openpilot/tools WORKDIR $HOME/openpilot RUN scons --cache-readonly -j12 -RUN python -c "from selfdrive.test.helpers import set_params_enabled; set_params_enabled()" +RUN python -c "from openpilot.selfdrive.test.helpers import set_params_enabled; set_params_enabled()" diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py index 64446e1115..bacf38296e 100755 --- a/tools/sim/bridge.py +++ b/tools/sim/bridge.py @@ -16,13 +16,13 @@ import pyopencl.array as cl_array import cereal.messaging as messaging from cereal import log from cereal.visionipc import VisionIpcServer, VisionStreamType -from common.basedir import BASEDIR -from common.numpy_fast import clip -from common.params import Params -from common.realtime import DT_DMON, Ratekeeper -from selfdrive.car.honda.values import CruiseButtons -from selfdrive.test.helpers import set_params_enabled -from tools.sim.lib.can import can_function +from openpilot.common.basedir import BASEDIR +from openpilot.common.numpy_fast import clip +from openpilot.common.params import Params +from openpilot.common.realtime import DT_DMON, Ratekeeper +from openpilot.selfdrive.car.honda.values import CruiseButtons +from openpilot.selfdrive.test.helpers import set_params_enabled +from openpilot.tools.sim.lib.can import can_function W, H = 1928, 1208 REPEAT_COUNTER = 5 @@ -550,12 +550,12 @@ if __name__ == "__main__": if args.joystick: # start input poll for joystick - from tools.sim.lib.manual_ctrl import wheel_poll_thread + from openpilot.tools.sim.lib.manual_ctrl import wheel_poll_thread wheel_poll_thread(q) else: # start input poll for keyboard - from tools.sim.lib.keyboard_ctrl import keyboard_poll_thread + from openpilot.tools.sim.lib.keyboard_ctrl import keyboard_poll_thread keyboard_poll_thread(q) p.join() diff --git a/tools/sim/lib/can.py b/tools/sim/lib/can.py index d0b5888392..4cecbb2a67 100755 --- a/tools/sim/lib/can.py +++ b/tools/sim/lib/can.py @@ -2,8 +2,8 @@ import cereal.messaging as messaging from opendbc.can.packer import CANPacker from opendbc.can.parser import CANParser -from selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error -from selfdrive.car import crc8_pedal +from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error +from openpilot.selfdrive.car import crc8_pedal packer = CANPacker("honda_civic_touring_2016_can_generated") rpacker = CANPacker("acura_ilx_2016_nidec") diff --git a/tools/sim/tests/test_carla_integration.py b/tools/sim/tests/test_carla_integration.py index cfaf95ca01..65f5f4a30f 100755 --- a/tools/sim/tests/test_carla_integration.py +++ b/tools/sim/tests/test_carla_integration.py @@ -6,10 +6,10 @@ import os from multiprocessing import Queue from cereal import messaging -from common.basedir import BASEDIR -from selfdrive.manager.helpers import unblock_stdout -from tools.sim import bridge -from tools.sim.bridge import CarlaBridge +from openpilot.common.basedir import BASEDIR +from openpilot.selfdrive.manager.helpers import unblock_stdout +from openpilot.tools.sim import bridge +from openpilot.tools.sim.bridge import CarlaBridge CI = "CI" in os.environ diff --git a/tools/tuning/measure_steering_accuracy.py b/tools/tuning/measure_steering_accuracy.py index b816d82f91..c615608852 100755 --- a/tools/tuning/measure_steering_accuracy.py +++ b/tools/tuning/measure_steering_accuracy.py @@ -8,7 +8,7 @@ import signal from collections import defaultdict import cereal.messaging as messaging -from tools.lib.logreader import logreader_from_route_or_segment +from openpilot.tools.lib.logreader import logreader_from_route_or_segment def sigint_handler(signal, frame): exit(0) diff --git a/tools/webcam/front_mount_helper.py b/tools/webcam/front_mount_helper.py index 2ae35992ec..d4f7d71b41 100755 --- a/tools/webcam/front_mount_helper.py +++ b/tools/webcam/front_mount_helper.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import numpy as np -# copied from common.transformations/camera.py +# copied from openpilot.common.transformations/camera.py eon_dcam_focal_length = 860.0 # pixels webcam_focal_length = 908.0 # pixels diff --git a/tools/webcam/warp_vis.py b/tools/webcam/warp_vis.py index 4331614acf..a9ae25ee67 100755 --- a/tools/webcam/warp_vis.py +++ b/tools/webcam/warp_vis.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import numpy as np -# copied from common.transformations/camera.py +# copied from openpilot.common.transformations/camera.py eon_focal_length = 910.0 # pixels eon_dcam_focal_length = 860.0 # pixels diff --git a/tools/zookeeper/check_consumption.py b/tools/zookeeper/check_consumption.py index 1345b90571..dab948318f 100755 --- a/tools/zookeeper/check_consumption.py +++ b/tools/zookeeper/check_consumption.py @@ -2,7 +2,7 @@ import sys import time -from tools.zookeeper import Zookeeper +from openpilot.tools.zookeeper import Zookeeper # Usage: check_consumption.py # Exit code: 0 -> passed diff --git a/tools/zookeeper/disable.py b/tools/zookeeper/disable.py index 6c1eecc18b..4bea3e7ed0 100755 --- a/tools/zookeeper/disable.py +++ b/tools/zookeeper/disable.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from tools.zookeeper import Zookeeper +from openpilot.tools.zookeeper import Zookeeper if __name__ == "__main__": z = Zookeeper() diff --git a/tools/zookeeper/enable_and_wait.py b/tools/zookeeper/enable_and_wait.py index 6907e6017c..51b8dc0a5c 100755 --- a/tools/zookeeper/enable_and_wait.py +++ b/tools/zookeeper/enable_and_wait.py @@ -3,7 +3,7 @@ import os import sys import time from socket import gethostbyname, gaierror -from tools.zookeeper import Zookeeper +from openpilot.tools.zookeeper import Zookeeper def is_online(ip): try: diff --git a/tools/zookeeper/ignition.py b/tools/zookeeper/ignition.py index 5c85be203d..d5f01c362f 100755 --- a/tools/zookeeper/ignition.py +++ b/tools/zookeeper/ignition.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import sys -from tools.zookeeper import Zookeeper +from openpilot.tools.zookeeper import Zookeeper if __name__ == "__main__": diff --git a/tools/zookeeper/power_monitor.py b/tools/zookeeper/power_monitor.py index fa1f442bbc..a081baa72a 100755 --- a/tools/zookeeper/power_monitor.py +++ b/tools/zookeeper/power_monitor.py @@ -3,9 +3,9 @@ import sys import time import datetime -from common.realtime import Ratekeeper -from common.filter_simple import FirstOrderFilter -from tools.zookeeper import Zookeeper +from openpilot.common.realtime import Ratekeeper +from openpilot.common.filter_simple import FirstOrderFilter +from openpilot.tools.zookeeper import Zookeeper if __name__ == "__main__": z = Zookeeper() diff --git a/tools/zookeeper/test_zookeeper.py b/tools/zookeeper/test_zookeeper.py index ba395ad7ba..89f7f28975 100755 --- a/tools/zookeeper/test_zookeeper.py +++ b/tools/zookeeper/test_zookeeper.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import time -from tools.zookeeper import Zookeeper +from openpilot.tools.zookeeper import Zookeeper if __name__ == "__main__": From ff068dd722b31078b9356d3f55e4898cf00a89cb Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 20 Aug 2023 21:08:04 -0700 Subject: [PATCH 036/159] move mypy config into pyproject.toml (#29501) * move mypy config into pyproject.toml * rm reference --- .github/workflows/selfdrive_tests.yaml | 1 - mypy.ini | 16 ------------- pyproject.toml | 31 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 17 deletions(-) delete mode 100644 mypy.ini diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 0aad8ba0bb..435c2df251 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -64,7 +64,6 @@ jobs: run: | cd $GITHUB_WORKSPACE cp .pre-commit-config.yaml $STRIPPED_DIR - cp mypy.ini $STRIPPED_DIR cp pyproject.toml $STRIPPED_DIR cp poetry.lock $STRIPPED_DIR cd $STRIPPED_DIR diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 74d0ac2175..0000000000 --- a/mypy.ini +++ /dev/null @@ -1,16 +0,0 @@ -[mypy] -python_version = 3.11 -plugins = numpy.typing.mypy_plugin -files = body, common, docs, scripts, selfdrive, site_scons, system, tools -exclude = ^(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/) - -; third-party packages -ignore_missing_imports = True - -; helpful warnings -warn_redundant_casts = True -warn_unreachable = True -warn_unused_ignores = True - -; restrict dynamic typing -warn_return_any = True diff --git a/pyproject.toml b/pyproject.toml index d9cc49bfd0..0af1bfcfae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,37 @@ addopts = "--ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --igno python_files = "test_*.py" timeout = "30" # you get this long by default +[tool.mypy] +python_version = "3.11" +plugins = [ + "numpy.typing.mypy_plugin", +] +exclude = [ + "body/", + "cereal/", + "opendbc/", + "panda/", + "laika/", + "laika_repo/", + "rednose/", + "rednose_repo/", + "tinygrad/", + "tinygrad_repo/", + "third_party/", +] + +# third-party packages +ignore_missing_imports=true + +# helpful warnings +warn_redundant_casts=true +warn_unreachable=true +warn_unused_ignores=true + +# restrict dynamic typing +warn_return_any=true + + [tool.poetry] name = "openpilot" version = "0.1.0" From 3eef63af9b4f4a25bc4c3a0d6ad450bba9f62205 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 21 Aug 2023 12:27:02 +0800 Subject: [PATCH 037/159] common: C++ RateKeeper (#29374) * c++ RateKeeper * add to files_common * use util::random_int * improve monotor_time * remove ~ratekeeper --- .github/workflows/selfdrive_tests.yaml | 1 + common/SConscript | 2 ++ common/ratekeeper.cc | 38 ++++++++++++++++++++++++++ common/ratekeeper.h | 22 +++++++++++++++ common/tests/.gitignore | 1 + common/tests/test_ratekeeper.cc | 17 ++++++++++++ release/files_common | 2 ++ selfdrive/boardd/boardd.cc | 24 ++++------------ system/proclogd/main.cc | 5 +++- system/sensord/sensors_qcom2.cc | 8 +++--- 10 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 common/ratekeeper.cc create mode 100644 common/ratekeeper.h create mode 100644 common/tests/test_ratekeeper.cc diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 435c2df251..90a1c14aa0 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -275,6 +275,7 @@ jobs: QT_QPA_PLATFORM=offscreen ./selfdrive/ui/tests/test_translations && \ ./selfdrive/ui/tests/test_translations.py && \ ./common/tests/test_util && \ + ./common/tests/test_ratekeeper && \ ./common/tests/test_swaglog && \ ./selfdrive/boardd/tests/test_boardd_usbprotocol && \ ./system/loggerd/tests/test_logger &&\ diff --git a/common/SConscript b/common/SConscript index 71894923a6..bece09947a 100644 --- a/common/SConscript +++ b/common/SConscript @@ -12,6 +12,7 @@ common_libs = [ 'util.cc', 'i2c.cc', 'watchdog.cc', + 'ratekeeper.cc' ] if arch != "Darwin": @@ -29,6 +30,7 @@ Export('_common', '_gpucommon') if GetOption('test'): env.Program('tests/test_util', ['tests/test_util.cc'], LIBS=[_common]) env.Program('tests/test_swaglog', ['tests/test_swaglog.cc'], LIBS=[_common, 'json11', 'zmq', 'pthread']) + env.Program('tests/test_ratekeeper', ['tests/test_ratekeeper.cc'], LIBS=[_common, 'json11', 'zmq', 'pthread']) # Cython envCython.Program('params_pyx.so', 'params_pyx.pyx', LIBS=envCython['LIBS'] + [_common, 'zmq', 'json11']) diff --git a/common/ratekeeper.cc b/common/ratekeeper.cc new file mode 100644 index 0000000000..c00d72a94a --- /dev/null +++ b/common/ratekeeper.cc @@ -0,0 +1,38 @@ +#include "common/ratekeeper.h" + +#include "common/swaglog.h" +#include "common/timing.h" +#include "common/util.h" + +RateKeeper::RateKeeper(const std::string &name, float rate, float print_delay_threshold) + : name(name), + print_delay_threshold(std::max(0.f, print_delay_threshold)) { + interval = 1 / rate; + last_monitor_time = seconds_since_boot(); + next_frame_time = last_monitor_time + interval; +} + +bool RateKeeper::keepTime() { + bool lagged = monitorTime(); + if (remaining_ > 0) { + util::sleep_for(remaining_ * 1000); + } + return lagged; +} + +bool RateKeeper::monitorTime() { + ++frame_; + last_monitor_time = seconds_since_boot(); + remaining_ = next_frame_time - last_monitor_time; + + bool lagged = remaining_ < 0; + if (lagged) { + if (print_delay_threshold > 0 && remaining_ < -print_delay_threshold) { + LOGW("%s lagging by %.2f ms", name.c_str(), -remaining_ * 1000); + } + next_frame_time = last_monitor_time + interval; + } else { + next_frame_time += interval; + } + return lagged; +} diff --git a/common/ratekeeper.h b/common/ratekeeper.h new file mode 100644 index 0000000000..ff4cb42c7b --- /dev/null +++ b/common/ratekeeper.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +class RateKeeper { +public: + RateKeeper(const std::string &name, float rate, float print_delay_threshold = 0); + ~RateKeeper() {} + bool keepTime(); + bool monitorTime(); + inline double frame() const { return frame_; } + inline double remaining() const { return remaining_; } + +private: + double interval; + double next_frame_time; + double last_monitor_time; + double remaining_ = 0; + float print_delay_threshold = 0; + uint64_t frame_ = 0; + std::string name; +}; diff --git a/common/tests/.gitignore b/common/tests/.gitignore index 1350b3b825..984c505f92 100644 --- a/common/tests/.gitignore +++ b/common/tests/.gitignore @@ -1,2 +1,3 @@ +test_ratekeeper test_util test_swaglog diff --git a/common/tests/test_ratekeeper.cc b/common/tests/test_ratekeeper.cc new file mode 100644 index 0000000000..66d229bdbb --- /dev/null +++ b/common/tests/test_ratekeeper.cc @@ -0,0 +1,17 @@ +#define CATCH_CONFIG_MAIN +#include "catch2/catch.hpp" +#include "common/ratekeeper.h" +#include "common/timing.h" +#include "common/util.h" + +TEST_CASE("RateKeeper") { + float freq = GENERATE(10, 50, 100); + RateKeeper rk("Test RateKeeper", freq); + for (int i = 0; i < freq; ++i) { + double begin = seconds_since_boot(); + util::sleep_for(util::random_int(0, 1000.0 / freq - 1)); + bool lagged = rk.keepTime(); + REQUIRE(std::abs(seconds_since_boot() - begin - (1 / freq)) < 1e-3); + REQUIRE(lagged == false); + } +} diff --git a/release/files_common b/release/files_common index 023fd9e3af..bac9b382d6 100644 --- a/release/files_common +++ b/release/files_common @@ -162,6 +162,8 @@ common/clutil.cc common/clutil.h common/params.h common/params.cc +common/ratekeeper.cc +common/ratekeeper.h common/watchdog.cc common/watchdog.h diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 31ae0a4102..20c2800e8e 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -23,6 +23,7 @@ #include "cereal/gen/cpp/car.capnp.h" #include "cereal/messaging/messaging.h" #include "common/params.h" +#include "common/ratekeeper.h" #include "common/swaglog.h" #include "common/timing.h" #include "common/util.h" @@ -248,8 +249,7 @@ void can_recv_thread(std::vector pandas) { PubMaster pm({"can"}); // run at 100Hz - const uint64_t dt = 10000000ULL; - uint64_t next_frame_time = nanos_since_boot() + dt; + RateKeeper rk("boardd_can_recv", 100); std::vector raw_can_data; while (!do_exit && check_all_connected(pandas)) { @@ -271,18 +271,7 @@ void can_recv_thread(std::vector pandas) { } pm.send("can", msg); - uint64_t cur_time = nanos_since_boot(); - int64_t remaining = next_frame_time - cur_time; - if (remaining > 0) { - std::this_thread::sleep_for(std::chrono::nanoseconds(remaining)); - } else { - if (ignition) { - LOGW("missed cycles (%lu) %lld", (unsigned long)(-1*remaining/dt), (long long)remaining); - } - next_frame_time = cur_time; - } - - next_frame_time += dt; + rk.keepTime(); } } @@ -483,9 +472,9 @@ void panda_state_thread(std::vector pandas, bool spoofing_started) { LOGD("start panda state thread"); // run at 2hz - while (!do_exit && check_all_connected(pandas)) { - uint64_t start_time = nanos_since_boot(); + RateKeeper rk("panda_state_thread", 2); + while (!do_exit && check_all_connected(pandas)) { // send out peripheralState send_peripheral_state(&pm, peripheral_panda); auto ignition_opt = send_panda_states(&pm, pandas, spoofing_started); @@ -543,8 +532,7 @@ void panda_state_thread(std::vector pandas, bool spoofing_started) { panda->send_heartbeat(engaged); } - uint64_t dt = nanos_since_boot() - start_time; - util::sleep_for(500 - dt / 1000000ULL); + rk.keepTime(); } } diff --git a/system/proclogd/main.cc b/system/proclogd/main.cc index c4faa916d9..3f8a889eea 100644 --- a/system/proclogd/main.cc +++ b/system/proclogd/main.cc @@ -1,6 +1,7 @@ #include +#include "common/ratekeeper.h" #include "common/util.h" #include "system/proclogd/proclog.h" @@ -9,13 +10,15 @@ ExitHandler do_exit; int main(int argc, char **argv) { setpriority(PRIO_PROCESS, 0, -15); + RateKeeper rk("proclogd", 0.5); PubMaster publisher({"procLog"}); + while (!do_exit) { MessageBuilder msg; buildProcLogMessage(msg); publisher.send("procLog", msg); - util::sleep_for(2000); // 2 secs + rk.keepTime(); } return 0; diff --git a/system/sensord/sensors_qcom2.cc b/system/sensord/sensors_qcom2.cc index 349c67f498..e09c722fc2 100644 --- a/system/sensord/sensors_qcom2.cc +++ b/system/sensord/sensors_qcom2.cc @@ -9,6 +9,7 @@ #include "cereal/messaging/messaging.h" #include "common/i2c.h" +#include "common/ratekeeper.h" #include "common/swaglog.h" #include "common/timing.h" #include "common/util.h" @@ -173,10 +174,10 @@ int sensor_loop(I2CBus *i2c_bus_imu) { std::thread lsm_interrupt_thread(&interrupt_loop, std::ref(lsm_interrupt_sensors), std::ref(sensor_service)); + RateKeeper rk("sensord", 100); + // polling loop for non interrupt handled sensors while (!do_exit) { - std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); - for (Sensor *sensor : sensors) { MessageBuilder msg; if (!sensor->get_event(msg)) { @@ -190,8 +191,7 @@ int sensor_loop(I2CBus *i2c_bus_imu) { pm_non_int.send(sensor_service[sensor].c_str(), msg); } - std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); - std::this_thread::sleep_for(std::chrono::milliseconds(10) - (end - begin)); + rk.keepTime(); } for (Sensor *sensor : sensors) { From f5071411cb460cc64474f533143f37ba3eb54ce6 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 20 Aug 2023 22:38:39 -0700 Subject: [PATCH 038/159] sensord: rm light sensor (#29503) --- system/sensord/SConscript | 2 -- system/sensord/sensors/file_sensor.cc | 17 ---------------- system/sensord/sensors/file_sensor.h | 19 ------------------ system/sensord/sensors/light_sensor.cc | 27 -------------------------- system/sensord/sensors/light_sensor.h | 9 --------- system/sensord/sensors_qcom2.cc | 9 +-------- system/sensord/tests/test_sensord.py | 18 +++++------------ 7 files changed, 6 insertions(+), 95 deletions(-) delete mode 100644 system/sensord/sensors/file_sensor.cc delete mode 100644 system/sensord/sensors/file_sensor.h delete mode 100644 system/sensord/sensors/light_sensor.cc delete mode 100644 system/sensord/sensors/light_sensor.h diff --git a/system/sensord/SConscript b/system/sensord/SConscript index 8f26c00853..63d1d0d690 100644 --- a/system/sensord/SConscript +++ b/system/sensord/SConscript @@ -1,9 +1,7 @@ Import('env', 'arch', 'common', 'cereal', 'messaging') sensors = [ - 'sensors/file_sensor.cc', 'sensors/i2c_sensor.cc', - 'sensors/light_sensor.cc', 'sensors/bmx055_accel.cc', 'sensors/bmx055_gyro.cc', 'sensors/bmx055_magn.cc', diff --git a/system/sensord/sensors/file_sensor.cc b/system/sensord/sensors/file_sensor.cc deleted file mode 100644 index a74ae1ae1e..0000000000 --- a/system/sensord/sensors/file_sensor.cc +++ /dev/null @@ -1,17 +0,0 @@ -#include "file_sensor.h" - -#include - -FileSensor::FileSensor(std::string filename) : file(filename) {} - -int FileSensor::init() { - return file.is_open() ? 0 : 1; -} - -FileSensor::~FileSensor() { - file.close(); -} - -bool FileSensor::has_interrupt_enabled() { - return false; -} \ No newline at end of file diff --git a/system/sensord/sensors/file_sensor.h b/system/sensord/sensors/file_sensor.h deleted file mode 100644 index 07d7e8f946..0000000000 --- a/system/sensord/sensors/file_sensor.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include - -#include "cereal/gen/cpp/log.capnp.h" -#include "system/sensord/sensors/sensor.h" - -class FileSensor : public Sensor { -protected: - std::ifstream file; - -public: - FileSensor(std::string filename); - ~FileSensor(); - int init(); - bool has_interrupt_enabled(); - virtual bool get_event(MessageBuilder &msg, uint64_t ts = 0) = 0; -}; diff --git a/system/sensord/sensors/light_sensor.cc b/system/sensord/sensors/light_sensor.cc deleted file mode 100644 index 99e321b47d..0000000000 --- a/system/sensord/sensors/light_sensor.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include "light_sensor.h" - -#include - -#include "common/timing.h" -#include "system/sensord/sensors/constants.h" - -LightSensor::LightSensor(std::string filename) : FileSensor(filename) {} - -bool LightSensor::get_event(MessageBuilder &msg, uint64_t ts) { - uint64_t start_time = nanos_since_boot(); - file.clear(); - file.seekg(0); - - int value; - file >> value; - - auto event = msg.initEvent().initLightSensor(); - event.setSource(cereal::SensorEventData::SensorSource::RPR0521); - event.setVersion(1); - event.setSensor(SENSOR_LIGHT); - event.setType(SENSOR_TYPE_LIGHT); - event.setTimestamp(start_time); - event.setLight(value); - - return true; -} diff --git a/system/sensord/sensors/light_sensor.h b/system/sensord/sensors/light_sensor.h deleted file mode 100644 index 7ed1c1f70c..0000000000 --- a/system/sensord/sensors/light_sensor.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "file_sensor.h" - -class LightSensor : public FileSensor { -public: - LightSensor(std::string filename); - bool get_event(MessageBuilder &msg, uint64_t ts = 0); - int shutdown() { return 0; } -}; diff --git a/system/sensord/sensors_qcom2.cc b/system/sensord/sensors_qcom2.cc index e09c722fc2..9276a029c3 100644 --- a/system/sensord/sensors_qcom2.cc +++ b/system/sensord/sensors_qcom2.cc @@ -18,7 +18,6 @@ #include "system/sensord/sensors/bmx055_magn.h" #include "system/sensord/sensors/bmx055_temp.h" #include "system/sensord/sensors/constants.h" -#include "system/sensord/sensors/light_sensor.h" #include "system/sensord/sensors/lsm6ds3_accel.h" #include "system/sensord/sensors/lsm6ds3_gyro.h" #include "system/sensord/sensors/lsm6ds3_temp.h" @@ -101,8 +100,6 @@ int sensor_loop(I2CBus *i2c_bus_imu) { MMC5603NJ_Magn mmc5603nj_magn(i2c_bus_imu); - LightSensor light("/sys/class/i2c-adapter/i2c-2/2-0038/iio:device1/in_intensity_both_raw"); - std::map sensor_service = { {&bmx055_accel, "accelerometer2"}, {&bmx055_gyro, "gyroscope2"}, @@ -114,7 +111,6 @@ int sensor_loop(I2CBus *i2c_bus_imu) { {&lsm6ds3_temp, "temperatureSensor"}, {&mmc5603nj_magn, "magnetometer"}, - {&light, "lightSensor"} }; // Sensor init @@ -130,8 +126,6 @@ int sensor_loop(I2CBus *i2c_bus_imu) { sensors_init.push_back({&mmc5603nj_magn, false}); - sensors_init.push_back({&light, true}); - bool has_magnetometer = false; // Initialize sensors @@ -165,8 +159,7 @@ int sensor_loop(I2CBus *i2c_bus_imu) { util::set_core_affinity({1}); std::system("sudo su -c 'echo 1 > /proc/irq/336/smp_affinity_list'"); - PubMaster pm_non_int({"gyroscope2", "accelerometer2", "temperatureSensor", - "lightSensor", "magnetometer"}); + PubMaster pm_non_int({"gyroscope2", "accelerometer2", "temperatureSensor", "magnetometer"}); init_ts = nanos_since_boot(); // thread for reading events via interrupts diff --git a/system/sensord/tests/test_sensord.py b/system/sensord/tests/test_sensord.py index b394a86b59..87ead0bc1b 100755 --- a/system/sensord/tests/test_sensord.py +++ b/system/sensord/tests/test_sensord.py @@ -29,24 +29,16 @@ MMC = { ('mmc5603nj', 'magneticUncalibrated'), } -RPR = { - ('rpr0521', 'light'), -} - SENSOR_CONFIGURATIONS = ( - (BMX | LSM | RPR), - (MMC | LSM | RPR), - (BMX | LSM_C | RPR), - (MMC| LSM_C | RPR), + (BMX | LSM), + (MMC | LSM), + (BMX | LSM_C), + (MMC| LSM_C), ) Sensor = log.SensorEventData.SensorSource SensorConfig = namedtuple('SensorConfig', ['type', 'sanity_min', 'sanity_max', 'expected_freq']) ALL_SENSORS = { - Sensor.rpr0521: { - SensorConfig("light", 0, 1023, 100), - }, - Sensor.lsm6ds3: { SensorConfig("acceleration", 5, 15, 100), SensorConfig("gyroUncalibrated", 0, .2, 100), @@ -79,7 +71,7 @@ def get_irq_count(irq: int): def read_sensor_events(duration_sec): sensor_types = ['accelerometer', 'gyroscope', 'magnetometer', 'accelerometer2', - 'gyroscope2', 'lightSensor', 'temperatureSensor'] + 'gyroscope2', 'temperatureSensor'] esocks = {} events = defaultdict(list) for stype in sensor_types: From 71d8f41ed8fd8644b44420b4f695c5f4ac820e30 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Tue, 22 Aug 2023 00:41:17 +0800 Subject: [PATCH 039/159] boardd: keepTime after failing to get `ignition_opt` (#29506) * keep time after failing to get ignition_opt * Update selfdrive/boardd/boardd.cc --------- Co-authored-by: Adeeb Shihadeh --- selfdrive/boardd/boardd.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 20c2800e8e..6a19f6d593 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -480,6 +480,8 @@ void panda_state_thread(std::vector pandas, bool spoofing_started) { auto ignition_opt = send_panda_states(&pm, pandas, spoofing_started); if (!ignition_opt) { + LOGE("Failed to get ignition_opt"); + rk.keepTime(); continue; } From 551b0cc8f20794362ce66ecee0afb7cbcf4f97b1 Mon Sep 17 00:00:00 2001 From: Caleb Stultz Date: Mon, 21 Aug 2023 10:43:31 -0700 Subject: [PATCH 040/159] Remove Kia Sorento from LEGACY_SAFETY_MODE_CAR (#29502) * Remove Kia Sorento from LEGACY_SAFETY_MODE_CAR * Update values.py * Added Kia Sorento to UNSUPPORTED_LONGITUDINAL_CAR --- selfdrive/car/hyundai/values.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index dc90fbfba7..c82674a43e 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1939,11 +1939,11 @@ EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR # these cars require a special panda safety mode due to missing counters and checksums in the messages LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, - CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, + CAR.SONATA_LF, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022} # these cars have not been verified to work with longitudinal yet - radar disable, sending correct messages, etc -UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV} +UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV, CAR.KIA_SORENTO} # If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points. # If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py From 0f7be5b1e6efa04c59ce2a45afacd650b2e4d417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Mon, 21 Aug 2023 13:30:48 -0700 Subject: [PATCH 041/159] Setup cleanup vol. 2 (#29456) * code from setup cleanup #29419 update ci update ci export variables for mac os check env what is in the profile script? install pyenv the same everywhere temporarily disable brew cache temporarily disable brew cache try fixing pyenv virtualenv-init try this inject shims path earlier try alternate install method switch back to brew install try eval "$(pyenv init --path)" add eval "\$(pyenv init --path)" * Add local .env file to the cache list * Change .env paths * debug line * order? * remove .env * Add .venv to caches --------- Co-authored-by: Greg Hogan --- .github/workflows/selfdrive_tests.yaml | 9 +++++---- tools/install_python_dependencies.sh | 16 ++++++++++------ tools/mac_setup.sh | 9 +-------- tools/openpilot_env.sh | 22 ---------------------- tools/ubuntu_setup.sh | 7 ------- 5 files changed, 16 insertions(+), 47 deletions(-) delete mode 100755 tools/openpilot_env.sh diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 90a1c14aa0..2b2341d6ff 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -117,6 +117,8 @@ jobs: uses: actions/cache@v3 with: path: | + .env + .venv ~/github_brew_cache_entries.txt ~/.pyenv ~/Library/Caches/pypoetry @@ -148,18 +150,17 @@ jobs: PYTHONWARNINGS: default - name: Build openpilot run: | - source tools/openpilot_env.sh + eval "$(pyenv init --path)" poetry run scons -j$(nproc) - name: Run tests run: | - source tools/openpilot_env.sh - export PYTHONPATH=$PWD + eval "$(pyenv init --path)" poetry run tools/plotjuggler/test_plotjuggler.py - name: Pre Cache - Cleanup scons cache if: github.ref == 'refs/heads/master' run: | - source tools/openpilot_env.sh rm -rf /tmp/scons_cache/* + eval "$(pyenv init --path)" poetry run scons -j$(nproc) --cache-populate - name: Save scons cache id: scons-save-cache diff --git a/tools/install_python_dependencies.sh b/tools/install_python_dependencies.sh index ffa9a6efef..79c36d57d9 100755 --- a/tools/install_python_dependencies.sh +++ b/tools/install_python_dependencies.sh @@ -14,21 +14,19 @@ if ! command -v "pyenv" > /dev/null 2>&1; then echo "pyenv install ..." curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash - echo -e "\n. ~/.pyenvrc" >> $RC_FILE cat < "${HOME}/.pyenvrc" if [ -z "\$PYENV_ROOT" ]; then export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH export PYENV_ROOT="\$HOME/.pyenv" + eval "\$(pyenv init --path)" eval "\$(pyenv init -)" eval "\$(pyenv virtualenv-init -)" fi EOF + echo -e "\nsource ~/.pyenvrc" >> $RC_FILE - # setup now without restarting shell - export PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH - export PYENV_ROOT="$HOME/.pyenv" - eval "$(pyenv init -)" - eval "$(pyenv virtualenv-init -)" + # activate pyenv now + source $RC_FILE fi export MAKEFLAGS="-j$(nproc)" @@ -53,6 +51,12 @@ poetry config virtualenvs.prefer-active-python true --local poetry config virtualenvs.in-project true --local echo "PYTHONPATH=${PWD}" > $ROOT/.env +if [[ "$(uname)" == 'Darwin' ]]; then + echo "# msgq doesn't work on mac" >> $ROOT/.env + echo "export ZMQ=1" >> $ROOT/.env + echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> $ROOT/.env +fi + poetry self add poetry-dotenv-plugin@^0.1.0 echo "pip packages install..." diff --git a/tools/mac_setup.sh b/tools/mac_setup.sh index 45bdf90383..3892efd6bb 100755 --- a/tools/mac_setup.sh +++ b/tools/mac_setup.sh @@ -46,6 +46,7 @@ brew "libtool" brew "llvm" brew "openssl@3.0" brew "pyenv" +brew "pyenv-virtualenv" brew "qt@5" brew "zeromq" brew "gcc@12" @@ -69,16 +70,8 @@ export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/openssl@3/include" export PYCURL_CURL_CONFIG=/usr/bin/curl-config export PYCURL_SSL_LIBRARY=openssl -# openpilot environment -if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then - echo "source $ROOT/tools/openpilot_env.sh" >> $RC_FILE - source "$ROOT/tools/openpilot_env.sh" - echo "Added openpilot_env to RC file: $RC_FILE" -fi - # install python dependencies $DIR/install_python_dependencies.sh -eval "$(pyenv init --path)" echo "[ ] installed python dependencies t=$SECONDS" echo diff --git a/tools/openpilot_env.sh b/tools/openpilot_env.sh deleted file mode 100755 index 59108312ac..0000000000 --- a/tools/openpilot_env.sh +++ /dev/null @@ -1,22 +0,0 @@ -if [ -z "$OPENPILOT_ENV" ]; then - export PATH="$HOME/.pyenv/bin:$PATH" - - # Pyenv suggests we place the below two lines in .profile before we source - # .bashrc, but there is no simple way to guarantee we do this correctly - # programmatically across heterogeneous systems. For end-user convenience, - # we add the lines here as a workaround. - # https://github.com/pyenv/pyenv/issues/1906 - export PYENV_ROOT="$HOME/.pyenv" - - if [[ "$(uname)" == 'Linux' ]]; then - eval "$(pyenv virtualenv-init -)" - elif [[ "$(uname)" == 'Darwin' ]]; then - # msgq doesn't work on mac - export ZMQ=1 - export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - fi - eval "$(pyenv init --path)" - eval "$(pyenv init -)" - - export OPENPILOT_ENV=1 -fi diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 581b785252..9007611cc4 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -141,13 +141,6 @@ fi # python setup $DIR/install_python_dependencies.sh -source ~/.bashrc -if [ -z "$OPENPILOT_ENV" ]; then - printf "\nsource %s/tools/openpilot_env.sh" "$ROOT" >> ~/.bashrc - source ~/.bashrc - echo "added openpilot_env to bashrc" -fi - echo echo "---- OPENPILOT SETUP DONE ----" echo "Open a new shell or configure your active shell env by running:" From fc9a623d69919897c3e070ed11309c92651611a8 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 21 Aug 2023 13:31:57 -0700 Subject: [PATCH 042/159] Subaru: remove unused backoff rate calculation (#29368) * cancel rate * Update selfdrive/car/subaru/carcontroller.py Co-authored-by: Shane Smiskol * leave it as it was for now * cleanup --------- Co-authored-by: Shane Smiskol --- selfdrive/car/subaru/carcontroller.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index 3aba25fe8d..b00e38c807 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -12,7 +12,6 @@ class CarController: self.frame = 0 self.cruise_button_prev = 0 - self.last_cancel_frame = 0 self.p = CarControllerParams(CP) self.packer = CANPacker(DBC[CP.carFingerprint]['pt']) @@ -100,10 +99,9 @@ class CarController: can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, 0, pcm_cancel_cmd, self.CP.openpilotLongitudinalControl, cruise_brake > 0, cruise_throttle)) else: - if pcm_cancel_cmd and (self.frame - self.last_cancel_frame) > 0.2: + if pcm_cancel_cmd: bus = CanBus.alt if self.CP.carFingerprint in GLOBAL_GEN2 else CanBus.main can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, bus, pcm_cancel_cmd)) - self.last_cancel_frame = self.frame new_actuators = actuators.copy() new_actuators.steer = self.apply_steer_last / self.p.STEER_MAX From 985af1ce3cc9849c0c677d2f1a062daef1b8d0dc Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 21 Aug 2023 13:46:00 -0700 Subject: [PATCH 043/159] tici: add wait_for_power helper (#29507) * tici: add wait_for_power helper * deque * cleanup --------- Co-authored-by: Bruce Wayne --- system/hardware/tici/power_monitor.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/hardware/tici/power_monitor.py b/system/hardware/tici/power_monitor.py index 0a54319398..ef3055ac47 100755 --- a/system/hardware/tici/power_monitor.py +++ b/system/hardware/tici/power_monitor.py @@ -4,6 +4,7 @@ import time import datetime import numpy as np from typing import List +from collections import deque from openpilot.common.realtime import Ratekeeper from openpilot.common.filter_simple import FirstOrderFilter @@ -27,6 +28,15 @@ def get_power(seconds=5): pwrs = sample_power(seconds) return np.mean(pwrs) +def wait_for_power(min_pwr, max_pwr, min_secs_in_range, timeout): + start_time = time.monotonic() + pwrs = deque([min_pwr - 1.]*min_secs_in_range, maxlen=min_secs_in_range) + while (time.monotonic() - start_time < timeout): + pwrs.append(get_power(1)) + if all(min_pwr <= p <= max_pwr for p in pwrs): + break + return np.mean(pwrs) + if __name__ == "__main__": duration = None From 229c43a80838a80fb5a7c4c6fc7b968ba04d70cc Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 21 Aug 2023 14:11:32 -0700 Subject: [PATCH 044/159] Kia: update supported Sorento PHEV package (#29509) * Sorento PHEV includes all * update docs --- docs/CARS.md | 2 +- selfdrive/car/hyundai/values.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CARS.md b/docs/CARS.md index a502cde3ac..a22016182a 100644 --- a/docs/CARS.md +++ b/docs/CARS.md @@ -132,7 +132,7 @@ A supported vehicle is one that just works when you install a comma three. All s |Kia|Sorento 2018|Advanced Smart Cruise Control|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sorento 2019|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai E connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sorento 2021-23[6](#footnotes)|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai K connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| -|Kia|Sorento Plug-in Hybrid 2022-23[6](#footnotes)|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| +|Kia|Sorento Plug-in Hybrid 2022-23[6](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sportage 2023[6](#footnotes)|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai N connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sportage Hybrid 2023[6](#footnotes)|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai N connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Stinger 2018-20|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index c82674a43e..7b9a7d7628 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -245,7 +245,7 @@ CAR_INFO: Dict[str, Optional[Union[HyundaiCarInfo, List[HyundaiCarInfo]]]] = { HyundaiCarInfo("Kia Sorento 2019", video_link="https://www.youtube.com/watch?v=Fkh3s6WHJz8", car_parts=CarParts.common([CarHarness.hyundai_e])), ], CAR.KIA_SORENTO_4TH_GEN: HyundaiCarInfo("Kia Sorento 2021-23", car_parts=CarParts.common([CarHarness.hyundai_k])), - CAR.KIA_SORENTO_PHEV_4TH_GEN: HyundaiCarInfo("Kia Sorento Plug-in Hybrid 2022-23", car_parts=CarParts.common([CarHarness.hyundai_a])), + CAR.KIA_SORENTO_PHEV_4TH_GEN: HyundaiCarInfo("Kia Sorento Plug-in Hybrid 2022-23", "All", car_parts=CarParts.common([CarHarness.hyundai_a])), CAR.KIA_SPORTAGE_HYBRID_5TH_GEN: HyundaiCarInfo("Kia Sportage Hybrid 2023", car_parts=CarParts.common([CarHarness.hyundai_n])), CAR.KIA_STINGER: HyundaiCarInfo("Kia Stinger 2018-20", video_link="https://www.youtube.com/watch?v=MJ94qoofYw0", car_parts=CarParts.common([CarHarness.hyundai_c])), From de7bcb04fccaf41b3149e26d353a18598d1030d0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 21 Aug 2023 14:32:56 -0700 Subject: [PATCH 045/159] add enhancement todo for hyundai fuzzy FP --- selfdrive/car/hyundai/values.py | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 7b9a7d7628..cc1a29981b 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -386,6 +386,7 @@ def match_fw_to_car_fuzzy(live_fw_versions) -> Set[str]: # Non-electric CAN FD platforms often do not have platform code specifiers needed # to distinguish between hybrid and ICE. All EVs so far are either exclusively # electric or specify electric in the platform code. + # TODO: whitelist platforms that we've seen hybrid and ICE versions of that have these specifiers fuzzy_platform_blacklist = set(CANFD_CAR - EV_CAR) candidates = set() From bfa714ef3b4a9cf00b79965bfb0f149b090008ef Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Mon, 21 Aug 2023 17:34:53 -0400 Subject: [PATCH 046/159] HKG: Car Port for Kia Sorento Hybrid 2023 (#29322) * HKG: Car Port for Kia Sorento Hybrid 2023 * Update CARS.md * Oops * add test route * specify segment * all packages --------- Co-authored-by: Shane Smiskol --- RELEASES.md | 1 + docs/CARS.md | 3 ++- selfdrive/car/hyundai/interface.py | 4 +++- selfdrive/car/hyundai/values.py | 19 ++++++++++++++++--- selfdrive/car/tests/routes.py | 1 + selfdrive/car/torque_data/override.yaml | 1 + 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index e9cfd69f7c..1b439c0fc8 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,6 @@ Version 0.9.5 (202X-XX-XX) ======================== +* Kia Sorento Hybrid 2023 support thanks to sunnyhaibin! * Lexus IS 2023 support thanks to L3R5! Version 0.9.4 (2023-07-27) diff --git a/docs/CARS.md b/docs/CARS.md index a22016182a..07155bf379 100644 --- a/docs/CARS.md +++ b/docs/CARS.md @@ -4,7 +4,7 @@ A supported vehicle is one that just works when you install a comma three. All supported cars provide a better experience than any stock system. Supported vehicles reference the US market unless otherwise specified. -# 257 Supported Cars +# 258 Supported Cars |Make|Model|Supported Package|ACC|No ACC accel below|No ALC below|Steering Torque|Resume from stop|Hardware Needed
 |Video| |---|---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:| @@ -132,6 +132,7 @@ A supported vehicle is one that just works when you install a comma three. All s |Kia|Sorento 2018|Advanced Smart Cruise Control|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sorento 2019|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai E connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sorento 2021-23[6](#footnotes)|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai K connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| +|Kia|Sorento Hybrid 2023[6](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sorento Plug-in Hybrid 2022-23[6](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai A connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sportage 2023[6](#footnotes)|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai N connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Kia|Sportage Hybrid 2023[6](#footnotes)|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai N connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index b4cf10d0ed..16e93e1623 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -196,11 +196,13 @@ class CarInterface(CarInterfaceBase): ret.mass = 1767. # SX Prestige trim support only ret.wheelbase = 2.756 ret.steerRatio = 13.6 - elif candidate in (CAR.KIA_SORENTO_4TH_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN): + elif candidate in (CAR.KIA_SORENTO_4TH_GEN, CAR.KIA_SORENTO_HEV_4TH_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN): ret.wheelbase = 2.81 ret.steerRatio = 13.5 # average of the platforms if candidate == CAR.KIA_SORENTO_4TH_GEN: ret.mass = 3957 * CV.LB_TO_KG + elif candidate == CAR.KIA_SORENTO_HEV_4TH_GEN: + ret.mass = 4255 * CV.LB_TO_KG else: ret.mass = 4537 * CV.LB_TO_KG elif candidate == CAR.KIA_CARNIVAL_4TH_GEN: diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index cc1a29981b..66f4b18668 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -114,6 +114,7 @@ class CAR: KIA_SPORTAGE_5TH_GEN = "KIA SPORTAGE 5TH GEN" KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_SORENTO_4TH_GEN = "KIA SORENTO 4TH GEN" + KIA_SORENTO_HEV_4TH_GEN = "KIA SORENTO HYBRID 4TH GEN" KIA_SORENTO_PHEV_4TH_GEN = "KIA SORENTO PLUG-IN HYBRID 4TH GEN" KIA_SPORTAGE_HYBRID_5TH_GEN = "KIA SPORTAGE HYBRID 5TH GEN" KIA_STINGER = "KIA STINGER GT2 2018" @@ -245,6 +246,7 @@ CAR_INFO: Dict[str, Optional[Union[HyundaiCarInfo, List[HyundaiCarInfo]]]] = { HyundaiCarInfo("Kia Sorento 2019", video_link="https://www.youtube.com/watch?v=Fkh3s6WHJz8", car_parts=CarParts.common([CarHarness.hyundai_e])), ], CAR.KIA_SORENTO_4TH_GEN: HyundaiCarInfo("Kia Sorento 2021-23", car_parts=CarParts.common([CarHarness.hyundai_k])), + CAR.KIA_SORENTO_HEV_4TH_GEN: HyundaiCarInfo("Kia Sorento Hybrid 2023", "All", car_parts=CarParts.common([CarHarness.hyundai_a])), CAR.KIA_SORENTO_PHEV_4TH_GEN: HyundaiCarInfo("Kia Sorento Plug-in Hybrid 2022-23", "All", car_parts=CarParts.common([CarHarness.hyundai_a])), CAR.KIA_SPORTAGE_HYBRID_5TH_GEN: HyundaiCarInfo("Kia Sportage Hybrid 2023", car_parts=CarParts.common([CarHarness.hyundai_n])), CAR.KIA_STINGER: HyundaiCarInfo("Kia Stinger 2018-20", video_link="https://www.youtube.com/watch?v=MJ94qoofYw0", @@ -1901,6 +1903,14 @@ FW_VERSIONS = { b'\xf1\x00KA4c SCC FHCUP 1.00 1.01 99110-I4000 ', ], }, + CAR.KIA_SORENTO_HEV_4TH_GEN: { + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00MQ4HMFC AT KOR LHD 1.00 1.12 99210-P2000 230331', + ], + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00MQhe SCC FHCUP 1.00 1.07 99110-P4000 ', + ], + }, } CHECKSUM = { @@ -1922,10 +1932,11 @@ CAN_GEARS = { CANFD_CAR = {CAR.KIA_EV6, CAR.IONIQ_5, CAR.IONIQ_6, CAR.TUCSON_4TH_GEN, CAR.TUCSON_HYBRID_4TH_GEN, CAR.KIA_SPORTAGE_HYBRID_5TH_GEN, CAR.SANTA_CRUZ_1ST_GEN, CAR.KIA_SPORTAGE_5TH_GEN, CAR.GENESIS_GV70_1ST_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN, CAR.GENESIS_GV60_EV_1ST_GEN, CAR.KIA_SORENTO_4TH_GEN, CAR.KIA_NIRO_HEV_2ND_GEN, CAR.KIA_NIRO_EV_2ND_GEN, - CAR.GENESIS_GV80, CAR.KIA_CARNIVAL_4TH_GEN} + CAR.GENESIS_GV80, CAR.KIA_CARNIVAL_4TH_GEN, CAR.KIA_SORENTO_HEV_4TH_GEN} # The radar does SCC on these cars when HDA I, rather than the camera -CANFD_RADAR_SCC_CAR = {CAR.GENESIS_GV70_1ST_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN, CAR.KIA_SORENTO_4TH_GEN, CAR.GENESIS_GV80, CAR.KIA_CARNIVAL_4TH_GEN} +CANFD_RADAR_SCC_CAR = {CAR.GENESIS_GV70_1ST_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN, CAR.KIA_SORENTO_4TH_GEN, CAR.GENESIS_GV80, + CAR.KIA_CARNIVAL_4TH_GEN, CAR.KIA_SORENTO_HEV_4TH_GEN} # The camera does SCC on these cars, rather than the radar CAMERA_SCC_CAR = {CAR.KONA_EV_2022, } @@ -1933,7 +1944,8 @@ CAMERA_SCC_CAR = {CAR.KONA_EV_2022, } # these cars use a different gas signal HYBRID_CAR = {CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021, CAR.KIA_NIRO_PHEV, CAR.KIA_NIRO_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV, CAR.IONIQ, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022, CAR.SANTA_FE_PHEV_2022, CAR.IONIQ_PHEV_2019, CAR.TUCSON_HYBRID_4TH_GEN, - CAR.KIA_SPORTAGE_HYBRID_5TH_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN, CAR.KIA_K5_HEV_2020, CAR.KIA_NIRO_HEV_2ND_GEN} + CAR.KIA_SPORTAGE_HYBRID_5TH_GEN, CAR.KIA_SORENTO_PHEV_4TH_GEN, CAR.KIA_K5_HEV_2020, CAR.KIA_NIRO_HEV_2ND_GEN, + CAR.KIA_SORENTO_HEV_4TH_GEN} EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR.KIA_NIRO_EV_2ND_GEN, CAR.KONA_EV_2022, CAR.KIA_EV6, CAR.IONIQ_5, CAR.IONIQ_6, CAR.GENESIS_GV60_EV_1ST_GEN} @@ -2007,4 +2019,5 @@ DBC = { CAR.KIA_NIRO_EV_2ND_GEN: dbc_dict('hyundai_canfd', None), CAR.GENESIS_GV80: dbc_dict('hyundai_canfd', None), CAR.KIA_CARNIVAL_4TH_GEN: dbc_dict('hyundai_canfd', None), + CAR.KIA_SORENTO_HEV_4TH_GEN: dbc_dict('hyundai_canfd', None), } diff --git a/selfdrive/car/tests/routes.py b/selfdrive/car/tests/routes.py index 9c56f578b9..60b99a1ad6 100644 --- a/selfdrive/car/tests/routes.py +++ b/selfdrive/car/tests/routes.py @@ -119,6 +119,7 @@ routes = [ CarTestRoute("36e10531feea61a4|2022-07-25--13-37-42", HYUNDAI.TUCSON_HYBRID_4TH_GEN), CarTestRoute("5875672fc1d4bf57|2020-07-23--21-33-28", HYUNDAI.KIA_SORENTO), CarTestRoute("1d0d000db3370fd0|2023-01-04--22-28-42", HYUNDAI.KIA_SORENTO_4TH_GEN, segment=5), + CarTestRoute("fc19648042eb6896|2023-08-16--11-43-27", HYUNDAI.KIA_SORENTO_HEV_4TH_GEN, segment=14), CarTestRoute("628935d7d3e5f4f7|2022-11-30--01-12-46", HYUNDAI.KIA_SORENTO_PHEV_4TH_GEN), CarTestRoute("9c917ba0d42ffe78|2020-04-17--12-43-19", HYUNDAI.PALISADE), CarTestRoute("05a8f0197fdac372|2022-10-19--14-14-09", HYUNDAI.IONIQ_5), # HDA2 diff --git a/selfdrive/car/torque_data/override.yaml b/selfdrive/car/torque_data/override.yaml index fa4bb6a171..372484fa6e 100644 --- a/selfdrive/car/torque_data/override.yaml +++ b/selfdrive/car/torque_data/override.yaml @@ -55,6 +55,7 @@ GENESIS GV80 2023: [2.5, 2.5, 0.1] KIA CARNIVAL 4TH GEN: [1.75, 1.75, 0.15] GMC ACADIA DENALI 2018: [1.6, 1.6, 0.2] LEXUS IS 2023: [2.0, 2.0, 0.1] +KIA SORENTO HYBRID 4TH GEN: [2.5, 2.5, 0.1] # Dashcam or fallback configured as ideal car mock: [10.0, 10, 0.0] From b20eba5f1d28ae623eecf5dbbc22f67ff02d3609 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 21 Aug 2023 14:54:42 -0700 Subject: [PATCH 047/159] Subaru: longitudinal incorrect "inactive" rpm (#29496) * fix incorrect base rpm issue * "min" name is better --- selfdrive/car/subaru/carcontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index b00e38c807..00915808d0 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -55,7 +55,7 @@ class CarController: cruise_brake = clip(apply_brake, CarControllerParams.BRAKE_MIN, CarControllerParams.BRAKE_MAX) else: cruise_throttle = CarControllerParams.THROTTLE_INACTIVE - cruise_rpm = CarControllerParams.RPM_INACTIVE + cruise_rpm = CarControllerParams.RPM_MIN cruise_brake = CarControllerParams.BRAKE_MIN # *** alerts and pcm cancel *** From 197460e06136f66f60e10ccefece646cb472b872 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 21 Aug 2023 15:11:31 -0700 Subject: [PATCH 048/159] CI: use scons cache mount for building simulator and docs (#29436) * build docker image with scons cache * use setup * scons cache * added the dockerfile * add the shell * docs use cache * dont pull lfs for docs * simulator too * dont pull the cache image * fix inputs * inputs * booleans aren't supported * bool not supported * bool isnt supported * fix * readonly cache * fix sim cache too * respect readonly * gitignore and move to correct folder * also copy old * move to tools/ci * move to selfdrive/test * just make the cache writable, it's discarded anyway * minimize diff in this pr --- .github/workflows/setup/action.yaml | 13 ++++++++++++- .github/workflows/tools_tests.yaml | 11 ++++++++--- docs/docker/Dockerfile | 8 +++++--- selfdrive/test/Dockerfile.scons_cache | 3 +++ tools/sim/Dockerfile.sim | 4 +++- 5 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 selfdrive/test/Dockerfile.scons_cache diff --git a/.github/workflows/setup/action.yaml b/.github/workflows/setup/action.yaml index a6c58aae08..e791e51ac2 100644 --- a/.github/workflows/setup/action.yaml +++ b/.github/workflows/setup/action.yaml @@ -1,6 +1,10 @@ name: 'openpilot env setup' inputs: + setup_docker_scons_cache: + description: 'Whether or not to build the scons-cache docker image' + required: false + default: 'false' git_lfs: description: 'Whether or not to pull the git lfs' required: false @@ -28,7 +32,14 @@ runs: restore-keys: | scons-${{ env.CACHE_COMMIT_DATE }}- scons- - + - id: setup-scons-cache-docker + name: Sets up a docker image with scons cache that can by mounted as a buildkit cache mount + shell: bash + if: ${{ inputs.setup_docker_scons_cache == 'true' }} + run: | + cp selfdrive/test/Dockerfile.scons_cache ~ + cd ~ + DOCKER_BUILDKIT=1 docker build -t scons-cache -f Dockerfile.scons_cache . # build our docker image - shell: bash run: eval ${{ env.BUILD }} diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index e0d471882f..b21f290880 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -58,10 +58,14 @@ jobs: with: submodules: true - uses: ./.github/workflows/setup + with: + setup_docker_scons_cache: true - name: Build base cl image run: eval "$BUILD_CL" - name: Build simulator image - run: DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f tools/sim/Dockerfile.sim . + run: | + docker pull $DOCKER_REGISTRY/$IMAGE_NAME:latest + DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f tools/sim/Dockerfile.sim . - name: Push to container registry if: github.ref == 'refs/heads/master' && github.repository == 'commaai/openpilot' run: | @@ -74,14 +78,15 @@ jobs: timeout-minutes: 45 env: BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/openpilot-docs-base:latest -t $DOCKER_REGISTRY/openpilot-docs-base:latest -f docs/docker/Dockerfile --target openpilot-docs-base . - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/openpilot-docs-base:latest --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . + docker pull $DOCKER_REGISTRY/openpilot-docs:latest + DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . steps: - uses: actions/checkout@v3 with: submodules: true - uses: ./.github/workflows/setup with: + setup_docker_scons_cache: true git_lfs: false - name: Push docker container if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' diff --git a/docs/docker/Dockerfile b/docs/docker/Dockerfile index 209fba010f..94ddd3c3ad 100644 --- a/docs/docker/Dockerfile +++ b/docs/docker/Dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/commaai/openpilot-base:latest as openpilot-docs-base +FROM scons-cache as scons-cache + +FROM ghcr.io/commaai/openpilot-base:latest ENV PYTHONUNBUFFERED 1 @@ -29,7 +31,7 @@ COPY ./selfdrive ${OPENPILOT_PATH}/selfdrive COPY ./system ${OPENPILOT_PATH}/system COPY ./*.md ${OPENPILOT_PATH}/ -RUN scons -j$(nproc) +RUN --mount=type=bind,from=scons-cache,source=/tmp/scons_cache,target=/tmp/scons_cache,rw scons -j$(nproc) RUN apt update && apt install doxygen -y COPY ./docs ${OPENPILOT_PATH}/docs @@ -38,5 +40,5 @@ WORKDIR ${OPENPILOT_PATH}/docs RUN make html FROM nginx:1.21 -COPY --from=0 /home/batman/openpilot/build/docs/html /usr/share/nginx/html +COPY --from=1 /home/batman/openpilot/build/docs/html /usr/share/nginx/html COPY ./docs/docker/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/selfdrive/test/Dockerfile.scons_cache b/selfdrive/test/Dockerfile.scons_cache new file mode 100644 index 0000000000..6e320d243c --- /dev/null +++ b/selfdrive/test/Dockerfile.scons_cache @@ -0,0 +1,3 @@ +FROM alpine:3 + +COPY ./scons_cache /tmp/scons_cache \ No newline at end of file diff --git a/tools/sim/Dockerfile.sim b/tools/sim/Dockerfile.sim index d312f34ecd..96630c9e6f 100644 --- a/tools/sim/Dockerfile.sim +++ b/tools/sim/Dockerfile.sim @@ -1,3 +1,5 @@ +FROM scons-cache as scons-cache + FROM ghcr.io/commaai/openpilot-base-cl:latest RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -29,6 +31,6 @@ COPY ./system $HOME/openpilot/system COPY ./tools $HOME/openpilot/tools WORKDIR $HOME/openpilot -RUN scons --cache-readonly -j12 +RUN --mount=type=bind,from=scons-cache,source=/tmp/scons_cache,target=/tmp/scons_cache,rw scons -j12 RUN python -c "from openpilot.selfdrive.test.helpers import set_params_enabled; set_params_enabled()" From 9188c560692d9c3019c291ed8ae0e899b2e4bfdf Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 21 Aug 2023 15:32:41 -0700 Subject: [PATCH 049/159] CI: remove old docs base image push (#29512) remove that push --- .github/workflows/tools_tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index b21f290880..86cfc279c5 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -92,5 +92,4 @@ jobs: if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' run: | $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/openpilot-docs-base:latest docker push $DOCKER_REGISTRY/openpilot-docs:latest \ No newline at end of file From b373e5d5ec8ad108925bc4f7aece5977dd405f97 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 21 Aug 2023 16:25:13 -0700 Subject: [PATCH 050/159] Revert "Subaru: always show LKAS active (#27945)" (#29515) This reverts commit 8f1e67f6259c436aff500f6bdff9067d4ca79eb1. --- selfdrive/car/subaru/subarucan.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/subaru/subarucan.py b/selfdrive/car/subaru/subarucan.py index caa1451842..890473a243 100644 --- a/selfdrive/car/subaru/subarucan.py +++ b/selfdrive/car/subaru/subarucan.py @@ -108,8 +108,11 @@ def create_es_lkas_state(packer, es_lkas_state_msg, enabled, visual_alert, left_ elif right_lane_depart: values["LKAS_Alert"] = 11 # Right lane departure dash alert - values["LKAS_ACTIVE"] = 1 # Show LKAS lane lines - values["LKAS_Dash_State"] = 2 if enabled else 0 # Green enabled indicator + if enabled: + values["LKAS_ACTIVE"] = 1 # Show LKAS lane lines + values["LKAS_Dash_State"] = 2 # Green enabled indicator + else: + values["LKAS_Dash_State"] = 0 # LKAS Not enabled values["LKAS_Left_Line_Visible"] = int(left_line) values["LKAS_Right_Line_Visible"] = int(right_line) From b24bbe4607c4b13010b2bbcd340b133b91c146e1 Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Mon, 21 Aug 2023 23:32:35 +0000 Subject: [PATCH 051/159] script to install only ubuntu dependencies (#29510) * script to install only ubuntu dependencies * update Dockerfile * add shebang --- Dockerfile.openpilot_base | 2 +- tools/install_ubuntu_dependencies.sh | 134 +++++++++++++++++++++++++++ tools/ubuntu_setup.sh | 134 +-------------------------- 3 files changed, 136 insertions(+), 134 deletions(-) create mode 100755 tools/install_ubuntu_dependencies.sh diff --git a/Dockerfile.openpilot_base b/Dockerfile.openpilot_base index f8b20be351..e21371ca4a 100644 --- a/Dockerfile.openpilot_base +++ b/Dockerfile.openpilot_base @@ -18,7 +18,7 @@ ENV PYENV_ROOT="/root/.pyenv" ENV PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH" COPY pyproject.toml poetry.lock .python-version /tmp/ -COPY tools/ubuntu_setup.sh tools/install_python_dependencies.sh /tmp/tools/ +COPY tools/ubuntu_setup.sh tools/install_ubuntu_dependencies.sh tools/install_python_dependencies.sh /tmp/tools/ RUN cd /tmp && \ tools/ubuntu_setup.sh && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/tools/install_ubuntu_dependencies.sh b/tools/install_ubuntu_dependencies.sh new file mode 100755 index 0000000000..6214452870 --- /dev/null +++ b/tools/install_ubuntu_dependencies.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash +set -e + +SUDO="" + +# Use sudo if not root +if [[ ! $(id -u) -eq 0 ]]; then + if [[ -z $(which sudo) ]]; then + echo "Please install sudo or run as root" + exit 1 + fi + SUDO="sudo" +fi + +# Install packages present in all supported versions of Ubuntu +function install_ubuntu_common_requirements() { + $SUDO apt-get update + $SUDO apt-get install -y --no-install-recommends \ + autoconf \ + build-essential \ + ca-certificates \ + casync \ + clang \ + cmake \ + make \ + cppcheck \ + libtool \ + gcc-arm-none-eabi \ + bzip2 \ + liblzma-dev \ + libarchive-dev \ + libbz2-dev \ + capnproto \ + libcapnp-dev \ + curl \ + libcurl4-openssl-dev \ + git \ + git-lfs \ + ffmpeg \ + libavformat-dev \ + libavcodec-dev \ + libavdevice-dev \ + libavutil-dev \ + libavfilter-dev \ + libeigen3-dev \ + libffi-dev \ + libglew-dev \ + libgles2-mesa-dev \ + libglfw3-dev \ + libglib2.0-0 \ + libncurses5-dev \ + libncursesw5-dev \ + libomp-dev \ + libopencv-dev \ + libpng16-16 \ + libportaudio2 \ + libssl-dev \ + libsqlite3-dev \ + libusb-1.0-0-dev \ + libzmq3-dev \ + libsystemd-dev \ + locales \ + opencl-headers \ + ocl-icd-libopencl1 \ + ocl-icd-opencl-dev \ + clinfo \ + portaudio19-dev \ + qml-module-qtquick2 \ + qtmultimedia5-dev \ + qtlocation5-dev \ + qtpositioning5-dev \ + qttools5-dev-tools \ + libqt5sql5-sqlite \ + libqt5svg5-dev \ + libqt5charts5-dev \ + libqt5x11extras5-dev \ + libreadline-dev \ + libdw1 \ + valgrind +} + +# Install Ubuntu 22.04 LTS packages +function install_ubuntu_lts_latest_requirements() { + install_ubuntu_common_requirements + + $SUDO apt-get install -y --no-install-recommends \ + g++-12 \ + qtbase5-dev \ + qtchooser \ + qt5-qmake \ + qtbase5-dev-tools \ + python3-dev +} + +# Install Ubuntu 20.04 packages +function install_ubuntu_focal_requirements() { + install_ubuntu_common_requirements + + $SUDO apt-get install -y --no-install-recommends \ + libavresample-dev \ + qt5-default \ + python-dev +} + +# Detect OS using /etc/os-release file +if [ -f "/etc/os-release" ]; then + source /etc/os-release + case "$VERSION_CODENAME" in + "jammy") + install_ubuntu_lts_latest_requirements + ;; + "kinetic") + install_ubuntu_lts_latest_requirements + ;; + "focal") + install_ubuntu_focal_requirements + ;; + *) + echo "$ID $VERSION_ID is unsupported. This setup script is written for Ubuntu 20.04." + read -p "Would you like to attempt installation anyway? " -n 1 -r + echo "" + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 + fi + if [ "$UBUNTU_CODENAME" = "jammy" ] || [ "$UBUNTU_CODENAME" = "kinetic" ]; then + install_ubuntu_lts_latest_requirements + else + install_ubuntu_focal_requirements + fi + esac +else + echo "No /etc/os-release in the system" + exit 1 +fi diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 9007611cc4..6b9cf7eff6 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -3,142 +3,10 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -ROOT="$(cd $DIR/../ && pwd)" -SUDO="" # NOTE: this is used in a docker build, so do not run any scripts here. -# Use sudo if not root -if [[ ! $(id -u) -eq 0 ]]; then - if [[ -z $(which sudo) ]]; then - echo "Please install sudo or run as root" - exit 1 - fi - SUDO="sudo" -fi - -# Install packages present in all supported versions of Ubuntu -function install_ubuntu_common_requirements() { - $SUDO apt-get update - $SUDO apt-get install -y --no-install-recommends \ - autoconf \ - build-essential \ - ca-certificates \ - casync \ - clang \ - cmake \ - make \ - cppcheck \ - libtool \ - gcc-arm-none-eabi \ - bzip2 \ - liblzma-dev \ - libarchive-dev \ - libbz2-dev \ - capnproto \ - libcapnp-dev \ - curl \ - libcurl4-openssl-dev \ - git \ - git-lfs \ - ffmpeg \ - libavformat-dev \ - libavcodec-dev \ - libavdevice-dev \ - libavutil-dev \ - libavfilter-dev \ - libeigen3-dev \ - libffi-dev \ - libglew-dev \ - libgles2-mesa-dev \ - libglfw3-dev \ - libglib2.0-0 \ - libncurses5-dev \ - libncursesw5-dev \ - libomp-dev \ - libopencv-dev \ - libpng16-16 \ - libportaudio2 \ - libssl-dev \ - libsqlite3-dev \ - libusb-1.0-0-dev \ - libzmq3-dev \ - libsystemd-dev \ - locales \ - opencl-headers \ - ocl-icd-libopencl1 \ - ocl-icd-opencl-dev \ - clinfo \ - portaudio19-dev \ - qml-module-qtquick2 \ - qtmultimedia5-dev \ - qtlocation5-dev \ - qtpositioning5-dev \ - qttools5-dev-tools \ - libqt5sql5-sqlite \ - libqt5svg5-dev \ - libqt5charts5-dev \ - libqt5x11extras5-dev \ - libreadline-dev \ - libdw1 \ - valgrind -} - -# Install Ubuntu 22.04 LTS packages -function install_ubuntu_lts_latest_requirements() { - install_ubuntu_common_requirements - - $SUDO apt-get install -y --no-install-recommends \ - g++-12 \ - qtbase5-dev \ - qtchooser \ - qt5-qmake \ - qtbase5-dev-tools \ - python3-dev -} - -# Install Ubuntu 20.04 packages -function install_ubuntu_focal_requirements() { - install_ubuntu_common_requirements - - $SUDO apt-get install -y --no-install-recommends \ - libavresample-dev \ - qt5-default \ - python-dev -} - -# Detect OS using /etc/os-release file -if [ -f "/etc/os-release" ]; then - source /etc/os-release - case "$VERSION_CODENAME" in - "jammy") - install_ubuntu_lts_latest_requirements - ;; - "kinetic") - install_ubuntu_lts_latest_requirements - ;; - "focal") - install_ubuntu_focal_requirements - ;; - *) - echo "$ID $VERSION_ID is unsupported. This setup script is written for Ubuntu 20.04." - read -p "Would you like to attempt installation anyway? " -n 1 -r - echo "" - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi - if [ "$UBUNTU_CODENAME" = "jammy" ] || [ "$UBUNTU_CODENAME" = "kinetic" ]; then - install_ubuntu_lts_latest_requirements - else - install_ubuntu_focal_requirements - fi - esac -else - echo "No /etc/os-release in the system" - exit 1 -fi - -# python setup +$DIR/install_ubuntu_dependencies.sh $DIR/install_python_dependencies.sh echo From 8c478708ee53c7b473989cd48ac1fdad8702c372 Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Mon, 21 Aug 2023 19:22:47 -0700 Subject: [PATCH 052/159] exit if onnxmodel exec fails --- selfdrive/modeld/runners/onnxmodel.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/modeld/runners/onnxmodel.cc b/selfdrive/modeld/runners/onnxmodel.cc index 48c16457fd..9e8d306b76 100644 --- a/selfdrive/modeld/runners/onnxmodel.cc +++ b/selfdrive/modeld/runners/onnxmodel.cc @@ -35,6 +35,7 @@ ONNXModel::ONNXModel(const std::string path, float *_output, size_t _output_size close(pipeout[0]); close(pipeout[1]); execvp(onnx_runner.c_str(), argv); + exit(1); // exit if the exec fails } // parent From 24090d21219cb93de18103cda3a6ada02f4ba3f2 Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Mon, 21 Aug 2023 19:26:48 -0700 Subject: [PATCH 053/159] Move USE_RUNTIME flags into runmodel.h --- selfdrive/modeld/runners/runmodel.h | 4 ++++ selfdrive/modeld/runners/snpemodel.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/modeld/runners/runmodel.h b/selfdrive/modeld/runners/runmodel.h index 00c88131bf..18cc180cb7 100644 --- a/selfdrive/modeld/runners/runmodel.h +++ b/selfdrive/modeld/runners/runmodel.h @@ -8,6 +8,10 @@ #include "common/clutil.h" #include "common/swaglog.h" +#define USE_CPU_RUNTIME 0 +#define USE_GPU_RUNTIME 1 +#define USE_DSP_RUNTIME 2 + struct ModelInput { const std::string name; float *buffer; diff --git a/selfdrive/modeld/runners/snpemodel.h b/selfdrive/modeld/runners/snpemodel.h index e646e5225b..0ae5a8f820 100644 --- a/selfdrive/modeld/runners/snpemodel.h +++ b/selfdrive/modeld/runners/snpemodel.h @@ -13,10 +13,6 @@ #include "selfdrive/modeld/runners/runmodel.h" -#define USE_CPU_RUNTIME 0 -#define USE_GPU_RUNTIME 1 -#define USE_DSP_RUNTIME 2 - #ifdef USE_THNEED #include "selfdrive/modeld/thneed/thneed.h" #endif From 72950cd9bc6bc09edb2a5e0a8f6ef38af83e7881 Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Mon, 21 Aug 2023 19:32:48 -0700 Subject: [PATCH 054/159] Add cl_create_context function --- common/clutil.cc | 4 ++++ common/clutil.h | 1 + 2 files changed, 5 insertions(+) diff --git a/common/clutil.cc b/common/clutil.cc index fab1649ee1..4f2a783d3e 100644 --- a/common/clutil.cc +++ b/common/clutil.cc @@ -75,6 +75,10 @@ cl_device_id cl_get_device_id(cl_device_type device_type) { return nullptr; } +cl_context cl_create_context(cl_device_id device_id) { + return CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); +} + cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args) { return cl_program_from_source(ctx, device_id, util::read_file(path), args); } diff --git a/common/clutil.h b/common/clutil.h index be1a07c332..af986d6434 100644 --- a/common/clutil.h +++ b/common/clutil.h @@ -22,6 +22,7 @@ }) cl_device_id cl_get_device_id(cl_device_type device_type); +cl_context cl_create_context(cl_device_id device_id); cl_program cl_program_from_source(cl_context ctx, cl_device_id device_id, const std::string& src, const char* args = nullptr); cl_program cl_program_from_binary(cl_context ctx, cl_device_id device_id, const uint8_t* binary, size_t length, const char* args = nullptr); cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args); From 7699444816b04b95407f43ef631760666f1e2a11 Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Mon, 21 Aug 2023 19:38:40 -0700 Subject: [PATCH 055/159] Set paths for cl kernels and onnx_runner.py in modeld SConscript --- selfdrive/modeld/SConscript | 7 +++++++ selfdrive/modeld/runners/onnxmodel.cc | 3 +-- selfdrive/modeld/transforms/loadyuv.cc | 2 +- selfdrive/modeld/transforms/transform.cc | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index 7be4446e67..a3a1b94e01 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -60,6 +60,13 @@ else: del libs[libs.index('SNPE')] del common_src[common_src.index('runners/snpemodel.cc')] +onnxrunner_path = File("runners/onnx_runner.py").abspath +transform_path = File("transforms/transform.cl").abspath +loadyuv_path = File("transforms/loadyuv.cl").abspath +lenv['CXXFLAGS'].append(f'-DTRANSFORM_PATH=\\"{transform_path}\\"') +lenv['CXXFLAGS'].append(f'-DLOADYUV_PATH=\\"{loadyuv_path}\\"') +lenv['CXXFLAGS'].append(f'-DONNXRUNNER_PATH=\\"{onnxrunner_path}\\"') + common_model = lenv.Object(common_src) lenv.Program('_dmonitoringmodeld', [ diff --git a/selfdrive/modeld/runners/onnxmodel.cc b/selfdrive/modeld/runners/onnxmodel.cc index 9e8d306b76..ebe6ad847c 100644 --- a/selfdrive/modeld/runners/onnxmodel.cc +++ b/selfdrive/modeld/runners/onnxmodel.cc @@ -20,8 +20,7 @@ ONNXModel::ONNXModel(const std::string path, float *_output, size_t _output_size err = pipe(pipeout); assert(err == 0); - std::string exe_dir = util::dir_name(util::readlink("/proc/self/exe")); - std::string onnx_runner = exe_dir + "/runners/onnx_runner.py"; + std::string onnx_runner = ONNXRUNNER_PATH; std::string tf8_arg = use_tf8 ? "--use_tf8" : ""; proc_pid = fork(); diff --git a/selfdrive/modeld/transforms/loadyuv.cc b/selfdrive/modeld/transforms/loadyuv.cc index 39f404a897..c7ce7b0830 100644 --- a/selfdrive/modeld/transforms/loadyuv.cc +++ b/selfdrive/modeld/transforms/loadyuv.cc @@ -15,7 +15,7 @@ void loadyuv_init(LoadYUVState* s, cl_context ctx, cl_device_id device_id, int w "-cl-fast-relaxed-math -cl-denorms-are-zero " "-DTRANSFORMED_WIDTH=%d -DTRANSFORMED_HEIGHT=%d", width, height); - cl_program prg = cl_program_from_file(ctx, device_id, "transforms/loadyuv.cl", args); + cl_program prg = cl_program_from_file(ctx, device_id, LOADYUV_PATH, args); s->loadys_krnl = CL_CHECK_ERR(clCreateKernel(prg, "loadys", &err)); s->loaduv_krnl = CL_CHECK_ERR(clCreateKernel(prg, "loaduv", &err)); diff --git a/selfdrive/modeld/transforms/transform.cc b/selfdrive/modeld/transforms/transform.cc index f341314144..305643cf42 100644 --- a/selfdrive/modeld/transforms/transform.cc +++ b/selfdrive/modeld/transforms/transform.cc @@ -8,7 +8,7 @@ void transform_init(Transform* s, cl_context ctx, cl_device_id device_id) { memset(s, 0, sizeof(*s)); - cl_program prg = cl_program_from_file(ctx, device_id, "transforms/transform.cl", ""); + cl_program prg = cl_program_from_file(ctx, device_id, TRANSFORM_PATH, ""); s->krnl = CL_CHECK_ERR(clCreateKernel(prg, "warpPerspective", &err)); // done with this CL_CHECK(clReleaseProgram(prg)); From ec5e3bef956e3f6f2ba7bc1f1eb6e75b0563b987 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 21 Aug 2023 20:01:52 -0700 Subject: [PATCH 056/159] CI: simulator disable pull to save local space (#29517) we don't need to pull since the image is different most of the time --- .github/workflows/tools_tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 86cfc279c5..5891d5207e 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -64,7 +64,6 @@ jobs: run: eval "$BUILD_CL" - name: Build simulator image run: | - docker pull $DOCKER_REGISTRY/$IMAGE_NAME:latest DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f tools/sim/Dockerfile.sim . - name: Push to container registry if: github.ref == 'refs/heads/master' && github.repository == 'commaai/openpilot' From 3492e80d19a4395d9481076c916f9ab96a8fb004 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 21 Aug 2023 20:51:27 -0700 Subject: [PATCH 057/159] CI: use xdist for car model tests (#29514) * bump panda * try multithreaded for car models * need pytest-cov * upgraded to poetry 1.5.1 and regenerated --- .github/workflows/selfdrive_tests.yaml | 3 +-- poetry.lock | 24 ++++++++++++++++++++---- pyproject.toml | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 2b2341d6ff..991ce74ca9 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -383,8 +383,7 @@ jobs: - name: Test car models timeout-minutes: 25 run: | - ${{ env.RUN }} "coverage run -m pytest selfdrive/car/tests/test_models.py && \ - coverage xml && \ + ${{ env.RUN }} "pytest --cov --cov-report=xml -n auto --dist=loadscope selfdrive/car/tests/test_models.py && \ chmod -R 777 /tmp/comma_download_cache" env: NUM_JOBS: 5 diff --git a/poetry.lock b/poetry.lock index 16bfe6f375..da50b60ad4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -387,9 +387,7 @@ version = "0.9.14" description = "Python API for communicating with the CARLA server." optional = false python-versions = "*" -files = [ - {file = "carla-0.9.14-cp311-cp311-linux_x86_64.whl", hash = "sha256:f0a8ce0c760d1fef3577e2ef90e9d468e3d85e65bd6d68b44bce51f0d5a0723a"}, -] +files = [] [package.source] type = "url" @@ -3105,6 +3103,24 @@ pluggy = ">=0.12,<2.0" [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "pytest-cov" +version = "4.1.0" +description = "Pytest plugin for measuring coverage." +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, + {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, +] + +[package.dependencies] +coverage = {version = ">=5.2.1", extras = ["toml"]} +pytest = ">=4.6" + +[package.extras] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] + [[package]] name = "pytest-xdist" version = "3.3.1" @@ -4161,4 +4177,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "4b2510f1465520a9dc757f64861f4fcea9d9663c0ecdebd23b329ef5e0205863" +content-hash = "587fe0b312a1d4a0be2e13fdd4626683227f6c9038d3efacf9866c431d9453b1" diff --git a/pyproject.toml b/pyproject.toml index 0af1bfcfae..0801439945 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,6 +119,7 @@ pycurl = "*" pygame = "*" pyprof2calltree = "*" pytest = "*" +pytest-cov = "*" pytest-xdist = "*" scipy = "*" sphinx = "*" From 0c4b91975b113dbf06203d5ee4537a713d19e5fa Mon Sep 17 00:00:00 2001 From: Felixowns <41752582+Felixowns@users.noreply.github.com> Date: Tue, 22 Aug 2023 00:28:13 -0400 Subject: [PATCH 058/159] Remove Sonata LF from LEGACY_SAFETY_MODE_CAR (#29521) * Update values.py remove sonata_lf from legacy safety mode. added sonata_lf to unsupported longitudinal car * Update selfdrive/car/hyundai/values.py --------- Co-authored-by: Shane Smiskol --- selfdrive/car/hyundai/values.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 66f4b18668..63c684b799 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1952,11 +1952,11 @@ EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR # these cars require a special panda safety mode due to missing counters and checksums in the messages LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, - CAR.SONATA_LF, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, + CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022} -# these cars have not been verified to work with longitudinal yet - radar disable, sending correct messages, etc -UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV, CAR.KIA_SORENTO} +# these cars have not been verified to work with longitudinal yet - radar disable, sending correct messages, etc. +UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV, CAR.KIA_SORENTO, CAR.SONATA_LF} # If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points. # If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py From fd3b8a3d7511ad3d7c5aa0b82a1e2c28505e5a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Mon, 21 Aug 2023 22:51:02 -0700 Subject: [PATCH 059/159] Locationd: switch to laikad (#29278) * use_laika * Update test * fix spacing * fix proc replay * small fix * Try correct std * cast correctly * experimental * simpler * update reset thresholds * improve * Ready for live running * outlier reject * update laika * add fine speeds * more experiments * fixes * all in laika * more small tweaks * outlier rejection not needed * fix conflict * no more gpslocation * update test * refactor to laika * runs again * Update ref --- laika_repo | 2 +- selfdrive/locationd/laikad.py | 59 +++----- selfdrive/locationd/liblocationd.cc | 2 +- selfdrive/locationd/locationd.cc | 129 +++--------------- selfdrive/locationd/locationd.h | 13 +- selfdrive/locationd/test/test_laikad.py | 4 +- selfdrive/locationd/test/test_locationd.py | 29 ++-- .../test/process_replay/process_replay.py | 12 +- selfdrive/test/process_replay/ref_commit | 2 +- 9 files changed, 57 insertions(+), 195 deletions(-) diff --git a/laika_repo b/laika_repo index 65901a1e6c..6c79c96474 160000 --- a/laika_repo +++ b/laika_repo @@ -1 +1 @@ -Subproject commit 65901a1e6c7c7940d8c97027d3edaca7d0132253 +Subproject commit 6c79c964748ab930bb3699c06025bb2b0565cbea diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index 2073813363..6c9c199db1 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -18,7 +18,8 @@ from laika.downloader import DownloadFailed from laika.ephemeris import EphemerisType, GPSEphemeris, GLONASSEphemeris, ephemeris_structs, parse_qcom_ephem from laika.gps_time import GPSTime from laika.helpers import ConstellationId, get_sv_id -from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox, read_raw_qcom +from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox +from laika.raw_gnss import gps_time_from_qcom_report, get_measurements_from_qcom_reports from laika.opt import calc_pos_fix, get_posfix_sympy_fun, calc_vel_fix, get_velfix_sympy_func from openpilot.selfdrive.locationd.models.constants import GENERATED_DIR, ObservationKind from openpilot.selfdrive.locationd.models.gnss_kf import GNSSKalman @@ -102,9 +103,10 @@ class Laikad: self.use_qcom = use_qcom self.first_log_time = None self.ttff = -1 + self.measurement_lag = 0.630 if self.use_qcom else 0.095 # qcom specific stuff - self.qcom_reports_received = 1 + self.qcom_reports_received = 4 self.qcom_reports = [] def load_cache(self): @@ -161,47 +163,31 @@ class Laikad: def get_lsq_fix(self, t, measurements): if self.last_fix_t is None or abs(self.last_fix_t - t) > 0: min_measurements = 5 if any(p.constellation_id == ConstellationId.GLONASS for p in measurements) else 4 + position_solution, pr_residuals, pos_std = calc_pos_fix(measurements, self.posfix_functions, min_measurements=min_measurements) if len(position_solution) < 3: return None position_estimate = position_solution[:3] - - position_std_residual = np.median(np.abs(pr_residuals)) - position_std = np.median(np.abs(pos_std))/10 - position_std = max(position_std_residual, position_std) * np.ones(3) + position_std = pos_std[:3] velocity_solution, prr_residuals, vel_std = calc_vel_fix(measurements, position_estimate, self.velfix_function, min_measurements=min_measurements) if len(velocity_solution) < 3: return None velocity_estimate = velocity_solution[:3] - - velocity_std_residual = np.median(np.abs(prr_residuals)) - velocity_std = np.median(np.abs(vel_std))/10 - velocity_std = max(velocity_std, velocity_std_residual) * np.ones(3) + velocity_std = vel_std[:3] return position_estimate, position_std, velocity_estimate, velocity_std - def gps_time_from_qcom_report(self, gnss_msg): - report = gnss_msg.drMeasurementReport - if report.source == log.QcomGnss.MeasurementSource.gps: - report_time = GPSTime(report.gpsWeek, report.gpsMilliseconds / 1000.0) - elif report.source == log.QcomGnss.MeasurementSource.sbas: - report_time = GPSTime(report.gpsWeek, report.gpsMilliseconds / 1000.0) - elif report.source == log.QcomGnss.MeasurementSource.glonass: - report_time = GPSTime.from_glonass(report.glonassYear, - report.glonassDay, - report.glonassMilliseconds / 1000.0) - else: - raise NotImplementedError(f'Unknownconstellation {report.source}') - return report_time - def is_good_report(self, gnss_msg): - if gnss_msg.which() == 'drMeasurementReport' and self.use_qcom: + if gnss_msg.which() in ['drMeasurementReport', 'measurementReport'] and self.use_qcom: # TODO: Understand and use remaining unknown constellations try: - constellation_id = ConstellationId.from_qcom_source(gnss_msg.drMeasurementReport.source) + if gnss_msg.which() == 'drMeasurementReport': + constellation_id = ConstellationId.from_qcom_source(gnss_msg.drMeasurementReport.source) + else: + constellation_id = ConstellationId.from_qcom_source(gnss_msg.measurementReport.source) good_constellation = constellation_id in [ConstellationId.GPS, ConstellationId.SBAS, ConstellationId.GLONASS] - report_time = self.gps_time_from_qcom_report(gnss_msg) + report_time = gps_time_from_qcom_report(gnss_msg) except NotImplementedError: return False # Garbage timestamps with week > 32767 are sometimes sent by module. @@ -216,21 +202,20 @@ class Laikad: def read_report(self, gnss_msg): if self.use_qcom: # QCOM reports are per constellation, so we need to aggregate them - report = gnss_msg.drMeasurementReport - report_time = self.gps_time_from_qcom_report(gnss_msg) - + # Additionally, the pseudoranges are broken in the measurementReports + # and the doppler filteredSpeed is broken in the drMeasurementReports + report_time = gps_time_from_qcom_report(gnss_msg) if report_time - self.last_report_time > 0: self.qcom_reports_received = max(1, len(self.qcom_reports)) - self.qcom_reports = [report] + self.qcom_reports = [gnss_msg] else: - self.qcom_reports.append(report) + self.qcom_reports.append(gnss_msg) self.last_report_time = report_time - new_meas = [] if len(self.qcom_reports) == self.qcom_reports_received: - for report in self.qcom_reports: - new_meas.extend(read_raw_qcom(report)) - + new_meas = get_measurements_from_qcom_reports(self.qcom_reports) + else: + new_meas = [] else: report = gnss_msg.measurementReport self.last_report_time = GPSTime(report.gpsWeek, report.rcvTow) @@ -300,7 +285,7 @@ class Laikad: def process_gnss_msg(self, gnss_msg, gnss_mono_time: int, block=False): out_msg = messaging.new_message("gnssMeasurements") t = gnss_mono_time * 1e-9 - msg_dict: Dict[str, Any] = {"measTime": gnss_mono_time} + msg_dict: Dict[str, Any] = {"measTime": gnss_mono_time - int(1e9 * self.measurement_lag)} if self.first_log_time is None: self.first_log_time = 1e-9 * gnss_mono_time if self.is_ephemeris(gnss_msg): diff --git a/selfdrive/locationd/liblocationd.cc b/selfdrive/locationd/liblocationd.cc index 6f298deab6..73ed1b0a56 100755 --- a/selfdrive/locationd/liblocationd.cc +++ b/selfdrive/locationd/liblocationd.cc @@ -4,7 +4,7 @@ extern "C" { typedef Localizer* Localizer_t; Localizer *localizer_init(bool has_ublox) { - return new Localizer(has_ublox ? LocalizerGnssSource::UBLOX : LocalizerGnssSource::QCOM); + return new Localizer(); } void localizer_get_message_bytes(Localizer *localizer, bool inputsOK, bool sensorsOK, bool gpsOK, bool msgValid, diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 9b3e3b3b85..aedc4ac371 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -13,7 +13,6 @@ const double ACCEL_SANITY_CHECK = 100.0; // m/s^2 const double ROTATION_SANITY_CHECK = 10.0; // rad/s const double TRANS_SANITY_CHECK = 200.0; // m/s const double CALIB_RPY_SANITY_CHECK = 0.5; // rad (+- 30 deg) -const double ALTITUDE_SANITY_CHECK = 10000; // m const double MIN_STD_SANITY_CHECK = 1e-5; // m or rad const double VALID_TIME_SINCE_RESET = 1.0; // s const double VALID_POS_STD = 50.0; // m @@ -23,15 +22,11 @@ const double INPUT_INVALID_THRESHOLD = 5.0; // same as reset tracker const double DECAY = 0.99995; // same as reset tracker const double MAX_FILTER_REWIND_TIME = 0.8; // s -// TODO: GPS sensor time offsets are empirically calculated -// They should be replaced with synced time from a real clock -const double GPS_QUECTEL_SENSOR_TIME_OFFSET = 0.630; // s -const double GPS_UBLOX_SENSOR_TIME_OFFSET = 0.095; // s const float GPS_POS_STD_THRESHOLD = 50.0; const float GPS_VEL_STD_THRESHOLD = 5.0; const float GPS_POS_ERROR_RESET_THRESHOLD = 300.0; -const float GPS_POS_STD_RESET_THRESHOLD = 2.0; -const float GPS_VEL_STD_RESET_THRESHOLD = 0.5; +const float GPS_POS_STD_RESET_THRESHOLD = 10.0; +const float GPS_VEL_STD_RESET_THRESHOLD = 1.0; const float GPS_ORIENTATION_ERROR_RESET_THRESHOLD = 1.0; const int GPS_ORIENTATION_ERROR_RESET_CNT = 3; @@ -70,7 +65,7 @@ static VectorXd rotate_std(const MatrixXdr& rot_matrix, const VectorXd& std_in) return rotate_cov(rot_matrix, std_in.array().square().matrix().asDiagonal()).diagonal().array().sqrt(); } -Localizer::Localizer(LocalizerGnssSource gnss_source) { +Localizer::Localizer() { this->kf = std::make_unique(); this->reset_kalman(); @@ -84,7 +79,6 @@ Localizer::Localizer(LocalizerGnssSource gnss_source) { VectorXd ecef_pos = this->kf->get_x().segment(STATE_ECEF_POS_START); this->converter = std::make_unique((ECEF) { .x = ecef_pos[0], .y = ecef_pos[1], .z = ecef_pos[2] }); - this->configure_gnss_source(gnss_source); } void Localizer::build_live_location(cereal::LiveLocationKalman::Builder& fix) { @@ -300,64 +294,6 @@ void Localizer::input_fake_gps_observations(double current_time) { this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); } -void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset) { - // ignore the message if the fix is invalid - bool gps_invalid_flag = (log.getFlags() % 2 == 0); - bool gps_unreasonable = (Vector2d(log.getAccuracy(), log.getVerticalAccuracy()).norm() >= SANE_GPS_UNCERTAINTY); - bool gps_accuracy_insane = ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0)); - bool gps_lat_lng_alt_insane = ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK)); - bool gps_vel_insane = (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK); - - if (gps_invalid_flag || gps_unreasonable || gps_accuracy_insane || gps_lat_lng_alt_insane || gps_vel_insane) { - //this->gps_valid = false; - this->determine_gps_mode(current_time); - return; - } - - double sensor_time = current_time - sensor_time_offset; - - // Process message - //this->gps_valid = true; - this->gps_mode = true; - Geodetic geodetic = { log.getLatitude(), log.getLongitude(), log.getAltitude() }; - this->converter = std::make_unique(geodetic); - - VectorXd ecef_pos = this->converter->ned2ecef({ 0.0, 0.0, 0.0 }).to_vector(); - VectorXd ecef_vel = this->converter->ned2ecef({ log.getVNED()[0], log.getVNED()[1], log.getVNED()[2] }).to_vector() - ecef_pos; - float ecef_pos_std = std::sqrt(this->gps_variance_factor * std::pow(log.getAccuracy(), 2) + this->gps_vertical_variance_factor * std::pow(log.getVerticalAccuracy(), 2)); - MatrixXdr ecef_pos_R = Vector3d::Constant(std::pow(this->gps_std_factor * ecef_pos_std, 2)).asDiagonal(); - MatrixXdr ecef_vel_R = Vector3d::Constant(std::pow(this->gps_std_factor * log.getSpeedAccuracy(), 2)).asDiagonal(); - - this->unix_timestamp_millis = log.getUnixTimestampMillis(); - double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); - - VectorXd orientation_ecef = quat2euler(vector2quat(this->kf->get_x().segment(STATE_ECEF_ORIENTATION_START))); - VectorXd orientation_ned = ned_euler_from_ecef({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ecef); - VectorXd orientation_ned_gps = Vector3d(0.0, 0.0, DEG2RAD(log.getBearingDeg())); - VectorXd orientation_error = (orientation_ned - orientation_ned_gps).array() - M_PI; - for (int i = 0; i < orientation_error.size(); i++) { - orientation_error(i) = std::fmod(orientation_error(i), 2.0 * M_PI); - if (orientation_error(i) < 0.0) { - orientation_error(i) += 2.0 * M_PI; - } - orientation_error(i) -= M_PI; - } - VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); - - if (ecef_vel.norm() > 5.0 && orientation_error.norm() > 1.0) { - LOGE("Locationd vs ubloxLocation orientation difference too large, kalman reset"); - this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); - this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_ORIENTATION_FROM_GPS, { initial_pose_ecef_quat }); - } else if (gps_est_error > 100.0) { - LOGE("Locationd vs ubloxLocation position difference too large, kalman reset"); - this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); - } - - this->last_gps_msg = sensor_time; - this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_POS, { ecef_pos }, { ecef_pos_R }); - this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); -} - void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log) { if(!log.getPositionECEF().getValid() || !log.getVelocityECEF().getValid()) { @@ -366,21 +302,22 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: } double sensor_time = log.getMeasTime() * 1e-9; - sensor_time -= this->gps_time_offset; auto ecef_pos_v = log.getPositionECEF().getValue(); VectorXd ecef_pos = Vector3d(ecef_pos_v[0], ecef_pos_v[1], ecef_pos_v[2]); - // indexed at 0 cause all std values are the same MAE - auto ecef_pos_std = log.getPositionECEF().getStd()[0]; - MatrixXdr ecef_pos_R = Vector3d::Constant(pow(this->gps_std_factor*ecef_pos_std, 2)).asDiagonal(); + auto ecef_pos_std = log.getPositionECEF().getStd(); + VectorXd ecef_pos_var = Vector3d(ecef_pos_std[0], ecef_pos_std[1], ecef_pos_std[2]).array().square().matrix(); + double ecef_pos_std_norm = std::sqrt(ecef_pos_var.sum()); + MatrixXdr ecef_pos_R = ecef_pos_var.asDiagonal(); auto ecef_vel_v = log.getVelocityECEF().getValue(); VectorXd ecef_vel = Vector3d(ecef_vel_v[0], ecef_vel_v[1], ecef_vel_v[2]); - // indexed at 0 cause all std values are the same MAE - auto ecef_vel_std = log.getVelocityECEF().getStd()[0]; - MatrixXdr ecef_vel_R = Vector3d::Constant(pow(this->gps_std_factor*ecef_vel_std, 2)).asDiagonal(); + auto ecef_vel_std = log.getVelocityECEF().getStd(); + VectorXd ecef_vel_var = Vector3d(ecef_vel_std[0], ecef_vel_std[1], ecef_vel_std[2]).array().square().matrix(); + double ecef_vel_std_norm = std::sqrt(ecef_vel_var.sum()); + MatrixXdr ecef_vel_R = ecef_vel_var.asDiagonal(); double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); @@ -403,13 +340,13 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: } VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); - if (ecef_pos_std > GPS_POS_STD_THRESHOLD || ecef_vel_std > GPS_VEL_STD_THRESHOLD) { + if (ecef_pos_std_norm > GPS_POS_STD_THRESHOLD || ecef_vel_std_norm > GPS_VEL_STD_THRESHOLD) { this->determine_gps_mode(current_time); return; } // prevent jumping gnss measurements (covered lots, standstill...) - bool orientation_reset = ecef_vel_std < GPS_VEL_STD_RESET_THRESHOLD; + bool orientation_reset = ecef_vel_std_norm < GPS_VEL_STD_RESET_THRESHOLD; orientation_reset &= orientation_error.norm() > GPS_ORIENTATION_ERROR_RESET_THRESHOLD; orientation_reset &= !this->standstill; if (orientation_reset) { @@ -419,7 +356,7 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: this->orientation_reset_count = 0; } - if ((gps_est_error > GPS_POS_ERROR_RESET_THRESHOLD && ecef_pos_std < GPS_POS_STD_RESET_THRESHOLD) || this->last_gps_msg == 0) { + if ((gps_est_error > GPS_POS_ERROR_RESET_THRESHOLD && ecef_pos_std_norm < GPS_POS_STD_RESET_THRESHOLD) || this->last_gps_msg == 0) { // always reset on first gps message and if the location is off but the accuracy is high LOGE("Locationd vs gnssMeasurement position difference too large, kalman reset"); this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); @@ -588,12 +525,8 @@ void Localizer::handle_msg(const cereal::Event::Reader& log) { this->handle_sensor(t, log.getAccelerometer()); } else if (log.isGyroscope()) { this->handle_sensor(t, log.getGyroscope()); - } else if (log.isGpsLocation()) { - this->handle_gps(t, log.getGpsLocation(), GPS_QUECTEL_SENSOR_TIME_OFFSET); - } else if (log.isGpsLocationExternal()) { - this->handle_gps(t, log.getGpsLocationExternal(), GPS_UBLOX_SENSOR_TIME_OFFSET); - //} else if (log.isGnssMeasurements()) { - // this->handle_gnss(t, log.getGnssMeasurements()); + } else if (log.isGnssMeasurements()) { + this->handle_gnss(t, log.getGnssMeasurements()); } else if (log.isCarState()) { this->handle_car_state(t, log.getCarState()); } else if (log.isCameraOdometry()) { @@ -655,38 +588,12 @@ void Localizer::determine_gps_mode(double current_time) { } } -void Localizer::configure_gnss_source(LocalizerGnssSource source) { - this->gnss_source = source; - if (source == LocalizerGnssSource::UBLOX) { - this->gps_std_factor = 10.0; - this->gps_variance_factor = 1.0; - this->gps_vertical_variance_factor = 1.0; - this->gps_time_offset = GPS_UBLOX_SENSOR_TIME_OFFSET; - } else { - this->gps_std_factor = 2.0; - this->gps_variance_factor = 0.0; - this->gps_vertical_variance_factor = 3.0; - this->gps_time_offset = GPS_QUECTEL_SENSOR_TIME_OFFSET; - } -} - int Localizer::locationd_thread() { - LocalizerGnssSource source; - const char* gps_location_socket; - if (Params().getBool("UbloxAvailable")) { - source = LocalizerGnssSource::UBLOX; - gps_location_socket = "gpsLocationExternal"; - } else { - source = LocalizerGnssSource::QCOM; - gps_location_socket = "gpsLocation"; - } - - this->configure_gnss_source(source); - const std::initializer_list service_list = {gps_location_socket, "cameraOdometry", "liveCalibration", + const std::initializer_list service_list = {"gnssMeasurements", "cameraOdometry", "liveCalibration", "carState", "carParams", "accelerometer", "gyroscope"}; // TODO: remove carParams once we're always sending at 100Hz - SubMaster sm(service_list, {}, nullptr, {gps_location_socket, "carParams"}); + SubMaster sm(service_list, {}, nullptr, {"gnssMeasurements", "carParams"}); PubMaster pm({"liveLocationKalman"}); uint64_t cnt = 0; diff --git a/selfdrive/locationd/locationd.h b/selfdrive/locationd/locationd.h index e8f2f04a2c..cfa2d0a667 100755 --- a/selfdrive/locationd/locationd.h +++ b/selfdrive/locationd/locationd.h @@ -21,13 +21,10 @@ #define POSENET_STD_HIST_HALF 20 -enum LocalizerGnssSource { - UBLOX, QCOM -}; class Localizer { public: - Localizer(LocalizerGnssSource gnss_source = LocalizerGnssSource::UBLOX); + Localizer(); int locationd_thread(); @@ -55,7 +52,6 @@ public: void handle_msg_bytes(const char *data, const size_t size); void handle_msg(const cereal::Event::Reader& log); void handle_sensor(double current_time, const cereal::SensorEventData::Reader& log); - void handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset); void handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log); void handle_car_state(double current_time, const cereal::CarState::Reader& log); void handle_cam_odo(double current_time, const cereal::CameraOdometry::Reader& log); @@ -84,15 +80,8 @@ private: double first_valid_log_time = NAN; double ttff = NAN; double last_gps_msg = 0; - LocalizerGnssSource gnss_source; bool observation_timings_invalid = false; std::map observation_values_invalid; bool standstill = true; int32_t orientation_reset_count = 0; - float gps_std_factor; - float gps_variance_factor; - float gps_vertical_variance_factor; - double gps_time_offset; - - void configure_gnss_source(LocalizerGnssSource source); }; diff --git a/selfdrive/locationd/test/test_laikad.py b/selfdrive/locationd/test/test_laikad.py index 58c650e26c..a8d69502cf 100755 --- a/selfdrive/locationd/test/test_laikad.py +++ b/selfdrive/locationd/test/test_laikad.py @@ -177,8 +177,8 @@ class TestLaikad(unittest.TestCase): laikad = Laikad(auto_update=True, valid_ephem_types=EphemerisType.NAV, use_qcom=use_qcom) # Disable fetch_orbits to test NAV only correct_msgs = verify_messages(logs, laikad) - correct_msgs_expected = 56 if use_qcom else 560 - valid_fix_expected = 56 if use_qcom else 560 + correct_msgs_expected = 55 if use_qcom else 560 + valid_fix_expected = 55 if use_qcom else 560 self.assertEqual(correct_msgs_expected, len(correct_msgs)) self.assertEqual(valid_fix_expected, len([m for m in correct_msgs if m.gnssMeasurements.positionECEF.valid])) diff --git a/selfdrive/locationd/test/test_locationd.py b/selfdrive/locationd/test/test_locationd.py index 6c6ac33431..1fb36bf2fa 100755 --- a/selfdrive/locationd/test/test_locationd.py +++ b/selfdrive/locationd/test/test_locationd.py @@ -14,7 +14,7 @@ from openpilot.selfdrive.manager.process_config import managed_processes class TestLocationdProc(unittest.TestCase): - LLD_MSGS = ['gpsLocationExternal', 'cameraOdometry', 'carState', 'liveCalibration', + LLD_MSGS = ['gnssMeasurements', 'cameraOdometry', 'carState', 'liveCalibration', 'accelerometer', 'gyroscope', 'magnetometer'] def setUp(self): @@ -35,25 +35,14 @@ class TestLocationdProc(unittest.TestCase): msg = messaging.new_message(name) except capnp.lib.capnp.KjException: msg = messaging.new_message(name, 0) - - if name == "gpsLocationExternal": - msg.gpsLocationExternal.flags = 1 - msg.gpsLocationExternal.verticalAccuracy = 1.0 - msg.gpsLocationExternal.speedAccuracy = 1.0 - msg.gpsLocationExternal.bearingAccuracyDeg = 1.0 - msg.gpsLocationExternal.vNED = [0.0, 0.0, 0.0] - msg.gpsLocationExternal.latitude = float(self.lat) - msg.gpsLocationExternal.longitude = float(self.lon) - msg.gpsLocationExternal.unixTimestampMillis = t * 1e6 - msg.gpsLocationExternal.altitude = float(self.alt) - #if name == "gnssMeasurements": - # msg.gnssMeasurements.measTime = t - # msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] - # msg.gnssMeasurements.positionECEF.std = [0,0,0] - # msg.gnssMeasurements.positionECEF.valid = True - # msg.gnssMeasurements.velocityECEF.value = [] - # msg.gnssMeasurements.velocityECEF.std = [0,0,0] - # msg.gnssMeasurements.velocityECEF.valid = True + if name == "gnssMeasurements": + msg.gnssMeasurements.measTime = t + msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] + msg.gnssMeasurements.positionECEF.std = [0,0,0] + msg.gnssMeasurements.positionECEF.valid = True + msg.gnssMeasurements.velocityECEF.value = [] + msg.gnssMeasurements.velocityECEF.std = [0,0,0] + msg.gnssMeasurements.velocityECEF.valid = True elif name == 'cameraOdometry': msg.cameraOdometry.rot = [0.0, 0.0, 0.0] msg.cameraOdometry.rotStd = [0.0, 0.0, 0.0] diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 9256b6015c..c0a49e3324 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -433,13 +433,6 @@ def laikad_config_pubsub_callback(params, cfg, lr): cfg.main_pub_drained = True -def locationd_config_pubsub_callback(params, cfg, lr): - ublox = params.get_bool("UbloxAvailable") - sub_keys = ({"gpsLocation", } if ublox else {"gpsLocationExternal", }) - - cfg.pubs = set(cfg.pubs) - sub_keys - - CONFIGS = [ ProcessConfig( proc_name="controlsd", @@ -494,12 +487,11 @@ CONFIGS = [ ProcessConfig( proc_name="locationd", pubs=[ - "cameraOdometry", "accelerometer", "gyroscope", "gpsLocationExternal", - "liveCalibration", "carState", "carParams", "gpsLocation" + "cameraOdometry", "accelerometer", "gyroscope", "gnssMeasurements", + "liveCalibration", "carState", "carParams" ], subs=["liveLocationKalman"], ignore=["logMonoTime", "valid"], - config_callback=locationd_config_pubsub_callback, tolerance=NUMPY_TOLERANCE, ), ProcessConfig( diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 8aec881aa5..564eafa597 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -72e3d7b660ee92f5adcc249112cf04c703f4bf9e \ No newline at end of file +89db4d10a4eb0bfd0ea0ff83525e5cf358f5f690 \ No newline at end of file From 3523bef732316b534de66dcb9e7d29e53e37e99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Mon, 21 Aug 2023 23:16:49 -0700 Subject: [PATCH 060/159] bump laika (#29522) --- laika_repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laika_repo b/laika_repo index 6c79c96474..989b6a8505 160000 --- a/laika_repo +++ b/laika_repo @@ -1 +1 @@ -Subproject commit 6c79c964748ab930bb3699c06025bb2b0565cbea +Subproject commit 989b6a8505441a550c94f60b4378be296ea3fe92 From 92a7d702fcc8fd5188918871ed44fa0d4cb7d28f Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Tue, 22 Aug 2023 07:29:15 +0100 Subject: [PATCH 061/159] Ford: test FW query config and versions (#29016) * Ford: test FW query config and versions * comments about software p/n * should keep it in bytes * don't need car_model * it prints nicely * add todo * Update selfdrive/car/ford/tests/test_ford.py --------- Co-authored-by: Shane Smiskol --- selfdrive/car/ford/tests/__init__.py | 0 selfdrive/car/ford/tests/test_ford.py | 80 +++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 selfdrive/car/ford/tests/__init__.py create mode 100755 selfdrive/car/ford/tests/test_ford.py diff --git a/selfdrive/car/ford/tests/__init__.py b/selfdrive/car/ford/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selfdrive/car/ford/tests/test_ford.py b/selfdrive/car/ford/tests/test_ford.py new file mode 100755 index 0000000000..11746777f0 --- /dev/null +++ b/selfdrive/car/ford/tests/test_ford.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +import unittest +from parameterized import parameterized +from typing import Dict, Iterable, Optional, Tuple + +import capnp + +from cereal import car +from selfdrive.car.ford.values import FW_QUERY_CONFIG, FW_VERSIONS + +Ecu = car.CarParams.Ecu + + +ECU_ADDRESSES = { + Ecu.eps: 0x730, # Power Steering Control Module (PSCM) + Ecu.abs: 0x760, # Anti-Lock Brake System (ABS) + Ecu.fwdRadar: 0x764, # Cruise Control Module (CCM) + Ecu.fwdCamera: 0x706, # Image Processing Module A (IPMA) + Ecu.engine: 0x7E0, # Powertrain Control Module (PCM) + Ecu.shiftByWire: 0x732, # Gear Shift Module (GSM) +} + + +ECU_FW_CORE = { + Ecu.eps: [ + b"14D003", + ], + Ecu.abs: [ + b"2D053", + ], + Ecu.fwdRadar: [ + b"14D049", + ], + Ecu.fwdCamera: [ + b"14F397", # Ford Q3 + b"14H102", # Ford Q4 + ], + Ecu.engine: [ + b"14C204", + ], +} + + +class TestFordFW(unittest.TestCase): + def test_fw_query_config(self): + for (ecu, addr, subaddr) in FW_QUERY_CONFIG.extra_ecus: + self.assertIn(ecu, ECU_ADDRESSES, "Unknown ECU") + self.assertEqual(addr, ECU_ADDRESSES[ecu], "ECU address mismatch") + self.assertIsNone(subaddr, "Unexpected ECU subaddress") + + @parameterized.expand(FW_VERSIONS.items()) + def test_fw_versions(self, car_model: str, fw_versions: Dict[Tuple[capnp.lib.capnp._EnumModule, int, Optional[int]], Iterable[bytes]]): + for (ecu, addr, subaddr), fws in fw_versions.items(): + self.assertIn(ecu, ECU_ADDRESSES, "Unknown ECU") + self.assertEqual(addr, ECU_ADDRESSES[ecu], "ECU address mismatch") + self.assertIsNone(subaddr, "Unexpected ECU subaddress") + + # Software part number takes the form: PREFIX-CORE-SUFFIX + # Prefix changes based on the family of part. It includes the model year + # and likely the platform. + # Core identifies the type of the item (e.g. 14D003 = PSCM, 14C204 = PCM). + # Suffix specifies the version of the part. -AA would be followed by -AB. + # Small increments in the suffix are usually compatible. + # Details: https://forscan.org/forum/viewtopic.php?p=70008#p70008 + for fw in fws: + self.assertEqual(len(fw), 24, "Expected ECU response to be 24 bytes") + + # TODO: parse with regex, don't need detailed error message + fw_parts = fw.rstrip(b'\x00').split(b'-') + self.assertEqual(len(fw_parts), 3, "Expected FW to be in format: prefix-core-suffix") + + prefix, core, suffix = fw_parts + self.assertEqual(len(prefix), 4, "Expected FW prefix to be 4 characters") + self.assertIn(len(core), (5, 6), "Expected FW core to be 5-6 characters") + self.assertIn(core, ECU_FW_CORE[ecu], f"Unexpected FW core for {ecu}") + self.assertIn(len(suffix), (2, 3), "Expected FW suffix to be 2-3 characters") + + +if __name__ == "__main__": + unittest.main() From e8094affae0d7f49bc2b7136882dd1dad9e8dcdb Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Tue, 22 Aug 2023 16:21:16 +0200 Subject: [PATCH 062/159] ratekeeper.h: add missing include (#29523) --- common/ratekeeper.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/ratekeeper.h b/common/ratekeeper.h index ff4cb42c7b..b6e8ac66a6 100644 --- a/common/ratekeeper.h +++ b/common/ratekeeper.h @@ -1,5 +1,6 @@ #pragma once +#include #include class RateKeeper { From c5c73c4ddb819967388f3f9dd28c38596af10397 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 10:39:45 -0700 Subject: [PATCH 063/159] pre-commit: autoupdate hooks (#29524) Update pre-commit hook versions Co-authored-by: adeebshihadeh --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b777bc4368..471d2855f1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: args: ['--explicit-package-bases'] exclude: '^(third_party/)|(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)' - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.284 + rev: v0.0.285 hooks: - id: ruff exclude: '^(third_party/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)' @@ -61,7 +61,7 @@ repos: language: script pass_filenames: false - repo: https://github.com/python-poetry/poetry - rev: '1.5.0' + rev: '1.6.0' hooks: - id: poetry-check - id: poetry-lock From d1aedccfbe3cb880ad54adea578f91c04857d81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Tue, 22 Aug 2023 10:47:56 -0700 Subject: [PATCH 064/159] CI: prevent moc from running in cache population step (#29401) * Do not remove moc_files from cache * Add cache cleanup script * Use cache cleanup script * Dry-run in cache population command * Add newline * Temporarly disable master only constraint for cache cleanup step * Add test lines * one more * Fix shebang * Remove debug lines * Bring back master branch constraints --- .github/workflows/selfdrive_tests.yaml | 8 +++----- release/clean-cache.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100755 release/clean-cache.sh diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 991ce74ca9..143f831995 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -82,9 +82,8 @@ jobs: run: ${{ env.RUN }} "scons -j$(nproc) --extras && release/check-dirty.sh" - name: Cleanup scons cache and rebuild timeout-minutes: ${{ ((steps.restore-scons-cache.outputs.cache-hit == 'true') && 2 || 30) }} # allow more time when we missed the scons cache - run: | - ${{ env.RUN }} "rm -rf /tmp/scons_cache/* && \ - scons -j$(nproc) --cache-populate" + if: github.ref == 'refs/heads/master' + run: ${{ env.RUN }} "release/clean-cache.sh" - name: Save scons cache uses: actions/cache/save@v3 if: github.ref == 'refs/heads/master' @@ -159,9 +158,8 @@ jobs: - name: Pre Cache - Cleanup scons cache if: github.ref == 'refs/heads/master' run: | - rm -rf /tmp/scons_cache/* eval "$(pyenv init --path)" - poetry run scons -j$(nproc) --cache-populate + poetry run release/clean-cache.sh - name: Save scons cache id: scons-save-cache uses: actions/cache/save@v3 diff --git a/release/clean-cache.sh b/release/clean-cache.sh new file mode 100755 index 0000000000..ec63ee95b1 --- /dev/null +++ b/release/clean-cache.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +# delete outdated moc files +scons --dry-run --taskmastertrace /tmp/tasktrace.log >/dev/null +MOC_EXISTING_PROD="$(find /tmp/scons_cache/moc_files -type f | sort)" +MOC_CURRENT_PROD="$(egrep -o "'[^']*moc_files[^']*'" /tmp/tasktrace.log | sed "s/'//g" | sort | uniq)" +MOC_JUNK="$(comm -23 <(echo "$MOC_EXISTING_PROD") <(echo "$MOC_CURRENT_PROD"))" +echo "$MOC_JUNK" | xargs -I{} rm {} +rm /tmp/tasktrace.log + +# delete cache except for moc files +rm -rf $(find /tmp/scons_cache -maxdepth 1 ! -name moc_files ! -name scons_cache) + +# repopulate cache +scons --dry-run --cache-populate >/dev/null From 91dc8457ae8e9b188c8fe613be5b3aa2e86be276 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 11:16:58 -0700 Subject: [PATCH 065/159] Revert Qt MOC hacks (#29528) * Revert "CI: prevent moc from running in cache population step (#29401)" This reverts commit d1aedccfbe3cb880ad54adea578f91c04857d81b. * Revert "SCons: respect cache read only (#29437)" This reverts commit 59abb469ea4a8443ea07a0638acbc6ece0c9ddd2. * don't change moc path --- .github/workflows/selfdrive_tests.yaml | 8 +++++--- .gitignore | 1 - SConstruct | 13 ------------- release/clean-cache.sh | 16 ---------------- tools/cabana/SConscript | 2 -- 5 files changed, 5 insertions(+), 35 deletions(-) delete mode 100755 release/clean-cache.sh diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 143f831995..991ce74ca9 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -82,8 +82,9 @@ jobs: run: ${{ env.RUN }} "scons -j$(nproc) --extras && release/check-dirty.sh" - name: Cleanup scons cache and rebuild timeout-minutes: ${{ ((steps.restore-scons-cache.outputs.cache-hit == 'true') && 2 || 30) }} # allow more time when we missed the scons cache - if: github.ref == 'refs/heads/master' - run: ${{ env.RUN }} "release/clean-cache.sh" + run: | + ${{ env.RUN }} "rm -rf /tmp/scons_cache/* && \ + scons -j$(nproc) --cache-populate" - name: Save scons cache uses: actions/cache/save@v3 if: github.ref == 'refs/heads/master' @@ -158,8 +159,9 @@ jobs: - name: Pre Cache - Cleanup scons cache if: github.ref == 'refs/heads/master' run: | + rm -rf /tmp/scons_cache/* eval "$(pyenv init --path)" - poetry run release/clean-cache.sh + poetry run scons -j$(nproc) --cache-populate - name: Save scons cache id: scons-save-cache uses: actions/cache/save@v3 diff --git a/.gitignore b/.gitignore index 004c0a6441..a7c8c1c6f0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ venv/ .tags .ipynb_checkpoints .idea -.moc_files .overlay_init .overlay_consistent .sconsign.dblite diff --git a/SConstruct b/SConstruct index e384e31d94..0f720fcba7 100644 --- a/SConstruct +++ b/SConstruct @@ -1,5 +1,4 @@ import os -import shutil import subprocess import sys import sysconfig @@ -336,18 +335,6 @@ qt_env['CXXFLAGS'] += qt_flags qt_env['LIBPATH'] += ['#selfdrive/ui'] qt_env['LIBS'] = qt_libs -# Have to respect cache-readonly -if GetOption('cache_readonly'): - local_moc_files_dir = Dir("#.moc_files").abspath - cache_moc_files_dir = cache_dir + "/moc_files" - if os.path.exists(local_moc_files_dir): - shutil.rmtree(local_moc_files_dir) - if os.path.exists(cache_moc_files_dir): - shutil.copytree(cache_moc_files_dir, local_moc_files_dir) - qt_env['QT3_MOCHPREFIX'] = local_moc_files_dir + "/moc_" -else: - qt_env['QT3_MOCHPREFIX'] = cache_dir + '/moc_files/moc_' - if GetOption("clazy"): checks = [ "level0", diff --git a/release/clean-cache.sh b/release/clean-cache.sh deleted file mode 100755 index ec63ee95b1..0000000000 --- a/release/clean-cache.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e - -# delete outdated moc files -scons --dry-run --taskmastertrace /tmp/tasktrace.log >/dev/null -MOC_EXISTING_PROD="$(find /tmp/scons_cache/moc_files -type f | sort)" -MOC_CURRENT_PROD="$(egrep -o "'[^']*moc_files[^']*'" /tmp/tasktrace.log | sed "s/'//g" | sort | uniq)" -MOC_JUNK="$(comm -23 <(echo "$MOC_EXISTING_PROD") <(echo "$MOC_CURRENT_PROD"))" -echo "$MOC_JUNK" | xargs -I{} rm {} -rm /tmp/tasktrace.log - -# delete cache except for moc files -rm -rf $(find /tmp/scons_cache -maxdepth 1 ! -name moc_files ! -name scons_cache) - -# repopulate cache -scons --dry-run --cache-populate >/dev/null diff --git a/tools/cabana/SConscript b/tools/cabana/SConscript index cdc809f2b4..c6b47630ef 100644 --- a/tools/cabana/SConscript +++ b/tools/cabana/SConscript @@ -27,8 +27,6 @@ assets_src = "assets/assets.qrc" cabana_env.Command(assets, assets_src, f"rcc $SOURCES -o $TARGET") cabana_env.Depends(assets, Glob('/assets/*', exclude=[assets, assets_src, "assets/assets.o"])) -prev_moc_path = cabana_env['QT3_MOCHPREFIX'] -cabana_env['QT3_MOCHPREFIX'] = os.path.dirname(prev_moc_path) + '/cabana/moc_' cabana_lib = cabana_env.Library("cabana_lib", ['mainwin.cc', 'streams/pandastream.cc', 'streams/devicestream.cc', 'streams/livestream.cc', 'streams/abstractstream.cc', 'streams/replaystream.cc', 'binaryview.cc', 'historylog.cc', 'videowidget.cc', 'signalview.cc', 'dbc/dbc.cc', 'dbc/dbcfile.cc', 'dbc/dbcmanager.cc', 'chart/chartswidget.cc', 'chart/chart.cc', 'chart/signalselector.cc', 'chart/tiplabel.cc', 'chart/sparkline.cc', From d71a7190f1210f5ac97ce16892552ecf495e2437 Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Tue, 22 Aug 2023 20:47:09 +0200 Subject: [PATCH 066/159] Devcontainer (#29259) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * mvp devcontainer. builds, runs and UI works * fix indentation * enable color and fix openpilot_env path * separate dockerfile for devcontainer * use prebuilt image * Fix openpilot_env setup * Add dev container section in readme * Fix typo * Fix typo again * Move dev dockerfile to .devcontainer dir * Update README * Add note about x11 forwarding on macos * Update dev container json * Fix typo * Override DISPLAY on macOS * Mention XAUTHORITY for macOS setup in README * fix typo * Add devcontainer CI test * Rename to devcontainer * Fix git issues * ripgrep * Link instead of vscode manual * Replace raw path with containerWorkspaceFolder * Fix typo * Remove dev tools workflow * Link away X11 forwarding setup isntructions for mac * Remove fork consrtaint, add test run of scons * Add submodules as safe.directories in postStartCommand * Remove openpilot_env references * Add scons cache volume --------- Co-authored-by: Robbe Derks Co-authored-by: Kacper Rączy --- .devcontainer/Dockerfile | 6 ++++++ .devcontainer/devcontainer.json | 22 ++++++++++++++++++++++ .github/workflows/tools_tests.yaml | 18 +++++++++++++++++- tools/README.md | 10 ++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100755 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..e72704bfd0 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM ghcr.io/commaai/openpilot-base:latest + +# remove gitconfig if exists, since its gonna be replaced by host one +RUN rm -f /root/.gitconfig +RUN apt update && apt install -y vim net-tools usbutils htop ripgrep +RUN pip install ipython jupyter jupyterlab diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100755 index 0000000000..c2d26fb9a7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +{ + "name": "openpilot devcontainer", + "build": { + "dockerfile": "Dockerfile" + }, + "postCreateCommand": "bash -c 'if [[ $DISPLAY == *xquartz* ]]; then echo \"export DISPLAY=host.docker.internal:0\" >> /root/.bashrc; fi'", + "postStartCommand": "git config --file .gitmodules --get-regexp path | awk '{ print $2 }' | xargs -I{} git config --global --add safe.directory \"$PWD/{}\"", + "privileged": true, + "containerEnv": { + "DISPLAY": "${localEnv:DISPLAY}", + "PYTHONPATH": "${containerWorkspaceFolder}", + "force_color_prompt": "1" + }, + "runArgs": [ + "--volume=/tmp/.X11-unix:/tmp/.X11-unix", + "--volume=${localEnv:XAUTHORITY}:/root/.Xauthority", + "--volume=${localEnv:HOME}/.comma:/root/.comma", + "--volume=/tmp/comma_download_cache:/tmp/comma_download_cache", + "--volume=/tmp/devcontainer_scons_cache:/tmp/scons_cache", + "--shm-size=1G" + ] +} \ No newline at end of file diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 5891d5207e..04f73d21af 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -91,4 +91,20 @@ jobs: if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' run: | $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/openpilot-docs:latest \ No newline at end of file + docker push $DOCKER_REGISTRY/openpilot-docs:latest + + devcontainer: + name: devcontainer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Dev Container CLI + run: npm install -g @devcontainers/cli + - name: Build dev container image + run: devcontainer build --workspace-folder . + - name: Run dev container + run: devcontainer up --workspace-folder . + - name: Test environment + run: devcontainer exec --workspace-folder . scons --dry-run diff --git a/tools/README.md b/tools/README.md index fd03a5d77e..28f4f7ebd2 100644 --- a/tools/README.md +++ b/tools/README.md @@ -38,6 +38,16 @@ Build openpilot with this command: scons -u -j$(nproc) ``` +### Dev Container + +openpilot supports [Dev Containers](https://containers.dev/). Dev containers provide customizable and consistent development environment wrapped inside a container. This means you can develop in a designated environment matching our primary development target, regardless of your local setup. + +Dev containers are supported in [multiple editors and IDEs](https://containers.dev/supporting), including [Visual Studio Code](https://code.visualstudio.com/docs/devcontainers/containers). + +#### X11 forwarding on macOS + +GUI apps like `ui` or `cabana` can also run inside the container by leveraging X11 forwarding. To make use of it on macOS, additional configuration steps must be taken. Follow [these](https://gist.github.com/sorny/969fe55d85c9b0035b0109a31cbcb088) steps to setup X11 forwarding on macOS. + ### Windows Neither openpilot nor any of the tools are developed or tested on Windows, but the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/about) should provide a similar experience to native Ubuntu. [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/compare-versions) specifically has been reported by several users to be a seamless experience. From f546e9277466d298b1b3c62e70de9cbe002fa5d6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 12:41:52 -0700 Subject: [PATCH 067/159] Kia: move Optima Gen 4 FL out of legacy safety mode (#29530) move Optima Gen 4 Facelift out of legacy --- selfdrive/car/hyundai/values.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 63c684b799..3604b416fc 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1952,11 +1952,11 @@ EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR # these cars require a special panda safety mode due to missing counters and checksums in the messages LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, - CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, - CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022} + CAR.KIA_OPTIMA_G4, CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, + CAR.IONIQ_HEV_2022} # these cars have not been verified to work with longitudinal yet - radar disable, sending correct messages, etc. -UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV, CAR.KIA_SORENTO, CAR.SONATA_LF} +UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV, CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_OPTIMA_G4_FL} # If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points. # If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py From 2c835b81d9b206c04b23498c32bece1c8dbfaa52 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 12:59:56 -0700 Subject: [PATCH 068/159] Hyundai: remove Ioniq EV 2022 from legacy safety mode (#29531) * fw * remove from legacy * update docs --- docs/CARS.md | 2 +- selfdrive/car/hyundai/values.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CARS.md b/docs/CARS.md index 07155bf379..9ded53f201 100644 --- a/docs/CARS.md +++ b/docs/CARS.md @@ -81,7 +81,7 @@ A supported vehicle is one that just works when you install a comma three. All s |Hyundai|Ioniq 5 (with HDA II) 2022-23[6](#footnotes)|Highway Driving Assist II|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai Q connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Hyundai|Ioniq 5 (without HDA II) 2022-23[6](#footnotes)|Highway Driving Assist|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai K connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Hyundai|Ioniq Electric 2019|Smart Cruise Control (SCC)|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| -|Hyundai|Ioniq Electric 2020|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai H connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| +|Hyundai|Ioniq Electric 2020|All|openpilot available[1](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai H connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Hyundai|Ioniq Hybrid 2017-19|Smart Cruise Control (SCC)|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Hyundai|Ioniq Hybrid 2020-22|Smart Cruise Control (SCC)|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai H connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Hyundai|Ioniq Plug-in Hybrid 2019|Smart Cruise Control (SCC)|openpilot available[1](#footnotes)|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 Hyundai C connector
- 1 RJ45 cable (7 ft)
- 1 comma power v2
- 1 comma three
- 1 harness box
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 3604b416fc..5f5b48dba7 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -607,6 +607,7 @@ FW_VERSIONS = { b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.01 95740-G2600 190819', b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.03 95740-G2500 190516', b'\xf1\x00AEE MFC AT EUR RHD 1.00 1.01 95740-G2600 190819', + b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.00 95740-G2600 190730', ], }, CAR.IONIQ_EV_LTD: { @@ -1951,9 +1952,8 @@ EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR CAR.KIA_EV6, CAR.IONIQ_5, CAR.IONIQ_6, CAR.GENESIS_GV60_EV_1ST_GEN} # these cars require a special panda safety mode due to missing counters and checksums in the messages -LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, - CAR.KIA_OPTIMA_G4, CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, - CAR.IONIQ_HEV_2022} +LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_OPTIMA_G4, + CAR.VELOSTER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022} # these cars have not been verified to work with longitudinal yet - radar disable, sending correct messages, etc. UNSUPPORTED_LONGITUDINAL_CAR = LEGACY_SAFETY_MODE_CAR | {CAR.KIA_NIRO_PHEV, CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_OPTIMA_G4_FL} From 952d720b6e854b3ebbb9fd0fd82cd38f3ae04b90 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 13:55:23 -0700 Subject: [PATCH 069/159] add cpplint (#26855) * setup cpplint * only start that * check line length * check these * rm exceptions --- .pre-commit-config.yaml | 14 +++++++++++++- selfdrive/locationd/locationd.cc | 3 ++- selfdrive/ui/qt/offroad/settings.cc | 15 +++++++++------ selfdrive/ui/qt/widgets/ssh_keys.cc | 5 ++++- selfdrive/ui/translations/main_de.ts | 26 +++++++++++++------------- selfdrive/ui/translations/main_ja.ts | 26 +++++++++++++------------- selfdrive/ui/translations/main_tr.ts | 8 ++++---- system/camerad/cameras/camera_qcom2.cc | 7 ++++--- 8 files changed, 62 insertions(+), 42 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 471d2855f1..c58654b2d2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,18 @@ repos: - --quiet - --force - -j8 +- repo: https://github.com/cpplint/cpplint + rev: 1.6.1 + hooks: + - id: cpplint + exclude: '^(third_party/)|(cereal/)|(body/)|(rednose/)|(rednose_repo/)|(opendbc/)|(panda/)|(generated/)' + args: + - --quiet + - --counting=total + - --linelength=240 + # https://google.github.io/styleguide/cppguide.html + # relevant rules are whitelisted, see all options with: cpplint --filter= + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body - repo: local hooks: - id: test_translations @@ -66,5 +78,5 @@ repos: - id: poetry-check - id: poetry-lock name: validate poetry lock - args: + args: - --check diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index aedc4ac371..d17f6593e4 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -498,7 +498,8 @@ void Localizer::reset_kalman(double current_time, VectorXd init_orient, VectorXd init_P.block(STATE_ECEF_POS_ERR_START, STATE_ECEF_POS_ERR_START).diagonal() = init_pos_R.diagonal(); init_P.block(STATE_ECEF_ORIENTATION_ERR_START, STATE_ECEF_ORIENTATION_ERR_START).diagonal() = reset_orientation_P.diagonal(); init_P.block(STATE_ECEF_VELOCITY_ERR_START, STATE_ECEF_VELOCITY_ERR_START).diagonal() = init_vel_R.diagonal(); - init_P.block(STATE_ANGULAR_VELOCITY_ERR_START, STATE_ANGULAR_VELOCITY_ERR_START, non_ecef_state_err_len, non_ecef_state_err_len).diagonal() = current_P.block(STATE_ANGULAR_VELOCITY_ERR_START, STATE_ANGULAR_VELOCITY_ERR_START, non_ecef_state_err_len, non_ecef_state_err_len).diagonal(); + init_P.block(STATE_ANGULAR_VELOCITY_ERR_START, STATE_ANGULAR_VELOCITY_ERR_START, non_ecef_state_err_len, non_ecef_state_err_len).diagonal() = current_P.block(STATE_ANGULAR_VELOCITY_ERR_START, + STATE_ANGULAR_VELOCITY_ERR_START, non_ecef_state_err_len, non_ecef_state_err_len).diagonal(); this->reset_kalman(current_time, current_x, init_P); } diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 94a673dd71..3dd5a52d86 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -36,7 +36,8 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { tr("openpilot Longitudinal Control (Alpha)"), QString("%1

%2") .arg(tr("WARNING: openpilot longitudinal control is in alpha for this car and will disable Automatic Emergency Braking (AEB).")) - .arg(tr("On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha.")), + .arg(tr("On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. " + "Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha.")), "../assets/offroad/icon_speed_limit.png", }, { @@ -88,7 +89,8 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { std::vector longi_button_texts{tr("Aggressive"), tr("Standard"), tr("Relaxed")}; long_personality_setting = new ButtonParamControl("LongitudinalPersonality", tr("Driving Personality"), - tr("Standard is recommended. In aggressive mode, openpilot will follow lead cars closer and be more aggressive with the gas and brake. In relaxed mode openpilot will stay further away from lead cars."), + tr("Standard is recommended. In aggressive mode, openpilot will follow lead cars closer and be more aggressive with the gas and brake. " + "In relaxed mode openpilot will stay further away from lead cars."), "../assets/offroad/icon_speed_limit.png", longi_button_texts); for (auto &[param, title, desc, icon] : toggle_defs) { @@ -137,11 +139,12 @@ void TogglesPanel::updateToggles() { .arg(tr("openpilot defaults to driving in chill mode. Experimental mode enables alpha-level features that aren't ready for chill mode. Experimental features are listed below:")) .arg(tr("End-to-End Longitudinal Control" )) .arg(tr("Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would, including stopping for red lights and stop signs. " - "Since the driving model decides the speed to drive, the set speed will only act as an upper bound. This is an alpha quality feature; mistakes should be expected.")) + "Since the driving model decides the speed to drive, the set speed will only act as an upper bound. This is an alpha quality feature; " + "mistakes should be expected.")) .arg(tr("Navigate on openpilot")) - .arg(tr("When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right appropriately at forks/exits. " - "Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around exits and forks. " - "These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc.")) + .arg(tr("When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right " + "appropriately at forks/exits. Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around " + "exits and forks. These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc.")) .arg(tr("New Driving Visualization")) .arg(tr("The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner. " "When a navigation destination is set and the driving model is using it as input, the driving path on the map will turn green.")); diff --git a/selfdrive/ui/qt/widgets/ssh_keys.cc b/selfdrive/ui/qt/widgets/ssh_keys.cc index 1097a89268..26743952de 100644 --- a/selfdrive/ui/qt/widgets/ssh_keys.cc +++ b/selfdrive/ui/qt/widgets/ssh_keys.cc @@ -4,7 +4,10 @@ #include "selfdrive/ui/qt/api.h" #include "selfdrive/ui/qt/widgets/input.h" -SshControl::SshControl() : ButtonControl(tr("SSH Keys"), "", tr("Warning: This grants SSH access to all public keys in your GitHub settings. Never enter a GitHub username other than your own. A comma employee will NEVER ask you to add their GitHub username.")) { +SshControl::SshControl() : + ButtonControl(tr("SSH Keys"), "", tr("Warning: This grants SSH access to all public keys in your GitHub settings. Never enter a GitHub username " + "other than your own. A comma employee will NEVER ask you to add their GitHub username.")) { + QObject::connect(this, &ButtonControl::clicked, [=]() { if (text() == tr("ADD")) { QString username = InputDialog::getText(tr("Enter your GitHub username"), this); diff --git a/selfdrive/ui/translations/main_de.ts b/selfdrive/ui/translations/main_de.ts index a1b8faa2e3..17871ce58f 100644 --- a/selfdrive/ui/translations/main_de.ts +++ b/selfdrive/ui/translations/main_de.ts @@ -1072,10 +1072,6 @@ This may take up to a minute. Experimental mode is currently unavailable on this car since the car's stock ACC is used for longitudinal control. Der experimentelle Modus ist momentan für dieses Auto nicht verfügbar da es den eingebauten adaptiven Tempomaten des Autos benutzt. - - openpilot longitudinal control may come in a future update. - - openpilot Longitudinal Control (Alpha) @@ -1084,10 +1080,6 @@ This may take up to a minute. WARNING: openpilot longitudinal control is in alpha for this car and will disable Automatic Emergency Braking (AEB). - - On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha. - - Aggressive @@ -1104,12 +1096,16 @@ This may take up to a minute. Driving Personality + + On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha. + + Standard is recommended. In aggressive mode, openpilot will follow lead cars closer and be more aggressive with the gas and brake. In relaxed mode openpilot will stay further away from lead cars. - An alpha version of openpilot longitudinal control can be tested, along with Experimental mode, on non-release branches. + End-to-End Longitudinal Control @@ -1117,19 +1113,23 @@ This may take up to a minute. - Enable the openpilot longitudinal control (alpha) toggle to allow Experimental mode. + When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right appropriately at forks/exits. Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around exits and forks. These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc. - End-to-End Longitudinal Control + The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner. When a navigation destination is set and the driving model is using it as input, the driving path on the map will turn green. - When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right appropriately at forks/exits. Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around exits and forks. These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc. + openpilot longitudinal control may come in a future update. - The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner. When a navigation destination is set and the driving model is using it as input, the driving path on the map will turn green. + An alpha version of openpilot longitudinal control can be tested, along with Experimental mode, on non-release branches. + + + + Enable the openpilot longitudinal control (alpha) toggle to allow Experimental mode.
diff --git a/selfdrive/ui/translations/main_ja.ts b/selfdrive/ui/translations/main_ja.ts index e766204660..799aa84a2e 100644 --- a/selfdrive/ui/translations/main_ja.ts +++ b/selfdrive/ui/translations/main_ja.ts @@ -1064,10 +1064,6 @@ This may take up to a minute. Experimental mode is currently unavailable on this car since the car's stock ACC is used for longitudinal control. この車のACCがアクセル制御を行うため実験モードを利用することができません。 - - openpilot longitudinal control may come in a future update. - - openpilot Longitudinal Control (Alpha) @@ -1076,10 +1072,6 @@ This may take up to a minute. WARNING: openpilot longitudinal control is in alpha for this car and will disable Automatic Emergency Braking (AEB). - - On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha. - - Aggressive @@ -1096,12 +1088,16 @@ This may take up to a minute. Driving Personality + + On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha. + + Standard is recommended. In aggressive mode, openpilot will follow lead cars closer and be more aggressive with the gas and brake. In relaxed mode openpilot will stay further away from lead cars. - An alpha version of openpilot longitudinal control can be tested, along with Experimental mode, on non-release branches. + End-to-End Longitudinal Control @@ -1109,19 +1105,23 @@ This may take up to a minute. - Enable the openpilot longitudinal control (alpha) toggle to allow Experimental mode. + When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right appropriately at forks/exits. Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around exits and forks. These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc. - End-to-End Longitudinal Control + The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner. When a navigation destination is set and the driving model is using it as input, the driving path on the map will turn green. - When navigation has a destination, openpilot will input the map information into the model. This provides useful context for the model and allows openpilot to keep left or right appropriately at forks/exits. Lane change behavior is unchanged and still activated by the driver. This is an alpha quality feature; mistakes should be expected, particularly around exits and forks. These mistakes can include unintended laneline crossings, late exit taking, driving towards dividing barriers in the gore areas, etc. + openpilot longitudinal control may come in a future update. - The driving visualization will transition to the road-facing wide-angle camera at low speeds to better show some turns. The Experimental mode logo will also be shown in the top right corner. When a navigation destination is set and the driving model is using it as input, the driving path on the map will turn green. + An alpha version of openpilot longitudinal control can be tested, along with Experimental mode, on non-release branches. + + + + Enable the openpilot longitudinal control (alpha) toggle to allow Experimental mode. diff --git a/selfdrive/ui/translations/main_tr.ts b/selfdrive/ui/translations/main_tr.ts index ad882f5786..906884f640 100644 --- a/selfdrive/ui/translations/main_tr.ts +++ b/selfdrive/ui/translations/main_tr.ts @@ -1048,10 +1048,6 @@ This may take up to a minute. WARNING: openpilot longitudinal control is in alpha for this car and will disable Automatic Emergency Braking (AEB). - - On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha. - - Experimental Mode @@ -1076,6 +1072,10 @@ This may take up to a minute. Driving Personality + + On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha. + + Standard is recommended. In aggressive mode, openpilot will follow lead cars closer and be more aggressive with the gas and brake. In relaxed mode openpilot will stay further away from lead cars. diff --git a/system/camerad/cameras/camera_qcom2.cc b/system/camerad/cameras/camera_qcom2.cc index 6f4a134438..1480342ee3 100644 --- a/system/camerad/cameras/camera_qcom2.cc +++ b/system/camerad/cameras/camera_qcom2.cc @@ -725,7 +725,8 @@ void CameraState::camera_open(MultiCameraState *multi_cam_state_, int camera_num LOGD("acquire csiphy dev"); // config ISP - alloc_w_mmu_hdl(multi_cam_state->video0_fd, 984480, (uint32_t*)&buf0_handle, 0x20, CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE, multi_cam_state->device_iommu, multi_cam_state->cdm_iommu); + alloc_w_mmu_hdl(multi_cam_state->video0_fd, 984480, (uint32_t*)&buf0_handle, 0x20, CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | + CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE, multi_cam_state->device_iommu, multi_cam_state->cdm_iommu); config_isp(0, 0, 1, buf0_handle, 0); // config csiphy @@ -1273,9 +1274,9 @@ void cameras_run(MultiCameraState *s) { if (ret == 0) { if (ev.type == V4L_EVENT_CAM_REQ_MGR_EVENT) { struct cam_req_mgr_message *event_data = (struct cam_req_mgr_message *)ev.u.data; - // LOGD("v4l2 event: sess_hdl 0x%X, link_hdl 0x%X, frame_id %d, req_id %lld, timestamp 0x%llx, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp, event_data->u.frame_msg.sof_status); if (env_debug_frames) { - printf("sess_hdl 0x%6X, link_hdl 0x%6X, frame_id %lu, req_id %lu, timestamp %.2f ms, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp/1e6, event_data->u.frame_msg.sof_status); + printf("sess_hdl 0x%6X, link_hdl 0x%6X, frame_id %lu, req_id %lu, timestamp %.2f ms, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, + event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp/1e6, event_data->u.frame_msg.sof_status); } if (event_data->session_hdl == s->road_cam.session_handle) { From 5765c1d978c5890513e55398490447590d3b1d3e Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 23 Aug 2023 05:00:01 +0800 Subject: [PATCH 070/159] ui/settings: Don't apply styles to more elements than needed. (#29463) --- selfdrive/ui/qt/offroad/settings.cc | 8 ++++---- selfdrive/ui/qt/widgets/controls.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 3dd5a52d86..05aef8364c 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -348,10 +348,6 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { QVBoxLayout *sidebar_layout = new QVBoxLayout(sidebar_widget); sidebar_layout->setMargin(0); panel_widget = new QStackedWidget(); - panel_widget->setStyleSheet(R"( - border-radius: 30px; - background-color: #292929; - )"); // close button QPushButton *close_btn = new QPushButton(tr("×")); @@ -440,5 +436,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { SettingsWindow { background-color: black; } + QStackedWidget, ScrollView { + background-color: #292929; + border-radius: 30px; + } )"); } diff --git a/selfdrive/ui/qt/widgets/controls.cc b/selfdrive/ui/qt/widgets/controls.cc index e440bc6441..87304a4585 100644 --- a/selfdrive/ui/qt/widgets/controls.cc +++ b/selfdrive/ui/qt/widgets/controls.cc @@ -23,7 +23,7 @@ AbstractControl::AbstractControl(const QString &title, const QString &desc, cons // title title_label = new QPushButton(title); title_label->setFixedHeight(120); - title_label->setStyleSheet("font-size: 50px; font-weight: 400; text-align: left"); + title_label->setStyleSheet("font-size: 50px; font-weight: 400; text-align: left; border: none;"); hlayout->addWidget(title_label, 1); // value next to control button From 6a5725bb38007d61602c7c495c275d234cd29fac Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 14:03:15 -0700 Subject: [PATCH 071/159] sensord: update cpu usage after removing light sensor --- selfdrive/test/test_onroad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index 0fa9d9c711..c0cb49c0db 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -34,7 +34,7 @@ PROCS = { "selfdrive.controls.plannerd": 16.5, "./_ui": 18.0, "selfdrive.locationd.paramsd": 9.0, - "./_sensord": 12.0, + "./_sensord": 7.0, "selfdrive.controls.radard": 4.5, "./_modeld": 4.48, "./_dmonitoringmodeld": 5.0, From 65ad8fd8e7fa74c7eb7e75bba3046e4b9a8c68fc Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 14:03:27 -0700 Subject: [PATCH 072/159] bump cereal (#29532) --- cereal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cereal b/cereal index 3cac040c5b..e7c42fd11c 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 3cac040c5b219402cb9b234d53c78a6007298534 +Subproject commit e7c42fd11cc71f16ac762e6aed3409ce4c644b42 From 55c156dfb25d4cc594524d197a588a929a99f01f Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 23 Aug 2023 05:09:03 +0800 Subject: [PATCH 073/159] soundd: set volume on changes (#29389) * set volume on change * async set volumn * Revert "async set volumn" This reverts commit 7bc88c498353fff158b0de3d1923aa2c0f004a37. --- selfdrive/ui/soundd/sound.cc | 5 ++++- selfdrive/ui/soundd/sound.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/soundd/sound.cc b/selfdrive/ui/soundd/sound.cc index 8d5b2b96b0..ae06e3e903 100644 --- a/selfdrive/ui/soundd/sound.cc +++ b/selfdrive/ui/soundd/sound.cc @@ -36,7 +36,10 @@ void Sound::update() { if (sm.updated("microphone")) { float volume = util::map_val(sm["microphone"].getMicrophone().getFilteredSoundPressureWeightedDb(), 30.f, 60.f, 0.f, 1.f); volume = QAudio::convertVolume(volume, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale); - Hardware::set_volume(volume); + // set volume on changes + if (std::exchange(current_volume, std::nearbyint(volume * 10)) != current_volume) { + Hardware::set_volume(volume); + } } setAlert(Alert::get(sm, 0)); diff --git a/selfdrive/ui/soundd/sound.h b/selfdrive/ui/soundd/sound.h index da9814c543..9cabd1c6bd 100644 --- a/selfdrive/ui/soundd/sound.h +++ b/selfdrive/ui/soundd/sound.h @@ -30,4 +30,5 @@ protected: SubMaster sm; Alert current_alert = {}; QMap> sounds; + int current_volume = -1; }; From fda3106c28af236e8b3dc78bfdca7a1365904d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Tue, 22 Aug 2023 14:12:51 -0700 Subject: [PATCH 074/159] Revert laikad llk (#29535) * Revert "bump laika (#29522)" This reverts commit 3523bef732316b534de66dcb9e7d29e53e37e99f. * Revert "Locationd: switch to laikad (#29278)" This reverts commit fd3b8a3d7511ad3d7c5aa0b82a1e2c28505e5a7f. --- laika_repo | 2 +- selfdrive/locationd/laikad.py | 59 +++++--- selfdrive/locationd/liblocationd.cc | 2 +- selfdrive/locationd/locationd.cc | 129 +++++++++++++++--- selfdrive/locationd/locationd.h | 13 +- selfdrive/locationd/test/test_laikad.py | 4 +- selfdrive/locationd/test/test_locationd.py | 29 ++-- .../test/process_replay/process_replay.py | 12 +- selfdrive/test/process_replay/ref_commit | 2 +- 9 files changed, 195 insertions(+), 57 deletions(-) diff --git a/laika_repo b/laika_repo index 989b6a8505..65901a1e6c 160000 --- a/laika_repo +++ b/laika_repo @@ -1 +1 @@ -Subproject commit 989b6a8505441a550c94f60b4378be296ea3fe92 +Subproject commit 65901a1e6c7c7940d8c97027d3edaca7d0132253 diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index 6c9c199db1..2073813363 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -18,8 +18,7 @@ from laika.downloader import DownloadFailed from laika.ephemeris import EphemerisType, GPSEphemeris, GLONASSEphemeris, ephemeris_structs, parse_qcom_ephem from laika.gps_time import GPSTime from laika.helpers import ConstellationId, get_sv_id -from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox -from laika.raw_gnss import gps_time_from_qcom_report, get_measurements_from_qcom_reports +from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox, read_raw_qcom from laika.opt import calc_pos_fix, get_posfix_sympy_fun, calc_vel_fix, get_velfix_sympy_func from openpilot.selfdrive.locationd.models.constants import GENERATED_DIR, ObservationKind from openpilot.selfdrive.locationd.models.gnss_kf import GNSSKalman @@ -103,10 +102,9 @@ class Laikad: self.use_qcom = use_qcom self.first_log_time = None self.ttff = -1 - self.measurement_lag = 0.630 if self.use_qcom else 0.095 # qcom specific stuff - self.qcom_reports_received = 4 + self.qcom_reports_received = 1 self.qcom_reports = [] def load_cache(self): @@ -163,31 +161,47 @@ class Laikad: def get_lsq_fix(self, t, measurements): if self.last_fix_t is None or abs(self.last_fix_t - t) > 0: min_measurements = 5 if any(p.constellation_id == ConstellationId.GLONASS for p in measurements) else 4 - position_solution, pr_residuals, pos_std = calc_pos_fix(measurements, self.posfix_functions, min_measurements=min_measurements) if len(position_solution) < 3: return None position_estimate = position_solution[:3] - position_std = pos_std[:3] + + position_std_residual = np.median(np.abs(pr_residuals)) + position_std = np.median(np.abs(pos_std))/10 + position_std = max(position_std_residual, position_std) * np.ones(3) velocity_solution, prr_residuals, vel_std = calc_vel_fix(measurements, position_estimate, self.velfix_function, min_measurements=min_measurements) if len(velocity_solution) < 3: return None velocity_estimate = velocity_solution[:3] - velocity_std = vel_std[:3] + + velocity_std_residual = np.median(np.abs(prr_residuals)) + velocity_std = np.median(np.abs(vel_std))/10 + velocity_std = max(velocity_std, velocity_std_residual) * np.ones(3) return position_estimate, position_std, velocity_estimate, velocity_std + def gps_time_from_qcom_report(self, gnss_msg): + report = gnss_msg.drMeasurementReport + if report.source == log.QcomGnss.MeasurementSource.gps: + report_time = GPSTime(report.gpsWeek, report.gpsMilliseconds / 1000.0) + elif report.source == log.QcomGnss.MeasurementSource.sbas: + report_time = GPSTime(report.gpsWeek, report.gpsMilliseconds / 1000.0) + elif report.source == log.QcomGnss.MeasurementSource.glonass: + report_time = GPSTime.from_glonass(report.glonassYear, + report.glonassDay, + report.glonassMilliseconds / 1000.0) + else: + raise NotImplementedError(f'Unknownconstellation {report.source}') + return report_time + def is_good_report(self, gnss_msg): - if gnss_msg.which() in ['drMeasurementReport', 'measurementReport'] and self.use_qcom: + if gnss_msg.which() == 'drMeasurementReport' and self.use_qcom: # TODO: Understand and use remaining unknown constellations try: - if gnss_msg.which() == 'drMeasurementReport': - constellation_id = ConstellationId.from_qcom_source(gnss_msg.drMeasurementReport.source) - else: - constellation_id = ConstellationId.from_qcom_source(gnss_msg.measurementReport.source) + constellation_id = ConstellationId.from_qcom_source(gnss_msg.drMeasurementReport.source) good_constellation = constellation_id in [ConstellationId.GPS, ConstellationId.SBAS, ConstellationId.GLONASS] - report_time = gps_time_from_qcom_report(gnss_msg) + report_time = self.gps_time_from_qcom_report(gnss_msg) except NotImplementedError: return False # Garbage timestamps with week > 32767 are sometimes sent by module. @@ -202,20 +216,21 @@ class Laikad: def read_report(self, gnss_msg): if self.use_qcom: # QCOM reports are per constellation, so we need to aggregate them - # Additionally, the pseudoranges are broken in the measurementReports - # and the doppler filteredSpeed is broken in the drMeasurementReports - report_time = gps_time_from_qcom_report(gnss_msg) + report = gnss_msg.drMeasurementReport + report_time = self.gps_time_from_qcom_report(gnss_msg) + if report_time - self.last_report_time > 0: self.qcom_reports_received = max(1, len(self.qcom_reports)) - self.qcom_reports = [gnss_msg] + self.qcom_reports = [report] else: - self.qcom_reports.append(gnss_msg) + self.qcom_reports.append(report) self.last_report_time = report_time + new_meas = [] if len(self.qcom_reports) == self.qcom_reports_received: - new_meas = get_measurements_from_qcom_reports(self.qcom_reports) - else: - new_meas = [] + for report in self.qcom_reports: + new_meas.extend(read_raw_qcom(report)) + else: report = gnss_msg.measurementReport self.last_report_time = GPSTime(report.gpsWeek, report.rcvTow) @@ -285,7 +300,7 @@ class Laikad: def process_gnss_msg(self, gnss_msg, gnss_mono_time: int, block=False): out_msg = messaging.new_message("gnssMeasurements") t = gnss_mono_time * 1e-9 - msg_dict: Dict[str, Any] = {"measTime": gnss_mono_time - int(1e9 * self.measurement_lag)} + msg_dict: Dict[str, Any] = {"measTime": gnss_mono_time} if self.first_log_time is None: self.first_log_time = 1e-9 * gnss_mono_time if self.is_ephemeris(gnss_msg): diff --git a/selfdrive/locationd/liblocationd.cc b/selfdrive/locationd/liblocationd.cc index 73ed1b0a56..6f298deab6 100755 --- a/selfdrive/locationd/liblocationd.cc +++ b/selfdrive/locationd/liblocationd.cc @@ -4,7 +4,7 @@ extern "C" { typedef Localizer* Localizer_t; Localizer *localizer_init(bool has_ublox) { - return new Localizer(); + return new Localizer(has_ublox ? LocalizerGnssSource::UBLOX : LocalizerGnssSource::QCOM); } void localizer_get_message_bytes(Localizer *localizer, bool inputsOK, bool sensorsOK, bool gpsOK, bool msgValid, diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index d17f6593e4..68f16a572e 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -13,6 +13,7 @@ const double ACCEL_SANITY_CHECK = 100.0; // m/s^2 const double ROTATION_SANITY_CHECK = 10.0; // rad/s const double TRANS_SANITY_CHECK = 200.0; // m/s const double CALIB_RPY_SANITY_CHECK = 0.5; // rad (+- 30 deg) +const double ALTITUDE_SANITY_CHECK = 10000; // m const double MIN_STD_SANITY_CHECK = 1e-5; // m or rad const double VALID_TIME_SINCE_RESET = 1.0; // s const double VALID_POS_STD = 50.0; // m @@ -22,11 +23,15 @@ const double INPUT_INVALID_THRESHOLD = 5.0; // same as reset tracker const double DECAY = 0.99995; // same as reset tracker const double MAX_FILTER_REWIND_TIME = 0.8; // s +// TODO: GPS sensor time offsets are empirically calculated +// They should be replaced with synced time from a real clock +const double GPS_QUECTEL_SENSOR_TIME_OFFSET = 0.630; // s +const double GPS_UBLOX_SENSOR_TIME_OFFSET = 0.095; // s const float GPS_POS_STD_THRESHOLD = 50.0; const float GPS_VEL_STD_THRESHOLD = 5.0; const float GPS_POS_ERROR_RESET_THRESHOLD = 300.0; -const float GPS_POS_STD_RESET_THRESHOLD = 10.0; -const float GPS_VEL_STD_RESET_THRESHOLD = 1.0; +const float GPS_POS_STD_RESET_THRESHOLD = 2.0; +const float GPS_VEL_STD_RESET_THRESHOLD = 0.5; const float GPS_ORIENTATION_ERROR_RESET_THRESHOLD = 1.0; const int GPS_ORIENTATION_ERROR_RESET_CNT = 3; @@ -65,7 +70,7 @@ static VectorXd rotate_std(const MatrixXdr& rot_matrix, const VectorXd& std_in) return rotate_cov(rot_matrix, std_in.array().square().matrix().asDiagonal()).diagonal().array().sqrt(); } -Localizer::Localizer() { +Localizer::Localizer(LocalizerGnssSource gnss_source) { this->kf = std::make_unique(); this->reset_kalman(); @@ -79,6 +84,7 @@ Localizer::Localizer() { VectorXd ecef_pos = this->kf->get_x().segment(STATE_ECEF_POS_START); this->converter = std::make_unique((ECEF) { .x = ecef_pos[0], .y = ecef_pos[1], .z = ecef_pos[2] }); + this->configure_gnss_source(gnss_source); } void Localizer::build_live_location(cereal::LiveLocationKalman::Builder& fix) { @@ -294,6 +300,64 @@ void Localizer::input_fake_gps_observations(double current_time) { this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); } +void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset) { + // ignore the message if the fix is invalid + bool gps_invalid_flag = (log.getFlags() % 2 == 0); + bool gps_unreasonable = (Vector2d(log.getAccuracy(), log.getVerticalAccuracy()).norm() >= SANE_GPS_UNCERTAINTY); + bool gps_accuracy_insane = ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0)); + bool gps_lat_lng_alt_insane = ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK)); + bool gps_vel_insane = (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK); + + if (gps_invalid_flag || gps_unreasonable || gps_accuracy_insane || gps_lat_lng_alt_insane || gps_vel_insane) { + //this->gps_valid = false; + this->determine_gps_mode(current_time); + return; + } + + double sensor_time = current_time - sensor_time_offset; + + // Process message + //this->gps_valid = true; + this->gps_mode = true; + Geodetic geodetic = { log.getLatitude(), log.getLongitude(), log.getAltitude() }; + this->converter = std::make_unique(geodetic); + + VectorXd ecef_pos = this->converter->ned2ecef({ 0.0, 0.0, 0.0 }).to_vector(); + VectorXd ecef_vel = this->converter->ned2ecef({ log.getVNED()[0], log.getVNED()[1], log.getVNED()[2] }).to_vector() - ecef_pos; + float ecef_pos_std = std::sqrt(this->gps_variance_factor * std::pow(log.getAccuracy(), 2) + this->gps_vertical_variance_factor * std::pow(log.getVerticalAccuracy(), 2)); + MatrixXdr ecef_pos_R = Vector3d::Constant(std::pow(this->gps_std_factor * ecef_pos_std, 2)).asDiagonal(); + MatrixXdr ecef_vel_R = Vector3d::Constant(std::pow(this->gps_std_factor * log.getSpeedAccuracy(), 2)).asDiagonal(); + + this->unix_timestamp_millis = log.getUnixTimestampMillis(); + double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); + + VectorXd orientation_ecef = quat2euler(vector2quat(this->kf->get_x().segment(STATE_ECEF_ORIENTATION_START))); + VectorXd orientation_ned = ned_euler_from_ecef({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ecef); + VectorXd orientation_ned_gps = Vector3d(0.0, 0.0, DEG2RAD(log.getBearingDeg())); + VectorXd orientation_error = (orientation_ned - orientation_ned_gps).array() - M_PI; + for (int i = 0; i < orientation_error.size(); i++) { + orientation_error(i) = std::fmod(orientation_error(i), 2.0 * M_PI); + if (orientation_error(i) < 0.0) { + orientation_error(i) += 2.0 * M_PI; + } + orientation_error(i) -= M_PI; + } + VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); + + if (ecef_vel.norm() > 5.0 && orientation_error.norm() > 1.0) { + LOGE("Locationd vs ubloxLocation orientation difference too large, kalman reset"); + this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); + this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_ORIENTATION_FROM_GPS, { initial_pose_ecef_quat }); + } else if (gps_est_error > 100.0) { + LOGE("Locationd vs ubloxLocation position difference too large, kalman reset"); + this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); + } + + this->last_gps_msg = sensor_time; + this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_POS, { ecef_pos }, { ecef_pos_R }); + this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); +} + void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log) { if(!log.getPositionECEF().getValid() || !log.getVelocityECEF().getValid()) { @@ -302,22 +366,21 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: } double sensor_time = log.getMeasTime() * 1e-9; + sensor_time -= this->gps_time_offset; auto ecef_pos_v = log.getPositionECEF().getValue(); VectorXd ecef_pos = Vector3d(ecef_pos_v[0], ecef_pos_v[1], ecef_pos_v[2]); - auto ecef_pos_std = log.getPositionECEF().getStd(); - VectorXd ecef_pos_var = Vector3d(ecef_pos_std[0], ecef_pos_std[1], ecef_pos_std[2]).array().square().matrix(); - double ecef_pos_std_norm = std::sqrt(ecef_pos_var.sum()); - MatrixXdr ecef_pos_R = ecef_pos_var.asDiagonal(); + // indexed at 0 cause all std values are the same MAE + auto ecef_pos_std = log.getPositionECEF().getStd()[0]; + MatrixXdr ecef_pos_R = Vector3d::Constant(pow(this->gps_std_factor*ecef_pos_std, 2)).asDiagonal(); auto ecef_vel_v = log.getVelocityECEF().getValue(); VectorXd ecef_vel = Vector3d(ecef_vel_v[0], ecef_vel_v[1], ecef_vel_v[2]); - auto ecef_vel_std = log.getVelocityECEF().getStd(); - VectorXd ecef_vel_var = Vector3d(ecef_vel_std[0], ecef_vel_std[1], ecef_vel_std[2]).array().square().matrix(); - double ecef_vel_std_norm = std::sqrt(ecef_vel_var.sum()); - MatrixXdr ecef_vel_R = ecef_vel_var.asDiagonal(); + // indexed at 0 cause all std values are the same MAE + auto ecef_vel_std = log.getVelocityECEF().getStd()[0]; + MatrixXdr ecef_vel_R = Vector3d::Constant(pow(this->gps_std_factor*ecef_vel_std, 2)).asDiagonal(); double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); @@ -340,13 +403,13 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: } VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); - if (ecef_pos_std_norm > GPS_POS_STD_THRESHOLD || ecef_vel_std_norm > GPS_VEL_STD_THRESHOLD) { + if (ecef_pos_std > GPS_POS_STD_THRESHOLD || ecef_vel_std > GPS_VEL_STD_THRESHOLD) { this->determine_gps_mode(current_time); return; } // prevent jumping gnss measurements (covered lots, standstill...) - bool orientation_reset = ecef_vel_std_norm < GPS_VEL_STD_RESET_THRESHOLD; + bool orientation_reset = ecef_vel_std < GPS_VEL_STD_RESET_THRESHOLD; orientation_reset &= orientation_error.norm() > GPS_ORIENTATION_ERROR_RESET_THRESHOLD; orientation_reset &= !this->standstill; if (orientation_reset) { @@ -356,7 +419,7 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: this->orientation_reset_count = 0; } - if ((gps_est_error > GPS_POS_ERROR_RESET_THRESHOLD && ecef_pos_std_norm < GPS_POS_STD_RESET_THRESHOLD) || this->last_gps_msg == 0) { + if ((gps_est_error > GPS_POS_ERROR_RESET_THRESHOLD && ecef_pos_std < GPS_POS_STD_RESET_THRESHOLD) || this->last_gps_msg == 0) { // always reset on first gps message and if the location is off but the accuracy is high LOGE("Locationd vs gnssMeasurement position difference too large, kalman reset"); this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); @@ -526,8 +589,12 @@ void Localizer::handle_msg(const cereal::Event::Reader& log) { this->handle_sensor(t, log.getAccelerometer()); } else if (log.isGyroscope()) { this->handle_sensor(t, log.getGyroscope()); - } else if (log.isGnssMeasurements()) { - this->handle_gnss(t, log.getGnssMeasurements()); + } else if (log.isGpsLocation()) { + this->handle_gps(t, log.getGpsLocation(), GPS_QUECTEL_SENSOR_TIME_OFFSET); + } else if (log.isGpsLocationExternal()) { + this->handle_gps(t, log.getGpsLocationExternal(), GPS_UBLOX_SENSOR_TIME_OFFSET); + //} else if (log.isGnssMeasurements()) { + // this->handle_gnss(t, log.getGnssMeasurements()); } else if (log.isCarState()) { this->handle_car_state(t, log.getCarState()); } else if (log.isCameraOdometry()) { @@ -589,12 +656,38 @@ void Localizer::determine_gps_mode(double current_time) { } } +void Localizer::configure_gnss_source(LocalizerGnssSource source) { + this->gnss_source = source; + if (source == LocalizerGnssSource::UBLOX) { + this->gps_std_factor = 10.0; + this->gps_variance_factor = 1.0; + this->gps_vertical_variance_factor = 1.0; + this->gps_time_offset = GPS_UBLOX_SENSOR_TIME_OFFSET; + } else { + this->gps_std_factor = 2.0; + this->gps_variance_factor = 0.0; + this->gps_vertical_variance_factor = 3.0; + this->gps_time_offset = GPS_QUECTEL_SENSOR_TIME_OFFSET; + } +} + int Localizer::locationd_thread() { - const std::initializer_list service_list = {"gnssMeasurements", "cameraOdometry", "liveCalibration", + LocalizerGnssSource source; + const char* gps_location_socket; + if (Params().getBool("UbloxAvailable")) { + source = LocalizerGnssSource::UBLOX; + gps_location_socket = "gpsLocationExternal"; + } else { + source = LocalizerGnssSource::QCOM; + gps_location_socket = "gpsLocation"; + } + + this->configure_gnss_source(source); + const std::initializer_list service_list = {gps_location_socket, "cameraOdometry", "liveCalibration", "carState", "carParams", "accelerometer", "gyroscope"}; // TODO: remove carParams once we're always sending at 100Hz - SubMaster sm(service_list, {}, nullptr, {"gnssMeasurements", "carParams"}); + SubMaster sm(service_list, {}, nullptr, {gps_location_socket, "carParams"}); PubMaster pm({"liveLocationKalman"}); uint64_t cnt = 0; diff --git a/selfdrive/locationd/locationd.h b/selfdrive/locationd/locationd.h index cfa2d0a667..e8f2f04a2c 100755 --- a/selfdrive/locationd/locationd.h +++ b/selfdrive/locationd/locationd.h @@ -21,10 +21,13 @@ #define POSENET_STD_HIST_HALF 20 +enum LocalizerGnssSource { + UBLOX, QCOM +}; class Localizer { public: - Localizer(); + Localizer(LocalizerGnssSource gnss_source = LocalizerGnssSource::UBLOX); int locationd_thread(); @@ -52,6 +55,7 @@ public: void handle_msg_bytes(const char *data, const size_t size); void handle_msg(const cereal::Event::Reader& log); void handle_sensor(double current_time, const cereal::SensorEventData::Reader& log); + void handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset); void handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log); void handle_car_state(double current_time, const cereal::CarState::Reader& log); void handle_cam_odo(double current_time, const cereal::CameraOdometry::Reader& log); @@ -80,8 +84,15 @@ private: double first_valid_log_time = NAN; double ttff = NAN; double last_gps_msg = 0; + LocalizerGnssSource gnss_source; bool observation_timings_invalid = false; std::map observation_values_invalid; bool standstill = true; int32_t orientation_reset_count = 0; + float gps_std_factor; + float gps_variance_factor; + float gps_vertical_variance_factor; + double gps_time_offset; + + void configure_gnss_source(LocalizerGnssSource source); }; diff --git a/selfdrive/locationd/test/test_laikad.py b/selfdrive/locationd/test/test_laikad.py index a8d69502cf..58c650e26c 100755 --- a/selfdrive/locationd/test/test_laikad.py +++ b/selfdrive/locationd/test/test_laikad.py @@ -177,8 +177,8 @@ class TestLaikad(unittest.TestCase): laikad = Laikad(auto_update=True, valid_ephem_types=EphemerisType.NAV, use_qcom=use_qcom) # Disable fetch_orbits to test NAV only correct_msgs = verify_messages(logs, laikad) - correct_msgs_expected = 55 if use_qcom else 560 - valid_fix_expected = 55 if use_qcom else 560 + correct_msgs_expected = 56 if use_qcom else 560 + valid_fix_expected = 56 if use_qcom else 560 self.assertEqual(correct_msgs_expected, len(correct_msgs)) self.assertEqual(valid_fix_expected, len([m for m in correct_msgs if m.gnssMeasurements.positionECEF.valid])) diff --git a/selfdrive/locationd/test/test_locationd.py b/selfdrive/locationd/test/test_locationd.py index 1fb36bf2fa..6c6ac33431 100755 --- a/selfdrive/locationd/test/test_locationd.py +++ b/selfdrive/locationd/test/test_locationd.py @@ -14,7 +14,7 @@ from openpilot.selfdrive.manager.process_config import managed_processes class TestLocationdProc(unittest.TestCase): - LLD_MSGS = ['gnssMeasurements', 'cameraOdometry', 'carState', 'liveCalibration', + LLD_MSGS = ['gpsLocationExternal', 'cameraOdometry', 'carState', 'liveCalibration', 'accelerometer', 'gyroscope', 'magnetometer'] def setUp(self): @@ -35,14 +35,25 @@ class TestLocationdProc(unittest.TestCase): msg = messaging.new_message(name) except capnp.lib.capnp.KjException: msg = messaging.new_message(name, 0) - if name == "gnssMeasurements": - msg.gnssMeasurements.measTime = t - msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] - msg.gnssMeasurements.positionECEF.std = [0,0,0] - msg.gnssMeasurements.positionECEF.valid = True - msg.gnssMeasurements.velocityECEF.value = [] - msg.gnssMeasurements.velocityECEF.std = [0,0,0] - msg.gnssMeasurements.velocityECEF.valid = True + + if name == "gpsLocationExternal": + msg.gpsLocationExternal.flags = 1 + msg.gpsLocationExternal.verticalAccuracy = 1.0 + msg.gpsLocationExternal.speedAccuracy = 1.0 + msg.gpsLocationExternal.bearingAccuracyDeg = 1.0 + msg.gpsLocationExternal.vNED = [0.0, 0.0, 0.0] + msg.gpsLocationExternal.latitude = float(self.lat) + msg.gpsLocationExternal.longitude = float(self.lon) + msg.gpsLocationExternal.unixTimestampMillis = t * 1e6 + msg.gpsLocationExternal.altitude = float(self.alt) + #if name == "gnssMeasurements": + # msg.gnssMeasurements.measTime = t + # msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] + # msg.gnssMeasurements.positionECEF.std = [0,0,0] + # msg.gnssMeasurements.positionECEF.valid = True + # msg.gnssMeasurements.velocityECEF.value = [] + # msg.gnssMeasurements.velocityECEF.std = [0,0,0] + # msg.gnssMeasurements.velocityECEF.valid = True elif name == 'cameraOdometry': msg.cameraOdometry.rot = [0.0, 0.0, 0.0] msg.cameraOdometry.rotStd = [0.0, 0.0, 0.0] diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index c0a49e3324..9256b6015c 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -433,6 +433,13 @@ def laikad_config_pubsub_callback(params, cfg, lr): cfg.main_pub_drained = True +def locationd_config_pubsub_callback(params, cfg, lr): + ublox = params.get_bool("UbloxAvailable") + sub_keys = ({"gpsLocation", } if ublox else {"gpsLocationExternal", }) + + cfg.pubs = set(cfg.pubs) - sub_keys + + CONFIGS = [ ProcessConfig( proc_name="controlsd", @@ -487,11 +494,12 @@ CONFIGS = [ ProcessConfig( proc_name="locationd", pubs=[ - "cameraOdometry", "accelerometer", "gyroscope", "gnssMeasurements", - "liveCalibration", "carState", "carParams" + "cameraOdometry", "accelerometer", "gyroscope", "gpsLocationExternal", + "liveCalibration", "carState", "carParams", "gpsLocation" ], subs=["liveLocationKalman"], ignore=["logMonoTime", "valid"], + config_callback=locationd_config_pubsub_callback, tolerance=NUMPY_TOLERANCE, ), ProcessConfig( diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 564eafa597..8aec881aa5 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -89db4d10a4eb0bfd0ea0ff83525e5cf358f5f690 \ No newline at end of file +72e3d7b660ee92f5adcc249112cf04c703f4bf9e \ No newline at end of file From df9564e1722f589fa17e15bce55a4f179f58ab70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Tue, 22 Aug 2023 14:14:14 -0700 Subject: [PATCH 075/159] devcontainer: CI fix (#29534) Export xauthority before running devcontainer --- .github/workflows/tools_tests.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 04f73d21af..dff2a4b04d 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -105,6 +105,8 @@ jobs: - name: Build dev container image run: devcontainer build --workspace-folder . - name: Run dev container - run: devcontainer up --workspace-folder . + run: | + export XAUTHORITY="$HOME/.Xauthority" + devcontainer up --workspace-folder . - name: Test environment run: devcontainer exec --workspace-folder . scons --dry-run From 2cd311da29241501ef93c15e7de563cb3bfe3070 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 14:31:03 -0700 Subject: [PATCH 076/159] add pytest-subtests package (#29536) --- poetry.lock | 17 ++++++++++++++++- pyproject.toml | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index da50b60ad4..dca0c49b53 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3121,6 +3121,21 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +[[package]] +name = "pytest-subtests" +version = "0.11.0" +description = "unittest subTest() support and subtests fixture" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-subtests-0.11.0.tar.gz", hash = "sha256:51865c88457545f51fb72011942f0a3c6901ee9e24cbfb6d1b9dc1348bafbe37"}, + {file = "pytest_subtests-0.11.0-py3-none-any.whl", hash = "sha256:453389984952eec85ab0ce0c4f026337153df79587048271c7fd0f49119c07e4"}, +] + +[package.dependencies] +attrs = ">=19.2.0" +pytest = ">=7.0" + [[package]] name = "pytest-xdist" version = "3.3.1" @@ -4177,4 +4192,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "587fe0b312a1d4a0be2e13fdd4626683227f6c9038d3efacf9866c431d9453b1" +content-hash = "39a9e8fd6df654b3f503f9186e75f1a48d726c876696ff64cec9b6f53cc2f22a" diff --git a/pyproject.toml b/pyproject.toml index 0801439945..dcce2505e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,6 +120,7 @@ pygame = "*" pyprof2calltree = "*" pytest = "*" pytest-cov = "*" +pytest-subtests = "*" pytest-xdist = "*" scipy = "*" sphinx = "*" From e0e139a233daf207833ecc3655ca4fd3a86a9f8e Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 15:16:38 -0700 Subject: [PATCH 077/159] soundd: update cpu usage --- selfdrive/test/test_onroad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index c0cb49c0db..fe5137f9a4 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -42,7 +42,7 @@ PROCS = { "selfdrive.thermald.thermald": 3.87, "selfdrive.locationd.calibrationd": 2.0, "selfdrive.locationd.torqued": 5.0, - "./_soundd": (15.0, 65.0), + "./_soundd": (1.0, 65.0), "selfdrive.monitoring.dmonitoringd": 4.0, "./proclogd": 1.54, "system.logmessaged": 0.2, From 2fe3231b49ea8cd82dd270682a4641ffd016d73a Mon Sep 17 00:00:00 2001 From: Vivek Aithal Date: Tue, 22 Aug 2023 16:11:21 -0700 Subject: [PATCH 078/159] CHEVROLET SILVERADO 1500 2020: Make Silverado lateral tune non-linear (#29540) add nonlinear values to silverado --- selfdrive/car/gm/interface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 511da405d8..75465b8dde 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -21,7 +21,8 @@ BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.D NON_LINEAR_TORQUE_PARAMS = { CAR.BOLT_EUV: [2.6531724862969748, 1.0, 0.1919764879840985, 0.009054123646805178], - CAR.ACADIA: [4.78003305, 1.0, 0.3122, 0.05591772] + CAR.ACADIA: [4.78003305, 1.0, 0.3122, 0.05591772], + CAR.SILVERADO: [3.29974374, 1.0, 0.25571356, 0.0465122] } From 979c96167d5ba2f07a7e0dee7c059c3a2ee4757b Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Tue, 22 Aug 2023 16:48:02 -0700 Subject: [PATCH 079/159] CI: enable missing tests (#29538) --- poetry.lock | 23 ++++++++++++++++++- pyproject.toml | 1 + selfdrive/controls/lib/tests/__init__.py | 0 .../controls/lib/tests/test_latcontrol.py | 5 +++- .../controls/lib/tests/test_vehicle_model.py | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 selfdrive/controls/lib/tests/__init__.py diff --git a/poetry.lock b/poetry.lock index dca0c49b53..60e1de7266 100644 --- a/poetry.lock +++ b/poetry.lock @@ -730,6 +730,27 @@ mypy = ["contourpy[bokeh,docs]", "docutils-stubs", "mypy (==1.2.0)", "types-Pill test = ["Pillow", "contourpy[test-no-images]", "matplotlib"] test-no-images = ["pytest", "pytest-cov", "wurlitzer"] +[[package]] +name = "control" +version = "0.9.4" +description = "Python Control Systems Library" +optional = false +python-versions = ">=3.8" +files = [ + {file = "control-0.9.4-py3-none-any.whl", hash = "sha256:ab68980abd8d35ae5015ffa090865cbbd926deea7e66d0b9a41cfd12577e63ff"}, + {file = "control-0.9.4.tar.gz", hash = "sha256:0fa57d2216b7ac4e9339c09eab6827660318a641779335864feee940bd19c9ce"}, +] + +[package.dependencies] +matplotlib = "*" +numpy = "*" +scipy = ">=1.3" + +[package.extras] +cvxopt = ["cvxopt (>=1.2.0)"] +slycot = ["slycot (>=0.4.0)"] +test = ["pytest", "pytest-timeout"] + [[package]] name = "coverage" version = "7.3.0" @@ -4192,4 +4213,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "39a9e8fd6df654b3f503f9186e75f1a48d726c876696ff64cec9b6f53cc2f22a" +content-hash = "320aa5cc075d746403abb872211ebdaf55e9504face8dab8c9b270c71953675d" diff --git a/pyproject.toml b/pyproject.toml index dcce2505e1..b5d03e9b4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ aiohttp = "*" aiortc = "*" casadi = "==3.6.3" cffi = "*" +control = "*" crcmod = "*" cryptography = "*" Cython = "*" diff --git a/selfdrive/controls/lib/tests/__init__.py b/selfdrive/controls/lib/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selfdrive/controls/lib/tests/test_latcontrol.py b/selfdrive/controls/lib/tests/test_latcontrol.py index 4ff7ef7c93..cf2243d033 100755 --- a/selfdrive/controls/lib/tests/test_latcontrol.py +++ b/selfdrive/controls/lib/tests/test_latcontrol.py @@ -12,6 +12,7 @@ from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel +from selfdrive.navd.tests.test_map_renderer import gen_llk class TestLatControl(unittest.TestCase): @@ -27,13 +28,15 @@ class TestLatControl(unittest.TestCase): CS = car.CarState.new_message() CS.vEgo = 30 + CS.steeringPressed = False last_actuators = car.CarControl.Actuators.new_message() params = log.LiveParametersData.new_message() + llk = gen_llk() for _ in range(1000): - _, _, lac_log = controller.update(True, CS, CP, VM, params, last_actuators, True, 1, 0) + _, _, lac_log = controller.update(True, CS, VM, params, last_actuators, False, 1, 0, llk) self.assertTrue(lac_log.saturated) diff --git a/selfdrive/controls/lib/tests/test_vehicle_model.py b/selfdrive/controls/lib/tests/test_vehicle_model.py index fc8ef2fb56..d016e87527 100755 --- a/selfdrive/controls/lib/tests/test_vehicle_model.py +++ b/selfdrive/controls/lib/tests/test_vehicle_model.py @@ -38,7 +38,7 @@ class TestVehicleModel(unittest.TestCase): # Compute yaw rate using direct computations yr2 = self.VM.yaw_rate(sa, u, roll) - self.assertAlmostEqual(float(yr1), yr2) + self.assertAlmostEqual(float(yr1[0]), yr2) def test_syn_ss_sol_simulate(self): """Verifies that dyn_ss_sol matches a simulation""" From 61653bf343bc189d9231234a5b95777998096fa6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 17:16:38 -0700 Subject: [PATCH 080/159] Toyota: prepare to disable radar (#29541) * try to disable radar * fix bug and bump panda * prep * always attempt longitudinal for testers * fix rav4 * send ACC_HUD * bump panda * revert * check for failure to disable * fix arg * bump to master * revert to master * comments only --- selfdrive/car/toyota/carcontroller.py | 5 +++++ selfdrive/car/toyota/interface.py | 9 +++++++++ selfdrive/car/toyota/toyotacan.py | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index c625c2e493..ab7e4b9d85 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -166,6 +166,7 @@ class CarController: hud_control.rightLaneVisible, hud_control.leftLaneDepart, hud_control.rightLaneDepart, CC.enabled, CS.lkas_hud)) + # TODO: send when disabling the radar to avoid a fault if (self.frame % 100 == 0 or send_ui) and self.CP.enableDsu: can_sends.append(create_fcw_command(self.packer, fcw_alert)) @@ -174,6 +175,10 @@ class CarController: if self.frame % fr_step == 0 and self.CP.enableDsu and self.CP.carFingerprint in cars: can_sends.append(make_can_msg(addr, vl, bus)) + # uncomment to keep radar disabled, rate can be tuned: + # if self.frame % 20 == 0: + # can_sends.append([0x750, 0, b"\x0F\x02\x3E\x00\x00\x00\x00\x00", 0]) + new_actuators = actuators.copy() new_actuators.steer = apply_steer / self.params.STEER_MAX new_actuators.steerOutputCan = apply_steer diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index c78479a97e..6b8977f9f1 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -261,6 +261,15 @@ class CarInterface(CarInterfaceBase): return ret + # uncomment to disable radar: + # @staticmethod + # def init(CP, logcan, sendcan): + # # a diagnostic mode of SESSION_TYPE.PROGRAMMING disabled the ECU on its own. car did not accept DISABLE_RX_DISABLE_TX, but it did not matter. + # # a diagnostic mode of SESSION_TYPE.EXTENDED_DIAGNOSTIC and CONTROL_TYPE.ENABLE_RX_DISABLE_TX did work, so use that + # # TODO: add a flag, radarUnavailable shouldn't be used as "radar acc" right now + # if CP.openpilotLongitudinalControl and CP.radarUnavailable: + # disable_ecu(logcan, sendcan, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=b'\x28\x01\x01') + # returns a car.CarState def _update(self, c): ret = self.CS.update(self.cp, self.cp_cam) diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 0c3330efa2..0792ac869f 100644 --- a/selfdrive/car/toyota/toyotacan.py +++ b/selfdrive/car/toyota/toyotacan.py @@ -56,7 +56,7 @@ def create_acc_cancel_command(packer): def create_fcw_command(packer, fcw): values = { - "PCS_INDICATOR": 1, + "PCS_INDICATOR": 1, # PCS turned off "FCW": fcw, "SET_ME_X20": 0x20, "SET_ME_X10": 0x10, From cb368163158fe8133b317273f99f011ce1fa2288 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 19:50:24 -0700 Subject: [PATCH 081/159] Revert "Toyota: prepare to disable radar (#29541)" This reverts commit 61653bf343bc189d9231234a5b95777998096fa6. --- selfdrive/car/toyota/carcontroller.py | 5 ----- selfdrive/car/toyota/interface.py | 9 --------- selfdrive/car/toyota/toyotacan.py | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index ab7e4b9d85..c625c2e493 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -166,7 +166,6 @@ class CarController: hud_control.rightLaneVisible, hud_control.leftLaneDepart, hud_control.rightLaneDepart, CC.enabled, CS.lkas_hud)) - # TODO: send when disabling the radar to avoid a fault if (self.frame % 100 == 0 or send_ui) and self.CP.enableDsu: can_sends.append(create_fcw_command(self.packer, fcw_alert)) @@ -175,10 +174,6 @@ class CarController: if self.frame % fr_step == 0 and self.CP.enableDsu and self.CP.carFingerprint in cars: can_sends.append(make_can_msg(addr, vl, bus)) - # uncomment to keep radar disabled, rate can be tuned: - # if self.frame % 20 == 0: - # can_sends.append([0x750, 0, b"\x0F\x02\x3E\x00\x00\x00\x00\x00", 0]) - new_actuators = actuators.copy() new_actuators.steer = apply_steer / self.params.STEER_MAX new_actuators.steerOutputCan = apply_steer diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 6b8977f9f1..c78479a97e 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -261,15 +261,6 @@ class CarInterface(CarInterfaceBase): return ret - # uncomment to disable radar: - # @staticmethod - # def init(CP, logcan, sendcan): - # # a diagnostic mode of SESSION_TYPE.PROGRAMMING disabled the ECU on its own. car did not accept DISABLE_RX_DISABLE_TX, but it did not matter. - # # a diagnostic mode of SESSION_TYPE.EXTENDED_DIAGNOSTIC and CONTROL_TYPE.ENABLE_RX_DISABLE_TX did work, so use that - # # TODO: add a flag, radarUnavailable shouldn't be used as "radar acc" right now - # if CP.openpilotLongitudinalControl and CP.radarUnavailable: - # disable_ecu(logcan, sendcan, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=b'\x28\x01\x01') - # returns a car.CarState def _update(self, c): ret = self.CS.update(self.cp, self.cp_cam) diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 0792ac869f..0c3330efa2 100644 --- a/selfdrive/car/toyota/toyotacan.py +++ b/selfdrive/car/toyota/toyotacan.py @@ -56,7 +56,7 @@ def create_acc_cancel_command(packer): def create_fcw_command(packer, fcw): values = { - "PCS_INDICATOR": 1, # PCS turned off + "PCS_INDICATOR": 1, "FCW": fcw, "SET_ME_X20": 0x20, "SET_ME_X10": 0x10, From bb1b641812353e9723cad0aa6f844466c67d9c6b Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 22 Aug 2023 20:58:43 -0700 Subject: [PATCH 082/159] build.py: retry with less threads (#29543) * build.py: retry with less threads * cleanup * fix no output * cleanup --- selfdrive/manager/build.py | 68 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/selfdrive/manager/build.py b/selfdrive/manager/build.py index c877e6ed97..96501051a8 100755 --- a/selfdrive/manager/build.py +++ b/selfdrive/manager/build.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 import os import subprocess -import textwrap from pathlib import Path +from typing import List # NOTE: Do NOT import anything here that needs be built (e.g. params) from openpilot.common.basedir import BASEDIR @@ -19,57 +19,59 @@ TOTAL_SCONS_NODES = 2560 MAX_BUILD_PROGRESS = 100 PREBUILT = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) - def build(spinner: Spinner, dirty: bool = False) -> None: env = os.environ.copy() env['SCONS_PROGRESS'] = "1" nproc = os.cpu_count() - j_flag = "" if nproc is None else f"-j{nproc - 1}" - - scons: subprocess.Popen = subprocess.Popen(["scons", j_flag, "--cache-populate"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) - assert scons.stderr is not None - - compile_output = [] - - # Read progress from stderr and update spinner - while scons.poll() is None: - try: - line = scons.stderr.readline() - if line is None: - continue - line = line.rstrip() - - prefix = b'progress: ' - if line.startswith(prefix): - i = int(line[len(prefix):]) - spinner.update_progress(MAX_BUILD_PROGRESS * min(1., i / TOTAL_SCONS_NODES), 100.) - elif len(line): - compile_output.append(line) - print(line.decode('utf8', 'replace')) - except Exception: - pass + if nproc is None: + nproc = 2 + + # building with all cores can result in using too + # much memory, so retry with less parallelism + compile_output: List[bytes] = [] + for n in (nproc, nproc/2, 1): + compile_output.clear() + scons: subprocess.Popen = subprocess.Popen(["scons", f"-j{int(n)}", "--cache-populate"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) + assert scons.stderr is not None + + # Read progress from stderr and update spinner + while scons.poll() is None: + try: + line = scons.stderr.readline() + if line is None: + continue + line = line.rstrip() + + prefix = b'progress: ' + if line.startswith(prefix): + i = int(line[len(prefix):]) + spinner.update_progress(MAX_BUILD_PROGRESS * min(1., i / TOTAL_SCONS_NODES), 100.) + elif len(line): + compile_output.append(line) + print(line.decode('utf8', 'replace')) + except Exception: + pass + + if scons.returncode == 0: + break if scons.returncode != 0: # Read remaining output - r = scons.stderr.read().split(b'\n') - compile_output += r + if scons.stderr is not None: + compile_output += scons.stderr.read().split(b'\n') # Build failed log errors - errors = [line.decode('utf8', 'replace') for line in compile_output - if any(err in line for err in [b'error: ', b'not found, needed by target'])] - error_s = "\n".join(errors) + error_s = b"\n".join(compile_output).decode('utf8', 'replace') add_file_handler(cloudlog) cloudlog.error("scons build failed\n" + error_s) # Show TextWindow spinner.close() if not os.getenv("CI"): - error_s = "\n \n".join("\n".join(textwrap.wrap(e, 65)) for e in errors) with TextWindow("openpilot failed to build\n \n" + error_s) as t: t.wait_for_exit() exit(1) - # enforce max cache size cache_files = [f for f in CACHE_DIR.rglob('*') if f.is_file()] cache_files.sort(key=lambda f: f.stat().st_mtime) From 16a8c9fbf13bf6a61f5704d5a2885b09ce4a8f80 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 21:09:33 -0700 Subject: [PATCH 083/159] Toyota: remove redundant car set union (#29546) remove confusing union --- selfdrive/car/toyota/carstate.py | 2 +- selfdrive/car/toyota/tests/test_toyota.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 7eefe43dd9..3297750a8d 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -130,7 +130,7 @@ class CarState(CarStateBase): cp_acc = cp_cam if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) else cp - if self.CP.carFingerprint in (TSS2_CAR | RADAR_ACC_CAR): + if self.CP.carFingerprint in TSS2_CAR: if not (self.CP.flags & ToyotaFlags.SMART_DSU.value): self.acc_type = cp_acc.vl["ACC_CONTROL"]["ACC_TYPE"] ret.stockFcw = bool(cp_acc.vl["PCS_HUD"]["FCW"]) diff --git a/selfdrive/car/toyota/tests/test_toyota.py b/selfdrive/car/toyota/tests/test_toyota.py index e877db3eb8..c621734e2b 100755 --- a/selfdrive/car/toyota/tests/test_toyota.py +++ b/selfdrive/car/toyota/tests/test_toyota.py @@ -2,14 +2,15 @@ from cereal import car import unittest -from openpilot.selfdrive.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, FW_VERSIONS +from openpilot.selfdrive.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, RADAR_ACC_CAR, FW_VERSIONS Ecu = car.CarParams.Ecu class TestToyotaInterfaces(unittest.TestCase): - def test_angle_car_set(self): + def test_car_sets(self): self.assertTrue(len(ANGLE_CONTROL_CAR - TSS2_CAR) == 0) + self.assertTrue(len(RADAR_ACC_CAR - TSS2_CAR) == 0) def test_tss2_dbc(self): # We make some assumptions about TSS2 platforms, From 0aa6e2ce41113a8f129ab88762037254f2951f91 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 21:17:30 -0700 Subject: [PATCH 084/159] Toyota: prepare to disable radar (#29542) * try to disable radar * fix bug and bump panda * prep * always attempt longitudinal for testers * fix rav4 * send ACC_HUD * bump panda * revert * check for failure to disable * fix arg * bump to master * revert to master * comments only * correct check * carcontroller * something like this * or this * use flag * send PCS HUD * clean up * carstate checks * fix from test models * consistent --- selfdrive/car/toyota/carcontroller.py | 8 ++++++-- selfdrive/car/toyota/carstate.py | 6 +++--- selfdrive/car/toyota/interface.py | 19 +++++++++++++++++-- selfdrive/car/toyota/toyotacan.py | 2 +- selfdrive/car/toyota/values.py | 1 + 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index c625c2e493..b765d70b9a 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -6,7 +6,7 @@ from openpilot.selfdrive.car.toyota.toyotacan import create_steer_command, creat create_accel_command, create_acc_cancel_command, \ create_fcw_command, create_lta_steer_command from openpilot.selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \ - MIN_ACC_SPEED, PEDAL_TRANSITION, CarControllerParams, \ + MIN_ACC_SPEED, PEDAL_TRANSITION, CarControllerParams, ToyotaFlags, \ UNSUPPORTED_DSU_CAR from opendbc.can.packer import CANPacker @@ -166,7 +166,7 @@ class CarController: hud_control.rightLaneVisible, hud_control.leftLaneDepart, hud_control.rightLaneDepart, CC.enabled, CS.lkas_hud)) - if (self.frame % 100 == 0 or send_ui) and self.CP.enableDsu: + if (self.frame % 100 == 0 or send_ui) and (self.CP.enableDsu or self.CP.flags & ToyotaFlags.DISABLE_RADAR.value): can_sends.append(create_fcw_command(self.packer, fcw_alert)) # *** static msgs *** @@ -174,6 +174,10 @@ class CarController: if self.frame % fr_step == 0 and self.CP.enableDsu and self.CP.carFingerprint in cars: can_sends.append(make_can_msg(addr, vl, bus)) + # keep radar disabled + if self.frame % 20 == 0 and self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: + can_sends.append([0x750, 0, b"\x0F\x02\x3E\x00\x00\x00\x00\x00", 0]) + new_actuators = actuators.copy() new_actuators.steer = apply_steer / self.params.STEER_MAX new_actuators.steerOutputCan = apply_steer diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 3297750a8d..c96df6f10f 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -130,7 +130,7 @@ class CarState(CarStateBase): cp_acc = cp_cam if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) else cp - if self.CP.carFingerprint in TSS2_CAR: + if self.CP.carFingerprint in TSS2_CAR and not self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: if not (self.CP.flags & ToyotaFlags.SMART_DSU.value): self.acc_type = cp_acc.vl["ACC_CONTROL"]["ACC_TYPE"] ret.stockFcw = bool(cp_acc.vl["PCS_HUD"]["FCW"]) @@ -153,7 +153,7 @@ class CarState(CarStateBase): ret.genericToggle = bool(cp.vl["LIGHT_STALK"]["AUTO_HIGH_BEAM"]) ret.espDisabled = cp.vl["ESP_CONTROL"]["TC_DISABLED"] != 0 - if not self.CP.enableDsu: + if not self.CP.enableDsu and not self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: ret.stockAeb = bool(cp_acc.vl["PRE_COLLISION"]["PRECOLLISION_ACTIVE"] and cp_acc.vl["PRE_COLLISION"]["FORCE"] < -1e-5) if self.CP.enableBsm: @@ -201,7 +201,7 @@ class CarState(CarStateBase): if CP.enableBsm: messages.append(("BSM", 1)) - if CP.carFingerprint in RADAR_ACC_CAR: + if CP.carFingerprint in RADAR_ACC_CAR and not CP.flags & ToyotaFlags.DISABLE_RADAR.value: if not CP.flags & ToyotaFlags.SMART_DSU.value: messages += [ ("ACC_CONTROL", 33), diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index c78479a97e..89b328b6ae 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -2,9 +2,11 @@ from cereal import car from openpilot.common.conversions import Conversions as CV from panda import Panda +from panda.python import uds from openpilot.selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \ MIN_ACC_SPEED, EPS_SCALE, EV_HYBRID_CAR, UNSUPPORTED_DSU_CAR, NO_STOP_TIMER_CAR, ANGLE_CONTROL_CAR from openpilot.selfdrive.car import get_safety_config +from openpilot.selfdrive.car.disable_ecu import disable_ecu from openpilot.selfdrive.car.interfaces import CarInterfaceBase EventName = car.CarEvent.EventName @@ -218,7 +220,12 @@ class CarInterface(CarInterfaceBase): use_sdsu = bool(ret.flags & ToyotaFlags.SMART_DSU) if candidate in RADAR_ACC_CAR: ret.experimentalLongitudinalAvailable = use_sdsu - use_sdsu = use_sdsu and experimental_long + + if not use_sdsu: + if experimental_long and False: # TODO: disabling radar isn't supported yet + ret.flags |= ToyotaFlags.DISABLE_RADAR.value + else: + use_sdsu = use_sdsu and experimental_long # openpilot longitudinal enabled by default: # - non-(TSS2 radar ACC cars) w/ smartDSU installed @@ -226,7 +233,8 @@ class CarInterface(CarInterfaceBase): # - TSS2 cars with camera sending ACC_CONTROL where we can block it # openpilot longitudinal behind experimental long toggle: # - TSS2 radar ACC cars w/ smartDSU installed - ret.openpilotLongitudinalControl = use_sdsu or ret.enableDsu or candidate in (TSS2_CAR - RADAR_ACC_CAR) + # - TSS2 radar ACC cars w/o smartDSU installed (disables radar) + ret.openpilotLongitudinalControl = use_sdsu or ret.enableDsu or candidate in (TSS2_CAR - RADAR_ACC_CAR) or bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR if not ret.openpilotLongitudinalControl: @@ -261,6 +269,13 @@ class CarInterface(CarInterfaceBase): return ret + @staticmethod + def init(CP, logcan, sendcan): + # disable radar if alpha longitudinal toggled on radar-ACC car without CAN filter/smartDSU + if CP.flags & ToyotaFlags.DISABLE_RADAR.value: + communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) + disable_ecu(logcan, sendcan, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control) + # returns a car.CarState def _update(self, c): ret = self.CS.update(self.cp, self.cp_cam) diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 0c3330efa2..0792ac869f 100644 --- a/selfdrive/car/toyota/toyotacan.py +++ b/selfdrive/car/toyota/toyotacan.py @@ -56,7 +56,7 @@ def create_acc_cancel_command(packer): def create_fcw_command(packer, fcw): values = { - "PCS_INDICATOR": 1, + "PCS_INDICATOR": 1, # PCS turned off "FCW": fcw, "SET_ME_X20": 0x20, "SET_ME_X10": 0x10, diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 7d62528748..bdde3c6095 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -42,6 +42,7 @@ class CarControllerParams: class ToyotaFlags(IntFlag): HYBRID = 1 SMART_DSU = 2 + DISABLE_RADAR = 4 class CAR: From 7de9842245dfb506ec340290469d7412989e2233 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 23:43:52 -0700 Subject: [PATCH 085/159] FW Query: test noOBD queries on aux panda (#29547) * huh, this test just works! * fix * Update selfdrive/car/tests/test_fw_fingerprint.py --- selfdrive/car/ford/values.py | 1 - selfdrive/car/tests/test_fw_fingerprint.py | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/ford/values.py b/selfdrive/car/ford/values.py index 5d99db945e..8968d1dc29 100644 --- a/selfdrive/car/ford/values.py +++ b/selfdrive/car/ford/values.py @@ -108,7 +108,6 @@ FW_QUERY_CONFIG = FwQueryConfig( [StdQueries.TESTER_PRESENT_REQUEST, StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST], [StdQueries.TESTER_PRESENT_RESPONSE, StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE], # whitelist_ecus=[Ecu.engine], - auxiliary=True, ), Request( [StdQueries.TESTER_PRESENT_REQUEST, StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST], diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 3280dea7dc..f5892a6090 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -168,6 +168,10 @@ class TestFwFingerprint(unittest.TestCase): for request_obj in config.requests: self.assertEqual(len(request_obj.request), len(request_obj.response)) + # No request on the OBD port (bus 1, multiplexed) should be run on an aux panda + self.assertFalse(request_obj.auxiliary and request_obj.bus == 1 and request_obj.obd_multiplexing, + f"{brand.title()}: OBD multiplexed request is marked auxiliary: {request_obj}") + class TestFwFingerprintTiming(unittest.TestCase): N: int = 5 @@ -237,7 +241,7 @@ class TestFwFingerprintTiming(unittest.TestCase): 'volkswagen': 0.2, }, 2: { - 'ford': 0.4, + 'ford': 0.3, 'hyundai': 1.1, } } From 1ea310b202ecedfad67831cca189970944977145 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 22 Aug 2023 23:58:29 -0700 Subject: [PATCH 086/159] Update FW query total time --- selfdrive/car/tests/test_fw_fingerprint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index f5892a6090..883a72897c 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -225,7 +225,7 @@ class TestFwFingerprintTiming(unittest.TestCase): print(f'get_vin, query time={vin_time / self.N} seconds') def test_fw_query_timing(self): - total_ref_time = 6.2 + total_ref_time = 6.1 brand_ref_times = { 1: { 'body': 0.1, From 8a7281d2859f2fa8d49cb3b679c2eaf5ec8f1729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Wed, 23 Aug 2023 00:13:10 -0700 Subject: [PATCH 087/159] Laikad upgrades: prep for laikad lld (#29545) * Laikad upgrades: prep for laikad lld * Update ref commit --- laika_repo | 2 +- selfdrive/locationd/laikad.py | 59 +++++++++--------------- selfdrive/locationd/test/test_laikad.py | 4 +- selfdrive/test/process_replay/ref_commit | 2 +- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/laika_repo b/laika_repo index 65901a1e6c..989b6a8505 160000 --- a/laika_repo +++ b/laika_repo @@ -1 +1 @@ -Subproject commit 65901a1e6c7c7940d8c97027d3edaca7d0132253 +Subproject commit 989b6a8505441a550c94f60b4378be296ea3fe92 diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index 2073813363..6c9c199db1 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -18,7 +18,8 @@ from laika.downloader import DownloadFailed from laika.ephemeris import EphemerisType, GPSEphemeris, GLONASSEphemeris, ephemeris_structs, parse_qcom_ephem from laika.gps_time import GPSTime from laika.helpers import ConstellationId, get_sv_id -from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox, read_raw_qcom +from laika.raw_gnss import GNSSMeasurement, correct_measurements, process_measurements, read_raw_ublox +from laika.raw_gnss import gps_time_from_qcom_report, get_measurements_from_qcom_reports from laika.opt import calc_pos_fix, get_posfix_sympy_fun, calc_vel_fix, get_velfix_sympy_func from openpilot.selfdrive.locationd.models.constants import GENERATED_DIR, ObservationKind from openpilot.selfdrive.locationd.models.gnss_kf import GNSSKalman @@ -102,9 +103,10 @@ class Laikad: self.use_qcom = use_qcom self.first_log_time = None self.ttff = -1 + self.measurement_lag = 0.630 if self.use_qcom else 0.095 # qcom specific stuff - self.qcom_reports_received = 1 + self.qcom_reports_received = 4 self.qcom_reports = [] def load_cache(self): @@ -161,47 +163,31 @@ class Laikad: def get_lsq_fix(self, t, measurements): if self.last_fix_t is None or abs(self.last_fix_t - t) > 0: min_measurements = 5 if any(p.constellation_id == ConstellationId.GLONASS for p in measurements) else 4 + position_solution, pr_residuals, pos_std = calc_pos_fix(measurements, self.posfix_functions, min_measurements=min_measurements) if len(position_solution) < 3: return None position_estimate = position_solution[:3] - - position_std_residual = np.median(np.abs(pr_residuals)) - position_std = np.median(np.abs(pos_std))/10 - position_std = max(position_std_residual, position_std) * np.ones(3) + position_std = pos_std[:3] velocity_solution, prr_residuals, vel_std = calc_vel_fix(measurements, position_estimate, self.velfix_function, min_measurements=min_measurements) if len(velocity_solution) < 3: return None velocity_estimate = velocity_solution[:3] - - velocity_std_residual = np.median(np.abs(prr_residuals)) - velocity_std = np.median(np.abs(vel_std))/10 - velocity_std = max(velocity_std, velocity_std_residual) * np.ones(3) + velocity_std = vel_std[:3] return position_estimate, position_std, velocity_estimate, velocity_std - def gps_time_from_qcom_report(self, gnss_msg): - report = gnss_msg.drMeasurementReport - if report.source == log.QcomGnss.MeasurementSource.gps: - report_time = GPSTime(report.gpsWeek, report.gpsMilliseconds / 1000.0) - elif report.source == log.QcomGnss.MeasurementSource.sbas: - report_time = GPSTime(report.gpsWeek, report.gpsMilliseconds / 1000.0) - elif report.source == log.QcomGnss.MeasurementSource.glonass: - report_time = GPSTime.from_glonass(report.glonassYear, - report.glonassDay, - report.glonassMilliseconds / 1000.0) - else: - raise NotImplementedError(f'Unknownconstellation {report.source}') - return report_time - def is_good_report(self, gnss_msg): - if gnss_msg.which() == 'drMeasurementReport' and self.use_qcom: + if gnss_msg.which() in ['drMeasurementReport', 'measurementReport'] and self.use_qcom: # TODO: Understand and use remaining unknown constellations try: - constellation_id = ConstellationId.from_qcom_source(gnss_msg.drMeasurementReport.source) + if gnss_msg.which() == 'drMeasurementReport': + constellation_id = ConstellationId.from_qcom_source(gnss_msg.drMeasurementReport.source) + else: + constellation_id = ConstellationId.from_qcom_source(gnss_msg.measurementReport.source) good_constellation = constellation_id in [ConstellationId.GPS, ConstellationId.SBAS, ConstellationId.GLONASS] - report_time = self.gps_time_from_qcom_report(gnss_msg) + report_time = gps_time_from_qcom_report(gnss_msg) except NotImplementedError: return False # Garbage timestamps with week > 32767 are sometimes sent by module. @@ -216,21 +202,20 @@ class Laikad: def read_report(self, gnss_msg): if self.use_qcom: # QCOM reports are per constellation, so we need to aggregate them - report = gnss_msg.drMeasurementReport - report_time = self.gps_time_from_qcom_report(gnss_msg) - + # Additionally, the pseudoranges are broken in the measurementReports + # and the doppler filteredSpeed is broken in the drMeasurementReports + report_time = gps_time_from_qcom_report(gnss_msg) if report_time - self.last_report_time > 0: self.qcom_reports_received = max(1, len(self.qcom_reports)) - self.qcom_reports = [report] + self.qcom_reports = [gnss_msg] else: - self.qcom_reports.append(report) + self.qcom_reports.append(gnss_msg) self.last_report_time = report_time - new_meas = [] if len(self.qcom_reports) == self.qcom_reports_received: - for report in self.qcom_reports: - new_meas.extend(read_raw_qcom(report)) - + new_meas = get_measurements_from_qcom_reports(self.qcom_reports) + else: + new_meas = [] else: report = gnss_msg.measurementReport self.last_report_time = GPSTime(report.gpsWeek, report.rcvTow) @@ -300,7 +285,7 @@ class Laikad: def process_gnss_msg(self, gnss_msg, gnss_mono_time: int, block=False): out_msg = messaging.new_message("gnssMeasurements") t = gnss_mono_time * 1e-9 - msg_dict: Dict[str, Any] = {"measTime": gnss_mono_time} + msg_dict: Dict[str, Any] = {"measTime": gnss_mono_time - int(1e9 * self.measurement_lag)} if self.first_log_time is None: self.first_log_time = 1e-9 * gnss_mono_time if self.is_ephemeris(gnss_msg): diff --git a/selfdrive/locationd/test/test_laikad.py b/selfdrive/locationd/test/test_laikad.py index 58c650e26c..a8d69502cf 100755 --- a/selfdrive/locationd/test/test_laikad.py +++ b/selfdrive/locationd/test/test_laikad.py @@ -177,8 +177,8 @@ class TestLaikad(unittest.TestCase): laikad = Laikad(auto_update=True, valid_ephem_types=EphemerisType.NAV, use_qcom=use_qcom) # Disable fetch_orbits to test NAV only correct_msgs = verify_messages(logs, laikad) - correct_msgs_expected = 56 if use_qcom else 560 - valid_fix_expected = 56 if use_qcom else 560 + correct_msgs_expected = 55 if use_qcom else 560 + valid_fix_expected = 55 if use_qcom else 560 self.assertEqual(correct_msgs_expected, len(correct_msgs)) self.assertEqual(valid_fix_expected, len([m for m in correct_msgs if m.gnssMeasurements.positionECEF.valid])) diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 8aec881aa5..51c84c4bdd 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -72e3d7b660ee92f5adcc249112cf04c703f4bf9e \ No newline at end of file +4846f6f416128ba74837829643aa3fe0897c5621 \ No newline at end of file From 861ceb2feeb8e9f303b96c0e7a9ef19c5423938d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 23 Aug 2023 01:31:04 -0700 Subject: [PATCH 088/159] FW query: query one sub-address in parallel (#28675) * put one subaddr in parallel_addrs * p * remove print * update test refs * test * revert test changes * do same in present ECU query, lower threshold to catch (~0.82 to ~0.72 right within bounds) * type * clean up * update test ref --- selfdrive/car/fw_versions.py | 12 ++++++++---- selfdrive/car/tests/test_fw_fingerprint.py | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 45c4967cb8..9b4b5d6a33 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -185,11 +185,13 @@ def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[EcuAddrBusType]: if len(r.whitelist_ecus) == 0 or ecu_type in r.whitelist_ecus: a = (addr, sub_addr, r.bus) # Build set of queries - if sub_addr is None: + # Add first sub-address to parallel queries since there will be no conflicts + sub_addr_in_parallel_addrs = any(p[1] is not None for p in parallel_queries[r.obd_multiplexing]) + if sub_addr is None or not sub_addr_in_parallel_addrs: if a not in parallel_queries[r.obd_multiplexing]: parallel_queries[r.obd_multiplexing].append(a) else: # subaddresses must be queried one by one - if [a] not in queries[r.obd_multiplexing]: + if [a] not in queries[r.obd_multiplexing] and a not in parallel_queries[r.obd_multiplexing]: queries[r.obd_multiplexing].append([a]) # Build set of expected responses to filter @@ -282,11 +284,13 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1, if a not in ecu_types: ecu_types[a] = ecu_type - if sub_addr is None: + # Add first sub-address to parallel queries since there will be no conflicts + sub_addr_in_parallel_addrs = any(p[2] is not None for p in parallel_addrs) + if sub_addr is None or not sub_addr_in_parallel_addrs: if a not in parallel_addrs: parallel_addrs.append(a) else: - if [a] not in addrs: + if [a] not in addrs and a not in parallel_addrs: addrs.append([a]) addrs.insert(0, parallel_addrs) diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 883a72897c..47b194bcf8 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -206,7 +206,7 @@ class TestFwFingerprintTiming(unittest.TestCase): def test_startup_timing(self): # Tests worse-case VIN query time and typical present ECU query time vin_ref_time = 1.0 - present_ecu_ref_time = 0.8 + present_ecu_ref_time = 0.7 fake_socket = FakeSocket() present_ecu_time = 0.0 @@ -225,7 +225,7 @@ class TestFwFingerprintTiming(unittest.TestCase): print(f'get_vin, query time={vin_time / self.N} seconds') def test_fw_query_timing(self): - total_ref_time = 6.1 + total_ref_time = 5.9 brand_ref_times = { 1: { 'body': 0.1, @@ -237,7 +237,7 @@ class TestFwFingerprintTiming(unittest.TestCase): 'nissan': 0.4, 'subaru': 0.2, 'tesla': 0.2, - 'toyota': 1.6, + 'toyota': 1.4, 'volkswagen': 0.2, }, 2: { From 365bdd342200b5348370de418a652301da2e3949 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 23 Aug 2023 01:41:28 -0700 Subject: [PATCH 089/159] Revert "FW query: query one sub-address in parallel" (#29550) Revert "FW query: query one sub-address in parallel (#28675)" This reverts commit 861ceb2feeb8e9f303b96c0e7a9ef19c5423938d. --- selfdrive/car/fw_versions.py | 12 ++++-------- selfdrive/car/tests/test_fw_fingerprint.py | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 9b4b5d6a33..45c4967cb8 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -185,13 +185,11 @@ def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[EcuAddrBusType]: if len(r.whitelist_ecus) == 0 or ecu_type in r.whitelist_ecus: a = (addr, sub_addr, r.bus) # Build set of queries - # Add first sub-address to parallel queries since there will be no conflicts - sub_addr_in_parallel_addrs = any(p[1] is not None for p in parallel_queries[r.obd_multiplexing]) - if sub_addr is None or not sub_addr_in_parallel_addrs: + if sub_addr is None: if a not in parallel_queries[r.obd_multiplexing]: parallel_queries[r.obd_multiplexing].append(a) else: # subaddresses must be queried one by one - if [a] not in queries[r.obd_multiplexing] and a not in parallel_queries[r.obd_multiplexing]: + if [a] not in queries[r.obd_multiplexing]: queries[r.obd_multiplexing].append([a]) # Build set of expected responses to filter @@ -284,13 +282,11 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1, if a not in ecu_types: ecu_types[a] = ecu_type - # Add first sub-address to parallel queries since there will be no conflicts - sub_addr_in_parallel_addrs = any(p[2] is not None for p in parallel_addrs) - if sub_addr is None or not sub_addr_in_parallel_addrs: + if sub_addr is None: if a not in parallel_addrs: parallel_addrs.append(a) else: - if [a] not in addrs and a not in parallel_addrs: + if [a] not in addrs: addrs.append([a]) addrs.insert(0, parallel_addrs) diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 47b194bcf8..883a72897c 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -206,7 +206,7 @@ class TestFwFingerprintTiming(unittest.TestCase): def test_startup_timing(self): # Tests worse-case VIN query time and typical present ECU query time vin_ref_time = 1.0 - present_ecu_ref_time = 0.7 + present_ecu_ref_time = 0.8 fake_socket = FakeSocket() present_ecu_time = 0.0 @@ -225,7 +225,7 @@ class TestFwFingerprintTiming(unittest.TestCase): print(f'get_vin, query time={vin_time / self.N} seconds') def test_fw_query_timing(self): - total_ref_time = 5.9 + total_ref_time = 6.1 brand_ref_times = { 1: { 'body': 0.1, @@ -237,7 +237,7 @@ class TestFwFingerprintTiming(unittest.TestCase): 'nissan': 0.4, 'subaru': 0.2, 'tesla': 0.2, - 'toyota': 1.4, + 'toyota': 1.6, 'volkswagen': 0.2, }, 2: { From 363740a497620249066522c87ddb03e1362749d4 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 01:13:46 +0800 Subject: [PATCH 090/159] cpplint: add `readability/braces` filter (#29554) --- .pre-commit-config.yaml | 2 +- common/swaglog.h | 2 +- common/util.h | 2 +- selfdrive/boardd/panda_comms.h | 4 ++-- selfdrive/boardd/spi.cc | 2 +- selfdrive/locationd/locationd.cc | 15 +++++---------- selfdrive/ui/qt/maps/map_settings.h | 2 +- selfdrive/ui/qt/offroad/onboarding.h | 4 ++-- selfdrive/ui/qt/onroad.h | 2 +- selfdrive/ui/qt/spinner.cc | 2 +- selfdrive/ui/soundd/sound.cc | 2 +- system/camerad/cameras/camera_qcom2.cc | 2 +- system/camerad/cameras/camera_util.cc | 2 +- system/hardware/base.h | 8 ++++---- system/hardware/pc/hardware.h | 4 ++-- system/hardware/tici/hardware.h | 22 +++++++++++----------- system/loggerd/encoder/encoder.h | 2 +- system/sensord/sensors/sensor.h | 2 +- system/ubloxd/ublox_msg.cc | 3 +-- tools/cabana/streams/abstractstream.h | 2 +- tools/replay/replay.h | 2 +- 21 files changed, 41 insertions(+), 47 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c58654b2d2..65140282ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+readability/braces - repo: local hooks: - id: test_translations diff --git a/common/swaglog.h b/common/swaglog.h index 5a3434d624..06d45b1d98 100644 --- a/common/swaglog.h +++ b/common/swaglog.h @@ -44,7 +44,7 @@ void cloudlog_te(int levelnum, const char* filename, int lineno, const char* fun int __millis = (millis); \ uint64_t __ts = nanos_since_boot(); \ \ - if (!__begin) __begin = __ts; \ + if (!__begin) { __begin = __ts; } \ \ if (__begin + __millis*1000000ULL < __ts) { \ if (__missed) { \ diff --git a/common/util.h b/common/util.h index aaa54d52a2..23c37f153a 100644 --- a/common/util.h +++ b/common/util.h @@ -115,7 +115,7 @@ public: #ifndef __APPLE__ std::signal(SIGPWR, (sighandler_t)set_do_exit); #endif - }; + } inline static std::atomic power_failure = false; inline static std::atomic signal = 0; inline operator bool() { return do_exit; } diff --git a/selfdrive/boardd/panda_comms.h b/selfdrive/boardd/panda_comms.h index c102642e59..e61d25402f 100644 --- a/selfdrive/boardd/panda_comms.h +++ b/selfdrive/boardd/panda_comms.h @@ -20,8 +20,8 @@ // comms base class class PandaCommsHandle { public: - PandaCommsHandle(std::string serial) {}; - virtual ~PandaCommsHandle() {}; + PandaCommsHandle(std::string serial) {} + virtual ~PandaCommsHandle() {} virtual void cleanup() = 0; std::string hw_serial; diff --git a/selfdrive/boardd/spi.cc b/selfdrive/boardd/spi.cc index 1732e902d5..d11e955c49 100644 --- a/selfdrive/boardd/spi.cc +++ b/selfdrive/boardd/spi.cc @@ -43,7 +43,7 @@ public: LockEx(int fd, std::recursive_mutex &m) : fd(fd), m(m) { m.lock(); flock(fd, LOCK_EX); - }; + } ~LockEx() { flock(fd, LOCK_UN); diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 68f16a572e..37fbb6b260 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -240,8 +240,7 @@ void Localizer::handle_sensor(double current_time, const cereal::SensorEventData LOGE("Sensor reading ignored, sensor timestamp more than 100ms off from log time"); this->observation_timings_invalid = true; return; - } - else if (!this->is_timestamp_valid(sensor_time)) { + } else if (!this->is_timestamp_valid(sensor_time)) { this->observation_timings_invalid = true; return; } @@ -258,8 +257,7 @@ void Localizer::handle_sensor(double current_time, const cereal::SensorEventData if (meas.norm() < ROTATION_SANITY_CHECK) { this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_GYRO, { meas }); this->observation_values_invalid["gyroscope"] *= DECAY; - } - else{ + } else { this->observation_values_invalid["gyroscope"] += 1.0; } } @@ -277,8 +275,7 @@ void Localizer::handle_sensor(double current_time, const cereal::SensorEventData if (meas.norm() < ACCEL_SANITY_CHECK) { this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_ACCEL, { meas }); this->observation_values_invalid["accelerometer"] *= DECAY; - } - else{ + } else { this->observation_values_invalid["accelerometer"] += 1.0; } } @@ -414,8 +411,7 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: orientation_reset &= !this->standstill; if (orientation_reset) { this->orientation_reset_count++; - } - else { + } else { this->orientation_reset_count = 0; } @@ -649,8 +645,7 @@ void Localizer::determine_gps_mode(double current_time) { if (this->gps_mode){ this->gps_mode = false; this->reset_kalman(current_time); - } - else{ + } else { this->input_fake_gps_observations(current_time); } } diff --git a/selfdrive/ui/qt/maps/map_settings.h b/selfdrive/ui/qt/maps/map_settings.h index bfffd9206d..ffec1f980f 100644 --- a/selfdrive/ui/qt/maps/map_settings.h +++ b/selfdrive/ui/qt/maps/map_settings.h @@ -25,7 +25,7 @@ class NavigationRequest : public QObject { public: static NavigationRequest *instance(); - QJsonArray currentLocations() const { return locations; }; + QJsonArray currentLocations() const { return locations; } signals: void locationsUpdated(const QJsonArray &locations); diff --git a/selfdrive/ui/qt/offroad/onboarding.h b/selfdrive/ui/qt/offroad/onboarding.h index 2fdae35de0..a1b6895ba0 100644 --- a/selfdrive/ui/qt/offroad/onboarding.h +++ b/selfdrive/ui/qt/offroad/onboarding.h @@ -63,7 +63,7 @@ class TermsPage : public QFrame { Q_OBJECT public: - explicit TermsPage(QWidget *parent = 0) : QFrame(parent) {}; + explicit TermsPage(QWidget *parent = 0) : QFrame(parent) {} public slots: void enableAccept(); @@ -82,7 +82,7 @@ class DeclinePage : public QFrame { Q_OBJECT public: - explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {}; + explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {} private: void showEvent(QShowEvent *event) override; diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 778322ed08..1975ec9f01 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -18,7 +18,7 @@ class OnroadAlerts : public QWidget { Q_OBJECT public: - OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {}; + OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {} void updateAlert(const Alert &a); protected: diff --git a/selfdrive/ui/qt/spinner.cc b/selfdrive/ui/qt/spinner.cc index 8f13576fb2..73a0f5014e 100644 --- a/selfdrive/ui/qt/spinner.cc +++ b/selfdrive/ui/qt/spinner.cc @@ -93,7 +93,7 @@ Spinner::Spinner(QWidget *parent) : QWidget(parent) { notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read); QObject::connect(notifier, &QSocketNotifier::activated, this, &Spinner::update); -}; +} void Spinner::update(int n) { std::string line; diff --git a/selfdrive/ui/soundd/sound.cc b/selfdrive/ui/soundd/sound.cc index ae06e3e903..d3c6486023 100644 --- a/selfdrive/ui/soundd/sound.cc +++ b/selfdrive/ui/soundd/sound.cc @@ -27,7 +27,7 @@ Sound::Sound(QObject *parent) : sm({"controlsState", "microphone"}) { QTimer *timer = new QTimer(this); QObject::connect(timer, &QTimer::timeout, this, &Sound::update); timer->start(1000 / UI_FREQ); -}; +} void Sound::update() { sm.update(0); diff --git a/system/camerad/cameras/camera_qcom2.cc b/system/camerad/cameras/camera_qcom2.cc index 1480342ee3..df70b7983d 100644 --- a/system/camerad/cameras/camera_qcom2.cc +++ b/system/camerad/cameras/camera_qcom2.cc @@ -194,7 +194,7 @@ static cam_cmd_power *power_set_wait(cam_cmd_power *power, int16_t delay_ms) { unconditional_wait->delay = delay_ms; unconditional_wait->op_code = CAMERA_SENSOR_WAIT_OP_SW_UCND; return (struct cam_cmd_power *)(unconditional_wait + 1); -}; +} int CameraState::sensors_init() { uint32_t cam_packet_handle = 0; diff --git a/system/camerad/cameras/camera_util.cc b/system/camerad/cameras/camera_util.cc index 5e8640e99a..74c81a878a 100644 --- a/system/camerad/cameras/camera_util.cc +++ b/system/camerad/cameras/camera_util.cc @@ -37,7 +37,7 @@ std::optional device_acquire(int fd, int32_t session_handle, void *data }; int err = do_cam_control(fd, CAM_ACQUIRE_DEV, &cmd, sizeof(cmd)); return err == 0 ? std::make_optional(cmd.dev_handle) : std::nullopt; -}; +} int device_config(int fd, int32_t session_handle, int32_t dev_handle, uint64_t packet_handle) { struct cam_config_dev_cmd cmd = { diff --git a/system/hardware/base.h b/system/hardware/base.h index 5460099723..2096e1e0bb 100644 --- a/system/hardware/base.h +++ b/system/hardware/base.h @@ -11,10 +11,10 @@ public: static constexpr float MIN_VOLUME = 0.2; static std::string get_os_version() { return ""; } - static std::string get_name() { return ""; }; - static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::UNKNOWN; }; - static int get_voltage() { return 0; }; - static int get_current() { return 0; }; + static std::string get_name() { return ""; } + static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::UNKNOWN; } + static int get_voltage() { return 0; } + static int get_current() { return 0; } static std::string get_serial() { return "cccccc"; } diff --git a/system/hardware/pc/hardware.h b/system/hardware/pc/hardware.h index 529b4bfe9d..84fb3bd89e 100644 --- a/system/hardware/pc/hardware.h +++ b/system/hardware/pc/hardware.h @@ -5,8 +5,8 @@ class HardwarePC : public HardwareNone { public: static std::string get_os_version() { return "openpilot for PC"; } - static std::string get_name() { return "pc"; }; - static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::PC; }; + static std::string get_name() { return "pc"; } + static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::PC; } static bool PC() { return true; } static bool TICI() { return util::getenv("TICI", 0) == 1; } static bool AGNOS() { return util::getenv("TICI", 0) == 1; } diff --git a/system/hardware/tici/hardware.h b/system/hardware/tici/hardware.h index 580dc83eec..82648ac984 100644 --- a/system/hardware/tici/hardware.h +++ b/system/hardware/tici/hardware.h @@ -15,19 +15,19 @@ public: static bool AGNOS() { return true; } static std::string get_os_version() { return "AGNOS " + util::read_file("/VERSION"); - }; + } static std::string get_name() { std::string devicetree_model = util::read_file("/sys/firmware/devicetree/base/model"); return (devicetree_model.find("tizi") != std::string::npos) ? "tizi" : "tici"; - }; + } static cereal::InitData::DeviceType get_device_type() { return (get_name() == "tizi") ? cereal::InitData::DeviceType::TIZI : cereal::InitData::DeviceType::TICI; - }; + } - static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); }; - static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); }; + static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); } + static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); } static std::string get_serial() { static std::string serial(""); @@ -47,8 +47,8 @@ public: return serial; } - static void reboot() { std::system("sudo reboot"); }; - static void poweroff() { std::system("sudo poweroff"); }; + static void reboot() { std::system("sudo reboot"); } + static void poweroff() { std::system("sudo poweroff"); } static void set_brightness(int percent) { std::string max = util::read_file("/sys/class/backlight/panel0-backlight/max_brightness"); @@ -57,14 +57,14 @@ public: brightness_control << (int)(percent * (std::stof(max)/100.)) << "\n"; brightness_control.close(); } - }; + } static void set_display_power(bool on) { std::ofstream bl_power_control("/sys/class/backlight/panel0-backlight/bl_power"); if (bl_power_control.is_open()) { bl_power_control << (on ? "0" : "4") << "\n"; bl_power_control.close(); } - }; + } static void set_volume(float volume) { volume = util::map_val(volume, 0.f, 1.f, MIN_VOLUME, MAX_VOLUME); @@ -99,6 +99,6 @@ public: return ret; } - static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); }; - static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); }; + static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); } + static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); } }; diff --git a/system/loggerd/encoder/encoder.h b/system/loggerd/encoder/encoder.h index 59ec4357ae..bf70775b7c 100644 --- a/system/loggerd/encoder/encoder.h +++ b/system/loggerd/encoder/encoder.h @@ -15,7 +15,7 @@ class VideoEncoder { public: VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height); - virtual ~VideoEncoder() {}; + virtual ~VideoEncoder() {} virtual int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra) = 0; virtual void encoder_open(const char* path) = 0; virtual void encoder_close() = 0; diff --git a/system/sensord/sensors/sensor.h b/system/sensord/sensors/sensor.h index 603aa3586e..2557155229 100644 --- a/system/sensord/sensors/sensor.h +++ b/system/sensord/sensors/sensor.h @@ -6,7 +6,7 @@ class Sensor { public: int gpio_fd = -1; uint64_t init_delay = 500e6; // default dealy 500ms - virtual ~Sensor() {}; + virtual ~Sensor() {} virtual int init() = 0; virtual bool get_event(MessageBuilder &msg, uint64_t ts = 0) = 0; virtual bool has_interrupt_enabled() = 0; diff --git a/system/ubloxd/ublox_msg.cc b/system/ubloxd/ublox_msg.cc index 7cecf58bed..02993a574d 100644 --- a/system/ubloxd/ublox_msg.cc +++ b/system/ubloxd/ublox_msg.cc @@ -295,8 +295,7 @@ kj::Array UbloxMsgParser::parse_glonass_ephemeris(ubx_t::rxm_sfrbx_ continue; if (glonass_string_superframes[msg->freq_id()][i] == 0 || gl_string.superframe_number() == 0) { superframe_unknown = true; - } - else if (glonass_string_superframes[msg->freq_id()][i] != gl_string.superframe_number()) { + } else if (glonass_string_superframes[msg->freq_id()][i] != gl_string.superframe_number()) { needs_clear = true; } // Check if string times add up to being from the same frame diff --git a/tools/cabana/streams/abstractstream.h b/tools/cabana/streams/abstractstream.h index fb42a58e24..21885d742b 100644 --- a/tools/cabana/streams/abstractstream.h +++ b/tools/cabana/streams/abstractstream.h @@ -39,7 +39,7 @@ class AbstractStream : public QObject { public: AbstractStream(QObject *parent); - virtual ~AbstractStream() {}; + virtual ~AbstractStream() {} virtual void start() = 0; inline bool liveStreaming() const { return route() == nullptr; } virtual void seekTo(double ts) {} diff --git a/tools/replay/replay.h b/tools/replay/replay.h index a9a6bfd910..1792702957 100644 --- a/tools/replay/replay.h +++ b/tools/replay/replay.h @@ -72,7 +72,7 @@ public: inline void setSpeed(float speed) { speed_ = speed; } inline float getSpeed() const { return speed_; } inline const std::vector *events() const { return events_.get(); } - inline const std::map> &segments() const { return segments_; }; + inline const std::map> &segments() const { return segments_; } inline const std::string &carFingerprint() const { return car_fingerprint_; } inline const std::vector> getTimeline() { std::lock_guard lk(timeline_lock); From 659795b1db85636a2f97eba7616159047bf0c6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Wed, 23 Aug 2023 10:26:38 -0700 Subject: [PATCH 091/159] devcontainer: handle hosts without X11 (#29537) * Setup xauthority link on host in initializeCommand * Create a dummy xauthority if it does no exist on host machine * Remove xauthority line from ci test --- .devcontainer/.gitignore | 1 + .devcontainer/devcontainer.json | 3 ++- .devcontainer/setup_host.sh | 16 ++++++++++++++++ .github/workflows/tools_tests.yaml | 4 +--- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/.gitignore create mode 100755 .devcontainer/setup_host.sh diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore new file mode 100644 index 0000000000..1f8ec242b8 --- /dev/null +++ b/.devcontainer/.gitignore @@ -0,0 +1 @@ +.Xauthority \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c2d26fb9a7..7c4d53960e 100755 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,6 +5,7 @@ }, "postCreateCommand": "bash -c 'if [[ $DISPLAY == *xquartz* ]]; then echo \"export DISPLAY=host.docker.internal:0\" >> /root/.bashrc; fi'", "postStartCommand": "git config --file .gitmodules --get-regexp path | awk '{ print $2 }' | xargs -I{} git config --global --add safe.directory \"$PWD/{}\"", + "initializeCommand": ".devcontainer/setup_host.sh", "privileged": true, "containerEnv": { "DISPLAY": "${localEnv:DISPLAY}", @@ -13,7 +14,7 @@ }, "runArgs": [ "--volume=/tmp/.X11-unix:/tmp/.X11-unix", - "--volume=${localEnv:XAUTHORITY}:/root/.Xauthority", + "--volume=${localWorkspaceFolder}/.devcontainer/.Xauthority:/root/.Xauthority", "--volume=${localEnv:HOME}/.comma:/root/.comma", "--volume=/tmp/comma_download_cache:/tmp/comma_download_cache", "--volume=/tmp/devcontainer_scons_cache:/tmp/scons_cache", diff --git a/.devcontainer/setup_host.sh b/.devcontainer/setup_host.sh new file mode 100755 index 0000000000..5c3c5e900c --- /dev/null +++ b/.devcontainer/setup_host.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# setup links to Xauthority +XAUTHORITY_LINK=".devcontainer/.Xauthority" +rm -f $XAUTHORITY_LINK +if [[ -z $XAUTHORITY ]]; then + echo "XAUTHORITY not set. Fallback to ~/.Xauthority ..." + if ! [[ -f $HOME/.Xauthority ]]; then + echo "~/.XAuthority file does not exist. GUI tools may not work properly." + touch $XAUTHORITY_LINK # dummy file to satisfy container volume mount + else + ln -sf $HOME/.Xauthority $XAUTHORITY_LINK + fi +else + ln -sf $XAUTHORITY $XAUTHORITY_LINK +fi diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index dff2a4b04d..04f73d21af 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -105,8 +105,6 @@ jobs: - name: Build dev container image run: devcontainer build --workspace-folder . - name: Run dev container - run: | - export XAUTHORITY="$HOME/.Xauthority" - devcontainer up --workspace-folder . + run: devcontainer up --workspace-folder . - name: Test environment run: devcontainer exec --workspace-folder . scons --dry-run From 2b0e4d46bbbb0ccbf028c975c3345d05765a7213 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 23 Aug 2023 19:50:11 +0200 Subject: [PATCH 092/159] cabana: socketcan support (#27952) * empty socketcan class * works on linux with vcan * add open stream widget * fix MacOS build * update readme * unused * no socketcan on C3 * fix in cabana sconstruct * serial -> device --- tools/cabana/README.md | 1 + tools/cabana/SConscript | 4 +- tools/cabana/cabana.cc | 8 ++ tools/cabana/streams/abstractstream.h | 6 ++ tools/cabana/streams/pandastream.h | 6 -- tools/cabana/streams/socketcanstream.cc | 115 ++++++++++++++++++++++++ tools/cabana/streams/socketcanstream.h | 50 +++++++++++ tools/cabana/streamselector.cc | 5 ++ tools/install_ubuntu_dependencies.sh | 1 + 9 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 tools/cabana/streams/socketcanstream.cc create mode 100644 tools/cabana/streams/socketcanstream.h diff --git a/tools/cabana/README.md b/tools/cabana/README.md index cfda056636..53723ef8a6 100644 --- a/tools/cabana/README.md +++ b/tools/cabana/README.md @@ -17,6 +17,7 @@ Options: --stream read can messages from live streaming --panda read can messages from panda --panda-serial read can messages from panda with given serial + --socketcan read can messages from given SocketCAN device --zmq the ip address on which to receive zmq messages --data_dir local directory with routes diff --git a/tools/cabana/SConscript b/tools/cabana/SConscript index c6b47630ef..a713b612fc 100644 --- a/tools/cabana/SConscript +++ b/tools/cabana/SConscript @@ -9,9 +9,11 @@ base_libs = [common, messaging, cereal, visionipc, transformations, 'zmq', if arch == "Darwin": base_frameworks.append('OpenCL') base_frameworks.append('QtCharts') + base_frameworks.append('QtSerialBus') else: base_libs.append('OpenCL') base_libs.append('Qt5Charts') + base_libs.append('Qt5SerialBus') qt_libs = ['qt_util'] + base_libs @@ -27,7 +29,7 @@ assets_src = "assets/assets.qrc" cabana_env.Command(assets, assets_src, f"rcc $SOURCES -o $TARGET") cabana_env.Depends(assets, Glob('/assets/*', exclude=[assets, assets_src, "assets/assets.o"])) -cabana_lib = cabana_env.Library("cabana_lib", ['mainwin.cc', 'streams/pandastream.cc', 'streams/devicestream.cc', 'streams/livestream.cc', 'streams/abstractstream.cc', 'streams/replaystream.cc', 'binaryview.cc', 'historylog.cc', 'videowidget.cc', 'signalview.cc', +cabana_lib = cabana_env.Library("cabana_lib", ['mainwin.cc', 'streams/socketcanstream.cc', 'streams/pandastream.cc', 'streams/devicestream.cc', 'streams/livestream.cc', 'streams/abstractstream.cc', 'streams/replaystream.cc', 'binaryview.cc', 'historylog.cc', 'videowidget.cc', 'signalview.cc', 'dbc/dbc.cc', 'dbc/dbcfile.cc', 'dbc/dbcmanager.cc', 'chart/chartswidget.cc', 'chart/chart.cc', 'chart/signalselector.cc', 'chart/tiplabel.cc', 'chart/sparkline.cc', 'commands.cc', 'messageswidget.cc', 'streamselector.cc', 'settings.cc', 'util.cc', 'detailwidget.cc', 'tools/findsimilarbits.cc', 'tools/findsignal.cc'], LIBS=cabana_libs, FRAMEWORKS=base_frameworks) diff --git a/tools/cabana/cabana.cc b/tools/cabana/cabana.cc index 49b8fcf6ca..7d3e6ab99f 100644 --- a/tools/cabana/cabana.cc +++ b/tools/cabana/cabana.cc @@ -7,6 +7,7 @@ #include "tools/cabana/streams/devicestream.h" #include "tools/cabana/streams/pandastream.h" #include "tools/cabana/streams/replaystream.h" +#include "tools/cabana/streams/socketcanstream.h" int main(int argc, char *argv[]) { QCoreApplication::setApplicationName("Cabana"); @@ -28,6 +29,9 @@ int main(int argc, char *argv[]) { cmd_parser.addOption({"stream", "read can messages from live streaming"}); cmd_parser.addOption({"panda", "read can messages from panda"}); cmd_parser.addOption({"panda-serial", "read can messages from panda with given serial", "panda-serial"}); + if (SocketCanStream::available()) { + cmd_parser.addOption({"socketcan", "read can messages from given SocketCAN device", "socketcan"}); + } cmd_parser.addOption({"zmq", "the ip address on which to receive zmq messages", "zmq"}); cmd_parser.addOption({"data_dir", "local directory with routes", "data_dir"}); cmd_parser.addOption({"no-vipc", "do not output video"}); @@ -50,6 +54,10 @@ int main(int argc, char *argv[]) { qWarning() << e.what(); return 0; } + } else if (cmd_parser.isSet("socketcan")) { + SocketCanStreamConfig config = {}; + config.device = cmd_parser.value("socketcan"); + stream = new SocketCanStream(&app, config); } else { uint32_t replay_flags = REPLAY_FLAG_NONE; if (cmd_parser.isSet("ecam")) { diff --git a/tools/cabana/streams/abstractstream.h b/tools/cabana/streams/abstractstream.h index 21885d742b..5cafa58cb8 100644 --- a/tools/cabana/streams/abstractstream.h +++ b/tools/cabana/streams/abstractstream.h @@ -34,6 +34,12 @@ struct CanEvent { uint8_t dat[]; }; +struct BusConfig { + int can_speed_kbps = 500; + int data_speed_kbps = 2000; + bool can_fd = false; +}; + class AbstractStream : public QObject { Q_OBJECT diff --git a/tools/cabana/streams/pandastream.h b/tools/cabana/streams/pandastream.h index f726c5cfb6..49e1836c2d 100644 --- a/tools/cabana/streams/pandastream.h +++ b/tools/cabana/streams/pandastream.h @@ -10,12 +10,6 @@ const uint32_t speeds[] = {10U, 20U, 50U, 100U, 125U, 250U, 500U, 1000U}; const uint32_t data_speeds[] = {10U, 20U, 50U, 100U, 125U, 250U, 500U, 1000U, 2000U, 5000U}; -struct BusConfig { - int can_speed_kbps = 500; - int data_speed_kbps = 2000; - bool can_fd = false; -}; - struct PandaStreamConfig { QString serial = ""; std::vector bus_config; diff --git a/tools/cabana/streams/socketcanstream.cc b/tools/cabana/streams/socketcanstream.cc new file mode 100644 index 0000000000..d5f9d115f2 --- /dev/null +++ b/tools/cabana/streams/socketcanstream.cc @@ -0,0 +1,115 @@ +#include "tools/cabana/streams/socketcanstream.h" +#include "socketcanstream.h" + +#include +#include +#include + +SocketCanStream::SocketCanStream(QObject *parent, SocketCanStreamConfig config_) : config(config_), LiveStream(parent) { + if (!available()) { + throw std::runtime_error("SocketCAN plugin not available"); + } + + qDebug() << "Connecting to SocketCAN device" << config.device; + if (!connect()) { + throw std::runtime_error("Failed to connect to SocketCAN device"); + } +} + +bool SocketCanStream::available() { + return QCanBus::instance()->plugins().contains("socketcan"); +} + +bool SocketCanStream::connect() { + // Connecting might generate some warnings about missing socketcan/libsocketcan libraries + // These are expected and can be ignored, we don't need the advanced features of libsocketcan + QString errorString; + device.reset(QCanBus::instance()->createDevice("socketcan", config.device, &errorString)); + + if (!device) { + qDebug() << "Failed to create SocketCAN device" << errorString; + return false; + } + + if (!device->connectDevice()) { + qDebug() << "Failed to connect to device"; + return false; + } + + return true; +} + +void SocketCanStream::streamThread() { + while (!QThread::currentThread()->isInterruptionRequested()) { + QThread::msleep(1); + + auto frames = device->readAllFrames(); + if (frames.size() == 0) continue; + + MessageBuilder msg; + auto evt = msg.initEvent(); + auto canData = evt.initCan(frames.size()); + + + for (uint i = 0; i < frames.size(); i++) { + if (!frames[i].isValid()) continue; + + canData[i].setAddress(frames[i].frameId()); + canData[i].setSrc(0); + + auto payload = frames[i].payload(); + canData[i].setDat(kj::arrayPtr((uint8_t*)payload.data(), payload.size())); + } + + auto bytes = msg.toBytes(); + handleEvent((const char*)bytes.begin(), bytes.size()); + } +} + +AbstractOpenStreamWidget *SocketCanStream::widget(AbstractStream **stream) { + return new OpenSocketCanWidget(stream); +} + +OpenSocketCanWidget::OpenSocketCanWidget(AbstractStream **stream) : AbstractOpenStreamWidget(stream) { + QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout->addStretch(1); + + QFormLayout *form_layout = new QFormLayout(); + + QHBoxLayout *device_layout = new QHBoxLayout(); + device_edit = new QComboBox(); + device_edit->setFixedWidth(300); + device_layout->addWidget(device_edit); + + QPushButton *refresh = new QPushButton(tr("Refresh")); + refresh->setFixedWidth(100); + device_layout->addWidget(refresh); + form_layout->addRow(tr("Device"), device_layout); + main_layout->addLayout(form_layout); + + main_layout->addStretch(1); + + QObject::connect(refresh, &QPushButton::clicked, this, &OpenSocketCanWidget::refreshDevices); + QObject::connect(device_edit, &QComboBox::currentTextChanged, this, [=]{ config.device = device_edit->currentText(); }); + + // Populate devices + refreshDevices(); +} + +void OpenSocketCanWidget::refreshDevices() { + device_edit->clear(); + for (auto device : QCanBus::instance()->availableDevices(QStringLiteral("socketcan"))) { + device_edit->addItem(device.name()); + } +} + + +bool OpenSocketCanWidget::open() { + try { + *stream = new SocketCanStream(qApp, config); + } catch (std::exception &e) { + QMessageBox::warning(nullptr, tr("Warning"), tr("Failed to connect to SocketCAN device: '%1'").arg(e.what())); + return false; + } + return true; +} diff --git a/tools/cabana/streams/socketcanstream.h b/tools/cabana/streams/socketcanstream.h new file mode 100644 index 0000000000..9d34aaebac --- /dev/null +++ b/tools/cabana/streams/socketcanstream.h @@ -0,0 +1,50 @@ +#pragma once + +#include +#include +#include + +#include +#include +#include + +#include "tools/cabana/streams/livestream.h" + +struct SocketCanStreamConfig { + QString device = ""; // TODO: support multiple devices/buses at once +}; + +class SocketCanStream : public LiveStream { + Q_OBJECT +public: + SocketCanStream(QObject *parent, SocketCanStreamConfig config_ = {}); + static AbstractOpenStreamWidget *widget(AbstractStream **stream); + + static bool available(); + + inline QString routeName() const override { + return QString("Live Streaming From Socket CAN %1").arg(config.device); + } + +protected: + void streamThread() override; + bool connect(); + + SocketCanStreamConfig config = {}; + std::unique_ptr device; +}; + +class OpenSocketCanWidget : public AbstractOpenStreamWidget { + Q_OBJECT + +public: + OpenSocketCanWidget(AbstractStream **stream); + bool open() override; + QString title() override { return tr("&SocketCAN"); } + +private: + void refreshDevices(); + + QComboBox *device_edit; + SocketCanStreamConfig config = {}; +}; diff --git a/tools/cabana/streamselector.cc b/tools/cabana/streamselector.cc index 6da44ecd1a..719ba72920 100644 --- a/tools/cabana/streamselector.cc +++ b/tools/cabana/streamselector.cc @@ -6,9 +6,11 @@ #include #include +#include "streams/socketcanstream.h" #include "tools/cabana/streams/devicestream.h" #include "tools/cabana/streams/pandastream.h" #include "tools/cabana/streams/replaystream.h" +#include "tools/cabana/streams/socketcanstream.h" StreamSelector::StreamSelector(AbstractStream **stream, QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Open stream")); @@ -40,6 +42,9 @@ StreamSelector::StreamSelector(AbstractStream **stream, QWidget *parent) : QDial addStreamWidget(ReplayStream::widget(stream)); addStreamWidget(PandaStream::widget(stream)); + if (SocketCanStream::available()) { + addStreamWidget(SocketCanStream::widget(stream)); + } addStreamWidget(DeviceStream::widget(stream)); QObject::connect(btn_box, &QDialogButtonBox::rejected, this, &QDialog::reject); diff --git a/tools/install_ubuntu_dependencies.sh b/tools/install_ubuntu_dependencies.sh index 6214452870..78a01f2b75 100755 --- a/tools/install_ubuntu_dependencies.sh +++ b/tools/install_ubuntu_dependencies.sh @@ -73,6 +73,7 @@ function install_ubuntu_common_requirements() { libqt5sql5-sqlite \ libqt5svg5-dev \ libqt5charts5-dev \ + libqt5serialbus5-dev \ libqt5x11extras5-dev \ libreadline-dev \ libdw1 \ From 6a66b7555679c5cd3511e03ba6e1cb528706f84e Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 23 Aug 2023 12:58:09 -0700 Subject: [PATCH 093/159] sensord: setup per-sensor threads (#29558) * sensord: setup per-sensor threads * revert cereal * more cleanup * bump cereal * update test --------- Co-authored-by: Comma Device --- cereal | 2 +- system/sensord/sensors/lsm6ds3_accel.cc | 2 +- system/sensord/sensors/sensor.h | 8 +- system/sensord/sensors_qcom2.cc | 145 +++++++++--------------- system/sensord/tests/test_sensord.py | 2 +- 5 files changed, 65 insertions(+), 94 deletions(-) diff --git a/cereal b/cereal index e7c42fd11c..736a4cce2c 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit e7c42fd11cc71f16ac762e6aed3409ce4c644b42 +Subproject commit 736a4cce2c51cb73465e88dae6ff4cec5b9c3b43 diff --git a/system/sensord/sensors/lsm6ds3_accel.cc b/system/sensord/sensors/lsm6ds3_accel.cc index 2a09702c96..139b5df67a 100644 --- a/system/sensord/sensors/lsm6ds3_accel.cc +++ b/system/sensord/sensors/lsm6ds3_accel.cc @@ -121,7 +121,7 @@ int LSM6DS3_Accel::init() { uint8_t value = 0; bool do_self_test = false; - const char* env_lsm_selftest =env_lsm_selftest = std::getenv("LSM_SELF_TEST"); + const char* env_lsm_selftest = std::getenv("LSM_SELF_TEST"); if (env_lsm_selftest != nullptr && strncmp(env_lsm_selftest, "1", 1) == 0) { do_self_test = true; } diff --git a/system/sensord/sensors/sensor.h b/system/sensord/sensors/sensor.h index 2557155229..1b0e3be0dc 100644 --- a/system/sensord/sensors/sensor.h +++ b/system/sensord/sensors/sensor.h @@ -5,6 +5,7 @@ class Sensor { public: int gpio_fd = -1; + uint64_t start_ts = 0; uint64_t init_delay = 500e6; // default dealy 500ms virtual ~Sensor() {} virtual int init() = 0; @@ -12,7 +13,10 @@ public: virtual bool has_interrupt_enabled() = 0; virtual int shutdown() = 0; - virtual bool is_data_valid(uint64_t st, uint64_t ct) { - return (ct - st) > init_delay; + virtual bool is_data_valid(uint64_t current_ts) { + if (start_ts == 0) { + start_ts = current_ts; + } + return (current_ts - start_ts) > init_delay; } }; diff --git a/system/sensord/sensors_qcom2.cc b/system/sensord/sensors_qcom2.cc index 9276a029c3..313dc50095 100644 --- a/system/sensord/sensors_qcom2.cc +++ b/system/sensord/sensors_qcom2.cc @@ -22,19 +22,22 @@ #include "system/sensord/sensors/lsm6ds3_gyro.h" #include "system/sensord/sensors/lsm6ds3_temp.h" #include "system/sensord/sensors/mmc5603nj_magn.h" -#include "system/sensord/sensors/sensor.h" #define I2C_BUS_IMU 1 ExitHandler do_exit; -uint64_t init_ts = 0; -void interrupt_loop(std::vector& sensors, - std::map& sensor_service) -{ - PubMaster pm_int({"gyroscope", "accelerometer"}); +void interrupt_loop(std::vector> sensors) { + PubMaster pm({"gyroscope", "accelerometer"}); + + int fd = -1; + for (auto &[sensor, msg_name, required, polling_freq] : sensors) { + if (sensor->has_interrupt_enabled()) { + fd = sensor->gpio_fd; + break; + } + } - int fd = sensors[0]->gpio_fd; struct pollfd fd_list[1] = {0}; fd_list[0].fd = fd; fd_list[0].events = POLLIN | POLLPRI; @@ -68,90 +71,76 @@ void interrupt_loop(std::vector& sensors, uint64_t offset = nanos_since_epoch() - nanos_since_boot(); uint64_t ts = evdata[num_events - 1].timestamp - offset; - for (Sensor *sensor : sensors) { + for (auto &[sensor, msg_name, required, polling_freq] : sensors) { + if (!sensor->has_interrupt_enabled()) { + continue; + } + MessageBuilder msg; if (!sensor->get_event(msg, ts)) { continue; } - if (!sensor->is_data_valid(init_ts, ts)) { + if (!sensor->is_data_valid(ts)) { continue; } - pm_int.send(sensor_service[sensor].c_str(), msg); + pm.send(msg_name.c_str(), msg); } } // poweroff sensors, disable interrupts - for (Sensor *sensor : sensors) { - sensor->shutdown(); + for (auto &[sensor, msg_name, required, polling_freq] : sensors) { + if (sensor->has_interrupt_enabled()) { + sensor->shutdown(); + } } } -int sensor_loop(I2CBus *i2c_bus_imu) { - BMX055_Accel bmx055_accel(i2c_bus_imu); - BMX055_Gyro bmx055_gyro(i2c_bus_imu); - BMX055_Magn bmx055_magn(i2c_bus_imu); - BMX055_Temp bmx055_temp(i2c_bus_imu); - - LSM6DS3_Accel lsm6ds3_accel(i2c_bus_imu, GPIO_LSM_INT); - LSM6DS3_Gyro lsm6ds3_gyro(i2c_bus_imu, GPIO_LSM_INT, true); // GPIO shared with accel - LSM6DS3_Temp lsm6ds3_temp(i2c_bus_imu); - - MMC5603NJ_Magn mmc5603nj_magn(i2c_bus_imu); - - std::map sensor_service = { - {&bmx055_accel, "accelerometer2"}, - {&bmx055_gyro, "gyroscope2"}, - {&bmx055_magn, "magnetometer"}, - {&bmx055_temp, "temperatureSensor"}, - - {&lsm6ds3_accel, "accelerometer"}, - {&lsm6ds3_gyro, "gyroscope"}, - {&lsm6ds3_temp, "temperatureSensor"}, +void polling_loop(Sensor *sensor, std::string msg_name, int frequency) { + PubMaster pm({msg_name.c_str()}); + RateKeeper rk(msg_name, frequency); + while (!do_exit) { + MessageBuilder msg; + if (sensor->get_event(msg) && sensor->is_data_valid(nanos_since_boot())) { + pm.send(msg_name.c_str(), msg); + } + rk.keepTime(); + } - {&mmc5603nj_magn, "magnetometer"}, - }; + sensor->shutdown(); +} +int sensor_loop(I2CBus *i2c_bus_imu) { // Sensor init - std::vector> sensors_init; // Sensor, required - sensors_init.push_back({&bmx055_accel, false}); - sensors_init.push_back({&bmx055_gyro, false}); - sensors_init.push_back({&bmx055_magn, false}); - sensors_init.push_back({&bmx055_temp, false}); - - sensors_init.push_back({&lsm6ds3_accel, true}); - sensors_init.push_back({&lsm6ds3_gyro, true}); - sensors_init.push_back({&lsm6ds3_temp, true}); + std::vector> sensors_init = { + {new BMX055_Accel(i2c_bus_imu), "accelerometer2", false, 100}, + {new BMX055_Gyro(i2c_bus_imu), "gyroscope2", false, 100}, + {new BMX055_Magn(i2c_bus_imu), "magnetometer", false, 100}, + {new BMX055_Temp(i2c_bus_imu), "temperatureSensor2", false, 100}, - sensors_init.push_back({&mmc5603nj_magn, false}); + {new LSM6DS3_Accel(i2c_bus_imu, GPIO_LSM_INT), "accelerometer", true, 100}, + {new LSM6DS3_Gyro(i2c_bus_imu, GPIO_LSM_INT, true), "gyroscope", true, 100}, + {new LSM6DS3_Temp(i2c_bus_imu), "temperatureSensor", true, 100}, - bool has_magnetometer = false; + {new MMC5603NJ_Magn(i2c_bus_imu), "magnetometer", false, 100}, + }; // Initialize sensors - std::vector sensors; - for (auto &[sensor, required] : sensors_init) { + std::vector threads; + for (auto &[sensor, msg_name, required, polling_freq] : sensors_init) { int err = sensor->init(); if (err < 0) { if (required) { LOGE("Error initializing sensors"); return -1; } - } else { - - if (sensor == &bmx055_magn || sensor == &mmc5603nj_magn) { - has_magnetometer = true; - } - - if (!sensor->has_interrupt_enabled()) { - sensors.push_back(sensor); - } + continue; } - } - if (!has_magnetometer) { - LOGE("No magnetometer present"); - return -1; + if (!sensor->has_interrupt_enabled()) { + threads.emplace_back(polling_loop, sensor, msg_name, polling_freq); + } } // increase interrupt quality by pinning interrupt and process to core 1 @@ -159,39 +148,17 @@ int sensor_loop(I2CBus *i2c_bus_imu) { util::set_core_affinity({1}); std::system("sudo su -c 'echo 1 > /proc/irq/336/smp_affinity_list'"); - PubMaster pm_non_int({"gyroscope2", "accelerometer2", "temperatureSensor", "magnetometer"}); - init_ts = nanos_since_boot(); - // thread for reading events via interrupts - std::vector lsm_interrupt_sensors = {&lsm6ds3_accel, &lsm6ds3_gyro}; - std::thread lsm_interrupt_thread(&interrupt_loop, std::ref(lsm_interrupt_sensors), - std::ref(sensor_service)); - - RateKeeper rk("sensord", 100); - - // polling loop for non interrupt handled sensors - while (!do_exit) { - for (Sensor *sensor : sensors) { - MessageBuilder msg; - if (!sensor->get_event(msg)) { - continue; - } + threads.emplace_back(&interrupt_loop, std::ref(sensors_init)); - if (!sensor->is_data_valid(init_ts, nanos_since_boot())) { - continue; - } - - pm_non_int.send(sensor_service[sensor].c_str(), msg); - } - - rk.keepTime(); + // wait for all threads to finish + for (auto &t : threads) { + t.join(); } - for (Sensor *sensor : sensors) { - sensor->shutdown(); + for (auto &[sensor, msg_name, required, polling_freq] : sensors_init) { + delete sensor; } - - lsm_interrupt_thread.join(); return 0; } diff --git a/system/sensord/tests/test_sensord.py b/system/sensord/tests/test_sensord.py index 87ead0bc1b..815dd8b444 100755 --- a/system/sensord/tests/test_sensord.py +++ b/system/sensord/tests/test_sensord.py @@ -71,7 +71,7 @@ def get_irq_count(irq: int): def read_sensor_events(duration_sec): sensor_types = ['accelerometer', 'gyroscope', 'magnetometer', 'accelerometer2', - 'gyroscope2', 'temperatureSensor'] + 'gyroscope2', 'temperatureSensor', 'temperatureSensor2'] esocks = {} events = defaultdict(list) for stype in sensor_types: From aa585b17578a38b294ee748b172e6ad28f8266ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Wed, 23 Aug 2023 13:23:17 -0700 Subject: [PATCH 094/159] Laikad: reset est pos when in bad state (#29559) * reset est pos when cant delay correct * was just for debug --- selfdrive/locationd/laikad.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index 6c9c199db1..42d9303fd6 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -269,6 +269,11 @@ class Laikad: est_pos = self.gnss_kf.x[GStates.ECEF_POS].tolist() correct_delay = False corrected_measurements = correct_measurements(processed_measurements, est_pos, self.astro_dog, correct_delay=correct_delay) + # If many measurements weren't corrected, position may be garbage, so reset + if len(processed_measurements) >= 8 and len(corrected_measurements) < 5: + cloudlog.error("Didn't correct enough measurements, resetting estimate position") + self.last_fix_pos = None + self.last_fix_t = None return corrected_measurements def calc_fix(self, t, measurements): From 2d99521e7500902070d0aacce69528bcfd8b9964 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 04:25:17 +0800 Subject: [PATCH 095/159] cpplint: `build/include_what_you_use` (#29556) * include_what_you_use * remove comments * include --------- Co-authored-by: Adeeb Shihadeh --- .pre-commit-config.yaml | 2 +- common/gpio.cc | 2 ++ common/ratekeeper.cc | 2 ++ common/watchdog.cc | 2 ++ selfdrive/boardd/boardd.cc | 1 + selfdrive/boardd/boardd.h | 3 +++ selfdrive/boardd/panda.cc | 1 + selfdrive/boardd/panda.h | 1 + selfdrive/locationd/locationd.cc | 2 ++ selfdrive/locationd/locationd.h | 1 + selfdrive/locationd/models/live_kf.h | 2 ++ selfdrive/modeld/runners/onnxmodel.h | 2 ++ selfdrive/modeld/runners/snpemodel.cc | 4 ++++ selfdrive/modeld/runners/snpemodel.h | 4 ++++ selfdrive/modeld/runners/thneedmodel.cc | 2 ++ selfdrive/modeld/runners/thneedmodel.h | 2 ++ selfdrive/ui/installer/installer.cc | 1 + selfdrive/ui/qt/api.cc | 2 ++ selfdrive/ui/qt/maps/map_helpers.cc | 4 ++++ selfdrive/ui/qt/maps/map_helpers.h | 2 ++ selfdrive/ui/qt/maps/map_instructions.h | 3 +++ selfdrive/ui/qt/maps/map_settings.cc | 2 ++ selfdrive/ui/qt/maps/map_settings.h | 2 ++ selfdrive/ui/qt/offroad/driverview.cc | 1 + selfdrive/ui/qt/offroad/networking.h | 2 ++ selfdrive/ui/qt/offroad/onboarding.cc | 2 ++ selfdrive/ui/qt/offroad/settings.cc | 2 ++ selfdrive/ui/qt/offroad/settings.h | 3 +++ selfdrive/ui/qt/onroad.cc | 3 +++ selfdrive/ui/qt/onroad.h | 2 ++ selfdrive/ui/qt/setup/setup.cc | 2 ++ selfdrive/ui/qt/sidebar.h | 2 ++ selfdrive/ui/qt/spinner.cc | 1 + selfdrive/ui/qt/util.cc | 4 ++++ selfdrive/ui/qt/util.h | 1 + selfdrive/ui/qt/widgets/cameraview.cc | 3 +++ selfdrive/ui/qt/widgets/cameraview.h | 5 +++++ selfdrive/ui/qt/widgets/controls.h | 3 +++ selfdrive/ui/qt/widgets/keyboard.h | 2 ++ selfdrive/ui/qt/widgets/offroad_alerts.cc | 5 +++++ selfdrive/ui/qt/widgets/offroad_alerts.h | 1 + selfdrive/ui/soundd/sound.h | 2 ++ selfdrive/ui/ui.cc | 1 + selfdrive/ui/ui.h | 1 + system/camerad/cameras/camera_common.cc | 1 + system/camerad/cameras/camera_qcom2.cc | 3 +++ system/hardware/base.h | 3 +++ system/hardware/hw.h | 2 ++ system/hardware/pc/hardware.h | 2 ++ system/hardware/tici/hardware.h | 2 ++ system/loggerd/encoder/encoder.h | 1 + system/loggerd/encoder/v4l_encoder.cc | 1 + system/loggerd/logger.cc | 3 +++ system/loggerd/logger.h | 3 ++- system/loggerd/loggerd.cc | 4 ++++ system/loggerd/loggerd.h | 2 ++ system/sensord/sensors/i2c_sensor.h | 1 + system/ubloxd/ublox_msg.cc | 2 ++ system/ubloxd/ublox_msg.h | 3 ++- tools/cabana/binaryview.cc | 2 ++ tools/cabana/binaryview.h | 3 +++ tools/cabana/chart/chart.cc | 3 +++ tools/cabana/chart/chart.h | 3 +++ tools/cabana/chart/chartswidget.cc | 2 ++ tools/cabana/chart/chartswidget.h | 3 +++ tools/cabana/chart/sparkline.cc | 1 + tools/cabana/chart/sparkline.h | 2 ++ tools/cabana/chart/tiplabel.cc | 2 ++ tools/cabana/commands.h | 2 ++ tools/cabana/dbc/dbc.cc | 2 ++ tools/cabana/dbc/dbc.h | 6 +++++- tools/cabana/dbc/dbcmanager.h | 1 + tools/cabana/historylog.cc | 2 ++ tools/cabana/historylog.h | 2 ++ tools/cabana/mainwin.cc | 3 +++ tools/cabana/messageswidget.cc | 6 ++++++ tools/cabana/messageswidget.h | 4 ++++ tools/cabana/signalview.cc | 2 ++ tools/cabana/signalview.h | 2 ++ tools/cabana/streams/abstractstream.cc | 3 +++ tools/cabana/streams/abstractstream.h | 4 ++++ tools/cabana/streams/devicestream.cc | 3 +++ tools/cabana/streams/livestream.cc | 3 +++ tools/cabana/streams/livestream.h | 4 ++++ tools/cabana/streams/pandastream.cc | 2 ++ tools/cabana/streams/pandastream.h | 3 +++ tools/cabana/streams/replaystream.h | 6 ++++++ tools/cabana/streams/socketcanstream.h | 2 ++ tools/cabana/tools/findsignal.h | 3 +++ tools/cabana/tools/findsimilarbits.cc | 2 ++ tools/cabana/util.cc | 3 +++ tools/cabana/util.h | 2 ++ tools/cabana/videowidget.cc | 5 +++++ tools/cabana/videowidget.h | 4 ++++ tools/replay/camera.h | 4 ++++ tools/replay/consoleui.cc | 6 +++++- tools/replay/framereader.cc | 1 + tools/replay/logreader.h | 3 +++ tools/replay/replay.h | 8 ++++++++ tools/replay/route.cc | 6 ++++-- tools/replay/route.h | 5 +++++ tools/replay/util.cc | 2 ++ 102 files changed, 260 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65140282ee..85e75396ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+readability/braces - repo: local hooks: - id: test_translations diff --git a/common/gpio.cc b/common/gpio.cc index 8a16cd3703..c1805b7bdc 100644 --- a/common/gpio.cc +++ b/common/gpio.cc @@ -1,5 +1,7 @@ #include "common/gpio.h" +#include + #ifdef __APPLE__ int gpio_init(int pin_nr, bool output) { return 0; diff --git a/common/ratekeeper.cc b/common/ratekeeper.cc index c00d72a94a..7e63815168 100644 --- a/common/ratekeeper.cc +++ b/common/ratekeeper.cc @@ -1,5 +1,7 @@ #include "common/ratekeeper.h" +#include + #include "common/swaglog.h" #include "common/timing.h" #include "common/util.h" diff --git a/common/watchdog.cc b/common/watchdog.cc index 920df4030a..3483ad21c2 100644 --- a/common/watchdog.cc +++ b/common/watchdog.cc @@ -1,3 +1,5 @@ +#include + #include "common/watchdog.h" #include "common/util.h" diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 6a19f6d593..b64a81296e 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "cereal/gen/cpp/car.capnp.h" diff --git a/selfdrive/boardd/boardd.h b/selfdrive/boardd/boardd.h index d3c9e1f94a..0646fc6189 100644 --- a/selfdrive/boardd/boardd.h +++ b/selfdrive/boardd/boardd.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "selfdrive/boardd/panda.h" bool safety_setter_thread(std::vector pandas); diff --git a/selfdrive/boardd/panda.cc b/selfdrive/boardd/panda.cc index 8849a46bd8..e075887a4d 100644 --- a/selfdrive/boardd/panda.cc +++ b/selfdrive/boardd/panda.cc @@ -4,6 +4,7 @@ #include #include +#include #include "cereal/messaging/messaging.h" #include "common/swaglog.h" diff --git a/selfdrive/boardd/panda.h b/selfdrive/boardd/panda.h index 5edca04419..9d4b1b2092 100644 --- a/selfdrive/boardd/panda.h +++ b/selfdrive/boardd/panda.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "cereal/gen/cpp/car.capnp.h" diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 37fbb6b260..d79b5c9c44 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -1,7 +1,9 @@ #include #include +#include #include +#include #include "locationd.h" diff --git a/selfdrive/locationd/locationd.h b/selfdrive/locationd/locationd.h index e8f2f04a2c..f7adab3673 100755 --- a/selfdrive/locationd/locationd.h +++ b/selfdrive/locationd/locationd.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/selfdrive/locationd/models/live_kf.h b/selfdrive/locationd/models/live_kf.h index 06ec3854cb..c2f3f37eaf 100755 --- a/selfdrive/locationd/models/live_kf.h +++ b/selfdrive/locationd/models/live_kf.h @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include diff --git a/selfdrive/modeld/runners/onnxmodel.h b/selfdrive/modeld/runners/onnxmodel.h index 6c325f644e..42aa179ce9 100644 --- a/selfdrive/modeld/runners/onnxmodel.h +++ b/selfdrive/modeld/runners/onnxmodel.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "selfdrive/modeld/runners/runmodel.h" class ONNXModel : public RunModel { diff --git a/selfdrive/modeld/runners/snpemodel.cc b/selfdrive/modeld/runners/snpemodel.cc index 441122c522..5ed2d1270e 100644 --- a/selfdrive/modeld/runners/snpemodel.cc +++ b/selfdrive/modeld/runners/snpemodel.cc @@ -3,6 +3,10 @@ #include "selfdrive/modeld/runners/snpemodel.h" #include +#include +#include +#include +#include #include "common/util.h" #include "common/timing.h" diff --git a/selfdrive/modeld/runners/snpemodel.h b/selfdrive/modeld/runners/snpemodel.h index 0ae5a8f820..559b15f8b6 100644 --- a/selfdrive/modeld/runners/snpemodel.h +++ b/selfdrive/modeld/runners/snpemodel.h @@ -1,6 +1,10 @@ #pragma once #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#include +#include +#include + #include #include #include diff --git a/selfdrive/modeld/runners/thneedmodel.cc b/selfdrive/modeld/runners/thneedmodel.cc index 0f35c94800..a16d8b42aa 100644 --- a/selfdrive/modeld/runners/thneedmodel.cc +++ b/selfdrive/modeld/runners/thneedmodel.cc @@ -1,5 +1,7 @@ #include "selfdrive/modeld/runners/thneedmodel.h" +#include + #include "common/swaglog.h" ThneedModel::ThneedModel(const std::string path, float *_output, size_t _output_size, int runtime, bool luse_tf8, cl_context context) { diff --git a/selfdrive/modeld/runners/thneedmodel.h b/selfdrive/modeld/runners/thneedmodel.h index 90c40239bf..6ed479c081 100644 --- a/selfdrive/modeld/runners/thneedmodel.h +++ b/selfdrive/modeld/runners/thneedmodel.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "selfdrive/modeld/runners/runmodel.h" #include "selfdrive/modeld/thneed/thneed.h" diff --git a/selfdrive/ui/installer/installer.cc b/selfdrive/ui/installer/installer.cc index 1af72c04df..179ce60c63 100644 --- a/selfdrive/ui/installer/installer.cc +++ b/selfdrive/ui/installer/installer.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/selfdrive/ui/qt/api.cc b/selfdrive/ui/qt/api.cc index 84e1a4032e..b73772544b 100644 --- a/selfdrive/ui/qt/api.cc +++ b/selfdrive/ui/qt/api.cc @@ -12,6 +12,8 @@ #include #include +#include + #include "common/params.h" #include "common/util.h" #include "system/hardware/hw.h" diff --git a/selfdrive/ui/qt/maps/map_helpers.cc b/selfdrive/ui/qt/maps/map_helpers.cc index 0f96638820..a410ab6ee7 100644 --- a/selfdrive/ui/qt/maps/map_helpers.cc +++ b/selfdrive/ui/qt/maps/map_helpers.cc @@ -1,5 +1,9 @@ #include "selfdrive/ui/qt/maps/map_helpers.h" +#include +#include +#include + #include #include diff --git a/selfdrive/ui/qt/maps/map_helpers.h b/selfdrive/ui/qt/maps/map_helpers.h index 0090753a40..6c6a8d12fb 100644 --- a/selfdrive/ui/qt/maps/map_helpers.h +++ b/selfdrive/ui/qt/maps/map_helpers.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include #include #include diff --git a/selfdrive/ui/qt/maps/map_instructions.h b/selfdrive/ui/qt/maps/map_instructions.h index 6c08cb9b9e..06a943d27f 100644 --- a/selfdrive/ui/qt/maps/map_instructions.h +++ b/selfdrive/ui/qt/maps/map_instructions.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index 018d0df984..48a7733c52 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -1,5 +1,7 @@ #include "map_settings.h" +#include + #include #include diff --git a/selfdrive/ui/qt/maps/map_settings.h b/selfdrive/ui/qt/maps/map_settings.h index ffec1f980f..bee0061932 100644 --- a/selfdrive/ui/qt/maps/map_settings.h +++ b/selfdrive/ui/qt/maps/map_settings.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/selfdrive/ui/qt/offroad/driverview.cc b/selfdrive/ui/qt/offroad/driverview.cc index cc715c6755..4d09d914d3 100644 --- a/selfdrive/ui/qt/offroad/driverview.cc +++ b/selfdrive/ui/qt/offroad/driverview.cc @@ -1,5 +1,6 @@ #include "selfdrive/ui/qt/offroad/driverview.h" +#include #include #include "selfdrive/ui/qt/qt_window.h" diff --git a/selfdrive/ui/qt/offroad/networking.h b/selfdrive/ui/qt/offroad/networking.h index cdcdf067ab..81ffb3cf2d 100644 --- a/selfdrive/ui/qt/offroad/networking.h +++ b/selfdrive/ui/qt/offroad/networking.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "selfdrive/ui/qt/offroad/wifiManager.h" #include "selfdrive/ui/qt/widgets/input.h" #include "selfdrive/ui/qt/widgets/ssh_keys.h" diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc index 5bf1b6fc43..c7c22f0ea3 100644 --- a/selfdrive/ui/qt/offroad/onboarding.cc +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -1,5 +1,7 @@ #include "selfdrive/ui/qt/offroad/onboarding.h" +#include + #include #include #include diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 05aef8364c..804bf037a1 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include diff --git a/selfdrive/ui/qt/offroad/settings.h b/selfdrive/ui/qt/offroad/settings.h index edba5be800..a5dd25b14f 100644 --- a/selfdrive/ui/qt/offroad/settings.h +++ b/selfdrive/ui/qt/offroad/settings.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 7c070d2adf..d5b2bbcf6b 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -1,6 +1,9 @@ #include "selfdrive/ui/qt/onroad.h" +#include #include +#include +#include #include #include diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 1975ec9f01..df43ff97f1 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/selfdrive/ui/qt/setup/setup.cc b/selfdrive/ui/qt/setup/setup.cc index de5021c8bc..cdb49f1dfc 100644 --- a/selfdrive/ui/qt/setup/setup.cc +++ b/selfdrive/ui/qt/setup/setup.cc @@ -10,6 +10,8 @@ #include +#include + #include "common/util.h" #include "system/hardware/hw.h" #include "selfdrive/ui/qt/api.h" diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index fb96e1d540..f627aac810 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include diff --git a/selfdrive/ui/qt/spinner.cc b/selfdrive/ui/qt/spinner.cc index 73a0f5014e..2404efa668 100644 --- a/selfdrive/ui/qt/spinner.cc +++ b/selfdrive/ui/qt/spinner.cc @@ -1,5 +1,6 @@ #include "selfdrive/ui/qt/spinner.h" +#include #include #include #include diff --git a/selfdrive/ui/qt/util.cc b/selfdrive/ui/qt/util.cc index 3804aacd78..1e25d2d536 100644 --- a/selfdrive/ui/qt/util.cc +++ b/selfdrive/ui/qt/util.cc @@ -1,5 +1,9 @@ #include "selfdrive/ui/qt/util.h" +#include +#include +#include + #include #include #include diff --git a/selfdrive/ui/qt/util.h b/selfdrive/ui/qt/util.h index 2b1200a861..1aa3bd69b1 100644 --- a/selfdrive/ui/qt/util.h +++ b/selfdrive/ui/qt/util.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index 4da5b7b18e..38824aa8db 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -7,6 +7,9 @@ #endif #include +#include +#include +#include #include #include diff --git a/selfdrive/ui/qt/widgets/cameraview.h b/selfdrive/ui/qt/widgets/cameraview.h index 67568ea55c..647653cdd3 100644 --- a/selfdrive/ui/qt/widgets/cameraview.h +++ b/selfdrive/ui/qt/widgets/cameraview.h @@ -1,7 +1,12 @@ #pragma once +#include +#include #include #include +#include +#include +#include #include #include diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h index fac66de9ed..811595726d 100644 --- a/selfdrive/ui/qt/widgets/controls.h +++ b/selfdrive/ui/qt/widgets/controls.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/selfdrive/ui/qt/widgets/keyboard.h b/selfdrive/ui/qt/widgets/keyboard.h index 516105719b..efc02d075d 100644 --- a/selfdrive/ui/qt/widgets/keyboard.h +++ b/selfdrive/ui/qt/widgets/keyboard.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.cc b/selfdrive/ui/qt/widgets/offroad_alerts.cc index cdfa86c8eb..74ece36d15 100644 --- a/selfdrive/ui/qt/widgets/offroad_alerts.cc +++ b/selfdrive/ui/qt/widgets/offroad_alerts.cc @@ -1,5 +1,10 @@ #include "selfdrive/ui/qt/widgets/offroad_alerts.h" +#include +#include +#include +#include + #include #include #include diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.h b/selfdrive/ui/qt/widgets/offroad_alerts.h index 69c12b0602..ace2e75456 100644 --- a/selfdrive/ui/qt/widgets/offroad_alerts.h +++ b/selfdrive/ui/qt/widgets/offroad_alerts.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/selfdrive/ui/soundd/sound.h b/selfdrive/ui/soundd/sound.h index 9cabd1c6bd..f7084fff97 100644 --- a/selfdrive/ui/soundd/sound.h +++ b/selfdrive/ui/soundd/sound.h @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 32d8ae80ad..5a01e7f8eb 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -1,5 +1,6 @@ #include "selfdrive/ui/ui.h" +#include #include #include diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 31488431b1..82f65d128f 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include diff --git a/system/camerad/cameras/camera_common.cc b/system/camerad/cameras/camera_common.cc index 1b2594bc80..1eb636b7a2 100644 --- a/system/camerad/cameras/camera_common.cc +++ b/system/camerad/cameras/camera_common.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "libyuv.h" diff --git a/system/camerad/cameras/camera_qcom2.cc b/system/camerad/cameras/camera_qcom2.cc index df70b7983d..95ec47171d 100644 --- a/system/camerad/cameras/camera_qcom2.cc +++ b/system/camerad/cameras/camera_qcom2.cc @@ -6,12 +6,15 @@ #include #include +#include #include #include #include #include #include #include +#include +#include #include "media/cam_defs.h" #include "media/cam_isp.h" diff --git a/system/hardware/base.h b/system/hardware/base.h index 2096e1e0bb..d86b316843 100644 --- a/system/hardware/base.h +++ b/system/hardware/base.h @@ -2,6 +2,9 @@ #include #include +#include +#include + #include "cereal/messaging/messaging.h" // no-op base hw class diff --git a/system/hardware/hw.h b/system/hardware/hw.h index 3b0583a10b..1274851787 100644 --- a/system/hardware/hw.h +++ b/system/hardware/hw.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "system/hardware/base.h" #include "common/util.h" diff --git a/system/hardware/pc/hardware.h b/system/hardware/pc/hardware.h index 84fb3bd89e..5cd825d61d 100644 --- a/system/hardware/pc/hardware.h +++ b/system/hardware/pc/hardware.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "system/hardware/base.h" class HardwarePC : public HardwareNone { diff --git a/system/hardware/tici/hardware.h b/system/hardware/tici/hardware.h index 82648ac984..c1a2dcb169 100644 --- a/system/hardware/tici/hardware.h +++ b/system/hardware/tici/hardware.h @@ -2,6 +2,8 @@ #include #include +#include +#include #include "common/params.h" #include "common/util.h" diff --git a/system/loggerd/encoder/encoder.h b/system/loggerd/encoder/encoder.h index bf70775b7c..a8bfd5c054 100644 --- a/system/loggerd/encoder/encoder.h +++ b/system/loggerd/encoder/encoder.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "cereal/messaging/messaging.h" diff --git a/system/loggerd/encoder/v4l_encoder.cc b/system/loggerd/encoder/v4l_encoder.cc index a319d414ca..2f74c3785a 100644 --- a/system/loggerd/encoder/v4l_encoder.cc +++ b/system/loggerd/encoder/v4l_encoder.cc @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/system/loggerd/logger.cc b/system/loggerd/logger.cc index 1e710759e6..31b302ffe6 100644 --- a/system/loggerd/logger.cc +++ b/system/loggerd/logger.cc @@ -13,7 +13,10 @@ #include #include #include +#include #include +#include +#include #include "common/params.h" #include "common/swaglog.h" diff --git a/system/loggerd/logger.h b/system/loggerd/logger.h index e7594cee88..36db1a5a74 100644 --- a/system/loggerd/logger.h +++ b/system/loggerd/logger.h @@ -1,11 +1,12 @@ #pragma once -#include #include +#include #include #include #include +#include #include #include diff --git a/system/loggerd/loggerd.cc b/system/loggerd/loggerd.cc index 56fc11f62c..303235e9d8 100644 --- a/system/loggerd/loggerd.cc +++ b/system/loggerd/loggerd.cc @@ -1,6 +1,10 @@ #include +#include +#include +#include #include +#include #include "system/loggerd/encoder/encoder.h" #include "system/loggerd/loggerd.h" diff --git a/system/loggerd/loggerd.h b/system/loggerd/loggerd.h index 531b30e9f2..cfc06c28d3 100644 --- a/system/loggerd/loggerd.h +++ b/system/loggerd/loggerd.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "cereal/messaging/messaging.h" #include "cereal/services.h" #include "cereal/visionipc/visionipc_client.h" diff --git a/system/sensord/sensors/i2c_sensor.h b/system/sensord/sensors/i2c_sensor.h index ccac526c12..ba100c3b01 100644 --- a/system/sensord/sensors/i2c_sensor.h +++ b/system/sensord/sensors/i2c_sensor.h @@ -2,6 +2,7 @@ #include #include +#include #include "cereal/gen/cpp/log.capnp.h" #include "common/i2c.h" diff --git a/system/ubloxd/ublox_msg.cc b/system/ubloxd/ublox_msg.cc index 02993a574d..c0554773a2 100644 --- a/system/ubloxd/ublox_msg.cc +++ b/system/ubloxd/ublox_msg.cc @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include "common/swaglog.h" diff --git a/system/ubloxd/ublox_msg.h b/system/ubloxd/ublox_msg.h index a52a7db3e5..4eafeac2ca 100644 --- a/system/ubloxd/ublox_msg.h +++ b/system/ubloxd/ublox_msg.h @@ -2,10 +2,11 @@ #include #include +#include #include #include #include -#include +#include #include "cereal/messaging/messaging.h" #include "common/util.h" diff --git a/tools/cabana/binaryview.cc b/tools/cabana/binaryview.cc index 6aac56cc78..bd43c337bd 100644 --- a/tools/cabana/binaryview.cc +++ b/tools/cabana/binaryview.cc @@ -1,5 +1,7 @@ #include "tools/cabana/binaryview.h" +#include + #include #include #include diff --git a/tools/cabana/binaryview.h b/tools/cabana/binaryview.h index 161b2aad8a..04e1d5b2af 100644 --- a/tools/cabana/binaryview.h +++ b/tools/cabana/binaryview.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/tools/cabana/chart/chart.cc b/tools/cabana/chart/chart.cc index 08e8b54b73..18a9adbe07 100644 --- a/tools/cabana/chart/chart.cc +++ b/tools/cabana/chart/chart.cc @@ -1,5 +1,8 @@ #include "tools/cabana/chart/chart.h" +#include +#include + #include #include #include diff --git a/tools/cabana/chart/chart.h b/tools/cabana/chart/chart.h index 272ea0d193..2740d81b66 100644 --- a/tools/cabana/chart/chart.h +++ b/tools/cabana/chart/chart.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/tools/cabana/chart/chartswidget.cc b/tools/cabana/chart/chartswidget.cc index ebc463af0e..e852e6d206 100644 --- a/tools/cabana/chart/chartswidget.cc +++ b/tools/cabana/chart/chartswidget.cc @@ -1,5 +1,7 @@ #include "tools/cabana/chart/chartswidget.h" +#include + #include #include #include diff --git a/tools/cabana/chart/chartswidget.h b/tools/cabana/chart/chartswidget.h index 0d9f79062a..88ba4226c0 100644 --- a/tools/cabana/chart/chartswidget.h +++ b/tools/cabana/chart/chartswidget.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/tools/cabana/chart/sparkline.cc b/tools/cabana/chart/sparkline.cc index baedee8bb2..4692b41e4b 100644 --- a/tools/cabana/chart/sparkline.cc +++ b/tools/cabana/chart/sparkline.cc @@ -1,5 +1,6 @@ #include "tools/cabana/chart/sparkline.h" +#include #include #include "tools/cabana/streams/abstractstream.h" diff --git a/tools/cabana/chart/sparkline.h b/tools/cabana/chart/sparkline.h index 2061966ebb..21cbd40a3f 100644 --- a/tools/cabana/chart/sparkline.h +++ b/tools/cabana/chart/sparkline.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/tools/cabana/chart/tiplabel.cc b/tools/cabana/chart/tiplabel.cc index f34d7e8dfe..f5c9cc9cbd 100644 --- a/tools/cabana/chart/tiplabel.cc +++ b/tools/cabana/chart/tiplabel.cc @@ -1,5 +1,7 @@ #include "tools/cabana/chart/tiplabel.h" +#include + #include #include #include diff --git a/tools/cabana/commands.h b/tools/cabana/commands.h index a1e667807e..c7f59c4c7f 100644 --- a/tools/cabana/commands.h +++ b/tools/cabana/commands.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include diff --git a/tools/cabana/dbc/dbc.cc b/tools/cabana/dbc/dbc.cc index 691a1c4fb8..537749e48d 100644 --- a/tools/cabana/dbc/dbc.cc +++ b/tools/cabana/dbc/dbc.cc @@ -1,5 +1,7 @@ #include "tools/cabana/dbc/dbc.h" +#include + #include "tools/cabana/util.h" uint qHash(const MessageId &item) { diff --git a/tools/cabana/dbc/dbc.h b/tools/cabana/dbc/dbc.h index 6a3084d943..e44bc41abf 100644 --- a/tools/cabana/dbc/dbc.h +++ b/tools/cabana/dbc/dbc.h @@ -1,10 +1,14 @@ #pragma once +#include +#include +#include +#include + #include #include #include #include -#include #include "opendbc/can/common_dbc.h" diff --git a/tools/cabana/dbc/dbcmanager.h b/tools/cabana/dbc/dbcmanager.h index f20d4888e2..3ac0829487 100644 --- a/tools/cabana/dbc/dbcmanager.h +++ b/tools/cabana/dbc/dbcmanager.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "tools/cabana/dbc/dbcfile.h" diff --git a/tools/cabana/historylog.cc b/tools/cabana/historylog.cc index cf9dea88db..2b57e9d007 100644 --- a/tools/cabana/historylog.cc +++ b/tools/cabana/historylog.cc @@ -1,5 +1,7 @@ #include "tools/cabana/historylog.h" +#include + #include #include #include diff --git a/tools/cabana/historylog.h b/tools/cabana/historylog.h index 2dea698f68..a68fbdbf43 100644 --- a/tools/cabana/historylog.h +++ b/tools/cabana/historylog.h @@ -1,6 +1,8 @@ #pragma once #include +#include + #include #include #include diff --git a/tools/cabana/mainwin.cc b/tools/cabana/mainwin.cc index fa91095706..d3caf492a6 100644 --- a/tools/cabana/mainwin.cc +++ b/tools/cabana/mainwin.cc @@ -1,6 +1,9 @@ #include "tools/cabana/mainwin.h" +#include #include +#include + #include #include #include diff --git a/tools/cabana/messageswidget.cc b/tools/cabana/messageswidget.cc index fe4c7afb03..795683a9d0 100644 --- a/tools/cabana/messageswidget.cc +++ b/tools/cabana/messageswidget.cc @@ -1,4 +1,10 @@ #include "tools/cabana/messageswidget.h" + +#include +#include +#include +#include + #include #include #include diff --git a/tools/cabana/messageswidget.h b/tools/cabana/messageswidget.h index 2e165f5b7c..f6d71a5a2e 100644 --- a/tools/cabana/messageswidget.h +++ b/tools/cabana/messageswidget.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + #include #include #include diff --git a/tools/cabana/signalview.cc b/tools/cabana/signalview.cc index ce10576ffe..1b1c8dac22 100644 --- a/tools/cabana/signalview.cc +++ b/tools/cabana/signalview.cc @@ -1,5 +1,7 @@ #include "tools/cabana/signalview.h" +#include + #include #include #include diff --git a/tools/cabana/signalview.h b/tools/cabana/signalview.h index 9541ac8a3b..5cab7f8fa0 100644 --- a/tools/cabana/signalview.h +++ b/tools/cabana/signalview.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/tools/cabana/streams/abstractstream.cc b/tools/cabana/streams/abstractstream.cc index 7cd210d8f1..1d35e96c99 100644 --- a/tools/cabana/streams/abstractstream.cc +++ b/tools/cabana/streams/abstractstream.cc @@ -1,5 +1,8 @@ #include "tools/cabana/streams/abstractstream.h" +#include +#include + #include AbstractStream *can = nullptr; diff --git a/tools/cabana/streams/abstractstream.h b/tools/cabana/streams/abstractstream.h index 5cafa58cb8..e883f45d46 100644 --- a/tools/cabana/streams/abstractstream.h +++ b/tools/cabana/streams/abstractstream.h @@ -3,7 +3,11 @@ #include #include #include +#include +#include #include +#include + #include #include diff --git a/tools/cabana/streams/devicestream.cc b/tools/cabana/streams/devicestream.cc index 5631f64d68..349a2d7a1c 100644 --- a/tools/cabana/streams/devicestream.cc +++ b/tools/cabana/streams/devicestream.cc @@ -1,5 +1,8 @@ #include "tools/cabana/streams/devicestream.h" +#include +#include + #include #include #include diff --git a/tools/cabana/streams/livestream.cc b/tools/cabana/streams/livestream.cc index 91c88c97ca..3f8397f56c 100644 --- a/tools/cabana/streams/livestream.cc +++ b/tools/cabana/streams/livestream.cc @@ -1,5 +1,8 @@ #include "tools/cabana/streams/livestream.h" +#include +#include + struct LiveStream::Logger { Logger() : start_ts(seconds_since_epoch()), segment_num(-1) {} diff --git a/tools/cabana/streams/livestream.h b/tools/cabana/streams/livestream.h index b4816d090f..38ef2c67f9 100644 --- a/tools/cabana/streams/livestream.h +++ b/tools/cabana/streams/livestream.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + #include #include "tools/cabana/streams/abstractstream.h" diff --git a/tools/cabana/streams/pandastream.cc b/tools/cabana/streams/pandastream.cc index e19b2450bd..4a6c588e51 100644 --- a/tools/cabana/streams/pandastream.cc +++ b/tools/cabana/streams/pandastream.cc @@ -1,5 +1,7 @@ #include "tools/cabana/streams/pandastream.h" +#include + #include #include #include diff --git a/tools/cabana/streams/pandastream.h b/tools/cabana/streams/pandastream.h index 49e1836c2d..43803950f9 100644 --- a/tools/cabana/streams/pandastream.h +++ b/tools/cabana/streams/pandastream.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/tools/cabana/streams/replaystream.h b/tools/cabana/streams/replaystream.h index eddcf514f7..de69d9e86c 100644 --- a/tools/cabana/streams/replaystream.h +++ b/tools/cabana/streams/replaystream.h @@ -1,5 +1,11 @@ #pragma once +#include +#include +#include +#include +#include + #include "common/prefix.h" #include "tools/cabana/streams/abstractstream.h" diff --git a/tools/cabana/streams/socketcanstream.h b/tools/cabana/streams/socketcanstream.h index 9d34aaebac..6f2d7aa353 100644 --- a/tools/cabana/streams/socketcanstream.h +++ b/tools/cabana/streams/socketcanstream.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include diff --git a/tools/cabana/tools/findsignal.h b/tools/cabana/tools/findsignal.h index f046bdf7e3..e9e5f9f180 100644 --- a/tools/cabana/tools/findsignal.h +++ b/tools/cabana/tools/findsignal.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include #include #include diff --git a/tools/cabana/tools/findsimilarbits.cc b/tools/cabana/tools/findsimilarbits.cc index 72429104a5..c3c659791a 100644 --- a/tools/cabana/tools/findsimilarbits.cc +++ b/tools/cabana/tools/findsimilarbits.cc @@ -1,5 +1,7 @@ #include "tools/cabana/tools/findsimilarbits.h" +#include + #include #include #include diff --git a/tools/cabana/util.cc b/tools/cabana/util.cc index 31a4486772..278e776e9c 100644 --- a/tools/cabana/util.cc +++ b/tools/cabana/util.cc @@ -1,7 +1,10 @@ #include "tools/cabana/util.h" +#include #include #include +#include +#include #include #include diff --git a/tools/cabana/util.h b/tools/cabana/util.h index 76238569f0..696319b3a8 100644 --- a/tools/cabana/util.h +++ b/tools/cabana/util.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include #include diff --git a/tools/cabana/videowidget.cc b/tools/cabana/videowidget.cc index 46642e5244..f535c6b729 100644 --- a/tools/cabana/videowidget.cc +++ b/tools/cabana/videowidget.cc @@ -1,5 +1,10 @@ #include "tools/cabana/videowidget.h" +#include +#include +#include +#include + #include #include #include diff --git a/tools/cabana/videowidget.h b/tools/cabana/videowidget.h index 670e866534..7ddd315e48 100644 --- a/tools/cabana/videowidget.h +++ b/tools/cabana/videowidget.h @@ -1,7 +1,11 @@ #pragma once #include +#include +#include #include +#include +#include #include #include diff --git a/tools/replay/camera.h b/tools/replay/camera.h index 66d33142fb..f2d19ccfb2 100644 --- a/tools/replay/camera.h +++ b/tools/replay/camera.h @@ -1,6 +1,10 @@ #pragma once #include + +#include +#include + #include "cereal/visionipc/visionipc_server.h" #include "common/queue.h" #include "tools/replay/framereader.h" diff --git a/tools/replay/consoleui.cc b/tools/replay/consoleui.cc index 5cbd3818a6..719bbd69ca 100644 --- a/tools/replay/consoleui.cc +++ b/tools/replay/consoleui.cc @@ -1,7 +1,11 @@ #include "tools/replay/consoleui.h" -#include #include +#include +#include +#include + +#include #include "common/version.h" diff --git a/tools/replay/framereader.cc b/tools/replay/framereader.cc index ed276c627c..3083a0d376 100644 --- a/tools/replay/framereader.cc +++ b/tools/replay/framereader.cc @@ -2,6 +2,7 @@ #include "tools/replay/util.h" #include +#include #include "libyuv.h" #include "cereal/visionipc/visionbuf.h" diff --git a/tools/replay/logreader.h b/tools/replay/logreader.h index 1aa8c98b45..77d751a91b 100644 --- a/tools/replay/logreader.h +++ b/tools/replay/logreader.h @@ -5,7 +5,10 @@ #include #endif +#include #include +#include +#include #include "cereal/gen/cpp/log.capnp.h" #include "system/camerad/cameras/camera_common.h" diff --git a/tools/replay/replay.h b/tools/replay/replay.h index 1792702957..5ed4ff11b5 100644 --- a/tools/replay/replay.h +++ b/tools/replay/replay.h @@ -1,6 +1,14 @@ #pragma once +#include +#include +#include #include +#include +#include +#include +#include +#include #include diff --git a/tools/replay/route.cc b/tools/replay/route.cc index 619aeb3f5f..15a57e5e42 100644 --- a/tools/replay/route.cc +++ b/tools/replay/route.cc @@ -6,11 +6,13 @@ #include #include #include - #include +#include +#include +#include -#include "system/hardware/hw.h" #include "selfdrive/ui/qt/api.h" +#include "system/hardware/hw.h" #include "tools/replay/replay.h" #include "tools/replay/util.h" diff --git a/tools/replay/route.h b/tools/replay/route.h index 86adf6a14d..7207ff4f5c 100644 --- a/tools/replay/route.h +++ b/tools/replay/route.h @@ -1,5 +1,10 @@ #pragma once +#include +#include +#include +#include + #include #include diff --git a/tools/replay/util.cc b/tools/replay/util.cc index a6ebbec615..172d545c75 100644 --- a/tools/replay/util.cc +++ b/tools/replay/util.cc @@ -9,8 +9,10 @@ #include #include #include +#include #include #include +#include #include "common/timing.h" #include "common/util.h" From e726505918bfbaa4ee75714bd6ea391d7fff7fb8 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 23 Aug 2023 13:42:37 -0700 Subject: [PATCH 096/159] bump cereal (#29561) --- cereal | 2 +- common/util.cc | 8 ++++++++ common/util.h | 2 ++ system/loggerd/loggerd.cc | 10 +++++----- tools/replay/replay.cc | 11 ++++++----- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cereal b/cereal index 736a4cce2c..fa580de1b4 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 736a4cce2c51cb73465e88dae6ff4cec5b9c3b43 +Subproject commit fa580de1b42534d3417306c416784e1add99ad32 diff --git a/common/util.cc b/common/util.cc index 6ad619c35c..11e8ad4555 100644 --- a/common/util.cc +++ b/common/util.cc @@ -253,6 +253,14 @@ std::string dir_name(std::string const &path) { return path.substr(0, pos); } +bool starts_with(const std::string &s1, const std::string &s2) { + return strncmp(s1.c_str(), s2.c_str(), s2.size()) == 0; +} + +bool ends_with(const std::string &s1, const std::string &s2) { + return strcmp(s1.c_str() + (s1.size() - s2.size()), s2.c_str()) == 0; +} + std::string check_output(const std::string& command) { char buffer[128]; std::string result; diff --git a/common/util.h b/common/util.h index 23c37f153a..26bc15ba33 100644 --- a/common/util.h +++ b/common/util.h @@ -77,6 +77,8 @@ float getenv(const char* key, float default_val); std::string hexdump(const uint8_t* in, const size_t size); std::string dir_name(std::string const& path); +bool starts_with(const std::string &s1, const std::string &s2); +bool ends_with(const std::string &s1, const std::string &s2); // ***** random helpers ***** int random_int(int min, int max); diff --git a/system/loggerd/loggerd.cc b/system/loggerd/loggerd.cc index 303235e9d8..2bcf9e3256 100644 --- a/system/loggerd/loggerd.cc +++ b/system/loggerd/loggerd.cc @@ -207,11 +207,11 @@ void loggerd_thread() { std::unique_ptr poller(Poller::create()); // subscribe to all socks - for (const auto& it : services) { - const bool encoder = strcmp(it.name+strlen(it.name)-strlen("EncodeData"), "EncodeData") == 0; - const bool livestream_encoder = strncmp(it.name, "livestream", strlen("livestream")) == 0; + for (const auto& [_, it] : services) { + const bool encoder = util::ends_with(it.name, "EncodeData"); + const bool livestream_encoder = util::starts_with(it.name, "livestream"); if (!it.should_log && (!encoder || livestream_encoder)) continue; - LOGD("logging %s (on port %d)", it.name, it.port); + LOGD("logging %s (on port %d)", it.name.c_str(), it.port); SubSocket * sock = SubSocket::create(ctx.get(), it.name); assert(sock != NULL); @@ -221,7 +221,7 @@ void loggerd_thread() { .counter = 0, .freq = it.decimation, .encoder = encoder, - .user_flag = (strcmp(it.name, "userFlag") == 0), + .user_flag = it.name == "userFlag", }; } diff --git a/tools/replay/replay.cc b/tools/replay/replay.cc index 9029213af5..e323a9f64d 100644 --- a/tools/replay/replay.cc +++ b/tools/replay/replay.cc @@ -16,19 +16,20 @@ Replay::Replay(QString route, QStringList allow, QStringList block, QStringList auto event_struct = capnp::Schema::from().asStruct(); sockets_.resize(event_struct.getUnionFields().size()); for (const auto &it : services) { - uint16_t which = event_struct.getFieldByName(it.name).getProto().getDiscriminantValue(); + auto name = it.second.name.c_str(); + uint16_t which = event_struct.getFieldByName(name).getProto().getDiscriminantValue(); if ((which == cereal::Event::Which::UI_DEBUG || which == cereal::Event::Which::USER_FLAG) && !(flags & REPLAY_FLAG_ALL_SERVICES) && - !allow.contains(it.name)) { + !allow.contains(name)) { continue; } - if ((allow.empty() || allow.contains(it.name)) && !block.contains(it.name)) { - sockets_[which] = it.name; + if ((allow.empty() || allow.contains(name)) && !block.contains(name)) { + sockets_[which] = name; if (!allow.empty() || !block.empty()) { allow_list.insert((cereal::Event::Which)which); } - s.push_back(it.name); + s.push_back(name); } } From 42769345d505cc30978aaf9ed735cb8d644b13aa Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 23 Aug 2023 14:00:26 -0700 Subject: [PATCH 097/159] sensord: lower temperature sensor freq to 2Hz (#29563) --- system/sensord/sensors_qcom2.cc | 37 +++++++-------- system/sensord/tests/test_sensord.py | 67 +++++++++++----------------- 2 files changed, 44 insertions(+), 60 deletions(-) diff --git a/system/sensord/sensors_qcom2.cc b/system/sensord/sensors_qcom2.cc index 313dc50095..7a7e5d1e80 100644 --- a/system/sensord/sensors_qcom2.cc +++ b/system/sensord/sensors_qcom2.cc @@ -7,6 +7,7 @@ #include #include +#include "cereal/services.h" #include "cereal/messaging/messaging.h" #include "common/i2c.h" #include "common/ratekeeper.h" @@ -27,11 +28,11 @@ ExitHandler do_exit; -void interrupt_loop(std::vector> sensors) { +void interrupt_loop(std::vector> sensors) { PubMaster pm({"gyroscope", "accelerometer"}); int fd = -1; - for (auto &[sensor, msg_name, required, polling_freq] : sensors) { + for (auto &[sensor, msg_name, required] : sensors) { if (sensor->has_interrupt_enabled()) { fd = sensor->gpio_fd; break; @@ -71,7 +72,7 @@ void interrupt_loop(std::vector> se uint64_t offset = nanos_since_epoch() - nanos_since_boot(); uint64_t ts = evdata[num_events - 1].timestamp - offset; - for (auto &[sensor, msg_name, required, polling_freq] : sensors) { + for (auto &[sensor, msg_name, required] : sensors) { if (!sensor->has_interrupt_enabled()) { continue; } @@ -90,16 +91,16 @@ void interrupt_loop(std::vector> se } // poweroff sensors, disable interrupts - for (auto &[sensor, msg_name, required, polling_freq] : sensors) { + for (auto &[sensor, msg_name, required] : sensors) { if (sensor->has_interrupt_enabled()) { sensor->shutdown(); } } } -void polling_loop(Sensor *sensor, std::string msg_name, int frequency) { +void polling_loop(Sensor *sensor, std::string msg_name) { PubMaster pm({msg_name.c_str()}); - RateKeeper rk(msg_name, frequency); + RateKeeper rk(msg_name, services.at(msg_name).frequency); while (!do_exit) { MessageBuilder msg; if (sensor->get_event(msg) && sensor->is_data_valid(nanos_since_boot())) { @@ -113,22 +114,22 @@ void polling_loop(Sensor *sensor, std::string msg_name, int frequency) { int sensor_loop(I2CBus *i2c_bus_imu) { // Sensor init - std::vector> sensors_init = { - {new BMX055_Accel(i2c_bus_imu), "accelerometer2", false, 100}, - {new BMX055_Gyro(i2c_bus_imu), "gyroscope2", false, 100}, - {new BMX055_Magn(i2c_bus_imu), "magnetometer", false, 100}, - {new BMX055_Temp(i2c_bus_imu), "temperatureSensor2", false, 100}, + std::vector> sensors_init = { + {new BMX055_Accel(i2c_bus_imu), "accelerometer2", false}, + {new BMX055_Gyro(i2c_bus_imu), "gyroscope2", false}, + {new BMX055_Magn(i2c_bus_imu), "magnetometer", false}, + {new BMX055_Temp(i2c_bus_imu), "temperatureSensor2", false}, - {new LSM6DS3_Accel(i2c_bus_imu, GPIO_LSM_INT), "accelerometer", true, 100}, - {new LSM6DS3_Gyro(i2c_bus_imu, GPIO_LSM_INT, true), "gyroscope", true, 100}, - {new LSM6DS3_Temp(i2c_bus_imu), "temperatureSensor", true, 100}, + {new LSM6DS3_Accel(i2c_bus_imu, GPIO_LSM_INT), "accelerometer", true}, + {new LSM6DS3_Gyro(i2c_bus_imu, GPIO_LSM_INT, true), "gyroscope", true}, + {new LSM6DS3_Temp(i2c_bus_imu), "temperatureSensor", true}, - {new MMC5603NJ_Magn(i2c_bus_imu), "magnetometer", false, 100}, + {new MMC5603NJ_Magn(i2c_bus_imu), "magnetometer", false}, }; // Initialize sensors std::vector threads; - for (auto &[sensor, msg_name, required, polling_freq] : sensors_init) { + for (auto &[sensor, msg_name, required] : sensors_init) { int err = sensor->init(); if (err < 0) { if (required) { @@ -139,7 +140,7 @@ int sensor_loop(I2CBus *i2c_bus_imu) { } if (!sensor->has_interrupt_enabled()) { - threads.emplace_back(polling_loop, sensor, msg_name, polling_freq); + threads.emplace_back(polling_loop, sensor, msg_name); } } @@ -156,7 +157,7 @@ int sensor_loop(I2CBus *i2c_bus_imu) { t.join(); } - for (auto &[sensor, msg_name, required, polling_freq] : sensors_init) { + for (auto &[sensor, msg_name, required] : sensors_init) { delete sensor; } return 0; diff --git a/system/sensord/tests/test_sensord.py b/system/sensord/tests/test_sensord.py index 815dd8b444..e3cd77a1a3 100755 --- a/system/sensord/tests/test_sensord.py +++ b/system/sensord/tests/test_sensord.py @@ -7,6 +7,7 @@ from collections import namedtuple, defaultdict import cereal.messaging as messaging from cereal import log +from cereal.services import service_list from openpilot.common.gpio import get_irqs_for_action from openpilot.system.hardware import TICI from openpilot.selfdrive.manager.process_config import managed_processes @@ -37,29 +38,29 @@ SENSOR_CONFIGURATIONS = ( ) Sensor = log.SensorEventData.SensorSource -SensorConfig = namedtuple('SensorConfig', ['type', 'sanity_min', 'sanity_max', 'expected_freq']) +SensorConfig = namedtuple('SensorConfig', ['type', 'sanity_min', 'sanity_max']) ALL_SENSORS = { Sensor.lsm6ds3: { - SensorConfig("acceleration", 5, 15, 100), - SensorConfig("gyroUncalibrated", 0, .2, 100), - SensorConfig("temperature", 0, 60, 100), + SensorConfig("acceleration", 5, 15), + SensorConfig("gyroUncalibrated", 0, .2), + SensorConfig("temperature", 0, 60), }, Sensor.lsm6ds3trc: { - SensorConfig("acceleration", 5, 15, 104), - SensorConfig("gyroUncalibrated", 0, .2, 104), - SensorConfig("temperature", 0, 60, 100), + SensorConfig("acceleration", 5, 15), + SensorConfig("gyroUncalibrated", 0, .2), + SensorConfig("temperature", 0, 60), }, Sensor.bmx055: { - SensorConfig("acceleration", 5, 15, 100), - SensorConfig("gyroUncalibrated", 0, .2, 100), - SensorConfig("magneticUncalibrated", 0, 300, 100), - SensorConfig("temperature", 0, 60, 100), + SensorConfig("acceleration", 5, 15), + SensorConfig("gyroUncalibrated", 0, .2), + SensorConfig("magneticUncalibrated", 0, 300), + SensorConfig("temperature", 0, 60), }, Sensor.mmc5603nj: { - SensorConfig("magneticUncalibrated", 0, 300, 100), + SensorConfig("magneticUncalibrated", 0, 300), } } @@ -85,7 +86,7 @@ def read_sensor_events(duration_sec): assert sum(map(len, events.values())) != 0, "No sensor events collected!" - return events + return {k: v for k, v in events.items() if len(v) > 0} class TestSensord(unittest.TestCase): @classmethod @@ -119,7 +120,6 @@ class TestSensord(unittest.TestCase): def test_sensors_present(self): # verify correct sensors configuration - seen = set() for etype in self.events: for measurement in self.events[etype]: @@ -159,22 +159,12 @@ class TestSensord(unittest.TestCase): stddev = np.std(tdiffs) assert stddev < 2.0, f"Standard-dev to big {stddev}" - def test_events_check(self): - # verify if all sensors produce events - - sensor_events = dict() - for etype in self.events: - for measurement in self.events[etype]: - m = getattr(measurement, measurement.which()) - - if m.type in sensor_events: - sensor_events[m.type] += 1 - else: - sensor_events[m.type] = 1 - - for s in sensor_events: - err_msg = f"Sensor {s}: 200 < {sensor_events[s]}" - assert sensor_events[s] > 200, err_msg + def test_sensor_frequency(self): + for s, msgs in self.events.items(): + with self.subTest(sensor=s): + freq = len(msgs) / self.sample_secs + ef = service_list[s].frequency + assert ef*0.85 <= freq <= ef*1.15 def test_logmonottime_timestamp_diff(self): # ensure diff between the message logMonotime and sample timestamp is small @@ -193,16 +183,14 @@ class TestSensord(unittest.TestCase): # before the sensor is read tdiffs.append(abs(measurement.logMonoTime - m.timestamp) / 1e6) - high_delay_diffs = set(filter(lambda d: d >= 15., tdiffs)) - assert len(high_delay_diffs) < 20, f"Too many measurements published : {high_delay_diffs}" + # some sensors have a read procedure that will introduce an expected diff on the order of 20ms + high_delay_diffs = set(filter(lambda d: d >= 25., tdiffs)) + assert len(high_delay_diffs) < 20, f"Too many measurements published: {high_delay_diffs}" avg_diff = round(sum(tdiffs)/len(tdiffs), 4) assert avg_diff < 4, f"Avg packet diff: {avg_diff:.1f}ms" - stddev = np.std(tdiffs) - assert stddev < 2, f"Timing diffs have too high stddev: {stddev}" - - def test_sensor_values_sanity_check(self): + def test_sensor_values(self): sensor_values = dict() for etype in self.events: for measurement in self.events[etype]: @@ -219,18 +207,13 @@ class TestSensord(unittest.TestCase): else: sensor_values[key] = [values] - # Sanity check sensor values and counts + # Sanity check sensor values for sensor, stype in sensor_values: for s in ALL_SENSORS[sensor]: if s.type != stype: continue key = (sensor, s.type) - val_cnt = len(sensor_values[key]) - min_samples = self.sample_secs * s.expected_freq - err_msg = f"Sensor {sensor} {s.type} got {val_cnt} measurements, expected {min_samples}" - assert min_samples*0.9 < val_cnt < min_samples*1.1, err_msg - mean_norm = np.mean(np.linalg.norm(sensor_values[key], axis=1)) err_msg = f"Sensor '{sensor} {s.type}' failed sanity checks {mean_norm} is not between {s.sanity_min} and {s.sanity_max}" assert s.sanity_min <= mean_norm <= s.sanity_max, err_msg From d3fb75a972338e37d5537d900c8d2f55439db961 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 23 Aug 2023 14:07:00 -0700 Subject: [PATCH 098/159] sensord: run as many sensors as possible (#29564) --- system/sensord/sensors_qcom2.cc | 42 ++++++++++++--------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/system/sensord/sensors_qcom2.cc b/system/sensord/sensors_qcom2.cc index 7a7e5d1e80..36d9b4a13e 100644 --- a/system/sensord/sensors_qcom2.cc +++ b/system/sensord/sensors_qcom2.cc @@ -28,11 +28,11 @@ ExitHandler do_exit; -void interrupt_loop(std::vector> sensors) { +void interrupt_loop(std::vector> sensors) { PubMaster pm({"gyroscope", "accelerometer"}); int fd = -1; - for (auto &[sensor, msg_name, required] : sensors) { + for (auto &[sensor, msg_name] : sensors) { if (sensor->has_interrupt_enabled()) { fd = sensor->gpio_fd; break; @@ -72,7 +72,7 @@ void interrupt_loop(std::vector> sensors uint64_t offset = nanos_since_epoch() - nanos_since_boot(); uint64_t ts = evdata[num_events - 1].timestamp - offset; - for (auto &[sensor, msg_name, required] : sensors) { + for (auto &[sensor, msg_name] : sensors) { if (!sensor->has_interrupt_enabled()) { continue; } @@ -89,13 +89,6 @@ void interrupt_loop(std::vector> sensors pm.send(msg_name.c_str(), msg); } } - - // poweroff sensors, disable interrupts - for (auto &[sensor, msg_name, required] : sensors) { - if (sensor->has_interrupt_enabled()) { - sensor->shutdown(); - } - } } void polling_loop(Sensor *sensor, std::string msg_name) { @@ -108,34 +101,28 @@ void polling_loop(Sensor *sensor, std::string msg_name) { } rk.keepTime(); } - - sensor->shutdown(); } int sensor_loop(I2CBus *i2c_bus_imu) { // Sensor init - std::vector> sensors_init = { - {new BMX055_Accel(i2c_bus_imu), "accelerometer2", false}, - {new BMX055_Gyro(i2c_bus_imu), "gyroscope2", false}, - {new BMX055_Magn(i2c_bus_imu), "magnetometer", false}, - {new BMX055_Temp(i2c_bus_imu), "temperatureSensor2", false}, + std::vector> sensors_init = { + {new BMX055_Accel(i2c_bus_imu), "accelerometer2"}, + {new BMX055_Gyro(i2c_bus_imu), "gyroscope2"}, + {new BMX055_Magn(i2c_bus_imu), "magnetometer"}, + {new BMX055_Temp(i2c_bus_imu), "temperatureSensor2"}, - {new LSM6DS3_Accel(i2c_bus_imu, GPIO_LSM_INT), "accelerometer", true}, - {new LSM6DS3_Gyro(i2c_bus_imu, GPIO_LSM_INT, true), "gyroscope", true}, - {new LSM6DS3_Temp(i2c_bus_imu), "temperatureSensor", true}, + {new LSM6DS3_Accel(i2c_bus_imu, GPIO_LSM_INT), "accelerometer"}, + {new LSM6DS3_Gyro(i2c_bus_imu, GPIO_LSM_INT, true), "gyroscope"}, + {new LSM6DS3_Temp(i2c_bus_imu), "temperatureSensor"}, - {new MMC5603NJ_Magn(i2c_bus_imu), "magnetometer", false}, + {new MMC5603NJ_Magn(i2c_bus_imu), "magnetometer"}, }; // Initialize sensors std::vector threads; - for (auto &[sensor, msg_name, required] : sensors_init) { + for (auto &[sensor, msg_name] : sensors_init) { int err = sensor->init(); if (err < 0) { - if (required) { - LOGE("Error initializing sensors"); - return -1; - } continue; } @@ -157,7 +144,8 @@ int sensor_loop(I2CBus *i2c_bus_imu) { t.join(); } - for (auto &[sensor, msg_name, required] : sensors_init) { + for (auto &[sensor, msg_name] : sensors_init) { + sensor->shutdown(); delete sensor; } return 0; From 239d6a24bed850a6fbd3e0794da19130cdb773f7 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 23 Aug 2023 14:21:10 -0700 Subject: [PATCH 099/159] sensord: fix LSM magnetometer thermal variation (#29265) * do set reset for every measurement cycle * use one sensorvec * convert from continuous to manual mode * separate the set/reset and TM_M * make magnetometer readings manual, set appropriate sleep * add more sleep and check validity of values * add magnetometer to a separate thread * refactor * bugfix * each sensor in a new thread, handle generically * bugfix * rm global * update cpu * update test * update test * revert cereal change * split out temp sensors * little more * fix * fix * bump cereal * linter fixes --------- Co-authored-by: nuwandavek Co-authored-by: Comma Device --- system/sensord/sensors/mmc5603nj_magn.cc | 64 +++++++++++++++--------- system/sensord/sensors/mmc5603nj_magn.h | 7 +++ 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/system/sensord/sensors/mmc5603nj_magn.cc b/system/sensord/sensors/mmc5603nj_magn.cc index 048095786e..b69c602bdf 100644 --- a/system/sensord/sensors/mmc5603nj_magn.cc +++ b/system/sensord/sensors/mmc5603nj_magn.cc @@ -1,9 +1,12 @@ #include "mmc5603nj_magn.h" +#include #include +#include #include "common/swaglog.h" #include "common/timing.h" +#include "common/util.h" MMC5603NJ_Magn::MMC5603NJ_Magn(I2CBus *bus) : I2CSensor(bus) {} @@ -11,8 +14,8 @@ int MMC5603NJ_Magn::init() { int ret = verify_chip_id(MMC5603NJ_I2C_REG_ID, {MMC5603NJ_CHIP_ID}); if (ret == -1) return -1; - // Set 100 Hz - ret = set_register(MMC5603NJ_I2C_REG_ODR, 100); + // Set ODR to 0 + ret = set_register(MMC5603NJ_I2C_REG_ODR, 0); if (ret < 0) { goto fail; } @@ -23,18 +26,6 @@ int MMC5603NJ_Magn::init() { goto fail; } - // Set compute measurement rate - ret = set_register(MMC5603NJ_I2C_REG_INTERNAL_0, MMC5603NJ_CMM_FREQ_EN | MMC5603NJ_AUTO_SR_EN); - if (ret < 0) { - goto fail; - } - - // Enable continuous mode, set every 100 measurements - ret = set_register(MMC5603NJ_I2C_REG_INTERNAL_2, MMC5603NJ_CMM_EN | MMC5603NJ_EN_PRD_SET | 0b11); - if (ret < 0) { - goto fail; - } - fail: return ret; } @@ -67,16 +58,36 @@ fail: return ret; } -bool MMC5603NJ_Magn::get_event(MessageBuilder &msg, uint64_t ts) { - uint64_t start_time = nanos_since_boot(); +void MMC5603NJ_Magn::start_measurement() { + set_register(MMC5603NJ_I2C_REG_INTERNAL_0, 0b01); + util::sleep_for(5); +} + +std::vector MMC5603NJ_Magn::read_measurement() { + int len; uint8_t buffer[9]; - int len = read_register(MMC5603NJ_I2C_REG_XOUT0, buffer, sizeof(buffer)); + len = read_register(MMC5603NJ_I2C_REG_XOUT0, buffer, sizeof(buffer)); assert(len == sizeof(buffer)); - float scale = 1.0 / 16384.0; - float x = read_20_bit(buffer[6], buffer[1], buffer[0]) * scale; - float y = read_20_bit(buffer[7], buffer[3], buffer[2]) * scale; - float z = read_20_bit(buffer[8], buffer[5], buffer[4]) * scale; + float x = (read_20_bit(buffer[6], buffer[1], buffer[0]) * scale) - 32.0; + float y = (read_20_bit(buffer[7], buffer[3], buffer[2]) * scale) - 32.0; + float z = (read_20_bit(buffer[8], buffer[5], buffer[4]) * scale) - 32.0; + std::vector xyz = {x, y, z}; + return xyz; +} + +bool MMC5603NJ_Magn::get_event(MessageBuilder &msg, uint64_t ts) { + uint64_t start_time = nanos_since_boot(); + // SET - RESET cycle + set_register(MMC5603NJ_I2C_REG_INTERNAL_0, MMC5603NJ_SET); + util::sleep_for(5); + MMC5603NJ_Magn::start_measurement(); + std::vector xyz = MMC5603NJ_Magn::read_measurement(); + + set_register(MMC5603NJ_I2C_REG_INTERNAL_0, MMC5603NJ_RESET); + util::sleep_for(5); + MMC5603NJ_Magn::start_measurement(); + std::vector reset_xyz = MMC5603NJ_Magn::read_measurement(); auto event = msg.initEvent().initMagnetometer(); event.setSource(cereal::SensorEventData::SensorSource::MMC5603NJ); @@ -85,10 +96,13 @@ bool MMC5603NJ_Magn::get_event(MessageBuilder &msg, uint64_t ts) { event.setType(SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED); event.setTimestamp(start_time); - float xyz[] = {x, y, z}; + float vals[] = {xyz[0], xyz[1], xyz[2], reset_xyz[0], reset_xyz[1], reset_xyz[2]}; + bool valid = true; + if (std::any_of(std::begin(vals), std::end(vals), [](float val) { return val == -32.0; })) { + valid = false; + } auto svec = event.initMagneticUncalibrated(); - svec.setV(xyz); - svec.setStatus(true); - + svec.setV(vals); + svec.setStatus(valid); return true; } diff --git a/system/sensord/sensors/mmc5603nj_magn.h b/system/sensord/sensors/mmc5603nj_magn.h index fce3f3fecb..9c0fbd2521 100644 --- a/system/sensord/sensors/mmc5603nj_magn.h +++ b/system/sensord/sensors/mmc5603nj_magn.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "system/sensord/sensors/i2c_sensor.h" // Address of the chip on the bus @@ -19,9 +21,14 @@ #define MMC5603NJ_AUTO_SR_EN (1 << 5) #define MMC5603NJ_CMM_EN (1 << 4) #define MMC5603NJ_EN_PRD_SET (1 << 3) +#define MMC5603NJ_SET (1 << 3) +#define MMC5603NJ_RESET (1 << 4) class MMC5603NJ_Magn : public I2CSensor { +private: uint8_t get_device_address() {return MMC5603NJ_I2C_ADDR;} + void start_measurement(); + std::vector read_measurement(); public: MMC5603NJ_Magn(I2CBus *bus); int init(); From 5480d32bb5d98d57100fd709b9ffe7bfcc6e020a Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 05:25:05 +0800 Subject: [PATCH 100/159] cpplint: add filter `whitespace/parens` (#29565) --- .pre-commit-config.yaml | 2 +- common/gpio.cc | 4 +-- common/i2c.cc | 12 ++++---- common/util.h | 2 +- selfdrive/boardd/panda_comms.cc | 4 +-- .../boardd/tests/test_boardd_usbprotocol.cc | 2 +- selfdrive/locationd/locationd.cc | 2 +- selfdrive/modeld/models/commonmodel.cc | 4 +-- selfdrive/modeld/models/driving.cc | 2 +- .../modeld/tests/snpe_benchmark/benchmark.cc | 4 +-- selfdrive/modeld/thneed/serialize.cc | 3 +- selfdrive/ui/qt/api.cc | 2 +- selfdrive/ui/qt/offroad/settings.cc | 2 +- selfdrive/ui/qt/util.cc | 5 ++-- selfdrive/ui/qt/util.h | 2 +- system/logcatd/logcatd_systemd.cc | 2 +- system/sensord/sensors/bmx055_magn.cc | 18 +++++------ system/sensord/sensors/lsm6ds3_gyro.cc | 2 +- system/ubloxd/tests/test_glonass_kaitai.cc | 2 +- system/ubloxd/ublox_msg.cc | 30 +++++++++---------- system/ubloxd/ublox_msg.h | 2 +- system/ubloxd/ubloxd.cc | 4 +-- tools/cabana/signalview.h | 2 +- 23 files changed, 56 insertions(+), 58 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85e75396ed..b5e638da32 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/parens,+readability/braces - repo: local hooks: - id: test_translations diff --git a/common/gpio.cc b/common/gpio.cc index c1805b7bdc..5088362380 100644 --- a/common/gpio.cc +++ b/common/gpio.cc @@ -31,7 +31,7 @@ int gpio_init(int pin_nr, bool output) { char pin_dir_path[50]; int pin_dir_path_len = snprintf(pin_dir_path, sizeof(pin_dir_path), "/sys/class/gpio/gpio%d/direction", pin_nr); - if(pin_dir_path_len <= 0) { + if (pin_dir_path_len <= 0) { return -1; } const char *value = output ? "out" : "in"; @@ -42,7 +42,7 @@ int gpio_set(int pin_nr, bool high) { char pin_val_path[50]; int pin_val_path_len = snprintf(pin_val_path, sizeof(pin_val_path), "/sys/class/gpio/gpio%d/value", pin_nr); - if(pin_val_path_len <= 0) { + if (pin_val_path_len <= 0) { return -1; } return util::write_file(pin_val_path, (void*)(high ? "1" : "0"), 1); diff --git a/common/i2c.cc b/common/i2c.cc index ef788ac9ea..fc72559ce7 100644 --- a/common/i2c.cc +++ b/common/i2c.cc @@ -26,23 +26,23 @@ I2CBus::I2CBus(uint8_t bus_id) { snprintf(bus_name, 20, "/dev/i2c-%d", bus_id); i2c_fd = HANDLE_EINTR(open(bus_name, O_RDWR)); - if(i2c_fd < 0) { + if (i2c_fd < 0) { throw std::runtime_error("Failed to open I2C bus"); } } I2CBus::~I2CBus() { - if(i2c_fd >= 0) { close(i2c_fd); } + if (i2c_fd >= 0) { close(i2c_fd); } } int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len) { int ret = 0; ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address)); - if(ret < 0) { goto fail; } + if (ret < 0) { goto fail; } ret = i2c_smbus_read_i2c_block_data(i2c_fd, register_address, len, buffer); - if((ret < 0) || (ret != len)) { goto fail; } + if ((ret < 0) || (ret != len)) { goto fail; } fail: return ret; @@ -52,10 +52,10 @@ int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t int ret = 0; ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address)); - if(ret < 0) { goto fail; } + if (ret < 0) { goto fail; } ret = i2c_smbus_write_byte_data(i2c_fd, register_address, data); - if(ret < 0) { goto fail; } + if (ret < 0) { goto fail; } fail: return ret; diff --git a/common/util.h b/common/util.h index 26bc15ba33..d6ab698245 100644 --- a/common/util.h +++ b/common/util.h @@ -171,7 +171,7 @@ private: template void update_max_atomic(std::atomic& max, T const& value) { T prev = max; - while(prev < value && !max.compare_exchange_weak(prev, value)) {} + while (prev < value && !max.compare_exchange_weak(prev, value)) {} } class LogState { diff --git a/selfdrive/boardd/panda_comms.cc b/selfdrive/boardd/panda_comms.cc index 120d2f67d5..bc4e5f5867 100644 --- a/selfdrive/boardd/panda_comms.cc +++ b/selfdrive/boardd/panda_comms.cc @@ -199,7 +199,7 @@ int PandaUsbHandle::bulk_write(unsigned char endpoint, unsigned char* data, int } else if (err != 0 || length != transferred) { handle_usb_issue(err, __func__); } - } while(err != 0 && connected); + } while (err != 0 && connected); return transferred; } @@ -226,7 +226,7 @@ int PandaUsbHandle::bulk_read(unsigned char endpoint, unsigned char* data, int l handle_usb_issue(err, __func__); } - } while(err != 0 && connected); + } while (err != 0 && connected); return transferred; } diff --git a/selfdrive/boardd/tests/test_boardd_usbprotocol.cc b/selfdrive/boardd/tests/test_boardd_usbprotocol.cc index 52cb11ec32..86476d05cd 100644 --- a/selfdrive/boardd/tests/test_boardd_usbprotocol.cc +++ b/selfdrive/boardd/tests/test_boardd_usbprotocol.cc @@ -82,7 +82,7 @@ void PandaTest::test_can_recv(uint32_t rx_chunk_size) { this->receive_buffer_size = 0; uint32_t pos = 0; - while(pos < size) { + while (pos < size) { uint32_t chunk_size = std::min(rx_chunk_size, size - pos); memcpy(&this->receive_buffer[this->receive_buffer_size], &data[pos], chunk_size); this->receive_buffer_size += chunk_size; diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index d79b5c9c44..722ead7dd4 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -359,7 +359,7 @@ void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::R void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log) { - if(!log.getPositionECEF().getValid() || !log.getVelocityECEF().getValid()) { + if (!log.getPositionECEF().getValid() || !log.getVelocityECEF().getValid()) { this->determine_gps_mode(current_time); return; } diff --git a/selfdrive/modeld/models/commonmodel.cc b/selfdrive/modeld/models/commonmodel.cc index b7c9051c6e..5e28e9b95d 100644 --- a/selfdrive/modeld/models/commonmodel.cc +++ b/selfdrive/modeld/models/commonmodel.cc @@ -55,14 +55,14 @@ ModelFrame::~ModelFrame() { void softmax(const float* input, float* output, size_t len) { const float max_val = *std::max_element(input, input + len); float denominator = 0; - for(int i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { float const v_exp = expf(input[i] - max_val); denominator += v_exp; output[i] = v_exp; } const float inv_denominator = 1. / denominator; - for(int i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { output[i] *= inv_denominator; } } diff --git a/selfdrive/modeld/models/driving.cc b/selfdrive/modeld/models/driving.cc index fb42fcd4f9..72137c4a97 100644 --- a/selfdrive/modeld/models/driving.cc +++ b/selfdrive/modeld/models/driving.cc @@ -264,7 +264,7 @@ void fill_plan(cereal::ModelDataV2::Builder &framed, const ModelOutputPlanPredic std::array acc_x, acc_y, acc_z; std::array rot_rate_x, rot_rate_y, rot_rate_z; - for(int i=0; igetInputDimensions(strList.at(0)); const auto &inputShape = *inputDims_opt; std::cout << "winkwink" << std::endl; @@ -167,7 +167,7 @@ void testrun(char* modelfile) { get_testframe(i,input); snpe->execute(input.get(), outputTensorMap); zdl::DlSystem::StringList tensorNames = outputTensorMap.getTensorNames(); - std::for_each( tensorNames.begin(), tensorNames.end(), [&](const char* name) { + std::for_each(tensorNames.begin(), tensorNames.end(), [&](const char* name) { std::ostringstream path; path << "/data/opt/Result_" << std::to_string(i) << ".raw"; auto tensorPtr = outputTensorMap.getTensor(name); diff --git a/selfdrive/modeld/thneed/serialize.cc b/selfdrive/modeld/thneed/serialize.cc index f789e5bf57..51e6d08699 100644 --- a/selfdrive/modeld/thneed/serialize.cc +++ b/selfdrive/modeld/thneed/serialize.cc @@ -75,8 +75,7 @@ void Thneed::load(const char *filename) { #endif if (clbuf == NULL) { printf("clError: %s create image %zux%zu rp %zu with buffer %p\n", cl_get_error_string(errcode), - desc.image_width, desc.image_height, desc.image_row_pitch, desc.buffer - ); + desc.image_width, desc.image_height, desc.image_row_pitch, desc.buffer); } assert(clbuf != NULL); } diff --git a/selfdrive/ui/qt/api.cc b/selfdrive/ui/qt/api.cc index b73772544b..0e321d4e10 100644 --- a/selfdrive/ui/qt/api.cc +++ b/selfdrive/ui/qt/api.cc @@ -85,7 +85,7 @@ void HttpRequest::sendRequest(const QString &requestURL, const HttpRequest::Meth return; } QString token; - if(create_jwt) { + if (create_jwt) { token = CommaApi::create_jwt(); } else { QString token_json = QString::fromStdString(util::read_file(util::getenv("HOME") + "/.comma/auth.json")); diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 804bf037a1..8b0f9c1f36 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -139,7 +139,7 @@ void TogglesPanel::updateToggles() { "

%6


" "%7") .arg(tr("openpilot defaults to driving in chill mode. Experimental mode enables alpha-level features that aren't ready for chill mode. Experimental features are listed below:")) - .arg(tr("End-to-End Longitudinal Control" )) + .arg(tr("End-to-End Longitudinal Control")) .arg(tr("Let the driving model control the gas and brakes. openpilot will drive as it thinks a human would, including stopping for red lights and stop signs. " "Since the driving model decides the speed to drive, the set speed will only act as an upper bound. This is an alpha quality feature; " "mistakes should be expected.")) diff --git a/selfdrive/ui/qt/util.cc b/selfdrive/ui/qt/util.cc index 1e25d2d536..7bd168121a 100644 --- a/selfdrive/ui/qt/util.cc +++ b/selfdrive/ui/qt/util.cc @@ -134,7 +134,7 @@ void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, co } -QWidget* topWidget (QWidget* widget) { +QWidget* topWidget(QWidget* widget) { while (widget->parentWidget() != nullptr) widget=widget->parentWidget(); return widget; } @@ -197,8 +197,7 @@ QColor interpColor(float xv, std::vector xp, std::vector fp) { (xv - xp[low]) * (fp[hi].red() - fp[low].red()) / (xp[hi] - xp[low]) + fp[low].red(), (xv - xp[low]) * (fp[hi].green() - fp[low].green()) / (xp[hi] - xp[low]) + fp[low].green(), (xv - xp[low]) * (fp[hi].blue() - fp[low].blue()) / (xp[hi] - xp[low]) + fp[low].blue(), - (xv - xp[low]) * (fp[hi].alpha() - fp[low].alpha()) / (xp[hi] - xp[low]) + fp[low].alpha() - ); + (xv - xp[low]) * (fp[hi].alpha() - fp[low].alpha()) / (xp[hi] - xp[low]) + fp[low].alpha()); } } diff --git a/selfdrive/ui/qt/util.h b/selfdrive/ui/qt/util.h index 1aa3bd69b1..2aae97b860 100644 --- a/selfdrive/ui/qt/util.h +++ b/selfdrive/ui/qt/util.h @@ -23,7 +23,7 @@ void sigTermHandler(int s); QString timeAgo(const QDateTime &date); void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg); void initApp(int argc, char *argv[], bool disable_hidpi = true); -QWidget* topWidget (QWidget* widget); +QWidget* topWidget(QWidget* widget); QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio); QPixmap bootstrapPixmap(const QString &id); diff --git a/system/logcatd/logcatd_systemd.cc b/system/logcatd/logcatd_systemd.cc index 70467a9c15..721726ed27 100644 --- a/system/logcatd/logcatd_systemd.cc +++ b/system/logcatd/logcatd_systemd.cc @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { // Wait for new message if we didn't receive anything if (err == 0) { err = sd_journal_wait(journal, 1000 * 1000); - assert (err >= 0); + assert(err >= 0); continue; // Try again } diff --git a/system/sensord/sensors/bmx055_magn.cc b/system/sensord/sensors/bmx055_magn.cc index 7716ce25c0..950e608923 100644 --- a/system/sensord/sensors/bmx055_magn.cc +++ b/system/sensord/sensors/bmx055_magn.cc @@ -77,7 +77,7 @@ int BMX055_Magn::init() { // suspend -> sleep int ret = set_register(BMX055_MAGN_I2C_REG_PWR_0, 0x01); - if(ret < 0) { + if (ret < 0) { LOGE("Enabling power failed: %d", ret); goto fail; } @@ -90,21 +90,21 @@ int BMX055_Magn::init() { // Load magnetometer trim ret = read_register(BMX055_MAGN_I2C_REG_DIG_X1, trim_x1y1, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_X2, trim_x2y2, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_XY2, trim_xy1xy2, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z1_LSB, trim_z1, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z2_LSB, trim_z2, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z3_LSB, trim_z3, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_Z4_LSB, trim_z4, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; ret = read_register(BMX055_MAGN_I2C_REG_DIG_XYZ1_LSB, trim_xyz1, 2); - if(ret < 0) goto fail; + if (ret < 0) goto fail; // Read trim data trim_data.dig_x1 = trim_x1y1[0]; diff --git a/system/sensord/sensors/lsm6ds3_gyro.cc b/system/sensord/sensors/lsm6ds3_gyro.cc index 9bc43485af..e6bdc6c8a9 100644 --- a/system/sensord/sensors/lsm6ds3_gyro.cc +++ b/system/sensord/sensors/lsm6ds3_gyro.cc @@ -128,7 +128,7 @@ int LSM6DS3_Gyro::init() { } ret = self_test(LSM6DS3_GYRO_POSITIVE_TEST); - if (ret < 0 ) { + if (ret < 0) { LOGE("LSM6DS3 gyro positive self-test failed!"); if (do_self_test) goto fail; } diff --git a/system/ubloxd/tests/test_glonass_kaitai.cc b/system/ubloxd/tests/test_glonass_kaitai.cc index 5ad274142a..96f43742b4 100644 --- a/system/ubloxd/tests/test_glonass_kaitai.cc +++ b/system/ubloxd/tests/test_glonass_kaitai.cc @@ -101,7 +101,7 @@ std::string generate_inp_data(string_data& data) { string_data.reserve(16); for (int i = 0; i < 128; i+=8) { std::string substr = inp_data.substr(i, 8); - string_data.push_back( (uint8_t)std::stoi(substr.c_str(), 0, 2)); + string_data.push_back((uint8_t)std::stoi(substr.c_str(), 0, 2)); } return string_data; diff --git a/system/ubloxd/ublox_msg.cc b/system/ubloxd/ublox_msg.cc index c0554773a2..338b879dcc 100644 --- a/system/ubloxd/ublox_msg.cc +++ b/system/ubloxd/ublox_msg.cc @@ -23,26 +23,26 @@ inline static bool bit_to_bool(uint8_t val, int shifts) { inline int UbloxMsgParser::needed_bytes() { // Msg header incomplete? - if(bytes_in_parse_buf < ublox::UBLOX_HEADER_SIZE) + if (bytes_in_parse_buf < ublox::UBLOX_HEADER_SIZE) return ublox::UBLOX_HEADER_SIZE + ublox::UBLOX_CHECKSUM_SIZE - bytes_in_parse_buf; uint16_t needed = UBLOX_MSG_SIZE(msg_parse_buf) + ublox::UBLOX_HEADER_SIZE + ublox::UBLOX_CHECKSUM_SIZE; // too much data - if(needed < (uint16_t)bytes_in_parse_buf) + if (needed < (uint16_t)bytes_in_parse_buf) return -1; return needed - (uint16_t)bytes_in_parse_buf; } inline bool UbloxMsgParser::valid_cheksum() { uint8_t ck_a = 0, ck_b = 0; - for(int i = 2; i < bytes_in_parse_buf - ublox::UBLOX_CHECKSUM_SIZE;i++) { + for (int i = 2; i < bytes_in_parse_buf - ublox::UBLOX_CHECKSUM_SIZE;i++) { ck_a = (ck_a + msg_parse_buf[i]) & 0xFF; ck_b = (ck_b + ck_a) & 0xFF; } - if(ck_a != msg_parse_buf[bytes_in_parse_buf - 2]) { + if (ck_a != msg_parse_buf[bytes_in_parse_buf - 2]) { LOGD("Checksum a mismatch: %02X, %02X", ck_a, msg_parse_buf[6]); return false; } - if(ck_b != msg_parse_buf[bytes_in_parse_buf - 1]) { + if (ck_b != msg_parse_buf[bytes_in_parse_buf - 1]) { LOGD("Checksum b mismatch: %02X, %02X", ck_b, msg_parse_buf[7]); return false; } @@ -55,13 +55,13 @@ inline bool UbloxMsgParser::valid() { } inline bool UbloxMsgParser::valid_so_far() { - if(bytes_in_parse_buf > 0 && msg_parse_buf[0] != ublox::PREAMBLE1) { + if (bytes_in_parse_buf > 0 && msg_parse_buf[0] != ublox::PREAMBLE1) { return false; } - if(bytes_in_parse_buf > 1 && msg_parse_buf[1] != ublox::PREAMBLE2) { + if (bytes_in_parse_buf > 1 && msg_parse_buf[1] != ublox::PREAMBLE2) { return false; } - if(needed_bytes() == 0 && !valid()) { + if (needed_bytes() == 0 && !valid()) { return false; } return true; @@ -70,8 +70,8 @@ inline bool UbloxMsgParser::valid_so_far() { bool UbloxMsgParser::add_data(float log_time, const uint8_t *incoming_data, uint32_t incoming_data_len, size_t &bytes_consumed) { last_log_time = log_time; int needed = needed_bytes(); - if(needed > 0) { - bytes_consumed = std::min((uint32_t)needed, incoming_data_len ); + if (needed > 0) { + bytes_consumed = std::min((uint32_t)needed, incoming_data_len); // Add data to buffer memcpy(msg_parse_buf + bytes_in_parse_buf, incoming_data, bytes_consumed); bytes_in_parse_buf += bytes_consumed; @@ -80,15 +80,15 @@ bool UbloxMsgParser::add_data(float log_time, const uint8_t *incoming_data, uint } // Validate msg format, detect invalid header and invalid checksum. - while(!valid_so_far() && bytes_in_parse_buf != 0) { + while (!valid_so_far() && bytes_in_parse_buf != 0) { // Corrupted msg, drop a byte. bytes_in_parse_buf -= 1; - if(bytes_in_parse_buf > 0) + if (bytes_in_parse_buf > 0) memmove(&msg_parse_buf[0], &msg_parse_buf[1], bytes_in_parse_buf); } // There is redundant data at the end of buffer, reset the buffer. - if(needed_bytes() == -1) { + if (needed_bytes() == -1) { bytes_in_parse_buf = 0; } return valid(); @@ -435,7 +435,7 @@ kj::Array UbloxMsgParser::gen_rxm_rawx(ubx_t::rxm_rawx_t *msg) { auto mb = mr.initMeasurements(msg->num_meas()); auto measurements = *msg->meas(); - for(int8_t i = 0; i < msg->num_meas(); i++) { + for (int8_t i = 0; i < msg->num_meas(); i++) { mb[i].setSvId(measurements[i]->sv_id()); mb[i].setPseudorange(measurements[i]->pr_mes()); mb[i].setCarrierCycles(measurements[i]->cp_mes()); @@ -470,7 +470,7 @@ kj::Array UbloxMsgParser::gen_nav_sat(ubx_t::nav_sat_t *msg) { auto svs = sr.initSvs(msg->num_svs()); auto svs_data = *msg->svs(); - for(int8_t i = 0; i < msg->num_svs(); i++) { + for (int8_t i = 0; i < msg->num_svs(); i++) { svs[i].setSvId(svs_data[i]->sv_id()); svs[i].setGnssId(svs_data[i]->gnss_id()); svs[i].setFlagsBitfield(svs_data[i]->flags()); diff --git a/system/ubloxd/ublox_msg.h b/system/ubloxd/ublox_msg.h index 4eafeac2ca..d21760edc2 100644 --- a/system/ubloxd/ublox_msg.h +++ b/system/ubloxd/ublox_msg.h @@ -52,7 +52,7 @@ namespace ublox { assert(msg.size() > 2); uint8_t ck_a = 0, ck_b = 0; - for(int i = 2; i < msg.size(); i++) { + for (int i = 2; i < msg.size(); i++) { ck_a = (ck_a + msg[i]) & 0xFF; ck_b = (ck_b + ck_a) & 0xFF; } diff --git a/system/ubloxd/ubloxd.cc b/system/ubloxd/ubloxd.cc index 1dae6dc866..668c1a7ec0 100644 --- a/system/ubloxd/ubloxd.cc +++ b/system/ubloxd/ubloxd.cc @@ -41,9 +41,9 @@ int main() { size_t len = ubloxRaw.size(); size_t bytes_consumed = 0; - while(bytes_consumed < len && !do_exit) { + while (bytes_consumed < len && !do_exit) { size_t bytes_consumed_this_time = 0U; - if(parser.add_data(log_time, data + bytes_consumed, (uint32_t)(len - bytes_consumed), bytes_consumed_this_time)) { + if (parser.add_data(log_time, data + bytes_consumed, (uint32_t)(len - bytes_consumed), bytes_consumed_this_time)) { try { auto ublox_msg = parser.gen_msg(); diff --git a/tools/cabana/signalview.h b/tools/cabana/signalview.h index 5cab7f8fa0..9d8571d0b8 100644 --- a/tools/cabana/signalview.h +++ b/tools/cabana/signalview.h @@ -131,7 +131,7 @@ private: QAbstractItemView::dataChanged(topLeft, bottomRight, roles); } void leaveEvent(QEvent *event) override { - emit ((SignalView *)parentWidget())->highlight(nullptr); + emit static_cast(parentWidget())->highlight(nullptr); QTreeView::leaveEvent(event); } }; From af8af3209dc0756ccc25e41612b855d54b8d7af4 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 23 Aug 2023 14:42:27 -0700 Subject: [PATCH 101/159] thermald: type annotate main thread (#29414) * type * stash * Revert "stash" This reverts commit f5e5e0d08c967d1a5d9c239e6335f8a47890b1a1. * bug in mypy --- selfdrive/thermald/thermald.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index b80ce71aea..266b28db04 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -165,7 +165,7 @@ def hw_state_thread(end_event, hw_queue): time.sleep(DT_TRML) -def thermald_thread(end_event, hw_queue): +def thermald_thread(end_event, hw_queue) -> None: pm = messaging.PubMaster(['deviceState']) sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "controlsState", "pandaStates"], poll=["pandaStates"]) @@ -177,10 +177,10 @@ def thermald_thread(end_event, hw_queue): startup_conditions: Dict[str, bool] = {} startup_conditions_prev: Dict[str, bool] = {} - off_ts = None - started_ts = None + off_ts: Optional[float] = None + started_ts: Optional[float] = None started_seen = False - startup_blocked_ts = None + startup_blocked_ts: Optional[float] = None thermal_status = ThermalStatus.yellow last_hw_state = HardwareState( From 2c20a2b5d7956d5ae5e27508ffa19b6694bbe224 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 05:47:34 +0800 Subject: [PATCH 102/159] sound.h: add #pragma once (#29567) --- selfdrive/ui/soundd/sound.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selfdrive/ui/soundd/sound.h b/selfdrive/ui/soundd/sound.h index f7084fff97..81a5f1a86b 100644 --- a/selfdrive/ui/soundd/sound.h +++ b/selfdrive/ui/soundd/sound.h @@ -1,3 +1,5 @@ +#pragma once + #include #include From f203648de0a9d78121d3a775ae454a43e1211e62 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 06:00:30 +0800 Subject: [PATCH 103/159] cpplint: add filter `whitespace/semicolon` (#29568) --- .pre-commit-config.yaml | 2 +- selfdrive/modeld/tests/snpe_benchmark/benchmark.cc | 2 +- selfdrive/ui/ui.cc | 2 +- system/camerad/cameras/camera_qcom2.cc | 2 +- system/ubloxd/ublox_msg.cc | 2 +- tools/cabana/messageswidget.cc | 2 +- tools/cabana/tools/findsignal.cc | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5e638da32..bcd19726ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/parens,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/parens,+whitespace/semicolon,+readability/braces - repo: local hooks: - id: test_translations diff --git a/selfdrive/modeld/tests/snpe_benchmark/benchmark.cc b/selfdrive/modeld/tests/snpe_benchmark/benchmark.cc index 2034c80888..0a17cf9fca 100644 --- a/selfdrive/modeld/tests/snpe_benchmark/benchmark.cc +++ b/selfdrive/modeld/tests/snpe_benchmark/benchmark.cc @@ -161,7 +161,7 @@ void testrun(char* modelfile) { const auto &inputShape = *inputDims_opt; std::cout << "winkwink" << std::endl; - for (int i=0;i<10000;i++) { + for (int i=0; i<10000; i++) { std::unique_ptr input; input = zdl::SNPE::SNPEFactory::getTensorFactory().createTensor(inputShape); get_testframe(i,input); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 5a01e7f8eb..26e8464a61 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -173,7 +173,7 @@ static void update_state(UIState *s) { 0,0,1, 1,0,0; Eigen::Matrix3d view_from_calib = view_from_device * device_from_calib; - Eigen::Matrix3d view_from_wide_calib = view_from_device * wide_from_device * device_from_calib ; + Eigen::Matrix3d view_from_wide_calib = view_from_device * wide_from_device * device_from_calib; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { scene.view_from_calib.v[i*3 + j] = view_from_calib(i,j); diff --git a/system/camerad/cameras/camera_qcom2.cc b/system/camerad/cameras/camera_qcom2.cc index 95ec47171d..b404c2a2e9 100644 --- a/system/camerad/cameras/camera_qcom2.cc +++ b/system/camerad/cameras/camera_qcom2.cc @@ -508,7 +508,7 @@ void CameraState::enqueue_buffer(int i, bool dp) { } void CameraState::enqueue_req_multi(int start, int n, bool dp) { - for (int i=start;i cmp = nullptr; switch (compare_cb->currentIndex()) { case 0: cmp = [v1](double v) { return v == v1;}; break; - case 1: cmp = [v1](double v) { return v > v1;};break; - case 2: cmp = [v1](double v) { return v >= v1;};break; + case 1: cmp = [v1](double v) { return v > v1;}; break; + case 2: cmp = [v1](double v) { return v >= v1;}; break; case 3: cmp = [v1](double v) { return v != v1;}; break; case 4: cmp = [v1](double v) { return v < v1;}; break; case 5: cmp = [v1](double v) { return v <= v1;}; break; From 3b01d99d3001034890f17aaf3834c92e7e689661 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 23 Aug 2023 18:22:52 -0400 Subject: [PATCH 104/159] Hyundai longitudinal (CAN): display AEB indicator on non-FCA cars (#29484) * Hyundai longitudinal (CAN): display AEB indicator on dashboard on non-FCA cars * clear up comment --------- Co-authored-by: Shane Smiskol --- selfdrive/car/hyundai/hyundaican.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index 64fc241273..0083974020 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -148,6 +148,13 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, s "aReqValue": accel, # stock ramps up and down respecting jerk limit until it reaches aReqRaw "CR_VSM_Alive": idx % 0xF, } + + # show AEB disabled indicator on dash with SCC12 if not sending FCA messages. + # these signals also prevent a TCS fault on non-FCA cars with alpha longitudinal + if not use_fca: + scc12_values["CF_VSM_ConfMode"] = 1 + scc12_values["AEB_Status"] = 1 # AEB disabled + scc12_dat = packer.make_can_msg("SCC12", 0, scc12_values)[2] scc12_values["CR_VSM_ChkSum"] = 0x10 - sum(sum(divmod(i, 16)) for i in scc12_dat) % 0x10 @@ -171,7 +178,7 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, s "CR_FCA_Alive": idx % 0xF, "PAINT1_Status": 1, "FCA_DrvSetStatus": 1, - "FCA_Status": 1, # AEB disabled + "FCA_Status": 1, # AEB disabled } fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2] fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7]) From 2e4f8e6608bafc89509f6c104688b7dd8273eeac Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 23 Aug 2023 15:33:23 -0700 Subject: [PATCH 105/159] CI: Docs rebuild base image (#29566) * docs rebuild base image * fix order --- .github/workflows/setup/action.yaml | 8 ++++---- .github/workflows/tools_tests.yaml | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/setup/action.yaml b/.github/workflows/setup/action.yaml index e791e51ac2..2eeefd9f3e 100644 --- a/.github/workflows/setup/action.yaml +++ b/.github/workflows/setup/action.yaml @@ -32,6 +32,9 @@ runs: restore-keys: | scons-${{ env.CACHE_COMMIT_DATE }}- scons- + # build our docker image + - shell: bash + run: eval ${{ env.BUILD }} - id: setup-scons-cache-docker name: Sets up a docker image with scons cache that can by mounted as a buildkit cache mount shell: bash @@ -39,7 +42,4 @@ runs: run: | cp selfdrive/test/Dockerfile.scons_cache ~ cd ~ - DOCKER_BUILDKIT=1 docker build -t scons-cache -f Dockerfile.scons_cache . - # build our docker image - - shell: bash - run: eval ${{ env.BUILD }} + DOCKER_BUILDKIT=1 docker build -t scons-cache -f Dockerfile.scons_cache . \ No newline at end of file diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 04f73d21af..5fd7555473 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -75,10 +75,6 @@ jobs: name: build docs runs-on: ubuntu-20.04 timeout-minutes: 45 - env: - BUILD: | - docker pull $DOCKER_REGISTRY/openpilot-docs:latest - DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . steps: - uses: actions/checkout@v3 with: @@ -87,6 +83,9 @@ jobs: with: setup_docker_scons_cache: true git_lfs: false + - name: Build docs image + run: | + DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . - name: Push docker container if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' run: | From 55cca6ed2669829a77ce660625b2fc8d73bf02bf Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 06:43:27 +0800 Subject: [PATCH 106/159] scons: remove missing MPC headers (#29485) * remove invalid files * Update selfdrive/controls/lib/lateral_mpc_lib/SConscript Co-authored-by: Shane Smiskol * Apply suggestions from code review --------- Co-authored-by: Shane Smiskol --- selfdrive/controls/lib/lateral_mpc_lib/SConscript | 5 ++--- selfdrive/controls/lib/longitudinal_mpc_lib/SConscript | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/selfdrive/controls/lib/lateral_mpc_lib/SConscript b/selfdrive/controls/lib/lateral_mpc_lib/SConscript index 507964efe4..a923baca62 100644 --- a/selfdrive/controls/lib/lateral_mpc_lib/SConscript +++ b/selfdrive/controls/lib/lateral_mpc_lib/SConscript @@ -38,9 +38,8 @@ generated_files = [ f'{gen}/lat_model/lat_expl_vde_adj.c', f'{gen}/lat_model/lat_model.h', - f'{gen}/lat_cost/lat_cost_y_fun.h', - f'{gen}/lat_cost/lat_cost_y_e_fun.h', - f'{gen}/lat_cost/lat_cost_y_0_fun.h', + f'{gen}/lat_constraints/lat_constraints.h', + f'{gen}/lat_cost/lat_cost.h', ] + build_files acados_dir = '#third_party/acados' diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript b/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript index 8717bdf89b..c78be70fe3 100644 --- a/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript @@ -44,10 +44,8 @@ generated_files = [ f'{gen}/long_model/long_expl_vde_adj.c', f'{gen}/long_model/long_model.h', - f'{gen}/long_constraints/long_h_constraint.h', - f'{gen}/long_cost/long_cost_y_fun.h', - f'{gen}/long_cost/long_cost_y_e_fun.h', - f'{gen}/long_cost/long_cost_y_0_fun.h', + f'{gen}/long_constraints/long_constraints.h', + f'{gen}/long_cost/long_cost.h', ] + build_files acados_dir = '#third_party/acados' From 5fcb7e9038ec9054dcdb8d9b832bea2f597d6aa9 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 07:34:18 +0800 Subject: [PATCH 107/159] ui/PrimeUserWidget: cleanup layout (#29492) cleanup layout Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/widgets/prime.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/selfdrive/ui/qt/widgets/prime.cc b/selfdrive/ui/qt/widgets/prime.cc index 782b7cb5ce..91a0fc8597 100644 --- a/selfdrive/ui/qt/widgets/prime.cc +++ b/selfdrive/ui/qt/widgets/prime.cc @@ -117,28 +117,19 @@ PairingPopup::PairingPopup(QWidget *parent) : QDialogBase(parent) { } -PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QFrame(parent) { +PrimeUserWidget::PrimeUserWidget(QWidget *parent) : QFrame(parent) { + setObjectName("primeWidget"); QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->setSpacing(30); - - // subscribed prime layout - QWidget *primeWidget = new QWidget; - primeWidget->setObjectName("primeWidget"); - QVBoxLayout *primeLayout = new QVBoxLayout(primeWidget); - primeLayout->setContentsMargins(56, 40, 56, 40); - primeLayout->setSpacing(20); + mainLayout->setContentsMargins(56, 40, 56, 40); + mainLayout->setSpacing(20); QLabel *subscribed = new QLabel(tr("✓ SUBSCRIBED")); subscribed->setStyleSheet("font-size: 41px; font-weight: bold; color: #86FF4E;"); - primeLayout->addWidget(subscribed); + mainLayout->addWidget(subscribed); QLabel *commaPrime = new QLabel(tr("comma prime")); commaPrime->setStyleSheet("font-size: 75px; font-weight: bold;"); - primeLayout->addWidget(commaPrime); - - mainLayout->addWidget(primeWidget); - mainLayout->addStretch(); + mainLayout->addWidget(commaPrime); } From 472151b6a004d387532415039196c2165f7d32df Mon Sep 17 00:00:00 2001 From: pencilpusher <83676301+jakethesnake420@users.noreply.github.com> Date: Wed, 23 Aug 2023 19:33:58 -0500 Subject: [PATCH 108/159] ui/map: keep the car icon aligned to its bearing (#29482) * rotate icon with current bearing When user is rotating the map, the car icon should stay fixed on the cars bearing, not the map. * spacing * comment --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/maps/map.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index d756a777c4..38bcc1a54e 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -191,6 +191,11 @@ void MapWindow::updateState(const UIState &s) { carPosSource["type"] = "geojson"; carPosSource["data"] = QVariant::fromValue(feature1); m_map->updateSource("carPosSource", carPosSource); + + // Map bearing isn't updated when interacting, keep location marker up to date + if (last_bearing) { + m_map->setLayoutProperty("carPosLayer", "icon-rotate", *last_bearing - m_map->bearing()); + } } if (interaction_counter == 0) { From ba1ad422d74622a6e565a1b5bed97cf379173e21 Mon Sep 17 00:00:00 2001 From: Erich Moraga <33645296+ErichMoraga@users.noreply.github.com> Date: Wed, 23 Aug 2023 19:37:38 -0500 Subject: [PATCH 109/159] Toyota: add engine & fwdRadar ECU versions for 2023 Toyota Camry Hybrid (#29508) `@Varvaras` 2023 Toyota Camry Hybrid Dongle ID/route 3a47f2dd831feb30|2023-08-20--19-41-21 --- selfdrive/car/toyota/values.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index bdde3c6095..b0f7a70985 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -641,12 +641,14 @@ FW_VERSIONS = { (Ecu.engine, 0x700, None): [ b'\x018966306Q6000\x00\x00\x00\x00', b'\x018966306Q7000\x00\x00\x00\x00', + b'\x018966306T0000\x00\x00\x00\x00', b'\x018966306V1000\x00\x00\x00\x00', b'\x01896633T20000\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 15): [ b'\x018821F6201200\x00\x00\x00\x00', b'\x018821F6201300\x00\x00\x00\x00', + b'\x018821F6201400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 109): [ b'\x028646F3305200\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', From 2fdde9b77d5d830277500d6841f32a356544718a Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 23 Aug 2023 17:41:33 -0700 Subject: [PATCH 110/159] CI: switch to --cache-to type=inline for buildkit cache (#29575) this is cleaner --- .github/workflows/prebuilt.yaml | 4 ++-- .github/workflows/selfdrive_tests.yaml | 4 ++-- .github/workflows/tools_tests.yaml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/prebuilt.yaml b/.github/workflows/prebuilt.yaml index 6acc7a2e9c..3b88011f5e 100644 --- a/.github/workflows/prebuilt.yaml +++ b/.github/workflows/prebuilt.yaml @@ -10,7 +10,7 @@ env: DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . + DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . jobs: build_prebuilt: @@ -34,7 +34,7 @@ jobs: - name: Build Docker image run: | eval "$BUILD" - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f Dockerfile.openpilot . + DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f Dockerfile.openpilot . - name: Push to container registry run: | $DOCKER_LOGIN diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 991ce74ca9..b9a9131d71 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -20,12 +20,12 @@ env: DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . + DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c BUILD_CL: | - DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $CL_BASE_IMAGE:latest -f Dockerfile.openpilot_base_cl . + DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $CL_BASE_IMAGE:latest -f Dockerfile.openpilot_base_cl . RUN_CL: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c UNIT_TEST: coverage run --append -m unittest discover diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 5fd7555473..8209c14126 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -17,12 +17,12 @@ env: DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . + DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . RUN: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c BUILD_CL: | - DOCKER_BUILDKIT=1 docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $CL_BASE_IMAGE:latest -f Dockerfile.openpilot_base_cl . + DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $CL_BASE_IMAGE:latest -f Dockerfile.openpilot_base_cl . RUN_CL: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c @@ -64,7 +64,7 @@ jobs: run: eval "$BUILD_CL" - name: Build simulator image run: | - DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f tools/sim/Dockerfile.sim . + DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f tools/sim/Dockerfile.sim . - name: Push to container registry if: github.ref == 'refs/heads/master' && github.repository == 'commaai/openpilot' run: | @@ -85,7 +85,7 @@ jobs: git_lfs: false - name: Build docs image run: | - DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . + DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . - name: Push docker container if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' run: | From a0f3b830622a2ebee2a718554c542cb208b10acf Mon Sep 17 00:00:00 2001 From: Gellis12 Date: Wed, 23 Aug 2023 17:46:34 -0700 Subject: [PATCH 111/159] Add initial fingerprint 2.0 for Nissan Leaf 2018-23 (#29505) Initial fingerprint 2.0 for Nissan Leaf 2018-23 --- selfdrive/car/nissan/values.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/selfdrive/car/nissan/values.py b/selfdrive/car/nissan/values.py index db69132a76..979e09eb66 100644 --- a/selfdrive/car/nissan/values.py +++ b/selfdrive/car/nissan/values.py @@ -131,6 +131,20 @@ FW_VERSIONS = { (Ecu.gateway, 0x18dad0f1, None): [ b'284U29HE0A', ], + }, + CAR.LEAF: { + (Ecu.abs, 0x740, None): [ + b'476606WK9B', + ], + (Ecu.eps, 0x742, None): [ + b'5SN2A\xb7A\x05\x02N126F\x15\xb2\x00\x00\x00\x00\x00\x00\x00\x80', + ], + (Ecu.fwdCamera, 0x707, None): [ + b'6WK2CDB\x04\x18\x00\x00\x00\x00\x00R=1\x18\x99\x10\x00\x00\x00\x80', + ], + (Ecu.gateway, 0x18dad0f1, None): [ + b'284U26WK0C', + ], }, CAR.LEAF_IC: { (Ecu.fwdCamera, 0x707, None): [ From ddd849a882ded042c1f5fb71cb4e200fe2cb8327 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 08:56:22 +0800 Subject: [PATCH 112/159] encoderd: remove unnecessary calls to ` encoder_close()` on exit. (#28970) --- system/loggerd/encoderd.cc | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/system/loggerd/encoderd.cc b/system/loggerd/encoderd.cc index 6dd1f2ae32..1b45df6827 100644 --- a/system/loggerd/encoderd.cc +++ b/system/loggerd/encoderd.cc @@ -47,7 +47,7 @@ bool sync_encoders(EncoderdState *s, CameraType cam_type, uint32_t frame_id) { void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) { util::set_thread_name(cam_info.thread_name); - std::vector encoders; + std::vector> encoders; VisionIpcClient vipc_client = VisionIpcClient("camerad", cam_info.stream_type, false); int cur_seg = 0; @@ -64,14 +64,11 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) { assert(buf_info.width > 0 && buf_info.height > 0); for (const auto &encoder_info : cam_info.encoder_infos) { - encoders.push_back(new Encoder(encoder_info, buf_info.width, buf_info.height)); + auto &e = encoders.emplace_back(new Encoder(encoder_info, buf_info.width, buf_info.height)); + e->encoder_open(nullptr); } } - for (int i = 0; i < encoders.size(); ++i) { - encoders[i]->encoder_open(NULL); - } - bool lagging = false; while (!do_exit) { VisionIpcBufExtra extra; @@ -113,12 +110,6 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) { } } } - - LOG("encoder destroy"); - for (auto &e : encoders) { - e->encoder_close(); - delete e; - } } template From 973d90be779efc0e4a83eeab213c0cc9b4d711ce Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 23 Aug 2023 18:50:55 -0700 Subject: [PATCH 113/159] Subaru: Crosstrek Hybrid dashcam mode (#25378) * Subaru: Crosstrek Hybrid support * hybrid cars in dashcam only * revert that * just dashcam * tah should be abs * remove unused import * use the old dbc for now * hybrid car exceptions in carstate * need dashstatus until we get a proper cruiseactivated bit * missing CP * merge conflicts * lets be consistent about extend * cleanup * fix and comments * preglobal fix * and the rest * and this * added hybrid to release --------- Co-authored-by: Justin Newberry --- release/files_common | 1 + selfdrive/car/subaru/carcontroller.py | 6 +- selfdrive/car/subaru/carstate.py | 84 +++++++++++++++-------- selfdrive/car/subaru/interface.py | 17 ++++- selfdrive/car/subaru/values.py | 23 +++++++ selfdrive/car/tests/routes.py | 1 + selfdrive/car/torque_data/substitute.yaml | 1 + 7 files changed, 101 insertions(+), 32 deletions(-) diff --git a/release/files_common b/release/files_common index bac9b382d6..a229954221 100644 --- a/release/files_common +++ b/release/files_common @@ -569,6 +569,7 @@ opendbc/nissan_x_trail_2017_generated.dbc opendbc/nissan_leaf_2018_generated.dbc opendbc/subaru_global_2017_generated.dbc +opendbc/subaru_global_2020_hybrid_generated.dbc opendbc/subaru_outback_2015_generated.dbc opendbc/subaru_outback_2019_generated.dbc opendbc/subaru_forester_2017_generated.dbc diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index 00915808d0..05524d4524 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -3,6 +3,7 @@ from opendbc.can.packer import CANPacker from openpilot.selfdrive.car import apply_driver_steer_torque_limits from openpilot.selfdrive.car.subaru import subarucan from openpilot.selfdrive.car.subaru.values import DBC, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, CarControllerParams, SubaruFlags +from selfdrive.car.subaru.values import HYBRID_CARS class CarController: @@ -100,8 +101,9 @@ class CarController: self.CP.openpilotLongitudinalControl, cruise_brake > 0, cruise_throttle)) else: if pcm_cancel_cmd: - bus = CanBus.alt if self.CP.carFingerprint in GLOBAL_GEN2 else CanBus.main - can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, bus, pcm_cancel_cmd)) + if self.CP.carFingerprint not in HYBRID_CARS: + bus = CanBus.alt if self.CP.carFingerprint in GLOBAL_GEN2 else CanBus.main + can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, bus, pcm_cancel_cmd)) new_actuators = actuators.copy() new_actuators.steer = self.apply_steer_last / self.p.STEER_MAX diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py index 66c4c6386e..80eab10eba 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -6,6 +6,7 @@ from openpilot.selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from openpilot.selfdrive.car.subaru.values import DBC, CAR, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, SubaruFlags from openpilot.selfdrive.car import CanSignalRateCalculator +from selfdrive.car.subaru.values import HYBRID_CARS class CarState(CarStateBase): @@ -19,7 +20,9 @@ class CarState(CarStateBase): def update(self, cp, cp_cam, cp_body): ret = car.CarState.new_message() - ret.gas = cp.vl["Throttle"]["Throttle_Pedal"] / 255. + throttle_msg = cp.vl["Throttle"] if self.car_fingerprint not in HYBRID_CARS else cp_body.vl["Throttle_Hybrid"] + ret.gas = throttle_msg["Throttle_Pedal"] / 255. + ret.gasPressed = ret.gas > 1e-5 if self.car_fingerprint in PREGLOBAL_CARS: ret.brakePressed = cp.vl["Brake_Pedal"]["Brake_Pedal"] > 2 @@ -46,7 +49,8 @@ class CarState(CarStateBase): ret.leftBlindspot = (cp.vl["BSD_RCTA"]["L_ADJACENT"] == 1) or (cp.vl["BSD_RCTA"]["L_APPROACHING"] == 1) ret.rightBlindspot = (cp.vl["BSD_RCTA"]["R_ADJACENT"] == 1) or (cp.vl["BSD_RCTA"]["R_APPROACHING"] == 1) - can_gear = int(cp.vl["Transmission"]["Gear"]) + cp_transmission = cp_body if self.car_fingerprint in HYBRID_CARS else cp + can_gear = int(cp_transmission.vl["Transmission"]["Gear"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) ret.steeringAngleDeg = cp.vl["Steering_Torque"]["Steering_Angle"] @@ -62,8 +66,12 @@ class CarState(CarStateBase): ret.steeringPressed = abs(ret.steeringTorque) > steer_threshold cp_cruise = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp - ret.cruiseState.enabled = cp_cruise.vl["CruiseControl"]["Cruise_Activated"] != 0 - ret.cruiseState.available = cp_cruise.vl["CruiseControl"]["Cruise_On"] != 0 + if self.car_fingerprint in HYBRID_CARS: + ret.cruiseState.enabled = cp_cam.vl["ES_DashStatus"]['Cruise_Activated'] != 0 + ret.cruiseState.available = cp_cam.vl["ES_DashStatus"]['Cruise_On'] != 0 + else: + ret.cruiseState.enabled = cp_cruise.vl["CruiseControl"]["Cruise_Activated"] != 0 + ret.cruiseState.available = cp_cruise.vl["CruiseControl"]["Cruise_On"] != 0 ret.cruiseState.speed = cp_cam.vl["ES_DashStatus"]["Cruise_Set_Speed"] * CV.KPH_TO_MS if (self.car_fingerprint in PREGLOBAL_CARS and cp.vl["Dash_State2"]["UNITS"] == 1) or \ @@ -77,7 +85,7 @@ class CarState(CarStateBase): cp.vl["BodyInfo"]["DOOR_OPEN_FL"]]) ret.steerFaultPermanent = cp.vl["Steering_Torque"]["Steer_Error_1"] == 1 - cp_es_distance = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp_cam + cp_es_distance = cp_body if self.car_fingerprint in (GLOBAL_GEN2 | HYBRID_CARS) else cp_cam if self.car_fingerprint in PREGLOBAL_CARS: self.cruise_button = cp_cam.vl["ES_Distance"]["Cruise_Button"] self.ready = not cp_cam.vl["ES_DashStatus"]["Not_Ready_Startup"] @@ -87,18 +95,23 @@ class CarState(CarStateBase): ret.cruiseState.standstill = cp_cam.vl["ES_DashStatus"]["Cruise_State"] == 3 ret.stockFcw = (cp_cam.vl["ES_LKAS_State"]["LKAS_Alert"] == 1) or \ (cp_cam.vl["ES_LKAS_State"]["LKAS_Alert"] == 2) - # 8 is known AEB, there are a few other values related to AEB we ignore - ret.stockAeb = (cp_es_distance.vl["ES_Brake"]["AEB_Status"] == 8) and \ - (cp_es_distance.vl["ES_Brake"]["Brake_Pressure"] != 0) + self.es_lkas_state_msg = copy.copy(cp_cam.vl["ES_LKAS_State"]) cp_es_brake = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp_cam self.es_brake_msg = copy.copy(cp_es_brake.vl["ES_Brake"]) cp_es_status = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp_cam - self.es_status_msg = copy.copy(cp_es_status.vl["ES_Status"]) - self.cruise_control_msg = copy.copy(cp_cruise.vl["CruiseControl"]) - self.brake_status_msg = copy.copy(cp_brakes.vl["Brake_Status"]) - self.es_distance_msg = copy.copy(cp_es_distance.vl["ES_Distance"]) + if self.car_fingerprint not in HYBRID_CARS: # Hybrid cars don't have es_distance, need a replacement + # 8 is known AEB, there are a few other values related to AEB we ignore + ret.stockAeb = (cp_es_distance.vl["ES_Brake"]["AEB_Status"] == 8) and \ + (cp_es_distance.vl["ES_Brake"]["Brake_Pressure"] != 0) + self.es_distance_msg = copy.copy(cp_es_distance.vl["ES_Distance"]) + + self.es_status_msg = copy.copy(cp_es_status.vl["ES_Status"]) + self.cruise_control_msg = copy.copy(cp_cruise.vl["CruiseControl"]) + + if self.car_fingerprint not in HYBRID_CARS: + self.es_distance_msg = copy.copy(cp_es_distance.vl["ES_Distance"]) self.es_dashstatus_msg = copy.copy(cp_cam.vl["ES_DashStatus"]) if self.CP.flags & SubaruFlags.SEND_INFOTAINMENT: self.es_infotainment_msg = copy.copy(cp_cam.vl["ES_Infotainment"]) @@ -106,44 +119,53 @@ class CarState(CarStateBase): return ret @staticmethod - def get_common_global_body_messages(): + def get_common_global_body_messages(CP): messages = [ - ("CruiseControl", 20), ("Wheel_Speeds", 50), ("Brake_Status", 50), ] + if CP.carFingerprint not in HYBRID_CARS: + messages.append(("CruiseControl", 20)) + return messages @staticmethod - def get_common_global_es_messages(): + def get_common_global_es_messages(CP): messages = [ ("ES_Brake", 20), - ("ES_Distance", 20), - ("ES_Status", 20), - ("ES_Brake", 20), ] + if CP.carFingerprint not in HYBRID_CARS: + messages += [ + ("ES_Distance", 20), + ("ES_Status", 20) + ] + return messages @staticmethod def get_can_parser(CP): messages = [ # sig_address, frequency - ("Throttle", 100), ("Dashlights", 10), - ("Brake_Pedal", 50), - ("Transmission", 100), ("Steering_Torque", 50), ("BodyInfo", 1), + ("Brake_Pedal", 50), ] + if CP.carFingerprint not in HYBRID_CARS: + messages += [ + ("Throttle", 100), + ("Transmission", 100) + ] + if CP.enableBsm: messages.append(("BSD_RCTA", 17)) if CP.carFingerprint not in PREGLOBAL_CARS: if CP.carFingerprint not in GLOBAL_GEN2: - messages += CarState.get_common_global_body_messages() + messages += CarState.get_common_global_body_messages(CP) messages += [ ("Dashlights", 10), @@ -184,7 +206,7 @@ class CarState(CarStateBase): ] if CP.carFingerprint not in GLOBAL_GEN2: - messages += CarState.get_common_global_es_messages() + messages += CarState.get_common_global_es_messages(CP) if CP.flags & SubaruFlags.SEND_INFOTAINMENT: messages.append(("ES_Infotainment", 10)) @@ -193,9 +215,17 @@ class CarState(CarStateBase): @staticmethod def get_body_can_parser(CP): + messages = [] + if CP.carFingerprint in GLOBAL_GEN2: - messages = CarState.get_common_global_body_messages() - messages += CarState.get_common_global_es_messages() - return CANParser(DBC[CP.carFingerprint]["pt"], messages, CanBus.alt) + messages += CarState.get_common_global_body_messages(CP) + messages += CarState.get_common_global_es_messages(CP) + + if CP.carFingerprint in HYBRID_CARS: + messages += [ + ("Throttle_Hybrid", 40), + ("Transmission", 100) + ] + + return CANParser(DBC[CP.carFingerprint]["pt"], messages, CanBus.alt) - return None diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index b206a816ac..e6e69316f8 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -3,7 +3,7 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car import get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase -from openpilot.selfdrive.car.subaru.values import CAR, LKAS_ANGLE, GLOBAL_GEN2, PREGLOBAL_CARS, SubaruFlags +from openpilot.selfdrive.car.subaru.values import CAR, LKAS_ANGLE, GLOBAL_GEN2, PREGLOBAL_CARS, HYBRID_CARS, SubaruFlags class CarInterface(CarInterfaceBase): @@ -12,7 +12,11 @@ class CarInterface(CarInterfaceBase): def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): ret.carName = "subaru" ret.radarUnavailable = True - ret.dashcamOnly = candidate in (PREGLOBAL_CARS | LKAS_ANGLE) + # for HYBRID CARS to be upstreamed, we need: + # - replacement for ES_Distance so we can cancel the cruise control + # - to find the Cruise_Activated bit from the car + # - proper panda safety setup (use the correct cruise_activated bit, throttle from Throttle_Hybrid, etc) + ret.dashcamOnly = candidate in (PREGLOBAL_CARS | LKAS_ANGLE | HYBRID_CARS) ret.autoResumeSng = False # Detect infotainment message sent from the camera @@ -68,6 +72,13 @@ class CarInterface(CarInterfaceBase): ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 14., 23.], [0., 14., 23.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.045, 0.042, 0.20], [0.04, 0.035, 0.045]] + elif candidate == CAR.CROSSTREK_HYBRID: + ret.mass = 1668. + ret.wheelbase = 2.67 + ret.centerToFront = ret.wheelbase * 0.5 + ret.steerRatio = 17 + ret.steerActuatorDelay = 0.1 + elif candidate in (CAR.FORESTER, CAR.FORESTER_2022): ret.mass = 1568. ret.wheelbase = 2.67 @@ -107,7 +118,7 @@ class CarInterface(CarInterfaceBase): else: raise ValueError(f"unknown car: {candidate}") - #ret.experimentalLongitudinalAvailable = candidate not in (GLOBAL_GEN2 | PREGLOBAL_CARS | LKAS_ANGLE) + #ret.experimentalLongitudinalAvailable = candidate not in (GLOBAL_GEN2 | PREGLOBAL_CARS | LKAS_ANGLE | HYBRID_CARS) ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable if ret.openpilotLongitudinalControl: diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index 8cb3a904b2..4cc1df9754 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -70,6 +70,7 @@ class CAR: IMPREZA_2020 = "SUBARU IMPREZA SPORT 2020" FORESTER = "SUBARU FORESTER 2019" OUTBACK = "SUBARU OUTBACK 6TH GEN" + CROSSTREK_HYBRID = "SUBARU CROSSTREK HYBRID 2020" LEGACY = "SUBARU LEGACY 7TH GEN" FORESTER_2022 = "SUBARU FORESTER 2022" OUTBACK_2023 = "SUBARU OUTBACK 7TH GEN" @@ -110,6 +111,8 @@ CAR_INFO: Dict[str, Union[SubaruCarInfo, List[SubaruCarInfo]]] = { SubaruCarInfo("Subaru Crosstrek 2020-23"), SubaruCarInfo("Subaru XV 2020-21"), ], + # TODO: is there an XV and Impreza too? + CAR.CROSSTREK_HYBRID: SubaruCarInfo("Subaru Crosstrek Hybrid 2020"), CAR.FORESTER: SubaruCarInfo("Subaru Forester 2019-21", "All"), CAR.FORESTER_PREGLOBAL: SubaruCarInfo("Subaru Forester 2017-18"), CAR.LEGACY_PREGLOBAL: SubaruCarInfo("Subaru Legacy 2015-18"), @@ -325,6 +328,24 @@ FW_VERSIONS = { b'\xe9\xf6B0\x00', ], }, + CAR.CROSSTREK_HYBRID: { + (Ecu.abs, 0x7b0, None): [ + b'\xa2 \x19e\x01', + b'\xa2 !e\x01', + ], + (Ecu.eps, 0x746, None): [ + b'\x9a\xc2\x01\x00', + b'\n\xc2\x01\x00', + ], + (Ecu.fwdCamera, 0x787, None): [ + b'\x00\x00el\x1f@ #', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xd7!`@\x07', + b'\xd7!`p\a', + b'\xf4!`0\x07', + ], + }, CAR.FORESTER: { (Ecu.abs, 0x7b0, None): [ b'\xa3 \x18\x14\x00', @@ -628,6 +649,7 @@ DBC = { CAR.FORESTER: dbc_dict('subaru_global_2017_generated', None), CAR.FORESTER_2022: dbc_dict('subaru_global_2017_generated', None), CAR.OUTBACK: dbc_dict('subaru_global_2017_generated', None), + CAR.CROSSTREK_HYBRID: dbc_dict('subaru_global_2020_hybrid_generated', None), CAR.OUTBACK_2023: dbc_dict('subaru_global_2017_generated', None), CAR.LEGACY: dbc_dict('subaru_global_2017_generated', None), CAR.FORESTER_PREGLOBAL: dbc_dict('subaru_forester_2017_generated', None), @@ -639,3 +661,4 @@ DBC = { LKAS_ANGLE = {CAR.FORESTER_2022, CAR.OUTBACK_2023} GLOBAL_GEN2 = {CAR.OUTBACK, CAR.LEGACY, CAR.OUTBACK_2023} PREGLOBAL_CARS = {CAR.FORESTER_PREGLOBAL, CAR.LEGACY_PREGLOBAL, CAR.OUTBACK_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018} +HYBRID_CARS = {CAR.CROSSTREK_HYBRID, } \ No newline at end of file diff --git a/selfdrive/car/tests/routes.py b/selfdrive/car/tests/routes.py index 60b99a1ad6..4ecf6e192a 100644 --- a/selfdrive/car/tests/routes.py +++ b/selfdrive/car/tests/routes.py @@ -240,6 +240,7 @@ routes = [ CarTestRoute("8bf7e79a3ce64055|2021-05-24--09-36-27", SUBARU.IMPREZA_2020), CarTestRoute("1bbe6bf2d62f58a8|2022-07-14--17-11-43", SUBARU.OUTBACK, segment=10), CarTestRoute("c56e69bbc74b8fad|2022-08-18--09-43-51", SUBARU.LEGACY, segment=3), + CarTestRoute("f4e3a0c511a076f4|2022-08-04--16-16-48", SUBARU.CROSSTREK_HYBRID, segment=2), CarTestRoute("7fd1e4f3a33c1673|2022-12-04--15-09-53", SUBARU.FORESTER_2022, segment=4), CarTestRoute("f3b34c0d2632aa83|2023-07-23--20-43-25", SUBARU.OUTBACK_2023, segment=7), # Pre-global, dashcam diff --git a/selfdrive/car/torque_data/substitute.yaml b/selfdrive/car/torque_data/substitute.yaml index d79dbe8573..0f742e6f39 100644 --- a/selfdrive/car/torque_data/substitute.yaml +++ b/selfdrive/car/torque_data/substitute.yaml @@ -76,6 +76,7 @@ VOLKSWAGEN POLO 6TH GEN: VOLKSWAGEN GOLF 7TH GEN SEAT LEON 3RD GEN: VOLKSWAGEN GOLF 7TH GEN SEAT ATECA 1ST GEN: VOLKSWAGEN GOLF 7TH GEN +SUBARU CROSSTREK HYBRID 2020: SUBARU IMPREZA SPORT 2020 SUBARU LEGACY 7TH GEN: SUBARU OUTBACK 6TH GEN # Old subarus don't have much data guessing it's like low torque impreza From f4f8047e979c3366ab4ecd7527cc6daf01f126db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Wed, 23 Aug 2023 19:48:55 -0700 Subject: [PATCH 114/159] Laikad: ignore more garbage measurements (#29569) * Laikad: ignore more garbage measurememnts * bump laika --- laika_repo | 2 +- selfdrive/locationd/laikad.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/laika_repo b/laika_repo index 989b6a8505..a028f6a2c9 160000 --- a/laika_repo +++ b/laika_repo @@ -1 +1 @@ -Subproject commit 989b6a8505441a550c94f60b4378be296ea3fe92 +Subproject commit a028f6a2c95adf03fa240a9479ad33290969055e diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index 42d9303fd6..3d190fb00a 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -205,12 +205,16 @@ class Laikad: # Additionally, the pseudoranges are broken in the measurementReports # and the doppler filteredSpeed is broken in the drMeasurementReports report_time = gps_time_from_qcom_report(gnss_msg) - if report_time - self.last_report_time > 0: + if report_time - self.last_report_time == 0: + self.qcom_reports.append(gnss_msg) + self.last_report_time = report_time + elif report_time - self.last_report_time > 0: self.qcom_reports_received = max(1, len(self.qcom_reports)) self.qcom_reports = [gnss_msg] + self.last_report_time = report_time else: - self.qcom_reports.append(gnss_msg) - self.last_report_time = report_time + # Sometimes DR reports get sent one iteration late (1second), they need to be ignored + cloudlog.warning(f"Received report with time {report_time} before last report time {self.last_report_time}") if len(self.qcom_reports) == self.qcom_reports_received: new_meas = get_measurements_from_qcom_reports(self.qcom_reports) From 95e9232963ad2deed377a3d840f25e40f921b8ca Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 11:08:19 +0800 Subject: [PATCH 115/159] encoder/VideoWriter: remove unnecessary call to `avcodec_close` (#29039) --- system/loggerd/video_writer.cc | 4 +--- system/loggerd/video_writer.h | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/system/loggerd/video_writer.cc b/system/loggerd/video_writer.cc index 1b449056cb..90b5f1af3d 100644 --- a/system/loggerd/video_writer.cc +++ b/system/loggerd/video_writer.cc @@ -1,6 +1,5 @@ #pragma clang diagnostic ignored "-Wdeprecated-declarations" #include -#include #include "system/loggerd/video_writer.h" #include "common/swaglog.h" @@ -8,7 +7,6 @@ VideoWriter::VideoWriter(const char *path, const char *filename, bool remuxing, int width, int height, int fps, cereal::EncodeIndex::Type codec) : remuxing(remuxing) { - raw = codec == cereal::EncodeIndex::Type::BIG_BOX_LOSSLESS; vid_path = util::string_format("%s/%s", path, filename); lock_path = util::string_format("%s/%s.lock", path, filename); @@ -18,6 +16,7 @@ VideoWriter::VideoWriter(const char *path, const char *filename, bool remuxing, LOGD("encoder_open %s remuxing:%d", this->vid_path.c_str(), this->remuxing); if (this->remuxing) { + bool raw = (codec == cereal::EncodeIndex::Type::BIG_BOX_LOSSLESS); avformat_alloc_output_context2(&this->ofmt_ctx, NULL, raw ? "matroska" : NULL, this->vid_path.c_str()); assert(this->ofmt_ctx); @@ -98,7 +97,6 @@ void VideoWriter::write(uint8_t *data, int len, long long timestamp, bool codecc VideoWriter::~VideoWriter() { if (this->remuxing) { - if (this->raw) { avcodec_close(this->codec_ctx); } int err = av_write_trailer(this->ofmt_ctx); if (err != 0) LOGE("av_write_trailer failed %d", err); avcodec_free_context(&this->codec_ctx); diff --git a/system/loggerd/video_writer.h b/system/loggerd/video_writer.h index 01a243904c..1aa758b42b 100644 --- a/system/loggerd/video_writer.h +++ b/system/loggerd/video_writer.h @@ -16,11 +16,10 @@ public: ~VideoWriter(); private: std::string vid_path, lock_path; - FILE *of = nullptr; AVCodecContext *codec_ctx; AVFormatContext *ofmt_ctx; AVStream *out_stream; - bool remuxing, raw; -}; \ No newline at end of file + bool remuxing; +}; From 8b7004e68dfad516adbdecc9925bd7fc954cc8d4 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 11:10:23 +0800 Subject: [PATCH 116/159] swaglog: remove unnecessary string copy (#29164) --- common/swaglog.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/swaglog.cc b/common/swaglog.cc index 060090e18f..c0614c85f5 100644 --- a/common/swaglog.cc +++ b/common/swaglog.cc @@ -64,8 +64,7 @@ static void log(int levelnum, const char* filename, int lineno, const char* func if (levelnum >= s.print_level) { printf("%s: %s\n", filename, msg); } - char levelnum_c = levelnum; - zmq_send(s.sock, (levelnum_c + log_s).c_str(), log_s.length() + 1, ZMQ_NOBLOCK); + zmq_send(s.sock, log_s.data(), log_s.length(), ZMQ_NOBLOCK); } static void cloudlog_common(int levelnum, const char* filename, int lineno, const char* func, @@ -87,8 +86,11 @@ static void cloudlog_common(int levelnum, const char* filename, int lineno, cons log_j["msg"] = msg_j; } - std::string log_s = ((json11::Json)log_j).dump(); + std::string log_s; + log_s += (char)levelnum; + ((json11::Json)log_j).dump(log_s); log(levelnum, filename, lineno, func, msg_buf, log_s); + free(msg_buf); } From cb342461f03e6ff0e6eccbe5de55796b44e659f1 Mon Sep 17 00:00:00 2001 From: Irene <12470297+cydia2020@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:52:01 +1000 Subject: [PATCH 117/159] Toyota: add TODO comment for TSS-P BSM (#28396) * Toyota: enable BSM on C-Hr * Update selfdrive/car/toyota/carstate.py Co-authored-by: Cameron Clough * remove duplicate block * Remove useless addition * make this a comment for now * remove extra bit * clean up * clean up --------- Co-authored-by: Cameron Clough Co-authored-by: Shane Smiskol --- selfdrive/car/toyota/interface.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 89b328b6ae..ab242a09a2 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -199,6 +199,9 @@ class CarInterface(CarInterfaceBase): ret.mass = 4305. * CV.LB_TO_KG ret.centerToFront = ret.wheelbase * 0.44 + + # TODO: Some TSS-P platforms have BSM, but are flipped based on region or driving direction. + # Detect flipped signals and enable for C-HR and others ret.enableBsm = 0x3F6 in fingerprint[0] and candidate in TSS2_CAR # Detect smartDSU, which intercepts ACC_CMD from the DSU (or radar) allowing openpilot to send it From 3719be8b76f81068da3aadd5bd0f76e8a4d00396 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 23 Aug 2023 21:30:12 -0700 Subject: [PATCH 118/159] Subaru: Forester Hybrid 2020 dashcam (#24770) * Add support for Forester Hybrid 2020 Co-authored-by: martinl * it's a param now * make it work * fix * merge and cleanup * remove duplicate * should be forester * bump submodules * should be abs * add missing params * still need a test route * still need a test route * consitent * here too * todo * more * Update selfdrive/car/tests/routes.py * clean up --------- Co-authored-by: martinl Co-authored-by: Justin Newberry --- selfdrive/car/subaru/carcontroller.py | 3 +-- selfdrive/car/subaru/carstate.py | 10 +++++----- selfdrive/car/subaru/interface.py | 8 ++++---- selfdrive/car/subaru/values.py | 22 +++++++++++++++++++++- selfdrive/car/tests/routes.py | 1 + selfdrive/car/torque_data/substitute.yaml | 1 + 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index 05524d4524..6de5bf89e2 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -2,8 +2,7 @@ from openpilot.common.numpy_fast import clip, interp from opendbc.can.packer import CANPacker from openpilot.selfdrive.car import apply_driver_steer_torque_limits from openpilot.selfdrive.car.subaru import subarucan -from openpilot.selfdrive.car.subaru.values import DBC, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, CarControllerParams, SubaruFlags -from selfdrive.car.subaru.values import HYBRID_CARS +from openpilot.selfdrive.car.subaru.values import DBC, GLOBAL_GEN2, PREGLOBAL_CARS, HYBRID_CARS, CanBus, CarControllerParams, SubaruFlags class CarController: diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py index 80eab10eba..ff203f387d 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -4,9 +4,8 @@ from opendbc.can.can_define import CANDefine from openpilot.common.conversions import Conversions as CV from openpilot.selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser -from openpilot.selfdrive.car.subaru.values import DBC, CAR, GLOBAL_GEN2, PREGLOBAL_CARS, CanBus, SubaruFlags +from openpilot.selfdrive.car.subaru.values import DBC, CAR, GLOBAL_GEN2, PREGLOBAL_CARS, HYBRID_CARS, CanBus, SubaruFlags from openpilot.selfdrive.car import CanSignalRateCalculator -from selfdrive.car.subaru.values import HYBRID_CARS class CarState(CarStateBase): @@ -101,17 +100,18 @@ class CarState(CarStateBase): self.es_brake_msg = copy.copy(cp_es_brake.vl["ES_Brake"]) cp_es_status = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp_cam - if self.car_fingerprint not in HYBRID_CARS: # Hybrid cars don't have es_distance, need a replacement + # TODO: Hybrid cars don't have ES_Distance, need a replacement + if self.car_fingerprint not in HYBRID_CARS: # 8 is known AEB, there are a few other values related to AEB we ignore ret.stockAeb = (cp_es_distance.vl["ES_Brake"]["AEB_Status"] == 8) and \ - (cp_es_distance.vl["ES_Brake"]["Brake_Pressure"] != 0) - self.es_distance_msg = copy.copy(cp_es_distance.vl["ES_Distance"]) + (cp_es_distance.vl["ES_Brake"]["Brake_Pressure"] != 0) self.es_status_msg = copy.copy(cp_es_status.vl["ES_Status"]) self.cruise_control_msg = copy.copy(cp_cruise.vl["CruiseControl"]) if self.car_fingerprint not in HYBRID_CARS: self.es_distance_msg = copy.copy(cp_es_distance.vl["ES_Distance"]) + self.es_dashstatus_msg = copy.copy(cp_cam.vl["ES_DashStatus"]) if self.CP.flags & SubaruFlags.SEND_INFOTAINMENT: self.es_infotainment_msg = copy.copy(cp_cam.vl["ES_Infotainment"]) diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index e6e69316f8..d9f3c5f41d 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -13,9 +13,9 @@ class CarInterface(CarInterfaceBase): ret.carName = "subaru" ret.radarUnavailable = True # for HYBRID CARS to be upstreamed, we need: - # - replacement for ES_Distance so we can cancel the cruise control - # - to find the Cruise_Activated bit from the car - # - proper panda safety setup (use the correct cruise_activated bit, throttle from Throttle_Hybrid, etc) + # - replacement for ES_Distance so we can cancel the cruise control + # - to find the Cruise_Activated bit from the car + # - proper panda safety setup (use the correct cruise_activated bit, throttle from Throttle_Hybrid, etc) ret.dashcamOnly = candidate in (PREGLOBAL_CARS | LKAS_ANGLE | HYBRID_CARS) ret.autoResumeSng = False @@ -79,7 +79,7 @@ class CarInterface(CarInterfaceBase): ret.steerRatio = 17 ret.steerActuatorDelay = 0.1 - elif candidate in (CAR.FORESTER, CAR.FORESTER_2022): + elif candidate in (CAR.FORESTER, CAR.FORESTER_2022, CAR.FORESTER_HYBRID): ret.mass = 1568. ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index 4cc1df9754..33ac2b390e 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -71,6 +71,7 @@ class CAR: FORESTER = "SUBARU FORESTER 2019" OUTBACK = "SUBARU OUTBACK 6TH GEN" CROSSTREK_HYBRID = "SUBARU CROSSTREK HYBRID 2020" + FORESTER_HYBRID = "SUBARU FORESTER HYBRID 2020" LEGACY = "SUBARU LEGACY 7TH GEN" FORESTER_2022 = "SUBARU FORESTER 2022" OUTBACK_2023 = "SUBARU OUTBACK 7TH GEN" @@ -113,6 +114,7 @@ CAR_INFO: Dict[str, Union[SubaruCarInfo, List[SubaruCarInfo]]] = { ], # TODO: is there an XV and Impreza too? CAR.CROSSTREK_HYBRID: SubaruCarInfo("Subaru Crosstrek Hybrid 2020"), + CAR.FORESTER_HYBRID: SubaruCarInfo("Subaru Forester Hybrid 2020"), CAR.FORESTER: SubaruCarInfo("Subaru Forester 2019-21", "All"), CAR.FORESTER_PREGLOBAL: SubaruCarInfo("Subaru Forester 2017-18"), CAR.LEGACY_PREGLOBAL: SubaruCarInfo("Subaru Legacy 2015-18"), @@ -389,6 +391,23 @@ FW_VERSIONS = { b'\x1a\xe6F1\x00', ], }, + CAR.FORESTER_HYBRID: { + (Ecu.abs, 0x7b0, None): [ + b'\xa3 \x19T\x00', + ], + (Ecu.eps, 0x746, None): [ + b'\x8d\xc2\x00\x00', + ], + (Ecu.fwdCamera, 0x787, None): [ + b'\x00\x00eY\x1f@ !', + ], + (Ecu.engine, 0x7e0, None): [ + b'\xd2\xa1`r\x07', + ], + (Ecu.transmission, 0x7e1, None): [ + b'\x1b\xa7@a\x00', + ], + }, CAR.FORESTER_PREGLOBAL: { (Ecu.abs, 0x7b0, None): [ b'\x7d\x97\x14\x40', @@ -649,6 +668,7 @@ DBC = { CAR.FORESTER: dbc_dict('subaru_global_2017_generated', None), CAR.FORESTER_2022: dbc_dict('subaru_global_2017_generated', None), CAR.OUTBACK: dbc_dict('subaru_global_2017_generated', None), + CAR.FORESTER_HYBRID: dbc_dict('subaru_global_2020_hybrid_generated', None), CAR.CROSSTREK_HYBRID: dbc_dict('subaru_global_2020_hybrid_generated', None), CAR.OUTBACK_2023: dbc_dict('subaru_global_2017_generated', None), CAR.LEGACY: dbc_dict('subaru_global_2017_generated', None), @@ -661,4 +681,4 @@ DBC = { LKAS_ANGLE = {CAR.FORESTER_2022, CAR.OUTBACK_2023} GLOBAL_GEN2 = {CAR.OUTBACK, CAR.LEGACY, CAR.OUTBACK_2023} PREGLOBAL_CARS = {CAR.FORESTER_PREGLOBAL, CAR.LEGACY_PREGLOBAL, CAR.OUTBACK_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018} -HYBRID_CARS = {CAR.CROSSTREK_HYBRID, } \ No newline at end of file +HYBRID_CARS = {CAR.CROSSTREK_HYBRID, CAR.FORESTER_HYBRID} diff --git a/selfdrive/car/tests/routes.py b/selfdrive/car/tests/routes.py index 4ecf6e192a..2c6a7472b5 100644 --- a/selfdrive/car/tests/routes.py +++ b/selfdrive/car/tests/routes.py @@ -28,6 +28,7 @@ non_tested_cars = [ VOLKSWAGEN.CRAFTER_MK2, # need a route from an ACC-equipped Crafter TOYOTA.RAV4_TSS2_2023, TOYOTA.RAV4H_TSS2_2023, + SUBARU.FORESTER_HYBRID, ] diff --git a/selfdrive/car/torque_data/substitute.yaml b/selfdrive/car/torque_data/substitute.yaml index 0f742e6f39..f02af01609 100644 --- a/selfdrive/car/torque_data/substitute.yaml +++ b/selfdrive/car/torque_data/substitute.yaml @@ -77,6 +77,7 @@ SEAT LEON 3RD GEN: VOLKSWAGEN GOLF 7TH GEN SEAT ATECA 1ST GEN: VOLKSWAGEN GOLF 7TH GEN SUBARU CROSSTREK HYBRID 2020: SUBARU IMPREZA SPORT 2020 +SUBARU FORESTER HYBRID 2020: SUBARU IMPREZA SPORT 2020 SUBARU LEGACY 7TH GEN: SUBARU OUTBACK 6TH GEN # Old subarus don't have much data guessing it's like low torque impreza From ac939029835542a02b866e8a0d174f09773e4e6e Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 13:46:02 +0800 Subject: [PATCH 119/159] cpplint: add filter `whitespace/forcolon` (#29582) whitespace/forcolon --- .pre-commit-config.yaml | 2 +- selfdrive/ui/qt/maps/map_helpers.cc | 2 +- selfdrive/ui/qt/widgets/prime.cc | 2 +- system/loggerd/loggerd.cc | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bcd19726ff..1b138752ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/parens,+whitespace/semicolon,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+readability/braces - repo: local hooks: - id: test_translations diff --git a/selfdrive/ui/qt/maps/map_helpers.cc b/selfdrive/ui/qt/maps/map_helpers.cc index a410ab6ee7..a23c8990d3 100644 --- a/selfdrive/ui/qt/maps/map_helpers.cc +++ b/selfdrive/ui/qt/maps/map_helpers.cc @@ -61,7 +61,7 @@ QMapbox::CoordinatesCollections coordinate_to_collection(const QMapbox::Coordina QMapbox::CoordinatesCollections capnp_coordinate_list_to_collection(const capnp::List::Reader& coordinate_list) { QMapbox::Coordinates coordinates; - for (auto const &c: coordinate_list) { + for (auto const &c : coordinate_list) { coordinates.push_back({c.getLatitude(), c.getLongitude()}); } return {QMapbox::CoordinatesCollection{coordinates}}; diff --git a/selfdrive/ui/qt/widgets/prime.cc b/selfdrive/ui/qt/widgets/prime.cc index 91a0fc8597..afc6bd898e 100644 --- a/selfdrive/ui/qt/widgets/prime.cc +++ b/selfdrive/ui/qt/widgets/prime.cc @@ -156,7 +156,7 @@ PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QFrame(parent) { main_layout->addSpacing(30); QVector bullets = {tr("Remote access"), tr("24/7 LTE connectivity"), tr("1 year of drive storage"), tr("Turn-by-turn navigation")}; - for (auto &b: bullets) { + for (auto &b : bullets) { const QString check = " "; QLabel *l = new QLabel(check + b); l->setAlignment(Qt::AlignLeft); diff --git a/system/loggerd/loggerd.cc b/system/loggerd/loggerd.cc index 2bcf9e3256..053bc6b1eb 100644 --- a/system/loggerd/loggerd.cc +++ b/system/loggerd/loggerd.cc @@ -98,7 +98,7 @@ int handle_encoder_msg(LoggerdState *s, Message *msg, std::string &name, struct re.marked_ready_to_rotate = false; // we are in this segment now, process any queued messages before this one if (!re.q.empty()) { - for (auto &qmsg: re.q) { + for (auto &qmsg : re.q) { bytes_count += handle_encoder_msg(s, qmsg, name, re, encoder_info); } re.q.clear(); @@ -233,7 +233,7 @@ void loggerd_thread() { std::map encoder_infos_dict; for (const auto &cam : cameras_logged) { - for (const auto &encoder_info: cam.encoder_infos) { + for (const auto &encoder_info : cam.encoder_infos) { encoder_infos_dict[encoder_info.publish_name] = encoder_info; s.max_waiting++; } From 4ea78330605cc3e46005e3d0f8915ef8a60c952a Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 14:32:01 +0800 Subject: [PATCH 120/159] ui/map_instructions: restore padding (#29548) * restore padding * fixes * fix left and right margins --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/maps/map_instructions.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/maps/map_instructions.cc b/selfdrive/ui/qt/maps/map_instructions.cc index 277e8915cd..ba8cb356bd 100644 --- a/selfdrive/ui/qt/maps/map_instructions.cc +++ b/selfdrive/ui/qt/maps/map_instructions.cc @@ -11,12 +11,13 @@ const QString ICON_SUFFIX = ".png"; MapInstructions::MapInstructions(QWidget *parent) : QWidget(parent) { is_rhd = Params().getBool("IsRhdDetected"); QVBoxLayout *main_layout = new QVBoxLayout(this); - main_layout->setContentsMargins(11, UI_BORDER_SIZE, 11, 11); + main_layout->setContentsMargins(11, UI_BORDER_SIZE, 11, 20); QHBoxLayout *top_layout = new QHBoxLayout; top_layout->addWidget(icon_01 = new QLabel, 0, Qt::AlignTop); QVBoxLayout *right_layout = new QVBoxLayout; + right_layout->setContentsMargins(9, 9, 9, 0); right_layout->addWidget(distance = new QLabel); distance->setStyleSheet(R"(font-size: 90px;)"); From da7504e1e72ac09063901361377a64ec074efe8f Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 23 Aug 2023 23:50:51 -0700 Subject: [PATCH 121/159] CI: Normalize file permissions (#29584) * normalize file permissions * comment * add comment * remove that * shell * should be on the top --- .github/workflows/selfdrive_tests.yaml | 5 +++-- .github/workflows/setup/action.yaml | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index b9a9131d71..e3f060b0dd 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -192,8 +192,9 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - name: Build Docker image - run: eval "$BUILD" + - uses: ./.github/workflows/setup + with: + git-lfs: false - name: Push to container registry run: | $DOCKER_LOGIN diff --git a/.github/workflows/setup/action.yaml b/.github/workflows/setup/action.yaml index 2eeefd9f3e..1181008f7e 100644 --- a/.github/workflows/setup/action.yaml +++ b/.github/workflows/setup/action.yaml @@ -32,6 +32,13 @@ runs: restore-keys: | scons-${{ env.CACHE_COMMIT_DATE }}- scons- + # as suggested here: https://github.com/moby/moby/issues/32816#issuecomment-910030001 + - id: normalize-file-permissions + shell: bash + name: Normalize file permissions to ensure a consistent docker build cache + run: | + find . -type f -executable -not -perm 755 -exec chmod 755 {} \; + find . -type f -not -executable -not -perm 644 -exec chmod 644 {} \; # build our docker image - shell: bash run: eval ${{ env.BUILD }} From 3c94d953ab9fcaf8ee2371af3f269ae46d3563c6 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 15:03:16 +0800 Subject: [PATCH 122/159] replay: fix visionbuf alignment on device (#26913) * align visionbuf * update test case * cleanup * fix cpplint warning --- tools/replay/SConscript | 2 +- tools/replay/camera.cc | 17 +++++++++++++++-- tools/replay/camera.h | 3 +++ tools/replay/framereader.cc | 29 ++++++++++++----------------- tools/replay/framereader.h | 8 ++++---- tools/replay/tests/test_replay.cc | 7 +++++-- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/tools/replay/SConscript b/tools/replay/SConscript index 4ddeb662e0..3abed43dde 100644 --- a/tools/replay/SConscript +++ b/tools/replay/SConscript @@ -22,4 +22,4 @@ replay_libs = [replay_lib, 'avutil', 'avcodec', 'avformat', 'bz2', 'curl', 'yuv' qt_env.Program("replay", ["main.cc"], LIBS=replay_libs, FRAMEWORKS=base_frameworks) if GetOption('test'): - qt_env.Program('tests/test_replay', ['tests/test_runner.cc', 'tests/test_replay.cc'], LIBS=[replay_libs]) + qt_env.Program('tests/test_replay', ['tests/test_runner.cc', 'tests/test_replay.cc'], LIBS=[replay_libs, qt_libs]) diff --git a/tools/replay/camera.cc b/tools/replay/camera.cc index 66898c9244..2bc8c66aaa 100644 --- a/tools/replay/camera.cc +++ b/tools/replay/camera.cc @@ -1,7 +1,18 @@ #include "tools/replay/camera.h" #include "tools/replay/util.h" +#include "msm_media_info.h" #include +#include + +std::tuple get_nv12_info(int width, int height) { + int nv12_width = VENUS_Y_STRIDE(COLOR_FMT_NV12, width); + int nv12_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, height); + assert(nv12_width == VENUS_UV_STRIDE(COLOR_FMT_NV12, width)); + assert(nv12_height / 2 == VENUS_UV_SCANLINES(COLOR_FMT_NV12, height)); + size_t nv12_buffer_size = 2346 * nv12_width; // comes from v4l2_format.fmt.pix_mp.plane_fmt[0].sizeimage + return {nv12_width, nv12_height, nv12_buffer_size}; +} CameraServer::CameraServer(std::pair camera_size[MAX_CAMERAS]) { for (int i = 0; i < MAX_CAMERAS; ++i) { @@ -25,7 +36,9 @@ void CameraServer::startVipcServer() { for (auto &cam : cameras_) { if (cam.width > 0 && cam.height > 0) { rInfo("camera[%d] frame size %dx%d", cam.type, cam.width, cam.height); - vipc_server_->create_buffers(cam.stream_type, YUV_BUFFER_COUNT, false, cam.width, cam.height); + auto [nv12_width, nv12_height, nv12_buffer_size] = get_nv12_info(cam.width, cam.height); + vipc_server_->create_buffers_with_sizes(cam.stream_type, YUV_BUFFER_COUNT, false, cam.width, cam.height, + nv12_buffer_size, nv12_width, nv12_width * nv12_height); if (!cam.thread.joinable()) { cam.thread = std::thread(&CameraServer::cameraThread, this, std::ref(cam)); } @@ -38,7 +51,7 @@ void CameraServer::cameraThread(Camera &cam) { auto read_frame = [&](FrameReader *fr, int frame_id) { VisionBuf *yuv_buf = vipc_server_->get_buffer(cam.stream_type); assert(yuv_buf); - bool ret = fr->get(frame_id, (uint8_t *)yuv_buf->addr); + bool ret = fr->get(frame_id, yuv_buf); return ret ? yuv_buf : nullptr; }; diff --git a/tools/replay/camera.h b/tools/replay/camera.h index f2d19ccfb2..9f43c5a362 100644 --- a/tools/replay/camera.h +++ b/tools/replay/camera.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "cereal/visionipc/visionipc_server.h" @@ -10,6 +11,8 @@ #include "tools/replay/framereader.h" #include "tools/replay/logreader.h" +std::tuple get_nv12_info(int width, int height); + class CameraServer { public: CameraServer(std::pair camera_size[MAX_CAMERAS] = nullptr); diff --git a/tools/replay/framereader.cc b/tools/replay/framereader.cc index 3083a0d376..f45996560e 100644 --- a/tools/replay/framereader.cc +++ b/tools/replay/framereader.cc @@ -5,8 +5,6 @@ #include #include "libyuv.h" -#include "cereal/visionipc/visionbuf.h" - #ifdef __APPLE__ #define HW_DEVICE_TYPE AV_HWDEVICE_TYPE_VIDEOTOOLBOX #define HW_PIX_FMT AV_PIX_FMT_VIDEOTOOLBOX @@ -119,7 +117,6 @@ bool FrameReader::load(const std::byte *data, size_t size, bool no_hw_decoder, s width = (decoder_ctx->width + 3) & ~3; height = decoder_ctx->height; - visionbuf_compute_aligned_width_and_height(width, height, &aligned_width, &aligned_height); if (has_hw_decoder && !no_hw_decoder) { if (!initHardwareDecoder(HW_DEVICE_TYPE)) { @@ -178,15 +175,15 @@ bool FrameReader::initHardwareDecoder(AVHWDeviceType hw_device_type) { return true; } -bool FrameReader::get(int idx, uint8_t *yuv) { - assert(yuv != nullptr); +bool FrameReader::get(int idx, VisionBuf *buf) { + assert(buf != nullptr); if (!valid_ || idx < 0 || idx >= packets.size()) { return false; } - return decode(idx, yuv); + return decode(idx, buf); } -bool FrameReader::decode(int idx, uint8_t *yuv) { +bool FrameReader::decode(int idx, VisionBuf *buf) { int from_idx = idx; if (idx != prev_idx + 1 && key_frames_count_ > 1) { // seeking to the nearest key frame @@ -202,7 +199,7 @@ bool FrameReader::decode(int idx, uint8_t *yuv) { for (int i = from_idx; i <= idx; ++i) { AVFrame *f = decodeFrame(packets[i]); if (f && i == idx) { - return copyBuffers(f, yuv); + return copyBuffers(f, buf); } } return false; @@ -234,22 +231,20 @@ AVFrame *FrameReader::decodeFrame(AVPacket *pkt) { } } -bool FrameReader::copyBuffers(AVFrame *f, uint8_t *yuv) { - assert(f != nullptr && yuv != nullptr); - uint8_t *y = yuv; - uint8_t *uv = y + width * height; +bool FrameReader::copyBuffers(AVFrame *f, VisionBuf *buf) { + assert(f != nullptr && buf != nullptr); if (hw_pix_fmt == HW_PIX_FMT) { for (int i = 0; i < height/2; i++) { - memcpy(y + (i*2 + 0)*width, f->data[0] + (i*2 + 0)*f->linesize[0], width); - memcpy(y + (i*2 + 1)*width, f->data[0] + (i*2 + 1)*f->linesize[0], width); - memcpy(uv + i*width, f->data[1] + i*f->linesize[1], width); + memcpy(buf->y + (i*2 + 0)*buf->stride, f->data[0] + (i*2 + 0)*f->linesize[0], width); + memcpy(buf->y + (i*2 + 1)*buf->stride, f->data[0] + (i*2 + 1)*f->linesize[0], width); + memcpy(buf->uv + i*buf->stride, f->data[1] + i*f->linesize[1], width); } } else { libyuv::I420ToNV12(f->data[0], f->linesize[0], f->data[1], f->linesize[1], f->data[2], f->linesize[2], - y, width, - uv, width, + buf->y, buf->stride, + buf->uv, buf->stride, width, height); } return true; diff --git a/tools/replay/framereader.h b/tools/replay/framereader.h index e50b61d7f4..bb72ac8f8d 100644 --- a/tools/replay/framereader.h +++ b/tools/replay/framereader.h @@ -4,6 +4,7 @@ #include #include +#include "cereal/visionipc/visionbuf.h" #include "tools/replay/filereader.h" extern "C" { @@ -22,19 +23,18 @@ public: bool load(const std::string &url, bool no_hw_decoder = false, std::atomic *abort = nullptr, bool local_cache = false, int chunk_size = -1, int retries = 0); bool load(const std::byte *data, size_t size, bool no_hw_decoder = false, std::atomic *abort = nullptr); - bool get(int idx, uint8_t *yuv); + bool get(int idx, VisionBuf *buf); int getYUVSize() const { return width * height * 3 / 2; } size_t getFrameCount() const { return packets.size(); } bool valid() const { return valid_; } int width = 0, height = 0; - int aligned_width = 0, aligned_height = 0; private: bool initHardwareDecoder(AVHWDeviceType hw_device_type); - bool decode(int idx, uint8_t *yuv); + bool decode(int idx, VisionBuf *buf); AVFrame * decodeFrame(AVPacket *pkt); - bool copyBuffers(AVFrame *f, uint8_t *yuv); + bool copyBuffers(AVFrame *f, VisionBuf *buf); std::vector packets; std::unique_ptrav_frame_, hw_frame; diff --git a/tools/replay/tests/test_replay.cc b/tools/replay/tests/test_replay.cc index 441bac0cbd..393a561c0f 100644 --- a/tools/replay/tests/test_replay.cc +++ b/tools/replay/tests/test_replay.cc @@ -95,10 +95,13 @@ void read_segment(int n, const SegmentFile &segment_file, uint32_t flags) { if (cam == RoadCam || cam == WideRoadCam) { REQUIRE(fr->getFrameCount() == 1200); } - std::unique_ptr yuv_buf = std::make_unique(fr->getYUVSize()); + auto [nv12_width, nv12_height, nv12_buffer_size] = get_nv12_info(fr->width, fr->height); + VisionBuf buf; + buf.allocate(nv12_buffer_size); + buf.init_yuv(fr->width, fr->height, nv12_width, nv12_width * nv12_height); // sequence get 100 frames for (int i = 0; i < 100; ++i) { - REQUIRE(fr->get(i, yuv_buf.get())); + REQUIRE(fr->get(i, &buf)); } } From 84b897cf44104d964834979d6fc34822baa999bf Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 00:34:36 -0700 Subject: [PATCH 123/159] manager: test process exclusion (#29586) * add test * add comment * Update selfdrive/manager/test/test_manager.py * more accurate --- selfdrive/manager/test/test_manager.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/selfdrive/manager/test/test_manager.py b/selfdrive/manager/test/test_manager.py index 8ae872d3df..89ad483744 100755 --- a/selfdrive/manager/test/test_manager.py +++ b/selfdrive/manager/test/test_manager.py @@ -16,6 +16,7 @@ os.environ['FAKEUPLOAD'] = "1" MAX_STARTUP_TIME = 3 BLACKLIST_PROCS = ['manage_athenad', 'pandad', 'pigeond'] + class TestManager(unittest.TestCase): def setUp(self): os.environ['PASSIVE'] = '0' @@ -32,6 +33,10 @@ class TestManager(unittest.TestCase): os.environ['PREPAREONLY'] = '1' manager.main() + def test_blacklisted_procs(self): + # TODO: ensure there are blacklisted procs until we have a dedicated test + self.assertTrue(len(BLACKLIST_PROCS), "No blacklisted procs to test not_run") + def test_startup_time(self): for _ in range(10): start = time.monotonic() @@ -59,6 +64,8 @@ class TestManager(unittest.TestCase): self.assertTrue(state.running, f"{p.name} not running") exit_code = p.stop(retry=False) + self.assertNotIn(p.name, BLACKLIST_PROCS, f"{p.name} was started") + # TODO: mapsd should exit cleanly if p.name == "mapsd": continue From e38ce6087fe56068de40dbbc57944ddf68b8642c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 04:24:22 -0700 Subject: [PATCH 124/159] car interfaces test: don't sleep (#29589) don't sleep in test_car_interfaces --- selfdrive/car/tests/test_car_interfaces.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index a447fc21b6..d9da048288 100755 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import os import math import unittest import hypothesis.strategies as st @@ -41,6 +42,10 @@ def get_fuzzy_car_interface_args(draw: DrawType) -> dict: class TestCarInterfaces(unittest.TestCase): + @classmethod + def setUpClass(cls): + os.environ['NO_RADAR_SLEEP'] = '1' + @parameterized.expand([(car,) for car in sorted(all_known_cars())]) @settings(max_examples=5) @given(data=st.data()) From 99279b8eef43586aa09d001668355fa41e01b98f Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 19:26:45 +0800 Subject: [PATCH 125/159] ui: use `enum PrimeType` for prime_type (#29491) --- selfdrive/ui/qt/home.cc | 4 ++-- selfdrive/ui/qt/offroad/networking.cc | 3 +-- selfdrive/ui/qt/widgets/prime.cc | 2 +- selfdrive/ui/qt/widgets/prime.h | 9 --------- selfdrive/ui/ui.cc | 7 +++++-- selfdrive/ui/ui.h | 17 +++++++++++++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index b674d39fbd..f5eab4664e 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -158,8 +158,8 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { left_widget->setStyleSheet("border-radius: 10px;"); left_widget->setCurrentIndex(uiState()->primeType() ? 0 : 1); - connect(uiState(), &UIState::primeTypeChanged, [=](int prime_type) { - left_widget->setCurrentIndex(prime_type ? 0 : 1); + connect(uiState(), &UIState::primeTypeChanged, [=](PrimeType prime_type) { + left_widget->setCurrentIndex((prime_type != PrimeType::NONE) ? 0 : 1); }); home_layout->addWidget(left_widget, 1); diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index 628a92fb58..0a5c07af70 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -10,7 +10,6 @@ #include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/widgets/controls.h" -#include "selfdrive/ui/qt/widgets/prime.h" #include "selfdrive/ui/qt/widgets/scrollview.h" @@ -184,7 +183,7 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid // Set initial config wifi->updateGsmSettings(roamingEnabled, QString::fromStdString(params.get("GsmApn")), metered); - connect(uiState(), &UIState::primeTypeChanged, this, [=](int prime_type) { + connect(uiState(), &UIState::primeTypeChanged, this, [=](PrimeType prime_type) { bool gsmVisible = prime_type == PrimeType::NONE || prime_type == PrimeType::LITE; roamingToggle->setVisible(gsmVisible); editApnButton->setVisible(gsmVisible); diff --git a/selfdrive/ui/qt/widgets/prime.cc b/selfdrive/ui/qt/widgets/prime.cc index afc6bd898e..57d9d87a64 100644 --- a/selfdrive/ui/qt/widgets/prime.cc +++ b/selfdrive/ui/qt/widgets/prime.cc @@ -269,7 +269,7 @@ void SetupWidget::replyFinished(const QString &response, bool success) { } QJsonObject json = doc.object(); - int prime_type = json["prime_type"].toInt(); + PrimeType prime_type = static_cast(json["prime_type"].toInt()); uiState()->setPrimeType(prime_type); if (!json["is_paired"].toBool()) { diff --git a/selfdrive/ui/qt/widgets/prime.h b/selfdrive/ui/qt/widgets/prime.h index b41bab1695..227a0f31c1 100644 --- a/selfdrive/ui/qt/widgets/prime.h +++ b/selfdrive/ui/qt/widgets/prime.h @@ -7,15 +7,6 @@ #include "selfdrive/ui/qt/widgets/input.h" -enum PrimeType { - NONE = 0, - MAGENTA = 1, - LITE = 2, - BLUE = 3, - MAGENTA_NEW = 4, -}; - - // pairing QR code class PairingQRWidget : public QWidget { Q_OBJECT diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 26e8464a61..7b12d54888 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -245,8 +245,11 @@ UIState::UIState(QObject *parent) : QObject(parent) { }); Params params; - prime_type = std::atoi(params.get("PrimeType").c_str()); language = QString::fromStdString(params.get("LanguageSetting")); + auto prime_value = params.get("PrimeType"); + if (!prime_value.empty()) { + prime_type = static_cast(std::atoi(prime_value.c_str())); + } // update timer timer = new QTimer(this); @@ -265,7 +268,7 @@ void UIState::update() { emit uiUpdate(*this); } -void UIState::setPrimeType(int type) { +void UIState::setPrimeType(PrimeType type) { if (type != prime_type) { prime_type = type; Params().put("PrimeType", std::to_string(prime_type)); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 82f65d128f..cac8995278 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -96,6 +96,15 @@ typedef enum UIStatus { STATUS_ENGAGED, } UIStatus; +enum PrimeType { + UNKNOWN = -1, + NONE = 0, + MAGENTA = 1, + LITE = 2, + BLUE = 3, + MAGENTA_NEW = 4, +}; + const QColor bg_colors [] = { [STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8), [STATUS_OVERRIDE] = QColor(0x91, 0x9b, 0x95, 0xf1), @@ -153,8 +162,8 @@ public: return scene.started && (*sm)["controlsState"].getControlsState().getEnabled(); } - void setPrimeType(int type); - inline int primeType() const { return prime_type; } + void setPrimeType(PrimeType type); + inline PrimeType primeType() const { return prime_type; } int fb_w = 0, fb_h = 0; @@ -170,7 +179,7 @@ public: signals: void uiUpdate(const UIState &s); void offroadTransition(bool offroad); - void primeTypeChanged(int prime_type); + void primeTypeChanged(PrimeType prime_type); private slots: void update(); @@ -178,7 +187,7 @@ private slots: private: QTimer *timer; bool started_prev = false; - int prime_type = -1; + PrimeType prime_type = PrimeType::UNKNOWN; }; UIState *uiState(); From 102047013f60e1a3c2e919ae237c1bfbda07ea06 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Thu, 24 Aug 2023 12:42:08 +0100 Subject: [PATCH 126/159] bump cereal --- cereal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cereal b/cereal index fa580de1b4..eb1b2ce255 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit fa580de1b42534d3417306c416784e1add99ad32 +Subproject commit eb1b2ce255371d7529e1b4341600ecca5052e1f4 From 05e91c074d0fbabfd3475d4f34b975819159519b Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Thu, 24 Aug 2023 12:47:22 +0100 Subject: [PATCH 127/159] ui: hasPrime/primeChanged helper (#29590) --- selfdrive/ui/qt/home.cc | 6 +++--- selfdrive/ui/ui.cc | 7 +++++++ selfdrive/ui/ui.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index f5eab4664e..f93b590007 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -157,9 +157,9 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { left_widget->addWidget(new PrimeAdWidget); left_widget->setStyleSheet("border-radius: 10px;"); - left_widget->setCurrentIndex(uiState()->primeType() ? 0 : 1); - connect(uiState(), &UIState::primeTypeChanged, [=](PrimeType prime_type) { - left_widget->setCurrentIndex((prime_type != PrimeType::NONE) ? 0 : 1); + left_widget->setCurrentIndex(uiState()->hasPrime() ? 0 : 1); + connect(uiState(), &UIState::primeChanged, [=](bool prime) { + left_widget->setCurrentIndex(prime ? 0 : 1); }); home_layout->addWidget(left_widget, 1); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 7b12d54888..fa857c769b 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -270,9 +270,16 @@ void UIState::update() { void UIState::setPrimeType(PrimeType type) { if (type != prime_type) { + bool prev_prime = hasPrime(); + prime_type = type; Params().put("PrimeType", std::to_string(prime_type)); emit primeTypeChanged(prime_type); + + bool prime = hasPrime(); + if (prev_prime != prime) { + emit primeChanged(prime); + } } } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index cac8995278..bd9d059422 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -164,6 +164,7 @@ public: void setPrimeType(PrimeType type); inline PrimeType primeType() const { return prime_type; } + inline bool hasPrime() const { return prime_type != PrimeType::UNKNOWN && prime_type != PrimeType::NONE; } int fb_w = 0, fb_h = 0; @@ -179,6 +180,7 @@ public: signals: void uiUpdate(const UIState &s); void offroadTransition(bool offroad); + void primeChanged(bool prime); void primeTypeChanged(PrimeType prime_type); private slots: From d58cb9994f678ad8625b5af8fee53ca2edffd334 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 05:27:58 -0700 Subject: [PATCH 128/159] car interface test: pick from possible ECUs (#29593) pick from possible ecus --- selfdrive/car/tests/test_car_interfaces.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index d9da048288..7abc4c6f41 100755 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -12,9 +12,12 @@ from openpilot.common.realtime import DT_CTRL from openpilot.selfdrive.car import gen_empty_fingerprint from openpilot.selfdrive.car.car_helpers import interfaces from openpilot.selfdrive.car.fingerprints import all_known_cars +from openpilot.selfdrive.car.fw_versions import FW_VERSIONS from openpilot.selfdrive.car.interfaces import get_interface_attr from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator +ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()}) + def get_fuzzy_car_interface_args(draw: DrawType) -> dict: # Fuzzy CAN fingerprints and FW versions to test more states of the CarInterface @@ -22,12 +25,8 @@ def get_fuzzy_car_interface_args(draw: DrawType) -> dict: st.integers(min_value=0, max_value=64)) for key in gen_empty_fingerprint()}) - # just the most important fields - car_fw_strategy = st.lists(st.fixed_dictionaries({ - 'ecu': st.sampled_from(list(car.CarParams.Ecu.schema.enumerants.keys())), - # TODO: only use reasonable addrs for the paired ecu and brand/platform - 'address': st.integers(min_value=0, max_value=0x800), - })) + # only pick from possible ecus to reduce search space + car_fw_strategy = st.lists(st.sampled_from(ALL_ECUS)) params_strategy = st.fixed_dictionaries({ 'fingerprints': fingerprint_strategy, @@ -36,7 +35,7 @@ def get_fuzzy_car_interface_args(draw: DrawType) -> dict: }) params: dict = draw(params_strategy) - params['car_fw'] = [car.CarParams.CarFw(**fw) for fw in params['car_fw']] + params['car_fw'] = [car.CarParams.CarFw(ecu=fw[0], address=fw[1], subAddress=fw[2] or 0) for fw in params['car_fw']] return params From d013f2174adf8ffbf2ba86e2656cf438930850a6 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 24 Aug 2023 06:00:55 -0700 Subject: [PATCH 129/159] manager: refactor process starting logic (#29574) * refactor into sane api * always set * cleanup * cleanup * and there too * fix order * fail * and ensure we test * pass test pass test * order * only diff not related --------- Co-authored-by: Shane Smiskol --- selfdrive/manager/process.py | 40 +++--------- selfdrive/manager/process_config.py | 98 ++++++++++++++++------------- 2 files changed, 64 insertions(+), 74 deletions(-) diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index 8328f1cee9..c56ffeab98 100644 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -66,9 +66,7 @@ def join_process(process: Process, timeout: float) -> None: class ManagerProcess(ABC): daemon = False sigkill = False - onroad = True - offroad = False - callback: Optional[Callable[[bool, Params, car.CarParams], bool]] = None + should_run: Callable[[bool, Params, car.CarParams], bool] proc: Optional[Process] = None enabled = True name = "" @@ -170,15 +168,12 @@ class ManagerProcess(ABC): class NativeProcess(ManagerProcess): - def __init__(self, name, cwd, cmdline, enabled=True, onroad=True, offroad=False, callback=None, unkillable=False, sigkill=False, watchdog_max_dt=None): + def __init__(self, name, cwd, cmdline, should_run, enabled=True, sigkill=False, watchdog_max_dt=None): self.name = name self.cwd = cwd self.cmdline = cmdline + self.should_run = should_run self.enabled = enabled - self.onroad = onroad - self.offroad = offroad - self.callback = callback - self.unkillable = unkillable self.sigkill = sigkill self.watchdog_max_dt = watchdog_max_dt self.launcher = nativelauncher @@ -203,14 +198,11 @@ class NativeProcess(ManagerProcess): class PythonProcess(ManagerProcess): - def __init__(self, name, module, enabled=True, onroad=True, offroad=False, callback=None, unkillable=False, sigkill=False, watchdog_max_dt=None): + def __init__(self, name, module, should_run, enabled=True, sigkill=False, watchdog_max_dt=None): self.name = name self.module = module + self.should_run = should_run self.enabled = enabled - self.onroad = onroad - self.offroad = offroad - self.callback = callback - self.unkillable = unkillable self.sigkill = sigkill self.watchdog_max_dt = watchdog_max_dt self.launcher = launcher @@ -243,10 +235,12 @@ class DaemonProcess(ManagerProcess): self.module = module self.param_name = param_name self.enabled = enabled - self.onroad = True - self.offroad = True self.params = None + @staticmethod + def should_run(started, params, CP): + return True + def prepare(self) -> None: pass @@ -286,21 +280,7 @@ def ensure_running(procs: ValuesView[ManagerProcess], started: bool, params=None running = [] for p in procs: - # Conditions that make a process run - run = any(( - p.offroad and not started, - p.onroad and started, - )) - if p.callback is not None and None not in (params, CP): - run = run or p.callback(started, params, CP) - - # Conditions that block a process from starting - run = run and not any(( - not p.enabled, - p.name in not_run, - )) - - if run: + if p.enabled and p.name not in not_run and p.should_run(started, params, CP): p.start() running.append(p) else: diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py index 936dff883b..50e684fcb5 100644 --- a/selfdrive/manager/process_config.py +++ b/selfdrive/manager/process_config.py @@ -8,13 +8,13 @@ from openpilot.selfdrive.manager.process import PythonProcess, NativeProcess, Da WEBCAM = os.getenv("USE_WEBCAM") is not None def driverview(started: bool, params: Params, CP: car.CarParams) -> bool: - return params.get_bool("IsDriverViewEnabled") # type: ignore + return started or params.get_bool("IsDriverViewEnabled") def notcar(started: bool, params: Params, CP: car.CarParams) -> bool: - return CP.notCar # type: ignore + return started and CP.notCar def iscar(started: bool, params: Params, CP: car.CarParams) -> bool: - return not CP.notCar + return started and not CP.notCar def logging(started, params, CP: car.CarParams) -> bool: run = (not CP.notCar) or not params.get_bool("DisableLogging") @@ -32,51 +32,61 @@ def ublox(started, params, CP: car.CarParams) -> bool: def qcomgps(started, params, CP: car.CarParams) -> bool: return started and not ublox_available() -procs = [ - NativeProcess("camerad", "system/camerad", ["./camerad"], callback=driverview), - NativeProcess("clocksd", "system/clocksd", ["./clocksd"]), - NativeProcess("logcatd", "system/logcatd", ["./logcatd"]), - NativeProcess("proclogd", "system/proclogd", ["./proclogd"]), - PythonProcess("logmessaged", "system.logmessaged", offroad=True), - PythonProcess("micd", "system.micd", callback=iscar), - PythonProcess("timezoned", "system.timezoned", enabled=not PC, offroad=True), +def always_run(started, params, CP: car.CarParams) -> bool: + return True + +def only_onroad(started: bool, params, CP: car.CarParams) -> bool: + return started + +def only_offroad(started, params, CP: car.CarParams) -> bool: + return not started +procs = [ DaemonProcess("manage_athenad", "selfdrive.athena.manage_athenad", "AthenadPid"), - NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], enabled=(not PC or WEBCAM), callback=driverview), - NativeProcess("encoderd", "system/loggerd", ["./encoderd"]), - NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], onroad=False, callback=notcar), - NativeProcess("loggerd", "system/loggerd", ["./loggerd"], onroad=False, callback=logging), - NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]), - NativeProcess("mapsd", "selfdrive/navd", ["./mapsd"]), - NativeProcess("navmodeld", "selfdrive/modeld", ["./navmodeld"]), - NativeProcess("sensord", "system/sensord", ["./sensord"], enabled=not PC), - NativeProcess("ui", "selfdrive/ui", ["./ui"], offroad=True, watchdog_max_dt=(5 if not PC else None)), - NativeProcess("soundd", "selfdrive/ui/soundd", ["./soundd"]), - NativeProcess("locationd", "selfdrive/locationd", ["./locationd"]), - NativeProcess("boardd", "selfdrive/boardd", ["./boardd"], enabled=False), - PythonProcess("calibrationd", "selfdrive.locationd.calibrationd"), - PythonProcess("torqued", "selfdrive.locationd.torqued"), - PythonProcess("controlsd", "selfdrive.controls.controlsd"), - PythonProcess("deleter", "system.loggerd.deleter", offroad=True), - PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", enabled=(not PC or WEBCAM), callback=driverview), - PythonProcess("laikad", "selfdrive.locationd.laikad"), - PythonProcess("rawgpsd", "system.sensord.rawgps.rawgpsd", enabled=TICI, onroad=False, callback=qcomgps), - PythonProcess("navd", "selfdrive.navd.navd"), - PythonProcess("pandad", "selfdrive.boardd.pandad", offroad=True), - PythonProcess("paramsd", "selfdrive.locationd.paramsd"), - NativeProcess("ubloxd", "system/ubloxd", ["./ubloxd"], enabled=TICI, onroad=False, callback=ublox), - PythonProcess("pigeond", "system.sensord.pigeond", enabled=TICI, onroad=False, callback=ublox), - PythonProcess("plannerd", "selfdrive.controls.plannerd"), - PythonProcess("radard", "selfdrive.controls.radard"), - PythonProcess("thermald", "selfdrive.thermald.thermald", offroad=True), - PythonProcess("tombstoned", "selfdrive.tombstoned", enabled=not PC, offroad=True), - PythonProcess("updated", "selfdrive.updated", enabled=not PC, onroad=False, offroad=True), - PythonProcess("uploader", "system.loggerd.uploader", offroad=True), - PythonProcess("statsd", "selfdrive.statsd", offroad=True), + + NativeProcess("camerad", "system/camerad", ["./camerad"], driverview), + NativeProcess("clocksd", "system/clocksd", ["./clocksd"], only_onroad), + NativeProcess("logcatd", "system/logcatd", ["./logcatd"], only_onroad), + NativeProcess("proclogd", "system/proclogd", ["./proclogd"], only_onroad), + PythonProcess("logmessaged", "system.logmessaged", always_run), + PythonProcess("micd", "system.micd", iscar), + PythonProcess("timezoned", "system.timezoned", always_run, enabled=not PC), + + NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], driverview, enabled=(not PC or WEBCAM)), + NativeProcess("encoderd", "system/loggerd", ["./encoderd"], only_onroad), + NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], notcar), + NativeProcess("loggerd", "system/loggerd", ["./loggerd"], logging), + NativeProcess("modeld", "selfdrive/modeld", ["./modeld"], only_onroad), + NativeProcess("mapsd", "selfdrive/navd", ["./mapsd"], only_onroad), + NativeProcess("navmodeld", "selfdrive/modeld", ["./navmodeld"], only_onroad), + NativeProcess("sensord", "system/sensord", ["./sensord"], only_onroad, enabled=not PC), + NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=(5 if not PC else None)), + NativeProcess("soundd", "selfdrive/ui/soundd", ["./soundd"], only_onroad), + NativeProcess("locationd", "selfdrive/locationd", ["./locationd"], only_onroad), + NativeProcess("boardd", "selfdrive/boardd", ["./boardd"], always_run, enabled=False), + PythonProcess("calibrationd", "selfdrive.locationd.calibrationd", only_onroad), + PythonProcess("torqued", "selfdrive.locationd.torqued", only_onroad), + PythonProcess("controlsd", "selfdrive.controls.controlsd", only_onroad), + PythonProcess("deleter", "system.loggerd.deleter", always_run), + PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(not PC or WEBCAM)), + PythonProcess("laikad", "selfdrive.locationd.laikad", only_onroad), + PythonProcess("rawgpsd", "system.sensord.rawgps.rawgpsd", qcomgps, enabled=TICI), + PythonProcess("navd", "selfdrive.navd.navd", only_onroad), + PythonProcess("pandad", "selfdrive.boardd.pandad", always_run), + PythonProcess("paramsd", "selfdrive.locationd.paramsd", only_onroad), + NativeProcess("ubloxd", "system/ubloxd", ["./ubloxd"], ublox, enabled=TICI), + PythonProcess("pigeond", "system.sensord.pigeond", ublox, enabled=TICI), + PythonProcess("plannerd", "selfdrive.controls.plannerd", only_onroad), + PythonProcess("radard", "selfdrive.controls.radard", only_onroad), + PythonProcess("thermald", "selfdrive.thermald.thermald", always_run), + PythonProcess("tombstoned", "selfdrive.tombstoned", always_run, enabled=not PC), + PythonProcess("updated", "selfdrive.updated", only_offroad, enabled=not PC), + PythonProcess("uploader", "system.loggerd.uploader", always_run), + PythonProcess("statsd", "selfdrive.statsd", always_run), # debug procs - NativeProcess("bridge", "cereal/messaging", ["./bridge"], onroad=False, callback=notcar), - PythonProcess("webjoystick", "tools.bodyteleop.web", onroad=False, callback=notcar), + NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar), + PythonProcess("webjoystick", "tools.bodyteleop.web", notcar), ] managed_processes = {p.name: p for p in procs} From 21da5a216fc8f5269d2deedc538c2f543a1c270a Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 22:42:17 +0800 Subject: [PATCH 130/159] cpplint: add filter `build/include_subdir` (#29585) --- .pre-commit-config.yaml | 2 +- common/swaglog.cc | 2 +- common/tests/test_swaglog.cc | 2 +- common/transformations/coordinates.cc | 6 ++---- common/transformations/coordinates.hpp | 2 ++ common/transformations/orientation.cc | 4 ++-- common/transformations/orientation.hpp | 2 +- selfdrive/boardd/can_list_to_can_capnp.cc | 2 +- selfdrive/locationd/liblocationd.cc | 2 +- selfdrive/locationd/locationd.cc | 4 ++-- selfdrive/locationd/models/live_kf.cc | 2 +- selfdrive/modeld/runners/run.h | 8 ++++---- selfdrive/modeld/thneed/serialize.cc | 2 +- selfdrive/modeld/thneed/thneed.h | 2 +- selfdrive/ui/qt/maps/map_settings.cc | 2 +- system/camerad/cameras/camera_common.cc | 4 ++-- system/camerad/test/ae_gray_test.cc | 2 +- system/logcatd/logcatd_systemd.cc | 2 +- system/loggerd/encoder/ffmpeg_encoder.cc | 2 +- system/loggerd/encoder/v4l_encoder.cc | 6 +++--- system/sensord/sensors/bmx055_accel.cc | 2 +- system/sensord/sensors/bmx055_gyro.cc | 2 +- system/sensord/sensors/bmx055_magn.cc | 2 +- system/sensord/sensors/bmx055_temp.cc | 2 +- system/sensord/sensors/i2c_sensor.cc | 2 +- system/sensord/sensors/lsm6ds3_accel.cc | 2 +- system/sensord/sensors/lsm6ds3_gyro.cc | 2 +- system/sensord/sensors/lsm6ds3_temp.cc | 2 +- system/sensord/sensors/mmc5603nj_magn.cc | 2 +- system/ubloxd/ublox_msg.cc | 2 +- tools/cabana/streams/socketcanstream.cc | 1 - tools/lib/vidindex/bitstream.c | 4 ++-- tools/lib/vidindex/vidindex.c | 2 +- tools/replay/camera.cc | 5 +++-- tools/replay/framereader.cc | 2 +- 35 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b138752ed..dd804eb588 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+readability/braces - repo: local hooks: - id: test_translations diff --git a/common/swaglog.cc b/common/swaglog.cc index c0614c85f5..923f701ab2 100644 --- a/common/swaglog.cc +++ b/common/swaglog.cc @@ -12,7 +12,7 @@ #include #include -#include "json11.hpp" +#include "third_party/json11/json11.hpp" #include "common/util.h" #include "common/version.h" diff --git a/common/tests/test_swaglog.cc b/common/tests/test_swaglog.cc index 20455ec74c..021656a78b 100644 --- a/common/tests/test_swaglog.cc +++ b/common/tests/test_swaglog.cc @@ -3,7 +3,7 @@ #define CATCH_CONFIG_MAIN #include "catch2/catch.hpp" -#include "json11.hpp" +#include "third_party/json11/json11.hpp" #include "common/swaglog.h" #include "common/util.h" #include "common/version.h" diff --git a/common/transformations/coordinates.cc b/common/transformations/coordinates.cc index b729ac3d87..5b00b53a4f 100644 --- a/common/transformations/coordinates.cc +++ b/common/transformations/coordinates.cc @@ -1,13 +1,11 @@ #define _USE_MATH_DEFINES +#include "common/transformations/coordinates.hpp" + #include #include #include -#include "coordinates.hpp" - - - double a = 6378137; // lgtm [cpp/short-global-name] double b = 6356752.3142; // lgtm [cpp/short-global-name] double esq = 6.69437999014 * 0.001; // lgtm [cpp/short-global-name] diff --git a/common/transformations/coordinates.hpp b/common/transformations/coordinates.hpp index f5ba0d3fe7..32ec2ff66e 100644 --- a/common/transformations/coordinates.hpp +++ b/common/transformations/coordinates.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #define DEG2RAD(x) ((x) * M_PI / 180.0) #define RAD2DEG(x) ((x) * 180.0 / M_PI) diff --git a/common/transformations/orientation.cc b/common/transformations/orientation.cc index 7909c0affb..00888c3a92 100644 --- a/common/transformations/orientation.cc +++ b/common/transformations/orientation.cc @@ -4,8 +4,8 @@ #include #include -#include "orientation.hpp" -#include "coordinates.hpp" +#include "common/transformations/orientation.hpp" +#include "common/transformations/coordinates.hpp" Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat){ if (quat.w() > 0){ diff --git a/common/transformations/orientation.hpp b/common/transformations/orientation.hpp index ebd7da0aee..150b12cade 100644 --- a/common/transformations/orientation.hpp +++ b/common/transformations/orientation.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include "coordinates.hpp" +#include "common/transformations/coordinates.hpp" Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat); diff --git a/selfdrive/boardd/can_list_to_can_capnp.cc b/selfdrive/boardd/can_list_to_can_capnp.cc index c1778c51a2..72ca72688a 100644 --- a/selfdrive/boardd/can_list_to_can_capnp.cc +++ b/selfdrive/boardd/can_list_to_can_capnp.cc @@ -1,5 +1,5 @@ #include "cereal/messaging/messaging.h" -#include "panda.h" +#include "selfdrive/boardd/panda.h" void can_list_to_can_capnp_cpp(const std::vector &can_list, std::string &out, bool sendCan, bool valid) { MessageBuilder msg; diff --git a/selfdrive/locationd/liblocationd.cc b/selfdrive/locationd/liblocationd.cc index 6f298deab6..e2b85d93a1 100755 --- a/selfdrive/locationd/liblocationd.cc +++ b/selfdrive/locationd/liblocationd.cc @@ -1,4 +1,4 @@ -#include "locationd.h" +#include "selfdrive/locationd/locationd.h" extern "C" { typedef Localizer* Localizer_t; diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 722ead7dd4..3a4286a18b 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -1,3 +1,5 @@ +#include "selfdrive/locationd/locationd.h" + #include #include @@ -5,8 +7,6 @@ #include #include -#include "locationd.h" - using namespace EKFS; using namespace Eigen; diff --git a/selfdrive/locationd/models/live_kf.cc b/selfdrive/locationd/models/live_kf.cc index f8c03365e1..915d0fd360 100755 --- a/selfdrive/locationd/models/live_kf.cc +++ b/selfdrive/locationd/models/live_kf.cc @@ -1,4 +1,4 @@ -#include "live_kf.h" +#include "selfdrive/locationd/models/live_kf.h" using namespace EKFS; using namespace Eigen; diff --git a/selfdrive/modeld/runners/run.h b/selfdrive/modeld/runners/run.h index c64f300fe2..7f6e1aa569 100644 --- a/selfdrive/modeld/runners/run.h +++ b/selfdrive/modeld/runners/run.h @@ -1,10 +1,10 @@ #pragma once -#include "runmodel.h" -#include "snpemodel.h" +#include "selfdrive/modeld/runners/runmodel.h" +#include "selfdrive/modeld/runners/snpemodel.h" #if defined(USE_THNEED) -#include "thneedmodel.h" +#include "selfdrive/modeld/runners/thneedmodel.h" #elif defined(USE_ONNX_MODEL) -#include "onnxmodel.h" +#include "selfdrive/modeld/runners/onnxmodel.h" #endif diff --git a/selfdrive/modeld/thneed/serialize.cc b/selfdrive/modeld/thneed/serialize.cc index 51e6d08699..6ed5c08e81 100644 --- a/selfdrive/modeld/thneed/serialize.cc +++ b/selfdrive/modeld/thneed/serialize.cc @@ -1,7 +1,7 @@ #include #include -#include "json11.hpp" +#include "third_party/json11/json11.hpp" #include "common/util.h" #include "common/clutil.h" #include "selfdrive/modeld/thneed/thneed.h" diff --git a/selfdrive/modeld/thneed/thneed.h b/selfdrive/modeld/thneed/thneed.h index 6475577734..47e18e0be3 100644 --- a/selfdrive/modeld/thneed/thneed.h +++ b/selfdrive/modeld/thneed/thneed.h @@ -12,7 +12,7 @@ #include -#include "msm_kgsl.h" +#include "third_party/linux/include/msm_kgsl.h" using namespace std; diff --git a/selfdrive/ui/qt/maps/map_settings.cc b/selfdrive/ui/qt/maps/map_settings.cc index 48a7733c52..a4386ded72 100644 --- a/selfdrive/ui/qt/maps/map_settings.cc +++ b/selfdrive/ui/qt/maps/map_settings.cc @@ -1,4 +1,4 @@ -#include "map_settings.h" +#include "selfdrive/ui/qt/maps/map_settings.h" #include diff --git a/system/camerad/cameras/camera_common.cc b/system/camerad/cameras/camera_common.cc index 1eb636b7a2..23b28357da 100644 --- a/system/camerad/cameras/camera_common.cc +++ b/system/camerad/cameras/camera_common.cc @@ -8,7 +8,7 @@ #include #include -#include "libyuv.h" +#include "third_party/libyuv/include/libyuv.h" #include #include "system/camerad/imgproc/utils.h" @@ -17,7 +17,7 @@ #include "common/swaglog.h" #include "common/util.h" #include "system/hardware/hw.h" -#include "msm_media_info.h" +#include "third_party/linux/include/msm_media_info.h" #include "system/camerad/cameras/camera_qcom2.h" #ifdef QCOM2 diff --git a/system/camerad/test/ae_gray_test.cc b/system/camerad/test/ae_gray_test.cc index aabd7534ee..8d18f7e93b 100644 --- a/system/camerad/test/ae_gray_test.cc +++ b/system/camerad/test/ae_gray_test.cc @@ -1,6 +1,6 @@ // unittest for set_exposure_target -#include "ae_gray_test.h" +#include "system/camerad/test/ae_gray_test.h" #include diff --git a/system/logcatd/logcatd_systemd.cc b/system/logcatd/logcatd_systemd.cc index 721726ed27..54b3782132 100644 --- a/system/logcatd/logcatd_systemd.cc +++ b/system/logcatd/logcatd_systemd.cc @@ -5,7 +5,7 @@ #include #include -#include "json11.hpp" +#include "third_party/json11/json11.hpp" #include "cereal/messaging/messaging.h" #include "common/timing.h" diff --git a/system/loggerd/encoder/ffmpeg_encoder.cc b/system/loggerd/encoder/ffmpeg_encoder.cc index b73f4e8f5d..dc20ea8791 100644 --- a/system/loggerd/encoder/ffmpeg_encoder.cc +++ b/system/loggerd/encoder/ffmpeg_encoder.cc @@ -11,7 +11,7 @@ #define __STDC_CONSTANT_MACROS -#include "libyuv.h" +#include "third_party/libyuv/include/libyuv.h" extern "C" { #include diff --git a/system/loggerd/encoder/v4l_encoder.cc b/system/loggerd/encoder/v4l_encoder.cc index 2f74c3785a..b09fa1e6ba 100644 --- a/system/loggerd/encoder/v4l_encoder.cc +++ b/system/loggerd/encoder/v4l_encoder.cc @@ -7,11 +7,11 @@ #include "common/util.h" #include "common/timing.h" -#include "libyuv.h" -#include "msm_media_info.h" +#include "third_party/libyuv/include/libyuv.h" +#include "third_party/linux/include/msm_media_info.h" // has to be in this order -#include "v4l2-controls.h" +#include "third_party/linux/include/v4l2-controls.h" #include #define V4L2_QCOM_BUF_FLAG_CODECCONFIG 0x00020000 #define V4L2_QCOM_BUF_FLAG_EOS 0x02000000 diff --git a/system/sensord/sensors/bmx055_accel.cc b/system/sensord/sensors/bmx055_accel.cc index 0c48d1e3ba..bdb0113de3 100644 --- a/system/sensord/sensors/bmx055_accel.cc +++ b/system/sensord/sensors/bmx055_accel.cc @@ -1,4 +1,4 @@ -#include "bmx055_accel.h" +#include "system/sensord/sensors/bmx055_accel.h" #include diff --git a/system/sensord/sensors/bmx055_gyro.cc b/system/sensord/sensors/bmx055_gyro.cc index ba41f3b47c..411b2f445e 100644 --- a/system/sensord/sensors/bmx055_gyro.cc +++ b/system/sensord/sensors/bmx055_gyro.cc @@ -1,4 +1,4 @@ -#include "bmx055_gyro.h" +#include "system/sensord/sensors/bmx055_gyro.h" #include #include diff --git a/system/sensord/sensors/bmx055_magn.cc b/system/sensord/sensors/bmx055_magn.cc index 950e608923..585bf1b2d2 100644 --- a/system/sensord/sensors/bmx055_magn.cc +++ b/system/sensord/sensors/bmx055_magn.cc @@ -1,4 +1,4 @@ -#include "bmx055_magn.h" +#include "system/sensord/sensors/bmx055_magn.h" #include diff --git a/system/sensord/sensors/bmx055_temp.cc b/system/sensord/sensors/bmx055_temp.cc index 68ee0da1d6..da7b86476c 100644 --- a/system/sensord/sensors/bmx055_temp.cc +++ b/system/sensord/sensors/bmx055_temp.cc @@ -1,4 +1,4 @@ -#include "bmx055_temp.h" +#include "system/sensord/sensors/bmx055_temp.h" #include diff --git a/system/sensord/sensors/i2c_sensor.cc b/system/sensord/sensors/i2c_sensor.cc index f563f93d2b..90220f551d 100644 --- a/system/sensord/sensors/i2c_sensor.cc +++ b/system/sensord/sensors/i2c_sensor.cc @@ -1,4 +1,4 @@ -#include "i2c_sensor.h" +#include "system/sensord/sensors/i2c_sensor.h" int16_t read_12_bit(uint8_t lsb, uint8_t msb) { uint16_t combined = (uint16_t(msb) << 8) | uint16_t(lsb & 0xF0); diff --git a/system/sensord/sensors/lsm6ds3_accel.cc b/system/sensord/sensors/lsm6ds3_accel.cc index 139b5df67a..03533e0657 100644 --- a/system/sensord/sensors/lsm6ds3_accel.cc +++ b/system/sensord/sensors/lsm6ds3_accel.cc @@ -1,4 +1,4 @@ -#include "lsm6ds3_accel.h" +#include "system/sensord/sensors/lsm6ds3_accel.h" #include #include diff --git a/system/sensord/sensors/lsm6ds3_gyro.cc b/system/sensord/sensors/lsm6ds3_gyro.cc index e6bdc6c8a9..0459b6ad64 100644 --- a/system/sensord/sensors/lsm6ds3_gyro.cc +++ b/system/sensord/sensors/lsm6ds3_gyro.cc @@ -1,4 +1,4 @@ -#include "lsm6ds3_gyro.h" +#include "system/sensord/sensors/lsm6ds3_gyro.h" #include #include diff --git a/system/sensord/sensors/lsm6ds3_temp.cc b/system/sensord/sensors/lsm6ds3_temp.cc index c2e2c83c1d..f481614154 100644 --- a/system/sensord/sensors/lsm6ds3_temp.cc +++ b/system/sensord/sensors/lsm6ds3_temp.cc @@ -1,4 +1,4 @@ -#include "lsm6ds3_temp.h" +#include "system/sensord/sensors/lsm6ds3_temp.h" #include diff --git a/system/sensord/sensors/mmc5603nj_magn.cc b/system/sensord/sensors/mmc5603nj_magn.cc index b69c602bdf..0e8ba967e3 100644 --- a/system/sensord/sensors/mmc5603nj_magn.cc +++ b/system/sensord/sensors/mmc5603nj_magn.cc @@ -1,4 +1,4 @@ -#include "mmc5603nj_magn.h" +#include "system/sensord/sensors/mmc5603nj_magn.h" #include #include diff --git a/system/ubloxd/ublox_msg.cc b/system/ubloxd/ublox_msg.cc index 48a39b7bef..7b4505dc81 100644 --- a/system/ubloxd/ublox_msg.cc +++ b/system/ubloxd/ublox_msg.cc @@ -1,4 +1,4 @@ -#include "ublox_msg.h" +#include "system/ubloxd/ublox_msg.h" #include diff --git a/tools/cabana/streams/socketcanstream.cc b/tools/cabana/streams/socketcanstream.cc index d5f9d115f2..3df8e31f3b 100644 --- a/tools/cabana/streams/socketcanstream.cc +++ b/tools/cabana/streams/socketcanstream.cc @@ -1,5 +1,4 @@ #include "tools/cabana/streams/socketcanstream.h" -#include "socketcanstream.h" #include #include diff --git a/tools/lib/vidindex/bitstream.c b/tools/lib/vidindex/bitstream.c index d174ffa8a7..dc6f43f14f 100644 --- a/tools/lib/vidindex/bitstream.c +++ b/tools/lib/vidindex/bitstream.c @@ -1,8 +1,8 @@ +#include "./bitstream.h" + #include #include -#include "bitstream.h" - static const uint32_t BS_MASKS[33] = { 0, 0x1L, 0x3L, 0x7L, 0xFL, 0x1FL, 0x3FL, 0x7FL, 0xFFL, 0x1FFL, 0x3FFL, 0x7FFL, diff --git a/tools/lib/vidindex/vidindex.c b/tools/lib/vidindex/vidindex.c index 4857c60dd2..1d7da2e193 100644 --- a/tools/lib/vidindex/vidindex.c +++ b/tools/lib/vidindex/vidindex.c @@ -9,7 +9,7 @@ #include #include -#include "bitstream.h" +#include "./bitstream.h" #define START_CODE 0x000001 diff --git a/tools/replay/camera.cc b/tools/replay/camera.cc index 2bc8c66aaa..49f3010c6c 100644 --- a/tools/replay/camera.cc +++ b/tools/replay/camera.cc @@ -1,10 +1,11 @@ #include "tools/replay/camera.h" -#include "tools/replay/util.h" -#include "msm_media_info.h" #include #include +#include "third_party/linux/include/msm_media_info.h" +#include "tools/replay/util.h" + std::tuple get_nv12_info(int width, int height) { int nv12_width = VENUS_Y_STRIDE(COLOR_FMT_NV12, width); int nv12_height = VENUS_Y_SCANLINES(COLOR_FMT_NV12, height); diff --git a/tools/replay/framereader.cc b/tools/replay/framereader.cc index f45996560e..303f0c60ca 100644 --- a/tools/replay/framereader.cc +++ b/tools/replay/framereader.cc @@ -3,7 +3,7 @@ #include #include -#include "libyuv.h" +#include "third_party/libyuv/include/libyuv.h" #ifdef __APPLE__ #define HW_DEVICE_TYPE AV_HWDEVICE_TYPE_VIDEOTOOLBOX From 74b9a6af9e10e97f1686732ab7b6ba0ace597c48 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Thu, 24 Aug 2023 15:46:56 +0100 Subject: [PATCH 131/159] add missing openpilot prefix to imports --- selfdrive/car/ford/tests/test_ford.py | 2 +- selfdrive/controls/lib/tests/test_latcontrol.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/ford/tests/test_ford.py b/selfdrive/car/ford/tests/test_ford.py index 11746777f0..e645b4cbe6 100755 --- a/selfdrive/car/ford/tests/test_ford.py +++ b/selfdrive/car/ford/tests/test_ford.py @@ -6,7 +6,7 @@ from typing import Dict, Iterable, Optional, Tuple import capnp from cereal import car -from selfdrive.car.ford.values import FW_QUERY_CONFIG, FW_VERSIONS +from openpilot.selfdrive.car.ford.values import FW_QUERY_CONFIG, FW_VERSIONS Ecu = car.CarParams.Ecu diff --git a/selfdrive/controls/lib/tests/test_latcontrol.py b/selfdrive/controls/lib/tests/test_latcontrol.py index cf2243d033..9580e604ff 100755 --- a/selfdrive/controls/lib/tests/test_latcontrol.py +++ b/selfdrive/controls/lib/tests/test_latcontrol.py @@ -12,7 +12,7 @@ from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel -from selfdrive.navd.tests.test_map_renderer import gen_llk +from openpilot.selfdrive.navd.tests.test_map_renderer import gen_llk class TestLatControl(unittest.TestCase): From 9c7bf50703e4da45163e175766b4bdfabcb9916c Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 23:06:58 +0800 Subject: [PATCH 132/159] cpplint: add filter `whitespace/tab` (#29588) --- .pre-commit-config.yaml | 2 +- common/mat.h | 4 ++-- selfdrive/modeld/runners/onnxmodel.h | 2 +- selfdrive/modeld/tests/tf_test/main.cc | 6 +++--- system/camerad/cameras/camera_qcom2.cc | 28 +++++++++++++------------- system/sensord/sensors/bmx055_magn.cc | 20 +++++++++--------- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dd804eb588..81782123ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces - repo: local hooks: - id: test_translations diff --git a/common/mat.h b/common/mat.h index 626f3404fe..8e10d61971 100644 --- a/common/mat.h +++ b/common/mat.h @@ -1,7 +1,7 @@ #pragma once typedef struct vec3 { - float v[3]; + float v[3]; } vec3; typedef struct vec4 { @@ -9,7 +9,7 @@ typedef struct vec4 { } vec4; typedef struct mat3 { - float v[3*3]; + float v[3*3]; } mat3; typedef struct mat4 { diff --git a/selfdrive/modeld/runners/onnxmodel.h b/selfdrive/modeld/runners/onnxmodel.h index 42aa179ce9..f9bae1a0a9 100644 --- a/selfdrive/modeld/runners/onnxmodel.h +++ b/selfdrive/modeld/runners/onnxmodel.h @@ -7,7 +7,7 @@ class ONNXModel : public RunModel { public: ONNXModel(const std::string path, float *output, size_t output_size, int runtime, bool _use_tf8 = false, cl_context context = NULL); - ~ONNXModel(); + ~ONNXModel(); void execute(); private: int proc_pid; diff --git a/selfdrive/modeld/tests/tf_test/main.cc b/selfdrive/modeld/tests/tf_test/main.cc index db1ef3d67e..b00f7f95e8 100644 --- a/selfdrive/modeld/tests/tf_test/main.cc +++ b/selfdrive/modeld/tests/tf_test/main.cc @@ -36,9 +36,9 @@ static void DeallocateBuffer(void* data, size_t) { int main(int argc, char* argv[]) { TF_Buffer* buf; - TF_Graph* graph; - TF_Status* status; - char *path = argv[1]; + TF_Graph* graph; + TF_Status* status; + char *path = argv[1]; // load model { diff --git a/system/camerad/cameras/camera_qcom2.cc b/system/camerad/cameras/camera_qcom2.cc index b404c2a2e9..3a9ecb467b 100644 --- a/system/camerad/cameras/camera_qcom2.cc +++ b/system/camerad/cameras/camera_qcom2.cc @@ -422,20 +422,20 @@ void CameraState::config_isp(int io_mem_handle, int fence, int request_id, int b if (io_mem_handle != 0) { io_cfg[0].mem_handle[0] = io_mem_handle; - io_cfg[0].planes[0] = (struct cam_plane_cfg){ - .width = ci.frame_width, - .height = ci.frame_height + ci.extra_height, - .plane_stride = ci.frame_stride, - .slice_height = ci.frame_height + ci.extra_height, - .meta_stride = 0x0, // YUV has meta(stride=0x400, size=0x5000) - .meta_size = 0x0, - .meta_offset = 0x0, - .packer_config = 0x0, // 0xb for YUV - .mode_config = 0x0, // 0x9ef for YUV - .tile_config = 0x0, - .h_init = 0x0, - .v_init = 0x0, - }; + io_cfg[0].planes[0] = (struct cam_plane_cfg){ + .width = ci.frame_width, + .height = ci.frame_height + ci.extra_height, + .plane_stride = ci.frame_stride, + .slice_height = ci.frame_height + ci.extra_height, + .meta_stride = 0x0, // YUV has meta(stride=0x400, size=0x5000) + .meta_size = 0x0, + .meta_offset = 0x0, + .packer_config = 0x0, // 0xb for YUV + .mode_config = 0x0, // 0x9ef for YUV + .tile_config = 0x0, + .h_init = 0x0, + .v_init = 0x0, + }; io_cfg[0].format = CAM_FORMAT_MIPI_RAW_12; // CAM_FORMAT_UBWC_TP10 for YUV io_cfg[0].color_space = CAM_COLOR_SPACE_BASE; // CAM_COLOR_SPACE_BT601_FULL for YUV io_cfg[0].color_pattern = 0x5; // 0x0 for YUV diff --git a/system/sensord/sensors/bmx055_magn.cc b/system/sensord/sensors/bmx055_magn.cc index 585bf1b2d2..3d0d3d2fc6 100644 --- a/system/sensord/sensors/bmx055_magn.cc +++ b/system/sensord/sensors/bmx055_magn.cc @@ -171,17 +171,17 @@ bool BMX055_Magn::perform_self_test() { uint8_t forced = BMX055_MAGN_FORCED; // Negative current - set_register(BMX055_MAGN_I2C_REG_MAG, forced | (uint8_t(0b10) << 6)); - util::sleep_for(100); + set_register(BMX055_MAGN_I2C_REG_MAG, forced | (uint8_t(0b10) << 6)); + util::sleep_for(100); - read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); - parse_xyz(buffer, &x, &y, &neg_z); + read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + parse_xyz(buffer, &x, &y, &neg_z); // Positive current - set_register(BMX055_MAGN_I2C_REG_MAG, forced | (uint8_t(0b11) << 6)); - util::sleep_for(100); + set_register(BMX055_MAGN_I2C_REG_MAG, forced | (uint8_t(0b11) << 6)); + util::sleep_for(100); - read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); + read_register(BMX055_MAGN_I2C_REG_DATAX_LSB, buffer, sizeof(buffer)); parse_xyz(buffer, &x, &y, &pos_z); // Put back in normal mode @@ -206,9 +206,9 @@ bool BMX055_Magn::parse_xyz(uint8_t buffer[8], int16_t *x, int16_t *y, int16_t * uint16_t data_r = (uint16_t) (((uint16_t)buffer[7] << 8) | buffer[6]) >> 2; assert(data_r != 0); - *x = compensate_x(trim_data, mdata_x, data_r); - *y = compensate_y(trim_data, mdata_y, data_r); - *z = compensate_z(trim_data, mdata_z, data_r); + *x = compensate_x(trim_data, mdata_x, data_r); + *y = compensate_y(trim_data, mdata_y, data_r); + *z = compensate_z(trim_data, mdata_z, data_r); } return ready; } From 20e81703995e74877248ac28fd653f059bc44e34 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 23:21:03 +0800 Subject: [PATCH 133/159] common/i2c: remove duplicate #include (#29594) --- common/i2c.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/common/i2c.cc b/common/i2c.cc index fc72559ce7..9508179c6e 100644 --- a/common/i2c.cc +++ b/common/i2c.cc @@ -8,7 +8,6 @@ #include #include -#include "common/util.h" #include "common/swaglog.h" #include "common/util.h" From 792ad7d81677ebb95888541bac14fb6089c1e5fc Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Aug 2023 23:51:53 +0800 Subject: [PATCH 134/159] ui/map: delete map after unsubscribing from prime (#29136) Co-authored-by: Cameron Clough --- selfdrive/ui/qt/onroad.cc | 14 +++++++++++++- selfdrive/ui/qt/onroad.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index d5b2bbcf6b..1b05509ae8 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -63,6 +63,7 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { setAttribute(Qt::WA_OpaquePaintEvent); QObject::connect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState); QObject::connect(uiState(), &UIState::offroadTransition, this, &OnroadWindow::offroadTransition); + QObject::connect(uiState(), &UIState::primeChanged, this, &OnroadWindow::primeChanged); } void OnroadWindow::updateState(const UIState &s) { @@ -105,7 +106,7 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) { void OnroadWindow::offroadTransition(bool offroad) { #ifdef ENABLE_MAPS if (!offroad) { - if (map == nullptr && (uiState()->primeType() || !MAPBOX_TOKEN.isEmpty())) { + if (map == nullptr && (uiState()->hasPrime() || !MAPBOX_TOKEN.isEmpty())) { auto m = new MapPanel(get_mapbox_settings()); map = m; @@ -125,6 +126,17 @@ void OnroadWindow::offroadTransition(bool offroad) { alerts->updateAlert({}); } +void OnroadWindow::primeChanged(bool prime) { +#ifdef ENABLE_MAPS + if (map && (!prime && MAPBOX_TOKEN.isEmpty())) { + nvg->map_settings_btn->setEnabled(false); + nvg->map_settings_btn->setVisible(false); + map->deleteLater(); + map = nullptr; + } +#endif +} + void OnroadWindow::paintEvent(QPaintEvent *event) { QPainter p(this); p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255)); diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index df43ff97f1..c94b1947d2 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -150,5 +150,6 @@ private: private slots: void offroadTransition(bool offroad); + void primeChanged(bool prime); void updateState(const UIState &s); }; From 7bfd3dac811ae95bfd09495e88377dfbaacda393 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 25 Aug 2023 01:42:06 +0800 Subject: [PATCH 135/159] cpplint: add filter `whitespace/comma` (#29595) --- .pre-commit-config.yaml | 2 +- scripts/dump_pll.c | 6 ++-- selfdrive/modeld/modeld.cc | 2 +- selfdrive/modeld/models/driving.cc | 2 +- .../modeld/tests/snpe_benchmark/benchmark.cc | 4 +-- selfdrive/ui/qt/widgets/keyboard.cc | 32 +++++++++---------- selfdrive/ui/ui.cc | 10 +++--- system/camerad/test/ae_gray_test.h | 21 ++++++------ system/loggerd/encoder/v4l_encoder.cc | 2 +- tools/cabana/messageswidget.cc | 2 +- tools/cabana/util.h | 2 +- 11 files changed, 42 insertions(+), 43 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 81782123ac..d4259dec17 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - --linelength=240 # https://google.github.io/styleguide/cppguide.html # relevant rules are whitelisted, see all options with: cpplint --filter= - - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces - repo: local hooks: - id: test_translations diff --git a/scripts/dump_pll.c b/scripts/dump_pll.c index 325ee2b4c0..3e2190235a 100644 --- a/scripts/dump_pll.c +++ b/scripts/dump_pll.c @@ -39,9 +39,9 @@ void hexdump(uint32_t *d, int l) { int main() { int fd = open("/dev/mem", O_RDWR); - volatile uint32_t *mb = (uint32_t*)mmap(0,0x1000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,0x06400000); - volatile uint32_t *mc = (uint32_t*)mmap(0,0x1000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,0x06480000); - volatile uint32_t *md = (uint32_t*)mmap(0,0x1000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,0x09A20000); + volatile uint32_t *mb = (uint32_t *)mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x06400000); + volatile uint32_t *mc = (uint32_t *)mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x06480000); + volatile uint32_t *md = (uint32_t *)mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x09A20000); while (1) { printf("PLL MODE:%x L_VAL:%x ALPHA:%x USER_CTL:%x CONFIG_CTL:%x CONFIG_CTL_HI:%x STATUS:%x TEST_CTL_LO:%x TEST_CTL_HI:%x\n", mb[C0_PLL_MODE/4], mb[C0_PLL_L_VAL/4], mb[C0_PLL_ALPHA/4], diff --git a/selfdrive/modeld/modeld.cc b/selfdrive/modeld/modeld.cc index d1769c4bec..9a5862fbf5 100644 --- a/selfdrive/modeld/modeld.cc +++ b/selfdrive/modeld/modeld.cc @@ -30,7 +30,7 @@ mat3 update_calibration(Eigen::Vector3d device_from_calib_euler, bool wide_camer static const auto calib_from_medmodel = (Eigen::Matrix() << 0.00000000e+00, 0.00000000e+00, 1.00000000e+00, 1.09890110e-03, 0.00000000e+00, -2.81318681e-01, - -2.25466395e-20, 1.09890110e-03,-5.23076923e-02).finished(); + -2.25466395e-20, 1.09890110e-03, -5.23076923e-02).finished(); static const auto calib_from_sbigmodel = (Eigen::Matrix() << 0.00000000e+00, 7.31372216e-19, 1.00000000e+00, diff --git a/selfdrive/modeld/models/driving.cc b/selfdrive/modeld/models/driving.cc index 72137c4a97..136bd255c3 100644 --- a/selfdrive/modeld/models/driving.cc +++ b/selfdrive/modeld/models/driving.cc @@ -157,7 +157,7 @@ void fill_meta(cereal::ModelDataV2::MetaData::Builder meta, const ModelOutputMet softmax(meta_data.desire_pred_prob[i].array.data(), desire_pred_softmax.data() + (i * DESIRE_LEN), DESIRE_LEN); } - std::array lat_long_t = {2,4,6,8,10}; + std::array lat_long_t = {2, 4, 6, 8, 10}; std::array gas_disengage_sigmoid, brake_disengage_sigmoid, steer_override_sigmoid, brake_3ms2_sigmoid, brake_4ms2_sigmoid, brake_5ms2_sigmoid; for (int i=0; i &input) { FILE * pFile; string filepath="/data/ipt/quantize_samples/sample_input_"+std::to_string(index); - pFile = fopen(filepath.c_str(),"rb"); + pFile = fopen(filepath.c_str(), "rb"); int length = 1*6*160*320*4; float * frame_buffer = new float[length/4]; // 32/8 fread(frame_buffer, length, 1, pFile); @@ -164,7 +164,7 @@ void testrun(char* modelfile) { for (int i=0; i<10000; i++) { std::unique_ptr input; input = zdl::SNPE::SNPEFactory::getTensorFactory().createTensor(inputShape); - get_testframe(i,input); + get_testframe(i, input); snpe->execute(input.get(), outputTensorMap); zdl::DlSystem::StringList tensorNames = outputTensorMap.getTensorNames(); std::for_each(tensorNames.begin(), tensorNames.end(), [&](const char* name) { diff --git a/selfdrive/ui/qt/widgets/keyboard.cc b/selfdrive/ui/qt/widgets/keyboard.cc index 162d27db02..370e9a53cc 100644 --- a/selfdrive/ui/qt/widgets/keyboard.cc +++ b/selfdrive/ui/qt/widgets/keyboard.cc @@ -104,37 +104,37 @@ Keyboard::Keyboard(QWidget *parent) : QFrame(parent) { // lowercase std::vector> lowercase = { - {"q","w","e","r","t","y","u","i","o","p"}, - {"a","s","d","f","g","h","j","k","l"}, - {"↑","z","x","c","v","b","n","m",BACKSPACE_KEY}, - {"123"," ",".",ENTER_KEY}, + {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p"}, + {"a", "s", "d", "f", "g", "h", "j", "k", "l"}, + {"↑", "z", "x", "c", "v", "b", "n", "m", BACKSPACE_KEY}, + {"123", " ", ".", ENTER_KEY}, }; main_layout->addWidget(new KeyboardLayout(this, lowercase)); // uppercase std::vector> uppercase = { - {"Q","W","E","R","T","Y","U","I","O","P"}, - {"A","S","D","F","G","H","J","K","L"}, - {"↓","Z","X","C","V","B","N","M",BACKSPACE_KEY}, - {"123"," ",".",ENTER_KEY}, + {"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"}, + {"A", "S", "D", "F", "G", "H", "J", "K", "L"}, + {"↓", "Z", "X", "C", "V", "B", "N", "M", BACKSPACE_KEY}, + {"123", " ", ".", ENTER_KEY}, }; main_layout->addWidget(new KeyboardLayout(this, uppercase)); // numbers + specials std::vector> numbers = { - {"1","2","3","4","5","6","7","8","9","0"}, - {"-","/",":",";","(",")","$","&&","@","\""}, - {"#+=",".",",","?","!","`",BACKSPACE_KEY}, - {"ABC"," ",".",ENTER_KEY}, + {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}, + {"-", "/", ":", ";", "(", ")", "$", "&&", "@", "\""}, + {"#+=", ".", ",", "?", "!", "`", BACKSPACE_KEY}, + {"ABC", " ", ".", ENTER_KEY}, }; main_layout->addWidget(new KeyboardLayout(this, numbers)); // extra specials std::vector> specials = { - {"[","]","{","}","#","%","^","*","+","="}, - {"_","\\","|","~","<",">","€","£","¥","•"}, - {"123",".",",","?","!","'",BACKSPACE_KEY}, - {"ABC"," ",".",ENTER_KEY}, + {"[", "]", "{", "}", "#", "%", "^", "*", "+", "="}, + {"_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"}, + {"123", ".", ",", "?", "!", "'", BACKSPACE_KEY}, + {"ABC", " ", ".", ENTER_KEY}, }; main_layout->addWidget(new KeyboardLayout(this, specials)); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index fa857c769b..03df2cf57a 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -169,15 +169,15 @@ static void update_state(UIState *s) { Eigen::Matrix3d device_from_calib = euler2rot(rpy); Eigen::Matrix3d wide_from_device = euler2rot(wfde); Eigen::Matrix3d view_from_device; - view_from_device << 0,1,0, - 0,0,1, - 1,0,0; + view_from_device << 0, 1, 0, + 0, 0, 1, + 1, 0, 0; Eigen::Matrix3d view_from_calib = view_from_device * device_from_calib; Eigen::Matrix3d view_from_wide_calib = view_from_device * wide_from_device * device_from_calib; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - scene.view_from_calib.v[i*3 + j] = view_from_calib(i,j); - scene.view_from_wide_calib.v[i*3 + j] = view_from_wide_calib(i,j); + scene.view_from_calib.v[i*3 + j] = view_from_calib(i, j); + scene.view_from_wide_calib.v[i*3 + j] = view_from_wide_calib(i, j); } } scene.calibration_valid = live_calib.getCalStatus() == cereal::LiveCalibrationData::Status::CALIBRATED; diff --git a/system/camerad/test/ae_gray_test.h b/system/camerad/test/ae_gray_test.h index fb54cd9584..8953fb017f 100644 --- a/system/camerad/test/ae_gray_test.h +++ b/system/camerad/test/ae_gray_test.h @@ -5,14 +5,13 @@ #define TONE_SPLITS 3 -float gts[TONE_SPLITS*TONE_SPLITS*TONE_SPLITS*TONE_SPLITS] = { - 0.917969,0.917969,0.375000,0.917969,0.375000,0.375000,0.187500,0.187500,0.187500,0.917969, - 0.375000,0.375000,0.187500,0.187500,0.187500,0.187500,0.187500,0.187500,0.093750,0.093750, - 0.093750,0.093750,0.093750,0.093750,0.093750,0.093750,0.093750,0.917969,0.375000,0.375000, - 0.187500,0.187500,0.187500,0.187500,0.187500,0.187500,0.093750,0.093750,0.093750,0.093750, - 0.093750,0.093750,0.093750,0.093750,0.093750,0.093750,0.093750,0.093750,0.093750,0.093750, - 0.093750,0.093750,0.093750,0.093750,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, - 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, - 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, - 0.000000 -}; +float gts[TONE_SPLITS * TONE_SPLITS * TONE_SPLITS * TONE_SPLITS] = { + 0.917969, 0.917969, 0.375000, 0.917969, 0.375000, 0.375000, 0.187500, 0.187500, 0.187500, 0.917969, + 0.375000, 0.375000, 0.187500, 0.187500, 0.187500, 0.187500, 0.187500, 0.187500, 0.093750, 0.093750, + 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.917969, 0.375000, 0.375000, + 0.187500, 0.187500, 0.187500, 0.187500, 0.187500, 0.187500, 0.093750, 0.093750, 0.093750, 0.093750, + 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, 0.093750, + 0.093750, 0.093750, 0.093750, 0.093750, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, + 0.000000}; diff --git a/system/loggerd/encoder/v4l_encoder.cc b/system/loggerd/encoder/v4l_encoder.cc index b09fa1e6ba..b5329bb8f1 100644 --- a/system/loggerd/encoder/v4l_encoder.cc +++ b/system/loggerd/encoder/v4l_encoder.cc @@ -19,7 +19,7 @@ // echo 0x7fffffff > /sys/kernel/debug/msm_vidc/debug_level const int env_debug_encoder = (getenv("DEBUG_ENCODER") != NULL) ? atoi(getenv("DEBUG_ENCODER")) : 0; -#define checked_ioctl(x,y,z) { int _ret = HANDLE_EINTR(ioctl(x,y,z)); if (_ret!=0) { LOGE("checked_ioctl failed %d %lx %p", x, y, z); } assert(_ret==0); } +#define checked_ioctl(x, y, z) { int _ret = HANDLE_EINTR(ioctl(x, y, z)); if (_ret!=0) { LOGE("checked_ioctl failed %d %lx %p", x, y, z); } assert(_ret==0); } static void dequeue_buffer(int fd, v4l2_buf_type buf_type, unsigned int *index=NULL, unsigned int *bytesused=NULL, unsigned int *flags=NULL, struct timeval *timestamp=NULL) { v4l2_plane plane = {0}; diff --git a/tools/cabana/messageswidget.cc b/tools/cabana/messageswidget.cc index 7c20186594..cd663f0e45 100644 --- a/tools/cabana/messageswidget.cc +++ b/tools/cabana/messageswidget.cc @@ -15,7 +15,7 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *main_layout = new QVBoxLayout(this); - main_layout->setContentsMargins(0 ,0, 0, 0); + main_layout->setContentsMargins(0, 0, 0, 0); QHBoxLayout *title_layout = new QHBoxLayout(); num_msg_label = new QLabel(this); diff --git a/tools/cabana/util.h b/tools/cabana/util.h index 696319b3a8..db681f80f9 100644 --- a/tools/cabana/util.h +++ b/tools/cabana/util.h @@ -59,7 +59,7 @@ public: private: std::pair get_minmax(int n, int left, int right, int range_left, int range_right) const; void build_tree(const QVector &arr, int n, int left, int right); - std::vector> tree; + std::vector> tree; int size = 0; }; From 821cfff56d00b61fc3b4fba12bf0830cdb21ed27 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 10:45:50 -0700 Subject: [PATCH 136/159] car interfaces: long running fuzzy test (#29592) * draft * draft 2 * increase deadline and run * imports * run -> use --- Jenkinsfile | 1 + selfdrive/car/tests/test_car_interfaces.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a698cc68cc..c0bdd53253 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -160,6 +160,7 @@ pipeline { sh "scons --clean && scons --no-cache --random -j42" sh "INTERNAL_SEG_CNT=500 INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt FILEREADER_CACHE=1 \ pytest -n42 --dist=loadscope selfdrive/car/tests/test_models.py" + sh "MAX_EXAMPLES=100 pytest -n42 selfdrive/car/tests/test_car_interfaces.py" } post { diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index 7abc4c6f41..d44c50ed90 100755 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -3,7 +3,7 @@ import os import math import unittest import hypothesis.strategies as st -from hypothesis import given, settings +from hypothesis import Phase, given, settings import importlib from parameterized import parameterized @@ -18,6 +18,8 @@ from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()}) +MAX_EXAMPLES = int(os.environ.get('MAX_EXAMPLES', '5')) + def get_fuzzy_car_interface_args(draw: DrawType) -> dict: # Fuzzy CAN fingerprints and FW versions to test more states of the CarInterface @@ -45,8 +47,11 @@ class TestCarInterfaces(unittest.TestCase): def setUpClass(cls): os.environ['NO_RADAR_SLEEP'] = '1' + # FIXME: Due to the lists used in carParams, Phase.target is very slow and will cause + # many generated examples to overrun when max_examples > ~20, don't use it @parameterized.expand([(car,) for car in sorted(all_known_cars())]) - @settings(max_examples=5) + @settings(max_examples=MAX_EXAMPLES, deadline=500, + phases=(Phase.reuse, Phase.generate, Phase.shrink)) @given(data=st.data()) def test_car_interfaces(self, car_name, data): CarInterface, CarController, CarState = interfaces[car_name] From b234cb022356baceba3fb4a990c7c483216bd860 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 25 Aug 2023 02:09:26 +0800 Subject: [PATCH 137/159] ui: remove Q_PROPERTY from `AnnotatedCameraWidget` (#28745) --- selfdrive/ui/qt/onroad.cc | 47 +++++++++++++++------------------------ selfdrive/ui/qt/onroad.h | 13 ----------- 2 files changed, 18 insertions(+), 42 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 1b05509ae8..d0b82207e6 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -283,53 +283,42 @@ void AnnotatedCameraWidget::updateState(const UIState &s) { const bool cs_alive = sm.alive("controlsState"); const bool nav_alive = sm.alive("navInstruction") && sm["navInstruction"].getValid(); - const auto cs = sm["controlsState"].getControlsState(); const auto car_state = sm["carState"].getCarState(); const auto nav_instruction = sm["navInstruction"].getNavInstruction(); // Handle older routes where vCruiseCluster is not set float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster(); - float set_speed = cs_alive ? v_cruise : SET_SPEED_NA; - bool cruise_set = set_speed > 0 && (int)set_speed != SET_SPEED_NA; - if (cruise_set && !s.scene.is_metric) { - set_speed *= KM_TO_MILE; + setSpeed = cs_alive ? v_cruise : SET_SPEED_NA; + is_cruise_set = setSpeed > 0 && (int)setSpeed != SET_SPEED_NA; + if (is_cruise_set && !s.scene.is_metric) { + setSpeed *= KM_TO_MILE; } // Handle older routes where vEgoCluster is not set - float v_ego; - if (car_state.getVEgoCluster() == 0.0 && !v_ego_cluster_seen) { - v_ego = car_state.getVEgo(); - } else { - v_ego = car_state.getVEgoCluster(); - v_ego_cluster_seen = true; - } - float cur_speed = cs_alive ? std::max(0.0, v_ego) : 0.0; - cur_speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH; + v_ego_cluster_seen = v_ego_cluster_seen || car_state.getVEgoCluster() != 0.0; + float v_ego = v_ego_cluster_seen ? car_state.getVEgoCluster() : car_state.getVEgo(); + speed = cs_alive ? std::max(0.0, v_ego) : 0.0; + speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH; auto speed_limit_sign = nav_instruction.getSpeedLimitSign(); - float speed_limit = nav_alive ? nav_instruction.getSpeedLimit() : 0.0; - speed_limit *= (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH); - - setProperty("speedLimit", speed_limit); - setProperty("has_us_speed_limit", nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::MUTCD); - setProperty("has_eu_speed_limit", nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::VIENNA); + speedLimit = nav_alive ? nav_instruction.getSpeedLimit() : 0.0; + speedLimit *= (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH); - setProperty("is_cruise_set", cruise_set); - setProperty("is_metric", s.scene.is_metric); - setProperty("speed", cur_speed); - setProperty("setSpeed", set_speed); - setProperty("speedUnit", s.scene.is_metric ? tr("km/h") : tr("mph")); - setProperty("hideBottomIcons", (cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE)); - setProperty("status", s.status); + has_us_speed_limit = (nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::MUTCD); + has_eu_speed_limit = (nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::VIENNA); + is_metric = s.scene.is_metric; + speedUnit = s.scene.is_metric ? tr("km/h") : tr("mph"); + hideBottomIcons = (cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE); + status = s.status; // update engageability/experimental mode button experimental_btn->updateState(s); // update DM icon auto dm_state = sm["driverMonitoringState"].getDriverMonitoringState(); - setProperty("dmActive", dm_state.getIsActiveMode()); - setProperty("rightHandDM", dm_state.getIsRHD()); + dmActive = dm_state.getIsActiveMode(); + rightHandDM = dm_state.getIsRHD(); // DM icon transition dm_fade_state = std::clamp(dm_fade_state+0.2*(0.5-dmActive), 0.0, 1.0); diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index c94b1947d2..b3ba411453 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -65,19 +65,6 @@ private: // container window for the NVG UI class AnnotatedCameraWidget : public CameraWidget { Q_OBJECT - Q_PROPERTY(float speed MEMBER speed); - Q_PROPERTY(QString speedUnit MEMBER speedUnit); - Q_PROPERTY(float setSpeed MEMBER setSpeed); - Q_PROPERTY(float speedLimit MEMBER speedLimit); - Q_PROPERTY(bool is_cruise_set MEMBER is_cruise_set); - Q_PROPERTY(bool has_eu_speed_limit MEMBER has_eu_speed_limit); - Q_PROPERTY(bool has_us_speed_limit MEMBER has_us_speed_limit); - Q_PROPERTY(bool is_metric MEMBER is_metric); - - Q_PROPERTY(bool dmActive MEMBER dmActive); - Q_PROPERTY(bool hideBottomIcons MEMBER hideBottomIcons); - Q_PROPERTY(bool rightHandDM MEMBER rightHandDM); - Q_PROPERTY(int status MEMBER status); public: explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0); From 3930ec9facb51491309ba37f66a7b3c59a8dd035 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 25 Aug 2023 03:55:47 +0800 Subject: [PATCH 138/159] locationd: passing eigen objects by reference (#28719) pass eigen objects by reference --- selfdrive/locationd/locationd.cc | 18 ++++++------ selfdrive/locationd/locationd.h | 8 +++--- selfdrive/locationd/models/live_kf.cc | 40 +++++++++++++-------------- selfdrive/locationd/models/live_kf.h | 28 +++++++++---------- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 3a4286a18b..401de0cfdd 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -292,8 +292,8 @@ void Localizer::input_fake_gps_observations(double current_time) { VectorXd current_x = this->kf->get_x(); VectorXd ecef_pos = current_x.segment(STATE_ECEF_POS_START); VectorXd ecef_vel = current_x.segment(STATE_ECEF_VELOCITY_START); - MatrixXdr ecef_pos_R = this->kf->get_fake_gps_pos_cov(); - MatrixXdr ecef_vel_R = this->kf->get_fake_gps_vel_cov(); + const MatrixXdr &ecef_pos_R = this->kf->get_fake_gps_pos_cov(); + const MatrixXdr &ecef_vel_R = this->kf->get_fake_gps_vel_cov(); this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_POS, { ecef_pos }, { ecef_pos_R }); this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); @@ -507,8 +507,8 @@ void Localizer::handle_live_calib(double current_time, const cereal::LiveCalibra } void Localizer::reset_kalman(double current_time) { - VectorXd init_x = this->kf->get_initial_x(); - MatrixXdr init_P = this->kf->get_initial_P(); + const VectorXd &init_x = this->kf->get_initial_x(); + const MatrixXdr &init_P = this->kf->get_initial_P(); this->reset_kalman(current_time, init_x, init_P); } @@ -544,12 +544,12 @@ void Localizer::update_reset_tracker() { } } -void Localizer::reset_kalman(double current_time, VectorXd init_orient, VectorXd init_pos, VectorXd init_vel, MatrixXdr init_pos_R, MatrixXdr init_vel_R) { +void Localizer::reset_kalman(double current_time, const VectorXd &init_orient, const VectorXd &init_pos, const VectorXd &init_vel, const MatrixXdr &init_pos_R, const MatrixXdr &init_vel_R) { // too nonlinear to init on completely wrong VectorXd current_x = this->kf->get_x(); MatrixXdr current_P = this->kf->get_P(); MatrixXdr init_P = this->kf->get_initial_P(); - MatrixXdr reset_orientation_P = this->kf->get_reset_orientation_P(); + const MatrixXdr &reset_orientation_P = this->kf->get_reset_orientation_P(); int non_ecef_state_err_len = init_P.rows() - (STATE_ECEF_POS_ERR_LEN + STATE_ECEF_ORIENTATION_ERR_LEN + STATE_ECEF_VELOCITY_ERR_LEN); current_x.segment(STATE_ECEF_ORIENTATION_START) = init_orient; @@ -565,7 +565,7 @@ void Localizer::reset_kalman(double current_time, VectorXd init_orient, VectorXd this->reset_kalman(current_time, current_x, init_P); } -void Localizer::reset_kalman(double current_time, VectorXd init_x, MatrixXdr init_P) { +void Localizer::reset_kalman(double current_time, const VectorXd &init_x, const MatrixXdr &init_P) { this->kf->init_state(init_x, init_P, current_time); this->last_reset_time = current_time; this->reset_tracker += 1.0; @@ -620,7 +620,7 @@ bool Localizer::is_gps_ok() { return (this->kf->get_filter_time() - this->last_gps_msg) < 2.0; } -bool Localizer::critical_services_valid(std::map critical_services) { +bool Localizer::critical_services_valid(const std::map &critical_services) { for (auto &kv : critical_services){ if (kv.second >= INPUT_INVALID_THRESHOLD){ return false; @@ -653,7 +653,7 @@ void Localizer::determine_gps_mode(double current_time) { } } -void Localizer::configure_gnss_source(LocalizerGnssSource source) { +void Localizer::configure_gnss_source(const LocalizerGnssSource &source) { this->gnss_source = source; if (source == LocalizerGnssSource::UBLOX) { this->gps_std_factor = 10.0; diff --git a/selfdrive/locationd/locationd.h b/selfdrive/locationd/locationd.h index f7adab3673..f3069048cd 100755 --- a/selfdrive/locationd/locationd.h +++ b/selfdrive/locationd/locationd.h @@ -33,13 +33,13 @@ public: int locationd_thread(); void reset_kalman(double current_time = NAN); - void reset_kalman(double current_time, Eigen::VectorXd init_orient, Eigen::VectorXd init_pos, Eigen::VectorXd init_vel, MatrixXdr init_pos_R, MatrixXdr init_vel_R); - void reset_kalman(double current_time, Eigen::VectorXd init_x, MatrixXdr init_P); + void reset_kalman(double current_time, const Eigen::VectorXd &init_orient, const Eigen::VectorXd &init_pos, const Eigen::VectorXd &init_vel, const MatrixXdr &init_pos_R, const MatrixXdr &init_vel_R); + void reset_kalman(double current_time, const Eigen::VectorXd &init_x, const MatrixXdr &init_P); void finite_check(double current_time = NAN); void time_check(double current_time = NAN); void update_reset_tracker(); bool is_gps_ok(); - bool critical_services_valid(std::map critical_services); + bool critical_services_valid(const std::map &critical_services); bool is_timestamp_valid(double current_time); void determine_gps_mode(double current_time); bool are_inputs_ok(); @@ -95,5 +95,5 @@ private: float gps_vertical_variance_factor; double gps_time_offset; - void configure_gnss_source(LocalizerGnssSource source); + void configure_gnss_source(const LocalizerGnssSource &source); }; diff --git a/selfdrive/locationd/models/live_kf.cc b/selfdrive/locationd/models/live_kf.cc index 915d0fd360..fc3bfb7246 100755 --- a/selfdrive/locationd/models/live_kf.cc +++ b/selfdrive/locationd/models/live_kf.cc @@ -3,25 +3,25 @@ using namespace EKFS; using namespace Eigen; -Eigen::Map get_mapvec(Eigen::VectorXd& vec) { - return Eigen::Map(vec.data(), vec.rows(), vec.cols()); +Eigen::Map get_mapvec(const Eigen::VectorXd &vec) { + return Eigen::Map((double*)vec.data(), vec.rows(), vec.cols()); } -Eigen::Map get_mapmat(MatrixXdr& mat) { - return Eigen::Map(mat.data(), mat.rows(), mat.cols()); +Eigen::Map get_mapmat(const MatrixXdr &mat) { + return Eigen::Map((double*)mat.data(), mat.rows(), mat.cols()); } -std::vector> get_vec_mapvec(std::vector& vec_vec) { +std::vector> get_vec_mapvec(const std::vector &vec_vec) { std::vector> res; - for (Eigen::VectorXd& vec : vec_vec) { + for (const Eigen::VectorXd &vec : vec_vec) { res.push_back(get_mapvec(vec)); } return res; } -std::vector> get_vec_mapmat(std::vector& mat_vec) { +std::vector> get_vec_mapmat(const std::vector &mat_vec) { std::vector> res; - for (MatrixXdr& mat : mat_vec) { + for (const MatrixXdr &mat : mat_vec) { res.push_back(get_mapmat(mat)); } return res; @@ -43,20 +43,20 @@ LiveKalman::LiveKalman() { // init filter this->filter = std::make_shared(this->name, get_mapmat(this->Q), get_mapvec(this->initial_x), - get_mapmat(initial_P), this->dim_state, this->dim_state_err, 0, 0, 0, std::vector(), + get_mapmat(initial_P), this->dim_state, this->dim_state_err, 0, 0, 0, std::vector(), std::vector{3}, std::vector(), 0.8); } -void LiveKalman::init_state(VectorXd& state, VectorXd& covs_diag, double filter_time) { +void LiveKalman::init_state(const VectorXd &state, const VectorXd &covs_diag, double filter_time) { MatrixXdr covs = covs_diag.asDiagonal(); this->filter->init_state(get_mapvec(state), get_mapmat(covs), filter_time); } -void LiveKalman::init_state(VectorXd& state, MatrixXdr& covs, double filter_time) { +void LiveKalman::init_state(const VectorXd &state, const MatrixXdr &covs, double filter_time) { this->filter->init_state(get_mapvec(state), get_mapmat(covs), filter_time); } -void LiveKalman::init_state(VectorXd& state, double filter_time) { +void LiveKalman::init_state(const VectorXd &state, double filter_time) { MatrixXdr covs = this->filter->covs(); this->filter->init_state(get_mapvec(state), get_mapmat(covs), filter_time); } @@ -81,7 +81,7 @@ std::vector LiveKalman::get_R(int kind, int n) { return R; } -std::optional LiveKalman::predict_and_observe(double t, int kind, std::vector meas, std::vector R) { +std::optional LiveKalman::predict_and_observe(double t, int kind, const std::vector &meas, std::vector R) { std::optional r; if (R.size() == 0) { R = this->get_R(kind, meas.size()); @@ -94,29 +94,29 @@ void LiveKalman::predict(double t) { this->filter->predict(t); } -Eigen::VectorXd LiveKalman::get_initial_x() { +const Eigen::VectorXd &LiveKalman::get_initial_x() { return this->initial_x; } -MatrixXdr LiveKalman::get_initial_P() { +const MatrixXdr &LiveKalman::get_initial_P() { return this->initial_P; } -MatrixXdr LiveKalman::get_fake_gps_pos_cov() { +const MatrixXdr &LiveKalman::get_fake_gps_pos_cov() { return this->fake_gps_pos_cov; } -MatrixXdr LiveKalman::get_fake_gps_vel_cov() { +const MatrixXdr &LiveKalman::get_fake_gps_vel_cov() { return this->fake_gps_vel_cov; } -MatrixXdr LiveKalman::get_reset_orientation_P() { +const MatrixXdr &LiveKalman::get_reset_orientation_P() { return this->reset_orientation_P; } -MatrixXdr LiveKalman::H(VectorXd in) { +MatrixXdr LiveKalman::H(const VectorXd &in) { assert(in.size() == 6); Matrix res; - this->filter->get_extra_routine("H")(in.data(), res.data()); + this->filter->get_extra_routine("H")((double*)in.data(), res.data()); return res; } diff --git a/selfdrive/locationd/models/live_kf.h b/selfdrive/locationd/models/live_kf.h index c2f3f37eaf..e4b3e326b3 100755 --- a/selfdrive/locationd/models/live_kf.h +++ b/selfdrive/locationd/models/live_kf.h @@ -16,37 +16,37 @@ using namespace EKFS; -Eigen::Map get_mapvec(Eigen::VectorXd& vec); -Eigen::Map get_mapmat(MatrixXdr& mat); -std::vector> get_vec_mapvec(std::vector& vec_vec); -std::vector> get_vec_mapmat(std::vector& mat_vec); +Eigen::Map get_mapvec(const Eigen::VectorXd &vec); +Eigen::Map get_mapmat(const MatrixXdr &mat); +std::vector> get_vec_mapvec(const std::vector &vec_vec); +std::vector> get_vec_mapmat(const std::vector &mat_vec); class LiveKalman { public: LiveKalman(); - void init_state(Eigen::VectorXd& state, Eigen::VectorXd& covs_diag, double filter_time); - void init_state(Eigen::VectorXd& state, MatrixXdr& covs, double filter_time); - void init_state(Eigen::VectorXd& state, double filter_time); + void init_state(const Eigen::VectorXd &state, const Eigen::VectorXd &covs_diag, double filter_time); + void init_state(const Eigen::VectorXd &state, const MatrixXdr &covs, double filter_time); + void init_state(const Eigen::VectorXd &state, double filter_time); Eigen::VectorXd get_x(); MatrixXdr get_P(); double get_filter_time(); std::vector get_R(int kind, int n); - std::optional predict_and_observe(double t, int kind, std::vector meas, std::vector R = {}); + std::optional predict_and_observe(double t, int kind, const std::vector &meas, std::vector R = {}); std::optional predict_and_update_odo_speed(std::vector speed, double t, int kind); std::optional predict_and_update_odo_trans(std::vector trans, double t, int kind); std::optional predict_and_update_odo_rot(std::vector rot, double t, int kind); void predict(double t); - Eigen::VectorXd get_initial_x(); - MatrixXdr get_initial_P(); - MatrixXdr get_fake_gps_pos_cov(); - MatrixXdr get_fake_gps_vel_cov(); - MatrixXdr get_reset_orientation_P(); + const Eigen::VectorXd &get_initial_x(); + const MatrixXdr &get_initial_P(); + const MatrixXdr &get_fake_gps_pos_cov(); + const MatrixXdr &get_fake_gps_vel_cov(); + const MatrixXdr &get_reset_orientation_P(); - MatrixXdr H(Eigen::VectorXd in); + MatrixXdr H(const Eigen::VectorXd &in); private: std::string name = "live"; From d54fa5c7f198af93474a73643b9363fc2a2043ba Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 25 Aug 2023 03:56:06 +0800 Subject: [PATCH 139/159] v4l_encoder: fix error handling for poll (#29166) * fix error handling for poll * revert --------- Co-authored-by: Adeeb Shihadeh --- system/loggerd/encoder/v4l_encoder.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/system/loggerd/encoder/v4l_encoder.cc b/system/loggerd/encoder/v4l_encoder.cc index b5329bb8f1..c6ee792265 100644 --- a/system/loggerd/encoder/v4l_encoder.cc +++ b/system/loggerd/encoder/v4l_encoder.cc @@ -86,7 +86,17 @@ void V4LEncoder::dequeue_handler(V4LEncoder *e) { while (!exit) { int rc = poll(&pfd, 1, 1000); - if (!rc) { LOGE("encoder dequeue poll timeout"); continue; } + if (rc < 0) { + if (errno != EINTR) { + // TODO: exit encoder? + // ignore the error and keep going + LOGE("poll failed (%d - %d)", rc, errno); + } + continue; + } else if (rc == 0) { + LOGE("encoder dequeue poll timeout"); + continue; + } if (env_debug_encoder >= 2) { printf("%20s poll %x at %.2f ms\n", e->encoder_info.filename, pfd.revents, millis_since_boot()); From 54e98fa888c9e28eb93513bada8371a63a54bb55 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 14:33:11 -0700 Subject: [PATCH 140/159] C++ FirstOrderFilter: add initialized flag (#29602) add initialized flag with default to not change behavior --- common/util.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/util.h b/common/util.h index d6ab698245..30f514f8dc 100644 --- a/common/util.h +++ b/common/util.h @@ -153,12 +153,18 @@ struct unique_fd { class FirstOrderFilter { public: - FirstOrderFilter(float x0, float ts, float dt) { + FirstOrderFilter(float x0, float ts, float dt, bool initialized = true) { k_ = (dt / ts) / (1.0 + dt / ts); x_ = x0; + initialized_ = initialized; } inline float update(float x) { - x_ = (1. - k_) * x_ + k_ * x; + if (initialized_) { + x_ = (1. - k_) * x_ + k_ * x; + } else { + initialized_ = true; + x_ = x; + } return x_; } inline void reset(float x) { x_ = x; } @@ -166,6 +172,7 @@ public: private: float x_, k_; + bool initialized_; }; template From a184d40b7aebbebd91000a199d90299457378381 Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Thu, 24 Aug 2023 14:33:48 -0700 Subject: [PATCH 141/159] Disable error message in thneed ioctl interceptor to fix pyenv issues --- selfdrive/modeld/thneed/thneed_qcom2.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/modeld/thneed/thneed_qcom2.cc b/selfdrive/modeld/thneed/thneed_qcom2.cc index a3bfb8a8c2..21de15d17c 100644 --- a/selfdrive/modeld/thneed/thneed_qcom2.cc +++ b/selfdrive/modeld/thneed/thneed_qcom2.cc @@ -107,7 +107,8 @@ int ioctl(int filedes, unsigned long request, void *argp) { } int ret = my_ioctl(filedes, request, argp); - if (ret != 0) printf("ioctl returned %d with errno %d\n", ret, errno); + // NOTE: This error message goes into stdout and messes up pyenv + // if (ret != 0) printf("ioctl returned %d with errno %d\n", ret, errno); return ret; } From fc8c97e7a9595e489f3f466cfc6c0097b9b8217c Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Thu, 24 Aug 2023 14:40:35 -0700 Subject: [PATCH 142/159] Some cleanup in modeld sconscript --- selfdrive/modeld/SConscript | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index a3a1b94e01..c523dddfb8 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -6,15 +6,6 @@ lenv = env.Clone() libs = [cereal, messaging, common, visionipc, gpucommon, 'OpenCL', 'SNPE', 'capnp', 'zmq', 'kj', 'yuv'] -def get_dlsym_offset(): - """Returns the offset between dlopen and dlsym in libdl.so""" - import ctypes - libdl = ctypes.PyDLL('libdl.so') - dlopen = ctypes.cast(libdl.dlopen, ctypes.c_void_p).value - dlsym = ctypes.cast(libdl.dlsym, ctypes.c_void_p).value - return dlsym - dlopen - - common_src = [ "models/commonmodel.cc", "runners/snpemodel.cc", @@ -36,9 +27,7 @@ if arch == "larch64": if use_thneed: common_src += thneed_src - dlsym_offset = get_dlsym_offset() lenv['CXXFLAGS'].append("-DUSE_THNEED") - lenv['CXXFLAGS'].append(f"-DDLSYM_OFFSET={dlsym_offset}") else: libs += ['pthread'] @@ -60,12 +49,9 @@ else: del libs[libs.index('SNPE')] del common_src[common_src.index('runners/snpemodel.cc')] -onnxrunner_path = File("runners/onnx_runner.py").abspath -transform_path = File("transforms/transform.cl").abspath -loadyuv_path = File("transforms/loadyuv.cl").abspath -lenv['CXXFLAGS'].append(f'-DTRANSFORM_PATH=\\"{transform_path}\\"') -lenv['CXXFLAGS'].append(f'-DLOADYUV_PATH=\\"{loadyuv_path}\\"') -lenv['CXXFLAGS'].append(f'-DONNXRUNNER_PATH=\\"{onnxrunner_path}\\"') +for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transforms/loadyuv.cl', 'ONNXRUNNER': 'runners/onnx_runner.py'}.items(): + path = File(fn).abspath + lenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{path}\\"') common_model = lenv.Object(common_src) @@ -74,8 +60,13 @@ lenv.Program('_dmonitoringmodeld', [ "models/dmonitoring.cc", ]+common_model, LIBS=libs) +lenv.Program('_navmodeld', [ + "navmodeld.cc", + "models/nav.cc", + ]+common_model, LIBS=libs) + # build thneed model -if use_thneed and arch == "larch64" or GetOption('pc_thneed'): +if (use_thneed and arch == "larch64") or GetOption('pc_thneed'): fn = File("models/supercombo").abspath tinygrad_opts = ["NATIVE_EXPLOG=1", "VALIDHACKS=1", "OPTLOCAL=1", "IMAGE=2", "GPU=1", "ENABLE_METHOD_CACHE=1"] @@ -104,8 +95,3 @@ llenv.Program('_modeld', [ "modeld.cc", "models/driving.cc", ]+common_model, LIBS=libs + transformations) - -lenv.Program('_navmodeld', [ - "navmodeld.cc", - "models/nav.cc", - ]+common_model, LIBS=libs + transformations) From b9d77afd7e91d46916b471bdc067f83edb2d64de Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 14:53:47 -0700 Subject: [PATCH 143/159] ui/map: initialize speed filter with current speed (#29605) fix map starting from 0 zoom --- selfdrive/ui/qt/maps/map.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 38bcc1a54e..162fc799ad 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -18,7 +18,7 @@ const float MAX_PITCH = 50; const float MIN_PITCH = 0; const float MAP_SCALE = 2; -MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings), velocity_filter(0, 10, 0.05) { +MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings), velocity_filter(0, 10, 0.05, false) { QObject::connect(uiState(), &UIState::uiUpdate, this, &MapWindow::updateState); map_overlay = new QWidget (this); From 4917e22615adbfcc9b3c3ec89b00d240e0b48883 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 24 Aug 2023 14:58:30 -0700 Subject: [PATCH 144/159] Minimal build (#29600) * add build flag for minimum build * add minimal build * update * fix pj * bump opendbc * update subaru --- .github/workflows/selfdrive_tests.yaml | 4 +++- .github/workflows/tools_tests.yaml | 2 +- SConstruct | 12 ++++-------- cereal | 2 +- common/SConscript | 2 +- opendbc | 2 +- panda | 2 +- selfdrive/boardd/SConscript | 2 +- selfdrive/car/subaru/subarucan.py | 2 +- selfdrive/manager/build.py | 2 +- selfdrive/ui/SConscript | 11 +++++------ system/camerad/SConscript | 2 +- system/loggerd/SConscript | 2 +- system/proclogd/SConscript | 2 +- system/ubloxd/SConscript | 2 +- tools/cabana/SConscript | 2 +- tools/replay/SConscript | 2 +- 17 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index e3f060b0dd..61d1602a4c 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -79,7 +79,9 @@ jobs: - uses: ./.github/workflows/setup - name: Build openpilot with all flags timeout-minutes: ${{ ((steps.restore-scons-cache.outputs.cache-hit == 'true') && 12 || 30) }} # allow more time when we missed the scons cache - run: ${{ env.RUN }} "scons -j$(nproc) --extras && release/check-dirty.sh" + run: | + ${{ env.RUN }} "scons -j$(nproc)" + ${{ env.RUN }} "release/check-dirty.sh" - name: Cleanup scons cache and rebuild timeout-minutes: ${{ ((steps.restore-scons-cache.outputs.cache-hit == 'true') && 2 || 30) }} # allow more time when we missed the scons cache run: | diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 8209c14126..f1f4868dcb 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -40,7 +40,7 @@ jobs: - name: Unit test timeout-minutes: 2 run: | - ${{ env.RUN }} "scons -j$(nproc) --directory=/tmp/openpilot/cereal && \ + ${{ env.RUN }} "scons -j$(nproc) --directory=/tmp/openpilot cereal && \ apt-get update && \ apt-get install -y libdw-dev libqt5svg5-dev libqt5x11extras5-dev && \ cd /tmp/openpilot/tools/plotjuggler && \ diff --git a/SConstruct b/SConstruct index 0f720fcba7..8d98eeae39 100644 --- a/SConstruct +++ b/SConstruct @@ -14,10 +14,6 @@ AGNOS = TICI Decider('MD5-timestamp') -AddOption('--extras', - action='store_true', - help='build misc extras, like setup and installer files') - AddOption('--kaitai', action='store_true', help='Regenerate kaitai struct parsers') @@ -58,11 +54,11 @@ AddOption('--pc-thneed', dest='pc_thneed', help='use thneed on pc') -AddOption('--no-test', +AddOption('--minimal', action='store_false', - dest='test', + dest='extras', default=os.path.islink(Dir('#laika/').abspath), - help='skip building test files') + help='the minimum build to run openpilot. no tests, tools, etc.') ## Architecture name breakdown (arch) ## - larch64: linux tici aarch64 @@ -436,7 +432,7 @@ SConscript(['selfdrive/navd/SConscript']) SConscript(['selfdrive/modeld/SConscript']) SConscript(['selfdrive/ui/SConscript']) -if (arch in ['x86_64', 'aarch64', 'Darwin'] and Dir('#tools/cabana/').exists()) or GetOption('extras'): +if arch in ['x86_64', 'aarch64', 'Darwin'] and Dir('#tools/cabana/').exists() and GetOption('extras'): SConscript(['tools/replay/SConscript']) SConscript(['tools/cabana/SConscript']) diff --git a/cereal b/cereal index eb1b2ce255..82bca3a971 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit eb1b2ce255371d7529e1b4341600ecca5052e1f4 +Subproject commit 82bca3a9714b73c05414fdf848b6016a0ffac17d diff --git a/common/SConscript b/common/SConscript index bece09947a..2f2b919154 100644 --- a/common/SConscript +++ b/common/SConscript @@ -27,7 +27,7 @@ files = [ _gpucommon = fxn('gpucommon', files) Export('_common', '_gpucommon') -if GetOption('test'): +if GetOption('extras'): env.Program('tests/test_util', ['tests/test_util.cc'], LIBS=[_common]) env.Program('tests/test_swaglog', ['tests/test_swaglog.cc'], LIBS=[_common, 'json11', 'zmq', 'pthread']) env.Program('tests/test_ratekeeper', ['tests/test_ratekeeper.cc'], LIBS=[_common, 'json11', 'zmq', 'pthread']) diff --git a/opendbc b/opendbc index a1582f5e28..a30a6775a5 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit a1582f5e28fe0df23b6821c907188be477aac11c +Subproject commit a30a6775a5013bd42626ae7e36a1d21c9082a333 diff --git a/panda b/panda index 57ec466a91..0587f22bf3 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 57ec466a91d1e2d51b43d54417091a50f0c9dc78 +Subproject commit 0587f22bf359c77296f9b03bef6c3bbcbc820f87 diff --git a/selfdrive/boardd/SConscript b/selfdrive/boardd/SConscript index 2fe4591484..666763d9b0 100644 --- a/selfdrive/boardd/SConscript +++ b/selfdrive/boardd/SConscript @@ -7,5 +7,5 @@ env.Program('boardd', ['main.cc', 'boardd.cc'], LIBS=[panda] + libs) env.Library('libcan_list_to_can_capnp', ['can_list_to_can_capnp.cc']) envCython.Program('boardd_api_impl.so', 'boardd_api_impl.pyx', LIBS=["can_list_to_can_capnp", 'capnp', 'kj'] + envCython["LIBS"]) -if GetOption('test'): +if GetOption('extras'): env.Program('tests/test_boardd_usbprotocol', ['tests/test_boardd_usbprotocol.cc'], LIBS=[panda] + libs) diff --git a/selfdrive/car/subaru/subarucan.py b/selfdrive/car/subaru/subarucan.py index 890473a243..4ae5023281 100644 --- a/selfdrive/car/subaru/subarucan.py +++ b/selfdrive/car/subaru/subarucan.py @@ -25,7 +25,7 @@ def create_es_distance(packer, es_distance_msg, bus, pcm_cancel_cmd, long_enable "Cruise_Throttle", "Signal2", "Car_Follow", - "Signal3", + "Low_Speed_Follow", "Cruise_Soft_Disable", "Signal7", "Cruise_Brake_Active", diff --git a/selfdrive/manager/build.py b/selfdrive/manager/build.py index 96501051a8..be37b3e7e4 100755 --- a/selfdrive/manager/build.py +++ b/selfdrive/manager/build.py @@ -31,7 +31,7 @@ def build(spinner: Spinner, dirty: bool = False) -> None: compile_output: List[bytes] = [] for n in (nproc, nproc/2, 1): compile_output.clear() - scons: subprocess.Popen = subprocess.Popen(["scons", f"-j{int(n)}", "--cache-populate"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) + scons: subprocess.Popen = subprocess.Popen(["scons", f"-j{int(n)}", "--cache-populate", "--minimal"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) assert scons.stderr is not None # Read progress from stderr and update spinner diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 7e90423fc2..6d5a502e05 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -46,7 +46,7 @@ asset_obj = qt_env.Object("assets", assets) # build soundd qt_env.Program("soundd/_soundd", ["soundd/main.cc", "soundd/sound.cc"], LIBS=qt_libs) -if GetOption('test'): +if GetOption('extras'): qt_env.Program("tests/playsound", "tests/playsound.cc", LIBS=base_libs) qt_env.Program('tests/test_sound', ['tests/test_runner.cc', 'soundd/sound.cc', 'tests/test_sound.cc'], LIBS=qt_libs) @@ -62,7 +62,7 @@ qt_src = ["main.cc", "qt/sidebar.cc", "qt/onroad.cc", "qt/body.cc", "qt/offroad/software_settings.cc", "qt/offroad/onboarding.cc", "qt/offroad/driverview.cc", "qt/offroad/experimental_mode.cc"] qt_env.Program("_ui", qt_src + [asset_obj], LIBS=qt_libs) -if GetOption('test'): +if GetOption('extras'): qt_src.remove("main.cc") # replaced by test_runner qt_env.Program('tests/test_translations', [asset_obj, 'tests/test_runner.cc', 'tests/test_translations.cc'] + qt_src, LIBS=qt_libs) qt_env.Program('tests/ui_snapshot', [asset_obj, "tests/ui_snapshot.cc"] + qt_src, LIBS=qt_libs) @@ -82,14 +82,13 @@ qt_env.NoClean(translation_sources) qt_env.Precious(translation_sources) qt_env.NoCache(lupdate) -# setup and factory resetter -if GetOption('extras'): + +if GetOption('extras') and arch != "Darwin": + # setup and factory resetter qt_env.Program("qt/setup/reset", ["qt/setup/reset.cc"], LIBS=qt_libs) qt_env.Program("qt/setup/setup", ["qt/setup/setup.cc", asset_obj], LIBS=qt_libs + ['curl', 'common', 'json11']) - -if GetOption('extras'): # build updater UI qt_env.Program("qt/setup/updater", ["qt/setup/updater.cc", asset_obj], LIBS=qt_libs) diff --git a/system/camerad/SConscript b/system/camerad/SConscript index 3ecc3f6d72..ffd7278bbb 100644 --- a/system/camerad/SConscript +++ b/system/camerad/SConscript @@ -8,7 +8,7 @@ env.Program('camerad', [ camera_obj, ], LIBS=libs) -if GetOption("test") and arch == "x86_64": +if GetOption("extras") and arch == "x86_64": env.Program('test/ae_gray_test', ['test/ae_gray_test.cc', camera_obj], LIBS=libs) diff --git a/system/loggerd/SConscript b/system/loggerd/SConscript index 3b961bce6e..d4f52fb5f1 100644 --- a/system/loggerd/SConscript +++ b/system/loggerd/SConscript @@ -23,5 +23,5 @@ env.Program('loggerd', ['loggerd.cc'], LIBS=libs) env.Program('encoderd', ['encoderd.cc'], LIBS=libs) env.Program('bootlog.cc', LIBS=libs) -if GetOption('test'): +if GetOption('extras'): env.Program('tests/test_logger', ['tests/test_runner.cc', 'tests/test_logger.cc'], LIBS=libs + ['curl', 'crypto']) diff --git a/system/proclogd/SConscript b/system/proclogd/SConscript index 1b94a32f1b..1f4b767011 100644 --- a/system/proclogd/SConscript +++ b/system/proclogd/SConscript @@ -2,5 +2,5 @@ Import('env', 'cereal', 'messaging', 'common') libs = [cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj', 'common', 'zmq', 'json11'] env.Program('proclogd', ['main.cc', 'proclog.cc'], LIBS=libs) -if GetOption('test'): +if GetOption('extras'): env.Program('tests/test_proclog', ['tests/test_proclog.cc', 'proclog.cc'], LIBS=libs) diff --git a/system/ubloxd/SConscript b/system/ubloxd/SConscript index fff0986efd..67d9856dad 100644 --- a/system/ubloxd/SConscript +++ b/system/ubloxd/SConscript @@ -16,5 +16,5 @@ if GetOption('kaitai'): glonass_obj = env.Object('generated/glonass.cpp') env.Program("ubloxd", ["ubloxd.cc", "ublox_msg.cc", "generated/ubx.cpp", "generated/gps.cpp", glonass_obj], LIBS=loc_libs) -if GetOption('test'): +if GetOption('extras'): env.Program("tests/test_glonass_runner", ['tests/test_glonass_runner.cc', 'tests/test_glonass_kaitai.cc', glonass_obj], LIBS=[loc_libs]) \ No newline at end of file diff --git a/tools/cabana/SConscript b/tools/cabana/SConscript index a713b612fc..be1f613e22 100644 --- a/tools/cabana/SConscript +++ b/tools/cabana/SConscript @@ -35,7 +35,7 @@ cabana_lib = cabana_env.Library("cabana_lib", ['mainwin.cc', 'streams/socketcans 'commands.cc', 'messageswidget.cc', 'streamselector.cc', 'settings.cc', 'util.cc', 'detailwidget.cc', 'tools/findsimilarbits.cc', 'tools/findsignal.cc'], LIBS=cabana_libs, FRAMEWORKS=base_frameworks) cabana_env.Program('cabana', ['cabana.cc', cabana_lib, assets], LIBS=cabana_libs, FRAMEWORKS=base_frameworks) -if GetOption('test'): +if GetOption('extras'): cabana_env.Program('tests/test_cabana', ['tests/test_runner.cc', 'tests/test_cabana.cc', cabana_lib], LIBS=[cabana_libs]) generate_dbc = cabana_env.Command('generate_dbc_json', diff --git a/tools/replay/SConscript b/tools/replay/SConscript index 3abed43dde..bce7512e44 100644 --- a/tools/replay/SConscript +++ b/tools/replay/SConscript @@ -21,5 +21,5 @@ Export('replay_lib') replay_libs = [replay_lib, 'avutil', 'avcodec', 'avformat', 'bz2', 'curl', 'yuv', 'ncurses'] + qt_libs qt_env.Program("replay", ["main.cc"], LIBS=replay_libs, FRAMEWORKS=base_frameworks) -if GetOption('test'): +if GetOption('extras'): qt_env.Program('tests/test_replay', ['tests/test_runner.cc', 'tests/test_replay.cc'], LIBS=[replay_libs, qt_libs]) From e7418cfa397ec2185e4b12baaa481017b7b23322 Mon Sep 17 00:00:00 2001 From: Bruce Wayne Date: Thu, 24 Aug 2023 15:04:47 -0700 Subject: [PATCH 145/159] KF1D: add steady state kalman code --- common/kalman/simple_kalman.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/kalman/simple_kalman.py b/common/kalman/simple_kalman.py index 31ad76c5b2..669da3919a 100644 --- a/common/kalman/simple_kalman.py +++ b/common/kalman/simple_kalman.py @@ -1,3 +1,13 @@ # pylint: skip-file from openpilot.common.kalman.simple_kalman_impl import KF1D as KF1D assert KF1D +import numpy as np + +def get_kalman_gain(dt, A, C, Q, R, iterations=100): + P = np.zeros_like(Q) + for _ in range(iterations): + P = A.dot(P).dot(A.T) + dt * Q + S = C.dot(P).dot(C.T) + R + K = P.dot(C.T).dot(np.linalg.inv(S)) + P = (np.eye(len(P)) - K.dot(C)).dot(P) + return K \ No newline at end of file From b8fb26055825f4ee35f647b6d84c2e6e6878a93f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 15:09:30 -0700 Subject: [PATCH 146/159] ui/map: clip vehicle speed to min of 10 m/s (#29601) * all the changes I want to make * Revert "all the changes I want to make" This reverts commit c18132b73eb9bba4d7871631d7cd4155eb7efcd0. * add initialized * clip to 10 m/s * fix bug * rm * here? --- selfdrive/ui/qt/maps/map.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 162fc799ad..d5e81bc9e0 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -1,5 +1,6 @@ #include "selfdrive/ui/qt/maps/map.h" +#include #include #include @@ -151,7 +152,7 @@ void MapWindow::updateState(const UIState &s) { if (locationd_valid) { last_position = QMapbox::Coordinate(locationd_pos.getValue()[0], locationd_pos.getValue()[1]); last_bearing = RAD2DEG(locationd_orientation.getValue()[2]); - velocity_filter.update(locationd_velocity.getValue()[0]); + velocity_filter.update(std::max(10.0, locationd_velocity.getValue()[0])); } } From 7dae580441ddad32bab13bea9b2fd87edbe5d887 Mon Sep 17 00:00:00 2001 From: mitchellgoffpc Date: Thu, 24 Aug 2023 15:11:11 -0700 Subject: [PATCH 147/159] Moved thneed src to top of modeld sconscript --- selfdrive/modeld/SConscript | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index c523dddfb8..863626967b 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -13,20 +13,23 @@ common_src = [ "transforms/transform.cc" ] -thneed_src = [ +thneed_src_common = [ "thneed/thneed_common.cc", - "thneed/thneed_qcom2.cc", "thneed/serialize.cc", "runners/thneedmodel.cc", ] +thneed_src_qcom = thneed_src_common + ["thneed/thneed_qcom2.cc"] +thneed_src_pc = thneed_src_common + ["thneed/thneed_pc.cc"] +thneed_src = thneed_src_qcom if arch == "larch64" else thneed_src_pc + use_thneed = not GetOption('no_thneed') if arch == "larch64": libs += ['gsl', 'CB', 'pthread', 'dl'] if use_thneed: - common_src += thneed_src + common_src += thneed_src_qcom lenv['CXXFLAGS'].append("-DUSE_THNEED") else: libs += ['pthread'] @@ -80,15 +83,9 @@ if (use_thneed and arch == "larch64") or GetOption('pc_thneed'): llenv = lenv.Clone() if GetOption('pc_thneed'): - pc_thneed_src = [ - "thneed/thneed_common.cc", - "thneed/thneed_pc.cc", - "thneed/serialize.cc", - "runners/thneedmodel.cc", - ] llenv['CFLAGS'].append("-DUSE_THNEED") llenv['CXXFLAGS'].append("-DUSE_THNEED") - common_model += llenv.Object(pc_thneed_src) + common_model += llenv.Object(thneed_src_pc) libs += ['dl'] llenv.Program('_modeld', [ From 3d9f238bf9a1f27c5a9a44df1b0f116182829be0 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 24 Aug 2023 16:09:08 -0700 Subject: [PATCH 148/159] CI: use scripts for docker build (#29599) * use scripts * remove common * do login in the workflow * separate step * cleanup * one script is cleaner * keep it consistent * review suggestions * move in ci too * PR cleanup --- .github/workflows/prebuilt.yaml | 18 +++-------- .github/workflows/selfdrive_tests.yaml | 25 +++++----------- .github/workflows/tools_tests.yaml | 34 ++++++++++----------- selfdrive/test/docker_build.sh | 41 ++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 51 deletions(-) create mode 100755 selfdrive/test/docker_build.sh diff --git a/.github/workflows/prebuilt.yaml b/.github/workflows/prebuilt.yaml index 3b88011f5e..8b16ea90b9 100644 --- a/.github/workflows/prebuilt.yaml +++ b/.github/workflows/prebuilt.yaml @@ -5,12 +5,8 @@ on: workflow_dispatch: env: - BASE_IMAGE: openpilot-base - DOCKER_REGISTRY: ghcr.io/commaai - DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} - BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . + BUILD: selfdrive/test/docker_build.sh prebuilt jobs: build_prebuilt: @@ -18,7 +14,7 @@ jobs: runs-on: ubuntu-20.04 if: github.repository == 'commaai/openpilot' env: - IMAGE_NAME: openpilot-prebuilt + PUSH_IMAGE: true steps: - name: Wait for green check mark if: ${{ github.event_name != 'workflow_dispatch' }} @@ -31,13 +27,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - name: Build Docker image - run: | - eval "$BUILD" - DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f Dockerfile.openpilot . - - name: Push to container registry + - name: Build and Push docker image run: | $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest - docker tag $DOCKER_REGISTRY/$IMAGE_NAME:latest $DOCKER_REGISTRY/$IMAGE_NAME:$GITHUB_SHA - docker push $DOCKER_REGISTRY/$IMAGE_NAME:$GITHUB_SHA + eval "$BUILD" diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 61d1602a4c..64c96280f8 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -12,20 +12,17 @@ concurrency: env: PYTHONWARNINGS: error - BASE_IMAGE: openpilot-base CL_BASE_IMAGE: openpilot-base-cl - DOCKER_REGISTRY: ghcr.io/commaai AZURE_TOKEN: ${{ secrets.AZURE_COMMADATACI_OPENPILOTCI_TOKEN }} DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} - BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . + BUILD: selfdrive/test/docker_build.sh base RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c - BUILD_CL: | - DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $CL_BASE_IMAGE:latest -f Dockerfile.openpilot_base_cl . + BUILD_CL: selfdrive/test/docker_build.sh cl + RUN_CL: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c UNIT_TEST: coverage run --append -m unittest discover @@ -190,6 +187,8 @@ jobs: name: docker push runs-on: ubuntu-20.04 if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' + env: + PUSH_IMAGE: true steps: - uses: actions/checkout@v3 with: @@ -197,20 +196,10 @@ jobs: - uses: ./.github/workflows/setup with: git-lfs: false - - name: Push to container registry - run: | - $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/$BASE_IMAGE:latest - docker tag $DOCKER_REGISTRY/$BASE_IMAGE:latest $DOCKER_REGISTRY/$BASE_IMAGE:$GITHUB_SHA - docker push $DOCKER_REGISTRY/$BASE_IMAGE:$GITHUB_SHA - - name: Build CL Docker image - run: eval "$BUILD_CL" - - name: Push to container registry + - name: Build and push CL Docker image run: | $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest - docker tag $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest $DOCKER_REGISTRY/$CL_BASE_IMAGE:$GITHUB_SHA - docker push $DOCKER_REGISTRY/$CL_BASE_IMAGE:$GITHUB_SHA + eval "$BUILD_CL" static_analysis: name: static analysis diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index f1f4868dcb..470c7662a4 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -13,16 +13,14 @@ concurrency: env: BASE_IMAGE: openpilot-base CL_BASE_IMAGE: openpilot-base-cl - DOCKER_REGISTRY: ghcr.io/commaai DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} - BUILD: | - DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base . + BUILD: selfdrive/test/docker_build.sh base RUN: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c - BUILD_CL: | - DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $DOCKER_REGISTRY/$CL_BASE_IMAGE:latest -t $CL_BASE_IMAGE:latest -f Dockerfile.openpilot_base_cl . + BUILD_CL: selfdrive/test/docker_build.sh cl + RUN_CL: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c @@ -49,8 +47,6 @@ jobs: simulator: name: simulator runs-on: ubuntu-20.04 - env: - IMAGE_NAME: openpilot-sim if: github.repository == 'commaai/openpilot' timeout-minutes: 45 steps: @@ -62,14 +58,14 @@ jobs: setup_docker_scons_cache: true - name: Build base cl image run: eval "$BUILD_CL" - - name: Build simulator image - run: | - DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f tools/sim/Dockerfile.sim . - - name: Push to container registry + - name: Setup to push to repo if: github.ref == 'refs/heads/master' && github.repository == 'commaai/openpilot' - run: | + run: + export PUSH_IMAGE=true $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest + - name: Build and push sim image + run: | + selfdrive/test/docker_build.sh sim docs: name: build docs @@ -83,14 +79,14 @@ jobs: with: setup_docker_scons_cache: true git_lfs: false - - name: Build docs image - run: | - DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile . - - name: Push docker container + - name: Setup to push to repo if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' - run: | + run: + export PUSH_IMAGE=true $DOCKER_LOGIN - docker push $DOCKER_REGISTRY/openpilot-docs:latest + - name: Build and push docs image + run: | + selfdrive/test/docker_build.sh docs devcontainer: name: devcontainer diff --git a/selfdrive/test/docker_build.sh b/selfdrive/test/docker_build.sh new file mode 100755 index 0000000000..b18c48123a --- /dev/null +++ b/selfdrive/test/docker_build.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +if [ $1 = "base" ]; then + export DOCKER_IMAGE=openpilot-base + export DOCKER_FILE=Dockerfile.openpilot_base +elif [ $1 = "docs" ]; then + export DOCKER_IMAGE=openpilot-docs + export DOCKER_FILE=docs/docker/Dockerfile +elif [ $1 = "sim" ]; then + export DOCKER_IMAGE=openpilot-sim + export DOCKER_FILE=tools/sim/Dockerfile.sim +elif [ $1 = "prebuilt" ]; then + export DOCKER_IMAGE=openpilot-prebuilt + export DOCKER_FILE=Dockerfile.openpilot +elif [ $1 = "cl" ]; then + export DOCKER_IMAGE=openpilot-base-cl + export DOCKER_FILE=Dockerfile.openpilot_base_cl +else + echo "Invalid docker build image $1" + exit 1 +fi + +export DOCKER_REGISTRY=ghcr.io/commaai +export COMMIT_SHA=$(git rev-parse HEAD) + +LOCAL_TAG=$DOCKER_IMAGE +REMOTE_TAG=$DOCKER_REGISTRY/$LOCAL_TAG +REMOTE_SHA_TAG=$REMOTE_TAG:$COMMIT_SHA + +SCRIPT_DIR=$(dirname "$0") +OPENPILOT_DIR=$SCRIPT_DIR/../../ + +DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from type=registry,ref=$REMOTE_TAG -t $REMOTE_TAG -t $LOCAL_TAG -f $OPENPILOT_DIR/$DOCKER_FILE $OPENPILOT_DIR + +if [[ ! -z "$PUSH_IMAGE" ]]; +then + docker push $REMOTE_TAG + docker tag $REMOTE_TAG $REMOTE_SHA_TAG + docker push $REMOTE_SHA_TAG +fi \ No newline at end of file From ede9f2cda5500d9e094e89a32518c88b56c3335b Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 24 Aug 2023 16:30:33 -0700 Subject: [PATCH 149/159] CI: fix docker push (#29614) * fix those * fix docker push too * dont need that twice --- .github/workflows/selfdrive_tests.yaml | 7 ++++--- .github/workflows/tools_tests.yaml | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 64c96280f8..0f68f425b6 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -187,18 +187,19 @@ jobs: name: docker push runs-on: ubuntu-20.04 if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' - env: - PUSH_IMAGE: true steps: - uses: actions/checkout@v3 with: submodules: true + - name: Setup to push to repo + run: | + export PUSH_IMAGE=true + $DOCKER_LOGIN - uses: ./.github/workflows/setup with: git-lfs: false - name: Build and push CL Docker image run: | - $DOCKER_LOGIN eval "$BUILD_CL" static_analysis: diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 470c7662a4..7a7acb1c87 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -60,7 +60,7 @@ jobs: run: eval "$BUILD_CL" - name: Setup to push to repo if: github.ref == 'refs/heads/master' && github.repository == 'commaai/openpilot' - run: + run: | export PUSH_IMAGE=true $DOCKER_LOGIN - name: Build and push sim image @@ -81,7 +81,7 @@ jobs: git_lfs: false - name: Setup to push to repo if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' - run: + run: | export PUSH_IMAGE=true $DOCKER_LOGIN - name: Build and push docs image From 1ee6ed4b16e2ade0dd887c0687243aee769043e5 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 24 Aug 2023 16:30:54 -0700 Subject: [PATCH 150/159] Linter: remove pylint (#29611) remove pylint --- common/kalman/simple_kalman.py | 1 - common/logging_extra.py | 2 +- common/params.py | 2 +- common/realtime.py | 4 ++-- common/transformations/coordinates.py | 1 - common/transformations/orientation.py | 1 - common/window.py | 4 ++-- docs/conf.py | 1 - scripts/pyqt_demo.py | 2 +- selfdrive/boardd/boardd.py | 2 -- selfdrive/car/tests/test_models.py | 1 - selfdrive/controls/tests/test_cruise_speed.py | 2 +- selfdrive/controls/tests/test_startup.py | 2 +- selfdrive/debug/toyota_eps_factor.py | 2 +- selfdrive/locationd/models/car_kf.py | 4 ++-- selfdrive/locationd/models/gnss_kf.py | 4 ++-- selfdrive/manager/process.py | 6 +++--- selfdrive/modeld/tests/tf_test/pb_loader.py | 2 +- selfdrive/modeld/tests/timing/benchmark.py | 1 - selfdrive/monitoring/test_monitoring.py | 1 - selfdrive/test/ciui.py | 4 ++-- selfdrive/test/openpilotci.py | 4 ++-- selfdrive/test/profiling/lib.py | 4 ++-- selfdrive/test/profiling/profiler.py | 2 +- selfdrive/test/test_valgrind_replay.py | 2 +- selfdrive/test/update_ci_routes.py | 6 +++--- selfdrive/thermald/thermald.py | 4 ++-- selfdrive/tombstoned.py | 4 ++-- selfdrive/ui/qt/python_helpers.py | 2 +- system/hardware/tici/hardware.py | 2 +- system/micd.py | 2 +- system/ubloxd/tests/ublox.py | 1 - system/ubloxd/tests/ubloxd.py | 1 - tools/bodyteleop/bodyav.py | 4 ++-- tools/camerastream/compressed_vipc.py | 2 +- tools/gpstest/fuzzy_testing.py | 2 +- tools/gpstest/rpc_server.py | 4 ++-- tools/lib/auth.py | 2 +- tools/lib/framereader.py | 1 - tools/lib/url_file.py | 2 -- tools/replay/lib/ui_helpers.py | 2 +- tools/replay/ui.py | 4 ++-- tools/replay/unlog_ci_segment.py | 1 - tools/sim/bridge.py | 2 +- tools/sim/lib/can.py | 2 +- tools/sim/lib/manual_ctrl.py | 4 ++-- tools/webcam/front_mount_helper.py | 2 +- tools/webcam/warp_vis.py | 2 +- 48 files changed, 52 insertions(+), 67 deletions(-) diff --git a/common/kalman/simple_kalman.py b/common/kalman/simple_kalman.py index 669da3919a..5e1b6ce1fb 100644 --- a/common/kalman/simple_kalman.py +++ b/common/kalman/simple_kalman.py @@ -1,4 +1,3 @@ -# pylint: skip-file from openpilot.common.kalman.simple_kalman_impl import KF1D as KF1D assert KF1D import numpy as np diff --git a/common/logging_extra.py b/common/logging_extra.py index e2637d2e05..5e0584c7bc 100644 --- a/common/logging_extra.py +++ b/common/logging_extra.py @@ -197,7 +197,7 @@ class SwagLogger(logging.Logger): filename = os.path.normcase(co.co_filename) # TODO: is this pylint exception correct? - if filename == _srcfile: # pylint: disable=comparison-with-callable + if filename == _srcfile: f = f.f_back continue sinfo = None diff --git a/common/params.py b/common/params.py index bc1422dd81..ea8ac7514a 100644 --- a/common/params.py +++ b/common/params.py @@ -1,5 +1,5 @@ from openpilot.common.params_pyx import Params, ParamKeyType, UnknownKeyName, put_nonblocking, \ - put_bool_nonblocking # pylint: disable=no-name-in-module, import-error + put_bool_nonblocking assert Params assert ParamKeyType assert UnknownKeyName diff --git a/common/realtime.py b/common/realtime.py index 7549a7ef52..05e19e770f 100644 --- a/common/realtime.py +++ b/common/realtime.py @@ -30,12 +30,12 @@ class Priority: def set_realtime_priority(level: int) -> None: if not PC: - os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) # pylint: disable=no-member + os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) def set_core_affinity(cores: List[int]) -> None: if not PC: - os.sched_setaffinity(0, cores) # pylint: disable=no-member + os.sched_setaffinity(0, cores) def config_realtime_process(cores: Union[int, List[int]], priority: int) -> None: diff --git a/common/transformations/coordinates.py b/common/transformations/coordinates.py index 7e7b56522a..696e7de2e5 100644 --- a/common/transformations/coordinates.py +++ b/common/transformations/coordinates.py @@ -1,4 +1,3 @@ -# pylint: skip-file from openpilot.common.transformations.orientation import numpy_wrap from openpilot.common.transformations.transformations import (ecef2geodetic_single, geodetic2ecef_single) diff --git a/common/transformations/orientation.py b/common/transformations/orientation.py index 657a86a574..ce4378738d 100644 --- a/common/transformations/orientation.py +++ b/common/transformations/orientation.py @@ -1,4 +1,3 @@ -# pylint: skip-file import numpy as np from typing import Callable diff --git a/common/window.py b/common/window.py index 613b3b201b..95886c0c92 100644 --- a/common/window.py +++ b/common/window.py @@ -1,6 +1,6 @@ import sys -import pygame # pylint: disable=import-error -import cv2 # pylint: disable=import-error +import pygame +import cv2 class Window: def __init__(self, w, h, caption="window", double=False, halve=False): diff --git a/docs/conf.py b/docs/conf.py index a4ed00c919..9a8d646697 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,4 @@ # type: ignore -# pylint: skip-file # Configuration file for the Sphinx documentation builder. # diff --git a/scripts/pyqt_demo.py b/scripts/pyqt_demo.py index b73d7dfad7..783728bdb8 100755 --- a/scripts/pyqt_demo.py +++ b/scripts/pyqt_demo.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from PyQt5.QtWidgets import QApplication, QLabel # pylint: disable=no-name-in-module, import-error +from PyQt5.QtWidgets import QApplication, QLabel from openpilot.selfdrive.ui.qt.python_helpers import set_main_window diff --git a/selfdrive/boardd/boardd.py b/selfdrive/boardd/boardd.py index 702c46565f..0cdaf5e912 100644 --- a/selfdrive/boardd/boardd.py +++ b/selfdrive/boardd/boardd.py @@ -1,5 +1,3 @@ -# pylint: skip-file - # Cython, now uses scons to build from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp assert can_list_to_can_capnp diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py index 0147725291..57b7037530 100755 --- a/selfdrive/car/tests/test_models.py +++ b/selfdrive/car/tests/test_models.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# pylint: disable=E1101 import capnp import os import importlib diff --git a/selfdrive/controls/tests/test_cruise_speed.py b/selfdrive/controls/tests/test_cruise_speed.py index c7221cfcfa..1d43b49ccf 100755 --- a/selfdrive/controls/tests/test_cruise_speed.py +++ b/selfdrive/controls/tests/test_cruise_speed.py @@ -52,7 +52,7 @@ class TestCruiseSpeed(unittest.TestCase): @parameterized_class(('pcm_cruise',), [(False,)]) class TestVCruiseHelper(unittest.TestCase): def setUp(self): - self.CP = car.CarParams(pcmCruise=self.pcm_cruise) # pylint: disable=E1101 + self.CP = car.CarParams(pcmCruise=self.pcm_cruise) self.v_cruise_helper = VCruiseHelper(self.CP) self.reset_cruise_speed_state() diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py index 72a5b4b48f..6eb803e8aa 100755 --- a/selfdrive/controls/tests/test_startup.py +++ b/selfdrive/controls/tests/test_startup.py @@ -6,7 +6,7 @@ from parameterized import parameterized from cereal import log, car import cereal.messaging as messaging from openpilot.common.params import Params -from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error +from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp from openpilot.selfdrive.car.fingerprints import _FINGERPRINTS from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA from openpilot.selfdrive.car.mazda.values import CAR as MAZDA diff --git a/selfdrive/debug/toyota_eps_factor.py b/selfdrive/debug/toyota_eps_factor.py index e1156c05aa..d60d2d372b 100755 --- a/selfdrive/debug/toyota_eps_factor.py +++ b/selfdrive/debug/toyota_eps_factor.py @@ -2,7 +2,7 @@ import sys import numpy as np import matplotlib.pyplot as plt -from sklearn import linear_model # pylint: disable=import-error +from sklearn import linear_model from openpilot.selfdrive.car.toyota.values import STEER_THRESHOLD from openpilot.tools.lib.route import Route diff --git a/selfdrive/locationd/models/car_kf.py b/selfdrive/locationd/models/car_kf.py index 6c02257a1f..b87c83cac2 100755 --- a/selfdrive/locationd/models/car_kf.py +++ b/selfdrive/locationd/models/car_kf.py @@ -15,7 +15,7 @@ if __name__ == '__main__': # Generating sympy import sympy as sp from rednose.helpers.ekf_sym import gen_code else: - from rednose.helpers.ekf_sym_pyx import EKF_sym_pyx # pylint: disable=no-name-in-module, import-error + from rednose.helpers.ekf_sym_pyx import EKF_sym_pyx i = 0 @@ -160,7 +160,7 @@ class CarKalman(KalmanFilter): gen_code(generated_dir, name, f_sym, dt, state_sym, obs_eqs, dim_state, dim_state, global_vars=global_vars) - def __init__(self, generated_dir, steer_ratio=15, stiffness_factor=1, angle_offset=0, P_initial=None): # pylint: disable=super-init-not-called + def __init__(self, generated_dir, steer_ratio=15, stiffness_factor=1, angle_offset=0, P_initial=None): dim_state = self.initial_x.shape[0] dim_state_err = self.P_initial.shape[0] x_init = self.initial_x diff --git a/selfdrive/locationd/models/gnss_kf.py b/selfdrive/locationd/models/gnss_kf.py index f98434c909..c4f3b2e210 100755 --- a/selfdrive/locationd/models/gnss_kf.py +++ b/selfdrive/locationd/models/gnss_kf.py @@ -11,8 +11,8 @@ if __name__ == '__main__': # Generating sympy import sympy as sp from rednose.helpers.ekf_sym import gen_code else: - from rednose.helpers.ekf_sym_pyx import EKF_sym_pyx # pylint: disable=no-name-in-module,import-error - from rednose.helpers.ekf_sym import EKF_sym # pylint: disable=no-name-in-module,import-error + from rednose.helpers.ekf_sym_pyx import EKF_sym_pyx + from rednose.helpers.ekf_sym import EKF_sym class States(): diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index c56ffeab98..82cc8d74a3 100644 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -8,7 +8,7 @@ from typing import Optional, Callable, List, ValuesView from abc import ABC, abstractmethod from multiprocessing import Process -from setproctitle import setproctitle # pylint: disable=no-name-in-module +from setproctitle import setproctitle from cereal import car, log import cereal.messaging as messaging @@ -96,7 +96,7 @@ class ManagerProcess(ABC): fn = WATCHDOG_FN + str(self.proc.pid) with open(fn, "rb") as f: # TODO: why can't pylint find struct.unpack? - self.last_watchdog_time = struct.unpack('Q', f.read())[0] # pylint: disable=no-member + self.last_watchdog_time = struct.unpack('Q', f.read())[0] except Exception: pass @@ -261,7 +261,7 @@ class DaemonProcess(ManagerProcess): pass cloudlog.info(f"starting daemon {self.name}") - proc = subprocess.Popen(['python', '-m', self.module], # pylint: disable=subprocess-popen-preexec-fn + proc = subprocess.Popen(['python', '-m', self.module], stdin=open('/dev/null'), stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'), diff --git a/selfdrive/modeld/tests/tf_test/pb_loader.py b/selfdrive/modeld/tests/tf_test/pb_loader.py index 78fd33aef2..3e476628eb 100755 --- a/selfdrive/modeld/tests/tf_test/pb_loader.py +++ b/selfdrive/modeld/tests/tf_test/pb_loader.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import sys -import tensorflow as tf # pylint: disable=import-error +import tensorflow as tf with open(sys.argv[1], "rb") as f: graph_def = tf.compat.v1.GraphDef() diff --git a/selfdrive/modeld/tests/timing/benchmark.py b/selfdrive/modeld/tests/timing/benchmark.py index 1463342a6a..4ab0afacbc 100755 --- a/selfdrive/modeld/tests/timing/benchmark.py +++ b/selfdrive/modeld/tests/timing/benchmark.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # type: ignore -# pylint: skip-file import os import time diff --git a/selfdrive/monitoring/test_monitoring.py b/selfdrive/monitoring/test_monitoring.py index b1011fb306..c02d44849f 100755 --- a/selfdrive/monitoring/test_monitoring.py +++ b/selfdrive/monitoring/test_monitoring.py @@ -54,7 +54,6 @@ always_false = [False] * int(TEST_TIMESPAN / DT_DMON) # TODO: this only tests DriverStatus class TestMonitoring(unittest.TestCase): - # pylint: disable=no-member def _run_seq(self, msgs, interaction, engaged, standstill): DS = DriverStatus() events = [] diff --git a/selfdrive/test/ciui.py b/selfdrive/test/ciui.py index ba55f3af24..3f33847b29 100755 --- a/selfdrive/test/ciui.py +++ b/selfdrive/test/ciui.py @@ -5,8 +5,8 @@ import subprocess signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) -from PyQt5.QtCore import QTimer # pylint: disable=no-name-in-module, import-error -from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel # pylint: disable=no-name-in-module, import-error +from PyQt5.QtCore import QTimer +from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel from openpilot.selfdrive.ui.qt.python_helpers import set_main_window class Window(QWidget): diff --git a/selfdrive/test/openpilotci.py b/selfdrive/test/openpilotci.py index 3a7868aaa6..fe1a0b0335 100755 --- a/selfdrive/test/openpilotci.py +++ b/selfdrive/test/openpilotci.py @@ -24,13 +24,13 @@ def get_sas_token(): return sas_token def upload_bytes(data, name): - from azure.storage.blob import BlockBlobService # pylint: disable=import-error + from azure.storage.blob import BlockBlobService service = BlockBlobService(account_name="commadataci", sas_token=get_sas_token()) service.create_blob_from_bytes("openpilotci", name, data) return BASE_URL + name def upload_file(path, name): - from azure.storage.blob import BlockBlobService # pylint: disable=import-error + from azure.storage.blob import BlockBlobService service = BlockBlobService(account_name="commadataci", sas_token=get_sas_token()) service.create_blob_from_path("openpilotci", name, path) return BASE_URL + name diff --git a/selfdrive/test/profiling/lib.py b/selfdrive/test/profiling/lib.py index f28346f3f0..843bf52211 100644 --- a/selfdrive/test/profiling/lib.py +++ b/selfdrive/test/profiling/lib.py @@ -34,7 +34,7 @@ class PubSocket(): class SubMaster(messaging.SubMaster): - def __init__(self, msgs, trigger, services, check_averag_freq=False): # pylint: disable=super-init-not-called + def __init__(self, msgs, trigger, services, check_averag_freq=False): self.frame = 0 self.data = {} self.ignore_alive = [] @@ -87,5 +87,5 @@ class SubMaster(messaging.SubMaster): class PubMaster(messaging.PubMaster): - def __init__(self): # pylint: disable=super-init-not-called + def __init__(self): self.sock = defaultdict(PubSocket) diff --git a/selfdrive/test/profiling/profiler.py b/selfdrive/test/profiling/profiler.py index 984907b870..1d380ba5eb 100755 --- a/selfdrive/test/profiling/profiler.py +++ b/selfdrive/test/profiling/profiler.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import os import sys -import cProfile # pylint: disable=import-error +import cProfile import pprofile import pyprof2calltree diff --git a/selfdrive/test/test_valgrind_replay.py b/selfdrive/test/test_valgrind_replay.py index dbcf3b18d4..a8a3463104 100755 --- a/selfdrive/test/test_valgrind_replay.py +++ b/selfdrive/test/test_valgrind_replay.py @@ -53,7 +53,7 @@ class TestValgrind(unittest.TestCase): os.chdir(os.path.join(BASEDIR, cwd)) # Run valgrind on a process command = "valgrind --leak-check=full " + arg - p = subprocess.Popen(command, stderr=subprocess.PIPE, shell=True, preexec_fn=os.setsid) # pylint: disable=W1509 + p = subprocess.Popen(command, stderr=subprocess.PIPE, shell=True, preexec_fn=os.setsid) while not self.replay_done: time.sleep(0.1) diff --git a/selfdrive/test/update_ci_routes.py b/selfdrive/test/update_ci_routes.py index a69eb80cef..dda8568fa8 100755 --- a/selfdrive/test/update_ci_routes.py +++ b/selfdrive/test/update_ci_routes.py @@ -3,13 +3,13 @@ from functools import lru_cache import sys import subprocess from tqdm import tqdm -from azure.storage.blob import BlockBlobService # pylint: disable=import-error +from azure.storage.blob import BlockBlobService from openpilot.selfdrive.car.tests.routes import routes as test_car_models_routes from openpilot.selfdrive.locationd.test.test_laikad import UBLOX_TEST_ROUTE, QCOM_TEST_ROUTE from openpilot.selfdrive.test.process_replay.test_processes import source_segments as replay_segments -from xx.chffr.lib import azureutil # pylint: disable=import-error -from xx.chffr.lib.storage import _DATA_ACCOUNT_PRODUCTION, _DATA_ACCOUNT_CI, _DATA_BUCKET_PRODUCTION # pylint: disable=import-error +from xx.chffr.lib import azureutil +from xx.chffr.lib.storage import _DATA_ACCOUNT_PRODUCTION, _DATA_ACCOUNT_CI, _DATA_BUCKET_PRODUCTION SOURCES = [ (_DATA_ACCOUNT_PRODUCTION, _DATA_BUCKET_PRODUCTION), diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 266b28db04..32cfe11c39 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -118,8 +118,8 @@ def hw_state_thread(end_event, hw_queue): # Log modem version once if AGNOS and ((modem_version is None) or (modem_nv is None)): - modem_version = HARDWARE.get_modem_version() # pylint: disable=assignment-from-none - modem_nv = HARDWARE.get_modem_nv() # pylint: disable=assignment-from-none + modem_version = HARDWARE.get_modem_version() + modem_nv = HARDWARE.get_modem_nv() if (modem_version is not None) and (modem_nv is not None): cloudlog.event("modem version", version=modem_version, nv=modem_nv) diff --git a/selfdrive/tombstoned.py b/selfdrive/tombstoned.py index 25f2a61f98..3f99e16831 100755 --- a/selfdrive/tombstoned.py +++ b/selfdrive/tombstoned.py @@ -38,7 +38,7 @@ def clear_apport_folder(): def get_apport_stacktrace(fn): try: cmd = f'apport-retrace -s <(cat <(echo "Package: openpilot") "{fn}")' - return subprocess.check_output(cmd, shell=True, encoding='utf8', timeout=30, executable='/bin/bash') # pylint: disable=unexpected-keyword-arg + return subprocess.check_output(cmd, shell=True, encoding='utf8', timeout=30, executable='/bin/bash') except subprocess.CalledProcessError: return "Error getting stacktrace" except subprocess.TimeoutExpired: @@ -95,7 +95,7 @@ def report_tombstone_apport(fn): try: sig_num = int(line.strip().split(': ')[-1]) - message += " (" + signal.Signals(sig_num).name + ")" # pylint: disable=no-member + message += " (" + signal.Signals(sig_num).name + ")" except ValueError: pass diff --git a/selfdrive/ui/qt/python_helpers.py b/selfdrive/ui/qt/python_helpers.py index 59e51a5517..88c36290d9 100644 --- a/selfdrive/ui/qt/python_helpers.py +++ b/selfdrive/ui/qt/python_helpers.py @@ -1,7 +1,7 @@ import os from cffi import FFI -import sip # pylint: disable=import-error +import sip from openpilot.common.ffi_wrapper import suffix from openpilot.common.basedir import BASEDIR diff --git a/system/hardware/tici/hardware.py b/system/hardware/tici/hardware.py index 3cd3427842..952693dd3a 100644 --- a/system/hardware/tici/hardware.py +++ b/system/hardware/tici/hardware.py @@ -97,7 +97,7 @@ def get_device_type(): class Tici(HardwareBase): @cached_property def bus(self): - import dbus # pylint: disable=import-error + import dbus return dbus.SystemBus() @cached_property diff --git a/system/micd.py b/system/micd.py index ae2bf86730..c7af1b0ad2 100755 --- a/system/micd.py +++ b/system/micd.py @@ -85,7 +85,7 @@ class Mic: def micd_thread(self): # sounddevice must be imported after forking processes - import sounddevice as sd # pylint: disable=import-outside-toplevel + import sounddevice as sd with sd.InputStream(channels=1, samplerate=SAMPLE_RATE, callback=self.callback) as stream: cloudlog.info(f"micd stream started: {stream.samplerate=} {stream.channels=} {stream.dtype=} {stream.device=}") diff --git a/system/ubloxd/tests/ublox.py b/system/ubloxd/tests/ublox.py index eeb6cde30a..3243500e74 100644 --- a/system/ubloxd/tests/ublox.py +++ b/system/ubloxd/tests/ublox.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# pylint: skip-file ''' UBlox binary protocol handling diff --git a/system/ubloxd/tests/ubloxd.py b/system/ubloxd/tests/ubloxd.py index 783eb1eb0d..4ee99dc28a 100755 --- a/system/ubloxd/tests/ubloxd.py +++ b/system/ubloxd/tests/ubloxd.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # type: ignore -# pylint: skip-file from openpilot.selfdrive.locationd.test import ublox import struct diff --git a/tools/bodyteleop/bodyav.py b/tools/bodyteleop/bodyav.py index fc9559f8dc..3f11f8d4f2 100644 --- a/tools/bodyteleop/bodyav.py +++ b/tools/bodyteleop/bodyav.py @@ -90,12 +90,12 @@ class WebClientSpeaker(MediaBlackhole): self.buffer.write(bio) async def start(self): - for track, task in self._MediaBlackhole__tracks.items(): # pylint: disable=access-member-before-definition + for track, task in self._MediaBlackhole__tracks.items(): if task is None: self._MediaBlackhole__tracks[track] = asyncio.ensure_future(self.consume(track)) async def stop(self): - for task in self._MediaBlackhole__tracks.values(): # pylint: disable=access-member-before-definition + for task in self._MediaBlackhole__tracks.values(): if task is not None: task.cancel() self._MediaBlackhole__tracks = {} diff --git a/tools/camerastream/compressed_vipc.py b/tools/camerastream/compressed_vipc.py index 495397d242..ac7ca2520b 100755 --- a/tools/camerastream/compressed_vipc.py +++ b/tools/camerastream/compressed_vipc.py @@ -26,7 +26,7 @@ def decoder(addr, vipc_server, vst, nvidia, debug=False): if nvidia: os.environ["NV_LOW_LATENCY"] = "3" # both bLowLatency and CUVID_PKT_ENDOFPICTURE sys.path += os.environ["LD_LIBRARY_PATH"].split(":") - import PyNvCodec as nvc # pylint: disable=import-error + import PyNvCodec as nvc nvDec = nvc.PyNvDecoder(W, H, nvc.PixelFormat.NV12, nvc.CudaVideoCodec.HEVC, 0) cc1 = nvc.ColorspaceConversionContext(nvc.ColorSpace.BT_709, nvc.ColorRange.JPEG) diff --git a/tools/gpstest/fuzzy_testing.py b/tools/gpstest/fuzzy_testing.py index a2e130342c..3bad2770cd 100755 --- a/tools/gpstest/fuzzy_testing.py +++ b/tools/gpstest/fuzzy_testing.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import argparse import multiprocessing -import rpyc # pylint: disable=import-error +import rpyc from collections import defaultdict from helper import download_rinex, exec_LimeGPS_bin diff --git a/tools/gpstest/rpc_server.py b/tools/gpstest/rpc_server.py index 060446370b..cdedd8ea57 100644 --- a/tools/gpstest/rpc_server.py +++ b/tools/gpstest/rpc_server.py @@ -4,8 +4,8 @@ import shutil from datetime import datetime from collections import defaultdict -import rpyc # pylint: disable=import-error -from rpyc.utils.server import ThreadedServer # pylint: disable=import-error +import rpyc +from rpyc.utils.server import ThreadedServer #from openpilot.common.params import Params import cereal.messaging as messaging diff --git a/tools/lib/auth.py b/tools/lib/auth.py index 7fc71b6895..997d1f860d 100755 --- a/tools/lib/auth.py +++ b/tools/lib/auth.py @@ -54,7 +54,7 @@ class ClientRedirectHandler(BaseHTTPRequestHandler): self.end_headers() self.wfile.write(b'Return to the CLI to continue') - def log_message(self, *args): # pylint: disable=redefined-builtin + def log_message(self, *args): pass # this prevent http server from dumping messages to stdout diff --git a/tools/lib/framereader.py b/tools/lib/framereader.py index 27984514e9..cbc9310790 100644 --- a/tools/lib/framereader.py +++ b/tools/lib/framereader.py @@ -1,4 +1,3 @@ -# pylint: skip-file import json import os import pickle diff --git a/tools/lib/url_file.py b/tools/lib/url_file.py index c2c7fc9d38..e93f8e715c 100644 --- a/tools/lib/url_file.py +++ b/tools/lib/url_file.py @@ -1,5 +1,3 @@ -# pylint: skip-file - import os import time import tempfile diff --git a/tools/replay/lib/ui_helpers.py b/tools/replay/lib/ui_helpers.py index aa13502143..e350b89bac 100644 --- a/tools/replay/lib/ui_helpers.py +++ b/tools/replay/lib/ui_helpers.py @@ -3,7 +3,7 @@ from typing import Any, Dict, Tuple import matplotlib.pyplot as plt import numpy as np -import pygame # pylint: disable=import-error +import pygame from matplotlib.backends.backend_agg import FigureCanvasAgg diff --git a/tools/replay/ui.py b/tools/replay/ui.py index 1659a024a4..43195a481d 100755 --- a/tools/replay/ui.py +++ b/tools/replay/ui.py @@ -3,9 +3,9 @@ import argparse import os import sys -import cv2 # pylint: disable=import-error +import cv2 import numpy as np -import pygame # pylint: disable=import-error +import pygame import cereal.messaging as messaging from openpilot.common.numpy_fast import clip diff --git a/tools/replay/unlog_ci_segment.py b/tools/replay/unlog_ci_segment.py index 8d69ae954b..ae97ad45d6 100755 --- a/tools/replay/unlog_ci_segment.py +++ b/tools/replay/unlog_ci_segment.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# pylint: skip-file import argparse import bisect diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py index bacf38296e..33fb2c020e 100755 --- a/tools/sim/bridge.py +++ b/tools/sim/bridge.py @@ -8,7 +8,7 @@ import time from multiprocessing import Process, Queue from typing import Any -import carla # pylint: disable=import-error +import carla import numpy as np import pyopencl as cl import pyopencl.array as cl_array diff --git a/tools/sim/lib/can.py b/tools/sim/lib/can.py index 4cecbb2a67..db321d3193 100755 --- a/tools/sim/lib/can.py +++ b/tools/sim/lib/can.py @@ -2,7 +2,7 @@ import cereal.messaging as messaging from opendbc.can.packer import CANPacker from opendbc.can.parser import CANParser -from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error +from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp from openpilot.selfdrive.car import crc8_pedal packer = CANPacker("honda_civic_touring_2016_can_generated") diff --git a/tools/sim/lib/manual_ctrl.py b/tools/sim/lib/manual_ctrl.py index 8f1bcc2b57..1687a2e6ba 100755 --- a/tools/sim/lib/manual_ctrl.py +++ b/tools/sim/lib/manual_ctrl.py @@ -135,8 +135,8 @@ def wheel_poll_thread(q: 'Queue[str]') -> NoReturn: print('%d buttons found: %s' % (num_buttons, ', '.join(button_map))) # Enable FF - import evdev # pylint: disable=import-error - from evdev import ecodes, InputDevice # pylint: disable=import-error + import evdev + from evdev import ecodes, InputDevice device = evdev.list_devices()[0] evtdev = InputDevice(device) val = 24000 diff --git a/tools/webcam/front_mount_helper.py b/tools/webcam/front_mount_helper.py index d4f7d71b41..0b7b676f6e 100755 --- a/tools/webcam/front_mount_helper.py +++ b/tools/webcam/front_mount_helper.py @@ -18,7 +18,7 @@ webcam_intrinsics = np.array([ cam_id = 2 if __name__ == "__main__": - import cv2 # pylint: disable=import-error + import cv2 trans_webcam_to_eon_front = np.dot(eon_dcam_intrinsics, np.linalg.inv(webcam_intrinsics)) diff --git a/tools/webcam/warp_vis.py b/tools/webcam/warp_vis.py index a9ae25ee67..e3f1284a45 100755 --- a/tools/webcam/warp_vis.py +++ b/tools/webcam/warp_vis.py @@ -23,7 +23,7 @@ webcam_intrinsics = np.array([ [ 0., 0., 1.]]) if __name__ == "__main__": - import cv2 # pylint: disable=import-error + import cv2 trans_webcam_to_eon_rear = np.dot(eon_intrinsics, np.linalg.inv(webcam_intrinsics)) trans_webcam_to_eon_front = np.dot(eon_dcam_intrinsics, np.linalg.inv(webcam_intrinsics)) print("trans_webcam_to_eon_rear:\n", trans_webcam_to_eon_rear) From 8205590624913b927d7abb1d214ea25886d7c1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Thu, 24 Aug 2023 16:51:45 -0700 Subject: [PATCH 151/159] Locationd: enable laikad (#29570) * experiment * llk back * update refs * update ref * no internet * Update ref --- selfdrive/locationd/liblocationd.cc | 2 +- selfdrive/locationd/locationd.cc | 129 +++--------------- selfdrive/locationd/locationd.h | 13 +- selfdrive/locationd/test/test_locationd.py | 29 ++-- .../test/process_replay/process_replay.py | 12 +- selfdrive/test/process_replay/ref_commit | 2 +- 6 files changed, 32 insertions(+), 155 deletions(-) diff --git a/selfdrive/locationd/liblocationd.cc b/selfdrive/locationd/liblocationd.cc index e2b85d93a1..47c6c150b4 100755 --- a/selfdrive/locationd/liblocationd.cc +++ b/selfdrive/locationd/liblocationd.cc @@ -4,7 +4,7 @@ extern "C" { typedef Localizer* Localizer_t; Localizer *localizer_init(bool has_ublox) { - return new Localizer(has_ublox ? LocalizerGnssSource::UBLOX : LocalizerGnssSource::QCOM); + return new Localizer(); } void localizer_get_message_bytes(Localizer *localizer, bool inputsOK, bool sensorsOK, bool gpsOK, bool msgValid, diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 401de0cfdd..c22230a049 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -15,7 +15,6 @@ const double ACCEL_SANITY_CHECK = 100.0; // m/s^2 const double ROTATION_SANITY_CHECK = 10.0; // rad/s const double TRANS_SANITY_CHECK = 200.0; // m/s const double CALIB_RPY_SANITY_CHECK = 0.5; // rad (+- 30 deg) -const double ALTITUDE_SANITY_CHECK = 10000; // m const double MIN_STD_SANITY_CHECK = 1e-5; // m or rad const double VALID_TIME_SINCE_RESET = 1.0; // s const double VALID_POS_STD = 50.0; // m @@ -25,15 +24,11 @@ const double INPUT_INVALID_THRESHOLD = 5.0; // same as reset tracker const double DECAY = 0.99995; // same as reset tracker const double MAX_FILTER_REWIND_TIME = 0.8; // s -// TODO: GPS sensor time offsets are empirically calculated -// They should be replaced with synced time from a real clock -const double GPS_QUECTEL_SENSOR_TIME_OFFSET = 0.630; // s -const double GPS_UBLOX_SENSOR_TIME_OFFSET = 0.095; // s const float GPS_POS_STD_THRESHOLD = 50.0; const float GPS_VEL_STD_THRESHOLD = 5.0; const float GPS_POS_ERROR_RESET_THRESHOLD = 300.0; -const float GPS_POS_STD_RESET_THRESHOLD = 2.0; -const float GPS_VEL_STD_RESET_THRESHOLD = 0.5; +const float GPS_POS_STD_RESET_THRESHOLD = 10.0; +const float GPS_VEL_STD_RESET_THRESHOLD = 1.0; const float GPS_ORIENTATION_ERROR_RESET_THRESHOLD = 1.0; const int GPS_ORIENTATION_ERROR_RESET_CNT = 3; @@ -72,7 +67,7 @@ static VectorXd rotate_std(const MatrixXdr& rot_matrix, const VectorXd& std_in) return rotate_cov(rot_matrix, std_in.array().square().matrix().asDiagonal()).diagonal().array().sqrt(); } -Localizer::Localizer(LocalizerGnssSource gnss_source) { +Localizer::Localizer() { this->kf = std::make_unique(); this->reset_kalman(); @@ -86,7 +81,6 @@ Localizer::Localizer(LocalizerGnssSource gnss_source) { VectorXd ecef_pos = this->kf->get_x().segment(STATE_ECEF_POS_START); this->converter = std::make_unique((ECEF) { .x = ecef_pos[0], .y = ecef_pos[1], .z = ecef_pos[2] }); - this->configure_gnss_source(gnss_source); } void Localizer::build_live_location(cereal::LiveLocationKalman::Builder& fix) { @@ -299,64 +293,6 @@ void Localizer::input_fake_gps_observations(double current_time) { this->kf->predict_and_observe(current_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); } -void Localizer::handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset) { - // ignore the message if the fix is invalid - bool gps_invalid_flag = (log.getFlags() % 2 == 0); - bool gps_unreasonable = (Vector2d(log.getAccuracy(), log.getVerticalAccuracy()).norm() >= SANE_GPS_UNCERTAINTY); - bool gps_accuracy_insane = ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0)); - bool gps_lat_lng_alt_insane = ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK)); - bool gps_vel_insane = (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK); - - if (gps_invalid_flag || gps_unreasonable || gps_accuracy_insane || gps_lat_lng_alt_insane || gps_vel_insane) { - //this->gps_valid = false; - this->determine_gps_mode(current_time); - return; - } - - double sensor_time = current_time - sensor_time_offset; - - // Process message - //this->gps_valid = true; - this->gps_mode = true; - Geodetic geodetic = { log.getLatitude(), log.getLongitude(), log.getAltitude() }; - this->converter = std::make_unique(geodetic); - - VectorXd ecef_pos = this->converter->ned2ecef({ 0.0, 0.0, 0.0 }).to_vector(); - VectorXd ecef_vel = this->converter->ned2ecef({ log.getVNED()[0], log.getVNED()[1], log.getVNED()[2] }).to_vector() - ecef_pos; - float ecef_pos_std = std::sqrt(this->gps_variance_factor * std::pow(log.getAccuracy(), 2) + this->gps_vertical_variance_factor * std::pow(log.getVerticalAccuracy(), 2)); - MatrixXdr ecef_pos_R = Vector3d::Constant(std::pow(this->gps_std_factor * ecef_pos_std, 2)).asDiagonal(); - MatrixXdr ecef_vel_R = Vector3d::Constant(std::pow(this->gps_std_factor * log.getSpeedAccuracy(), 2)).asDiagonal(); - - this->unix_timestamp_millis = log.getUnixTimestampMillis(); - double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); - - VectorXd orientation_ecef = quat2euler(vector2quat(this->kf->get_x().segment(STATE_ECEF_ORIENTATION_START))); - VectorXd orientation_ned = ned_euler_from_ecef({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ecef); - VectorXd orientation_ned_gps = Vector3d(0.0, 0.0, DEG2RAD(log.getBearingDeg())); - VectorXd orientation_error = (orientation_ned - orientation_ned_gps).array() - M_PI; - for (int i = 0; i < orientation_error.size(); i++) { - orientation_error(i) = std::fmod(orientation_error(i), 2.0 * M_PI); - if (orientation_error(i) < 0.0) { - orientation_error(i) += 2.0 * M_PI; - } - orientation_error(i) -= M_PI; - } - VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); - - if (ecef_vel.norm() > 5.0 && orientation_error.norm() > 1.0) { - LOGE("Locationd vs ubloxLocation orientation difference too large, kalman reset"); - this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); - this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_ORIENTATION_FROM_GPS, { initial_pose_ecef_quat }); - } else if (gps_est_error > 100.0) { - LOGE("Locationd vs ubloxLocation position difference too large, kalman reset"); - this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); - } - - this->last_gps_msg = sensor_time; - this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_POS, { ecef_pos }, { ecef_pos_R }); - this->kf->predict_and_observe(sensor_time, OBSERVATION_ECEF_VEL, { ecef_vel }, { ecef_vel_R }); -} - void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log) { if (!log.getPositionECEF().getValid() || !log.getVelocityECEF().getValid()) { @@ -365,21 +301,22 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: } double sensor_time = log.getMeasTime() * 1e-9; - sensor_time -= this->gps_time_offset; auto ecef_pos_v = log.getPositionECEF().getValue(); VectorXd ecef_pos = Vector3d(ecef_pos_v[0], ecef_pos_v[1], ecef_pos_v[2]); - // indexed at 0 cause all std values are the same MAE - auto ecef_pos_std = log.getPositionECEF().getStd()[0]; - MatrixXdr ecef_pos_R = Vector3d::Constant(pow(this->gps_std_factor*ecef_pos_std, 2)).asDiagonal(); + auto ecef_pos_std = log.getPositionECEF().getStd(); + VectorXd ecef_pos_var = Vector3d(ecef_pos_std[0], ecef_pos_std[1], ecef_pos_std[2]).array().square().matrix(); + double ecef_pos_std_norm = std::sqrt(ecef_pos_var.sum()); + MatrixXdr ecef_pos_R = ecef_pos_var.asDiagonal(); auto ecef_vel_v = log.getVelocityECEF().getValue(); VectorXd ecef_vel = Vector3d(ecef_vel_v[0], ecef_vel_v[1], ecef_vel_v[2]); - // indexed at 0 cause all std values are the same MAE - auto ecef_vel_std = log.getVelocityECEF().getStd()[0]; - MatrixXdr ecef_vel_R = Vector3d::Constant(pow(this->gps_std_factor*ecef_vel_std, 2)).asDiagonal(); + auto ecef_vel_std = log.getVelocityECEF().getStd(); + VectorXd ecef_vel_var = Vector3d(ecef_vel_std[0], ecef_vel_std[1], ecef_vel_std[2]).array().square().matrix(); + double ecef_vel_std_norm = std::sqrt(ecef_vel_var.sum()); + MatrixXdr ecef_vel_R = ecef_vel_var.asDiagonal(); double gps_est_error = (this->kf->get_x().segment(STATE_ECEF_POS_START) - ecef_pos).norm(); @@ -402,13 +339,13 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: } VectorXd initial_pose_ecef_quat = quat2vector(euler2quat(ecef_euler_from_ned({ ecef_pos(0), ecef_pos(1), ecef_pos(2) }, orientation_ned_gps))); - if (ecef_pos_std > GPS_POS_STD_THRESHOLD || ecef_vel_std > GPS_VEL_STD_THRESHOLD) { + if (ecef_pos_std_norm > GPS_POS_STD_THRESHOLD || ecef_vel_std_norm > GPS_VEL_STD_THRESHOLD) { this->determine_gps_mode(current_time); return; } // prevent jumping gnss measurements (covered lots, standstill...) - bool orientation_reset = ecef_vel_std < GPS_VEL_STD_RESET_THRESHOLD; + bool orientation_reset = ecef_vel_std_norm < GPS_VEL_STD_RESET_THRESHOLD; orientation_reset &= orientation_error.norm() > GPS_ORIENTATION_ERROR_RESET_THRESHOLD; orientation_reset &= !this->standstill; if (orientation_reset) { @@ -417,7 +354,7 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements: this->orientation_reset_count = 0; } - if ((gps_est_error > GPS_POS_ERROR_RESET_THRESHOLD && ecef_pos_std < GPS_POS_STD_RESET_THRESHOLD) || this->last_gps_msg == 0) { + if ((gps_est_error > GPS_POS_ERROR_RESET_THRESHOLD && ecef_pos_std_norm < GPS_POS_STD_RESET_THRESHOLD) || this->last_gps_msg == 0) { // always reset on first gps message and if the location is off but the accuracy is high LOGE("Locationd vs gnssMeasurement position difference too large, kalman reset"); this->reset_kalman(NAN, initial_pose_ecef_quat, ecef_pos, ecef_vel, ecef_pos_R, ecef_vel_R); @@ -587,12 +524,8 @@ void Localizer::handle_msg(const cereal::Event::Reader& log) { this->handle_sensor(t, log.getAccelerometer()); } else if (log.isGyroscope()) { this->handle_sensor(t, log.getGyroscope()); - } else if (log.isGpsLocation()) { - this->handle_gps(t, log.getGpsLocation(), GPS_QUECTEL_SENSOR_TIME_OFFSET); - } else if (log.isGpsLocationExternal()) { - this->handle_gps(t, log.getGpsLocationExternal(), GPS_UBLOX_SENSOR_TIME_OFFSET); - //} else if (log.isGnssMeasurements()) { - // this->handle_gnss(t, log.getGnssMeasurements()); + } else if (log.isGnssMeasurements()) { + this->handle_gnss(t, log.getGnssMeasurements()); } else if (log.isCarState()) { this->handle_car_state(t, log.getCarState()); } else if (log.isCameraOdometry()) { @@ -653,38 +586,12 @@ void Localizer::determine_gps_mode(double current_time) { } } -void Localizer::configure_gnss_source(const LocalizerGnssSource &source) { - this->gnss_source = source; - if (source == LocalizerGnssSource::UBLOX) { - this->gps_std_factor = 10.0; - this->gps_variance_factor = 1.0; - this->gps_vertical_variance_factor = 1.0; - this->gps_time_offset = GPS_UBLOX_SENSOR_TIME_OFFSET; - } else { - this->gps_std_factor = 2.0; - this->gps_variance_factor = 0.0; - this->gps_vertical_variance_factor = 3.0; - this->gps_time_offset = GPS_QUECTEL_SENSOR_TIME_OFFSET; - } -} - int Localizer::locationd_thread() { - LocalizerGnssSource source; - const char* gps_location_socket; - if (Params().getBool("UbloxAvailable")) { - source = LocalizerGnssSource::UBLOX; - gps_location_socket = "gpsLocationExternal"; - } else { - source = LocalizerGnssSource::QCOM; - gps_location_socket = "gpsLocation"; - } - - this->configure_gnss_source(source); - const std::initializer_list service_list = {gps_location_socket, "cameraOdometry", "liveCalibration", + const std::initializer_list service_list = {"gnssMeasurements", "cameraOdometry", "liveCalibration", "carState", "carParams", "accelerometer", "gyroscope"}; // TODO: remove carParams once we're always sending at 100Hz - SubMaster sm(service_list, {}, nullptr, {gps_location_socket, "carParams"}); + SubMaster sm(service_list, {}, nullptr, {"gnssMeasurements", "carParams"}); PubMaster pm({"liveLocationKalman"}); uint64_t cnt = 0; diff --git a/selfdrive/locationd/locationd.h b/selfdrive/locationd/locationd.h index f3069048cd..615251668d 100755 --- a/selfdrive/locationd/locationd.h +++ b/selfdrive/locationd/locationd.h @@ -22,13 +22,10 @@ #define POSENET_STD_HIST_HALF 20 -enum LocalizerGnssSource { - UBLOX, QCOM -}; class Localizer { public: - Localizer(LocalizerGnssSource gnss_source = LocalizerGnssSource::UBLOX); + Localizer(); int locationd_thread(); @@ -56,7 +53,6 @@ public: void handle_msg_bytes(const char *data, const size_t size); void handle_msg(const cereal::Event::Reader& log); void handle_sensor(double current_time, const cereal::SensorEventData::Reader& log); - void handle_gps(double current_time, const cereal::GpsLocationData::Reader& log, const double sensor_time_offset); void handle_gnss(double current_time, const cereal::GnssMeasurements::Reader& log); void handle_car_state(double current_time, const cereal::CarState::Reader& log); void handle_cam_odo(double current_time, const cereal::CameraOdometry::Reader& log); @@ -85,15 +81,8 @@ private: double first_valid_log_time = NAN; double ttff = NAN; double last_gps_msg = 0; - LocalizerGnssSource gnss_source; bool observation_timings_invalid = false; std::map observation_values_invalid; bool standstill = true; int32_t orientation_reset_count = 0; - float gps_std_factor; - float gps_variance_factor; - float gps_vertical_variance_factor; - double gps_time_offset; - - void configure_gnss_source(const LocalizerGnssSource &source); }; diff --git a/selfdrive/locationd/test/test_locationd.py b/selfdrive/locationd/test/test_locationd.py index 6c6ac33431..1fb36bf2fa 100755 --- a/selfdrive/locationd/test/test_locationd.py +++ b/selfdrive/locationd/test/test_locationd.py @@ -14,7 +14,7 @@ from openpilot.selfdrive.manager.process_config import managed_processes class TestLocationdProc(unittest.TestCase): - LLD_MSGS = ['gpsLocationExternal', 'cameraOdometry', 'carState', 'liveCalibration', + LLD_MSGS = ['gnssMeasurements', 'cameraOdometry', 'carState', 'liveCalibration', 'accelerometer', 'gyroscope', 'magnetometer'] def setUp(self): @@ -35,25 +35,14 @@ class TestLocationdProc(unittest.TestCase): msg = messaging.new_message(name) except capnp.lib.capnp.KjException: msg = messaging.new_message(name, 0) - - if name == "gpsLocationExternal": - msg.gpsLocationExternal.flags = 1 - msg.gpsLocationExternal.verticalAccuracy = 1.0 - msg.gpsLocationExternal.speedAccuracy = 1.0 - msg.gpsLocationExternal.bearingAccuracyDeg = 1.0 - msg.gpsLocationExternal.vNED = [0.0, 0.0, 0.0] - msg.gpsLocationExternal.latitude = float(self.lat) - msg.gpsLocationExternal.longitude = float(self.lon) - msg.gpsLocationExternal.unixTimestampMillis = t * 1e6 - msg.gpsLocationExternal.altitude = float(self.alt) - #if name == "gnssMeasurements": - # msg.gnssMeasurements.measTime = t - # msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] - # msg.gnssMeasurements.positionECEF.std = [0,0,0] - # msg.gnssMeasurements.positionECEF.valid = True - # msg.gnssMeasurements.velocityECEF.value = [] - # msg.gnssMeasurements.velocityECEF.std = [0,0,0] - # msg.gnssMeasurements.velocityECEF.valid = True + if name == "gnssMeasurements": + msg.gnssMeasurements.measTime = t + msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] + msg.gnssMeasurements.positionECEF.std = [0,0,0] + msg.gnssMeasurements.positionECEF.valid = True + msg.gnssMeasurements.velocityECEF.value = [] + msg.gnssMeasurements.velocityECEF.std = [0,0,0] + msg.gnssMeasurements.velocityECEF.valid = True elif name == 'cameraOdometry': msg.cameraOdometry.rot = [0.0, 0.0, 0.0] msg.cameraOdometry.rotStd = [0.0, 0.0, 0.0] diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 9256b6015c..c0a49e3324 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -433,13 +433,6 @@ def laikad_config_pubsub_callback(params, cfg, lr): cfg.main_pub_drained = True -def locationd_config_pubsub_callback(params, cfg, lr): - ublox = params.get_bool("UbloxAvailable") - sub_keys = ({"gpsLocation", } if ublox else {"gpsLocationExternal", }) - - cfg.pubs = set(cfg.pubs) - sub_keys - - CONFIGS = [ ProcessConfig( proc_name="controlsd", @@ -494,12 +487,11 @@ CONFIGS = [ ProcessConfig( proc_name="locationd", pubs=[ - "cameraOdometry", "accelerometer", "gyroscope", "gpsLocationExternal", - "liveCalibration", "carState", "carParams", "gpsLocation" + "cameraOdometry", "accelerometer", "gyroscope", "gnssMeasurements", + "liveCalibration", "carState", "carParams" ], subs=["liveLocationKalman"], ignore=["logMonoTime", "valid"], - config_callback=locationd_config_pubsub_callback, tolerance=NUMPY_TOLERANCE, ), ProcessConfig( diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 51c84c4bdd..d5ff4b6069 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -4846f6f416128ba74837829643aa3fe0897c5621 \ No newline at end of file +9d6369c5aa88c37499c330a06aa7a81a5f4f3283 \ No newline at end of file From e2e39d100b32a6706e83c81a1ef3dcdd7ea4001f Mon Sep 17 00:00:00 2001 From: Mitchell Goff Date: Thu, 24 Aug 2023 17:00:26 -0700 Subject: [PATCH 152/159] Added cython bindings for model runners and commonmodel (#29607) * Added cython bindings for model runners and commonmodel * Removed cython language_level=3 * loop to set CXXFLAGS for both envs --- release/files_common | 9 ++++ selfdrive/modeld/SConscript | 27 ++++++++++-- selfdrive/modeld/models/__init__.py | 0 selfdrive/modeld/models/commonmodel.pxd | 23 ++++++++++ selfdrive/modeld/models/commonmodel_pyx.pxd | 13 ++++++ selfdrive/modeld/models/commonmodel_pyx.pyx | 46 ++++++++++++++++++++ selfdrive/modeld/runners/__init__.py | 0 selfdrive/modeld/runners/onnxmodel.pxd | 9 ++++ selfdrive/modeld/runners/onnxmodel_pyx.pyx | 14 ++++++ selfdrive/modeld/runners/runmodel.pxd | 10 +++++ selfdrive/modeld/runners/runmodel_pyx.pxd | 6 +++ selfdrive/modeld/runners/runmodel_pyx.pyx | 32 ++++++++++++++ selfdrive/modeld/runners/snpemodel.pxd | 9 ++++ selfdrive/modeld/runners/snpemodel_pyx.pyx | 14 ++++++ selfdrive/modeld/runners/thneedmodel.pxd | 9 ++++ selfdrive/modeld/runners/thneedmodel_pyx.pyx | 14 ++++++ 16 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 selfdrive/modeld/models/__init__.py create mode 100644 selfdrive/modeld/models/commonmodel.pxd create mode 100644 selfdrive/modeld/models/commonmodel_pyx.pxd create mode 100644 selfdrive/modeld/models/commonmodel_pyx.pyx create mode 100644 selfdrive/modeld/runners/__init__.py create mode 100644 selfdrive/modeld/runners/onnxmodel.pxd create mode 100644 selfdrive/modeld/runners/onnxmodel_pyx.pyx create mode 100644 selfdrive/modeld/runners/runmodel.pxd create mode 100644 selfdrive/modeld/runners/runmodel_pyx.pxd create mode 100644 selfdrive/modeld/runners/runmodel_pyx.pyx create mode 100644 selfdrive/modeld/runners/snpemodel.pxd create mode 100644 selfdrive/modeld/runners/snpemodel_pyx.pyx create mode 100644 selfdrive/modeld/runners/thneedmodel.pxd create mode 100644 selfdrive/modeld/runners/thneedmodel_pyx.pyx diff --git a/release/files_common b/release/files_common index a229954221..f9acce8852 100644 --- a/release/files_common +++ b/release/files_common @@ -354,6 +354,7 @@ selfdrive/manager/process.py selfdrive/manager/test/__init__.py selfdrive/manager/test/test_manager.py +selfdrive/modeld/.gitignore selfdrive/modeld/__init__.py selfdrive/modeld/SConscript selfdrive/modeld/modeld.cc @@ -364,6 +365,10 @@ selfdrive/modeld/modeld selfdrive/modeld/navmodeld selfdrive/modeld/dmonitoringmodeld +selfdrive/modeld/models/__init__.py +selfdrive/modeld/models/*.pxd +selfdrive/modeld/models/*.pyx + selfdrive/modeld/models/commonmodel.cc selfdrive/modeld/models/commonmodel.h @@ -392,6 +397,10 @@ selfdrive/modeld/thneed/thneed_common.cc selfdrive/modeld/thneed/thneed_qcom2.cc selfdrive/modeld/thneed/serialize.cc +selfdrive/modeld/runners/__init__.py +selfdrive/modeld/runners/*.pxd +selfdrive/modeld/runners/*.pyx + selfdrive/modeld/runners/snpemodel.cc selfdrive/modeld/runners/snpemodel.h selfdrive/modeld/runners/thneedmodel.cc diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index 863626967b..61898645e5 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -1,7 +1,8 @@ import os -Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', 'transformations') +Import('env', 'envCython', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', 'transformations') lenv = env.Clone() +lenvCython = envCython.Clone() libs = [cereal, messaging, common, visionipc, gpucommon, 'OpenCL', 'SNPE', 'capnp', 'zmq', 'kj', 'yuv'] @@ -53,8 +54,28 @@ else: del common_src[common_src.index('runners/snpemodel.cc')] for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transforms/loadyuv.cl', 'ONNXRUNNER': 'runners/onnx_runner.py'}.items(): - path = File(fn).abspath - lenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{path}\\"') + for xenv in (lenv, lenvCython): + xenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{File(fn).abspath}\\"') + +if (use_thneed and arch == "larch64") or GetOption('pc_thneed'): + lenvCython['CFLAGS'].append("-DUSE_THNEED") + lenvCython['CXXFLAGS'].append("-DUSE_THNEED") + +common_frameworks = [] +common_libs = envCython["LIBS"] + [gpucommon, common, 'zmq'] +if arch == "Darwin": + common_frameworks.append('OpenCL') +else: + common_libs.append('OpenCL') + +onnxmodel_lib = lenv.Library('onnxmodel', ['runners/onnxmodel.cc']) +snpemodel_lib = lenv.Library('snpemodel', ['runners/snpemodel.cc']) +commonmodel_lib = lenv.Library('commonmodel', common_src) + +lenvCython.Program('runners/runmodel_pyx.so', 'runners/runmodel_pyx.pyx', LIBS=common_libs, FRAMEWORKS=common_frameworks) +lenvCython.Program('runners/onnxmodel_pyx.so', 'runners/onnxmodel_pyx.pyx', LIBS=[onnxmodel_lib, *common_libs], FRAMEWORKS=common_frameworks) +lenvCython.Program('runners/snpemodel_pyx.so', 'runners/snpemodel_pyx.pyx', LIBS=[snpemodel_lib, *common_libs], FRAMEWORKS=common_frameworks) +lenvCython.Program('models/commonmodel_pyx.so', 'models/commonmodel_pyx.pyx', LIBS=[commonmodel_lib, *common_libs], FRAMEWORKS=common_frameworks) common_model = lenv.Object(common_src) diff --git a/selfdrive/modeld/models/__init__.py b/selfdrive/modeld/models/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selfdrive/modeld/models/commonmodel.pxd b/selfdrive/modeld/models/commonmodel.pxd new file mode 100644 index 0000000000..d313dbef90 --- /dev/null +++ b/selfdrive/modeld/models/commonmodel.pxd @@ -0,0 +1,23 @@ +# distutils: language = c++ + +from cereal.visionipc.visionipc cimport cl_device_id, cl_context, cl_mem + +cdef extern from "common/mat.h": + cdef struct mat3: + float v[9] + +cdef extern from "common/clutil.h": + cdef unsigned long CL_DEVICE_TYPE_DEFAULT + cl_device_id cl_get_device_id(unsigned long) + cl_context cl_create_context(cl_device_id) + +cdef extern from "selfdrive/modeld/models/commonmodel.h": + cppclass ModelFrame: + int buf_size + ModelFrame(cl_device_id, cl_context) + float * prepare(cl_mem, int, int, int, int, mat3, cl_mem*) + +cdef extern from "selfdrive/modeld/runners/runmodel.h": + cdef int USE_CPU_RUNTIME + cdef int USE_GPU_RUNTIME + cdef int USE_DSP_RUNTIME diff --git a/selfdrive/modeld/models/commonmodel_pyx.pxd b/selfdrive/modeld/models/commonmodel_pyx.pxd new file mode 100644 index 0000000000..21c0716de4 --- /dev/null +++ b/selfdrive/modeld/models/commonmodel_pyx.pxd @@ -0,0 +1,13 @@ +# distutils: language = c++ + +from cereal.visionipc.visionipc cimport cl_mem +from cereal.visionipc.visionipc_pyx cimport CLContext as BaseCLContext + +cdef class CLContext(BaseCLContext): + pass + +cdef class CLMem: + cdef cl_mem * mem; + + @staticmethod + cdef create(void*) diff --git a/selfdrive/modeld/models/commonmodel_pyx.pyx b/selfdrive/modeld/models/commonmodel_pyx.pyx new file mode 100644 index 0000000000..c5576a5acb --- /dev/null +++ b/selfdrive/modeld/models/commonmodel_pyx.pyx @@ -0,0 +1,46 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii + +import numpy as np +cimport numpy as cnp +from libc.string cimport memcpy + +from cereal.visionipc.visionipc cimport cl_mem +from cereal.visionipc.visionipc_pyx cimport VisionBuf, CLContext as BaseCLContext +from .commonmodel cimport CL_DEVICE_TYPE_DEFAULT, cl_get_device_id, cl_create_context +from .commonmodel cimport USE_CPU_RUNTIME, USE_GPU_RUNTIME, USE_DSP_RUNTIME +from .commonmodel cimport mat3, ModelFrame as cppModelFrame + +class Runtime: + CPU = USE_CPU_RUNTIME + GPU = USE_GPU_RUNTIME + DSP = USE_DSP_RUNTIME + +cdef class CLContext(BaseCLContext): + def __cinit__(self): + self.device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT) + self.context = cl_create_context(self.device_id) + +cdef class CLMem: + @staticmethod + cdef create(void * cmem): + mem = CLMem() + mem.mem = cmem + return mem + +cdef class ModelFrame: + cdef cppModelFrame * frame + + def __cinit__(self, CLContext context): + self.frame = new cppModelFrame(context.device_id, context.context) + + def __dealloc__(self): + del self.frame + + def prepare(self, VisionBuf buf, float[:] projection, CLMem output): + cdef mat3 cprojection + memcpy(cprojection.v, &projection[0], 9*sizeof(float)) + cdef float * data = self.frame.prepare(buf.buf.buf_cl, buf.width, buf.height, buf.stride, buf.uv_offset, cprojection, output.mem) + if not data: + return None + return np.asarray( data) diff --git a/selfdrive/modeld/runners/__init__.py b/selfdrive/modeld/runners/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selfdrive/modeld/runners/onnxmodel.pxd b/selfdrive/modeld/runners/onnxmodel.pxd new file mode 100644 index 0000000000..165f043da8 --- /dev/null +++ b/selfdrive/modeld/runners/onnxmodel.pxd @@ -0,0 +1,9 @@ +# distutils: language = c++ + +from libcpp.string cimport string + +from cereal.visionipc.visionipc cimport cl_context + +cdef extern from "selfdrive/modeld/runners/onnxmodel.h": + cdef cppclass ONNXModel: + ONNXModel(string, float*, size_t, int, bool, cl_context) diff --git a/selfdrive/modeld/runners/onnxmodel_pyx.pyx b/selfdrive/modeld/runners/onnxmodel_pyx.pyx new file mode 100644 index 0000000000..27aa22d1c6 --- /dev/null +++ b/selfdrive/modeld/runners/onnxmodel_pyx.pyx @@ -0,0 +1,14 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii + +from libcpp cimport bool +from libcpp.string cimport string + +from .onnxmodel cimport ONNXModel as cppONNXModel +from selfdrive.modeld.models.commonmodel_pyx cimport CLContext +from selfdrive.modeld.runners.runmodel_pyx cimport RunModel +from selfdrive.modeld.runners.runmodel cimport RunModel as cppRunModel + +cdef class ONNXModel(RunModel): + def __cinit__(self, string path, float[:] output, int runtime, bool use_tf8, CLContext context): + self.model = new cppONNXModel(path, &output[0], len(output), runtime, use_tf8, context.context) diff --git a/selfdrive/modeld/runners/runmodel.pxd b/selfdrive/modeld/runners/runmodel.pxd new file mode 100644 index 0000000000..f12f3e7ab9 --- /dev/null +++ b/selfdrive/modeld/runners/runmodel.pxd @@ -0,0 +1,10 @@ +# distutils: language = c++ + +from libcpp.string cimport string + +cdef extern from "selfdrive/modeld/runners/runmodel.h": + cdef cppclass RunModel: + void addInput(string, float*, int) + void setInputBuffer(string, float*, int) + void * getCLBuffer(string) + void execute() diff --git a/selfdrive/modeld/runners/runmodel_pyx.pxd b/selfdrive/modeld/runners/runmodel_pyx.pxd new file mode 100644 index 0000000000..b6ede7cf37 --- /dev/null +++ b/selfdrive/modeld/runners/runmodel_pyx.pxd @@ -0,0 +1,6 @@ +# distutils: language = c++ + +from .runmodel cimport RunModel as cppRunModel + +cdef class RunModel: + cdef cppRunModel * model diff --git a/selfdrive/modeld/runners/runmodel_pyx.pyx b/selfdrive/modeld/runners/runmodel_pyx.pyx new file mode 100644 index 0000000000..a35f0fa280 --- /dev/null +++ b/selfdrive/modeld/runners/runmodel_pyx.pyx @@ -0,0 +1,32 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii + +from libcpp.string cimport string +from libc.string cimport memcpy + +from selfdrive.modeld.models.commonmodel_pyx cimport CLMem + +cdef class RunModel: + def __dealloc__(self): + del self.model + + def addInput(self, string name, float[:] buffer): + if buffer is not None: + self.model.addInput(name, &buffer[0], len(buffer)) + else: + self.model.addInput(name, NULL, 0) + + def setInputBuffer(self, string name, float[:] buffer): + if buffer is not None: + self.model.setInputBuffer(name, &buffer[0], len(buffer)) + else: + self.model.setInputBuffer(name, NULL, 0) + + def getCLBuffer(self, string name): + cdef void * cl_buf = self.model.getCLBuffer(name) + if not cl_buf: + return None + return CLMem.create(cl_buf) + + def execute(self): + self.model.execute() diff --git a/selfdrive/modeld/runners/snpemodel.pxd b/selfdrive/modeld/runners/snpemodel.pxd new file mode 100644 index 0000000000..1f928da332 --- /dev/null +++ b/selfdrive/modeld/runners/snpemodel.pxd @@ -0,0 +1,9 @@ +# distutils: language = c++ + +from libcpp.string cimport string + +from cereal.visionipc.visionipc cimport cl_context + +cdef extern from "selfdrive/modeld/runners/snpemodel.h": + cdef cppclass SNPEModel: + SNPEModel(string, float*, size_t, int, bool, cl_context) diff --git a/selfdrive/modeld/runners/snpemodel_pyx.pyx b/selfdrive/modeld/runners/snpemodel_pyx.pyx new file mode 100644 index 0000000000..a454aa7b92 --- /dev/null +++ b/selfdrive/modeld/runners/snpemodel_pyx.pyx @@ -0,0 +1,14 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii + +from libcpp cimport bool +from libcpp.string cimport string + +from .snpemodel cimport SNPEModel as cppSNPEModel +from selfdrive.modeld.models.commonmodel_pyx cimport CLContext +from selfdrive.modeld.runners.runmodel_pyx cimport RunModel +from selfdrive.modeld.runners.runmodel cimport RunModel as cppRunModel + +cdef class SNPEModel(RunModel): + def __cinit__(self, string path, float[:] output, int runtime, bool use_tf8, CLContext context): + self.model = new cppSNPEModel(path, &output[0], len(output), runtime, use_tf8, context.context) diff --git a/selfdrive/modeld/runners/thneedmodel.pxd b/selfdrive/modeld/runners/thneedmodel.pxd new file mode 100644 index 0000000000..90af972865 --- /dev/null +++ b/selfdrive/modeld/runners/thneedmodel.pxd @@ -0,0 +1,9 @@ +# distutils: language = c++ + +from libcpp.string cimport string + +from cereal.visionipc.visionipc cimport cl_context + +cdef extern from "selfdrive/modeld/runners/thneedmodel.h": + cdef cppclass ThneedModel: + ThneedModel(string, float*, size_t, int, bool, cl_context) diff --git a/selfdrive/modeld/runners/thneedmodel_pyx.pyx b/selfdrive/modeld/runners/thneedmodel_pyx.pyx new file mode 100644 index 0000000000..53487afa1b --- /dev/null +++ b/selfdrive/modeld/runners/thneedmodel_pyx.pyx @@ -0,0 +1,14 @@ +# distutils: language = c++ +# cython: c_string_encoding=ascii + +from libcpp cimport bool +from libcpp.string cimport string + +from .thneedmodel cimport ThneedModel as cppThneedModel +from selfdrive.modeld.models.commonmodel_pyx cimport CLContext +from selfdrive.modeld.runners.runmodel_pyx cimport RunModel +from selfdrive.modeld.runners.runmodel cimport RunModel as cppRunModel + +cdef class ThneedModel(RunModel): + def __cinit__(self, string path, float[:] output, int runtime, bool use_tf8, CLContext context): + self.model = new cppThneedModel(path, &output[0], len(output), runtime, use_tf8, context.context) From 90cb417caa049261797449d7e75eea01093e073d Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 24 Aug 2023 17:03:25 -0700 Subject: [PATCH 153/159] CI: use GITHUB_ENV for env variables (#29616) export doesn't work across steps --- .github/workflows/selfdrive_tests.yaml | 2 +- .github/workflows/tools_tests.yaml | 4 ++-- selfdrive/test/docker_build.sh | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 0f68f425b6..5c55420508 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -193,7 +193,7 @@ jobs: submodules: true - name: Setup to push to repo run: | - export PUSH_IMAGE=true + echo "PUSH_IMAGE=true" >> "$GITHUB_ENV" $DOCKER_LOGIN - uses: ./.github/workflows/setup with: diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 7a7acb1c87..e92a99dba1 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -61,7 +61,7 @@ jobs: - name: Setup to push to repo if: github.ref == 'refs/heads/master' && github.repository == 'commaai/openpilot' run: | - export PUSH_IMAGE=true + echo "PUSH_IMAGE=true" >> "$GITHUB_ENV" $DOCKER_LOGIN - name: Build and push sim image run: | @@ -82,7 +82,7 @@ jobs: - name: Setup to push to repo if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot' run: | - export PUSH_IMAGE=true + echo "PUSH_IMAGE=true" >> "$GITHUB_ENV" $DOCKER_LOGIN - name: Build and push docs image run: | diff --git a/selfdrive/test/docker_build.sh b/selfdrive/test/docker_build.sh index b18c48123a..c9be11ffa7 100755 --- a/selfdrive/test/docker_build.sh +++ b/selfdrive/test/docker_build.sh @@ -35,7 +35,7 @@ DOCKER_BUILDKIT=1 docker build --cache-to type=inline --cache-from type=registry if [[ ! -z "$PUSH_IMAGE" ]]; then - docker push $REMOTE_TAG - docker tag $REMOTE_TAG $REMOTE_SHA_TAG - docker push $REMOTE_SHA_TAG + docker push $REMOTE_TAG + docker tag $REMOTE_TAG $REMOTE_SHA_TAG + docker push $REMOTE_SHA_TAG fi \ No newline at end of file From e8638280518938e7029c576be421e7fc35ddc695 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 24 Aug 2023 17:18:11 -0700 Subject: [PATCH 154/159] CI: workaround syntax error in azure lib (#29618) --- .github/workflows/selfdrive_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 5c55420508..a046250ec2 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -317,7 +317,7 @@ jobs: - name: Upload reference logs if: ${{ failure() && steps.print-diff.outcome == 'success' && github.repository == 'commaai/openpilot' && env.AZURE_TOKEN != '' }} run: | - ${{ env.RUN }} "CI=1 AZURE_TOKEN='$AZURE_TOKEN' python selfdrive/test/process_replay/test_processes.py -j$(nproc) --upload-only" + ${{ env.RUN }} "unset PYTHONWARNINGS && CI=1 AZURE_TOKEN='$AZURE_TOKEN' python selfdrive/test/process_replay/test_processes.py -j$(nproc) --upload-only" - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 From 36cc41f619a50e21b90171bab1eedf1f15dd61a9 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 24 Aug 2023 17:32:15 -0700 Subject: [PATCH 155/159] CI: remove redundant apt installs (#29617) * CI: remove redundant apt installs * split build and test * faster build --- .github/workflows/tools_tests.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index e92a99dba1..e1ad67f930 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -20,7 +20,7 @@ env: RUN: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c BUILD_CL: selfdrive/test/docker_build.sh cl - + RUN_CL: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c @@ -35,14 +35,13 @@ jobs: submodules: true - name: Build Docker image run: eval "$BUILD" - - name: Unit test + - name: Build openpilot + timeout-minutes: 5 + run: ${{ env.RUN }} "scons -j$(nproc) --directory=/tmp/openpilot/cereal --minimal" + - name: Test PlotJuggler timeout-minutes: 2 run: | - ${{ env.RUN }} "scons -j$(nproc) --directory=/tmp/openpilot cereal && \ - apt-get update && \ - apt-get install -y libdw-dev libqt5svg5-dev libqt5x11extras5-dev && \ - cd /tmp/openpilot/tools/plotjuggler && \ - ./test_plotjuggler.py" + ${{ env.RUN }} "pytest tools/plotjuggler/" simulator: name: simulator From 465a72a87d9cfc058a256268ec0117d90aef35ed Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 24 Aug 2023 19:22:48 -0700 Subject: [PATCH 156/159] bump panda (#29619) Co-authored-by: Comma Device --- panda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda b/panda index 0587f22bf3..09cd81752d 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 0587f22bf359c77296f9b03bef6c3bbcbc820f87 +Subproject commit 09cd81752d1d53de4cc1c63f950dc717acc20ad8 From ae2a6537b7eb13a03820bc449e3448e97f0bd38b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 24 Aug 2023 21:11:01 -0700 Subject: [PATCH 157/159] fingerprinting: log FW query time (#27880) * Update car_helpers.py * put in carParams * bumpcereal * rename * bump cereal * add cached * bump cereal * just add to fingerprinted event --- selfdrive/car/car_helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 81a8c7eacd..7017580368 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -1,4 +1,5 @@ import os +import time from typing import Callable, Dict, List, Optional, Tuple from cereal import car @@ -125,6 +126,7 @@ def fingerprint(logcan, sendcan, num_pandas): ecu_rx_addrs = set() params = Params() + start_time = time.monotonic() if not skip_fw_query: # Vin query only reliably works through OBDII bus = 1 @@ -165,6 +167,8 @@ def fingerprint(logcan, sendcan, num_pandas): set_obd_multiplexing(params, False) params.put_bool("FirmwareQueryDone", True) + fw_query_time = time.monotonic() - start_time + # CAN fingerprint # drain CAN socket so we get the latest messages messaging.drain_sock_raw(logcan) @@ -185,7 +189,7 @@ def fingerprint(logcan, sendcan, num_pandas): cloudlog.event("fingerprinted", car_fingerprint=car_fingerprint, source=source, fuzzy=not exact_match, cached=cached, fw_count=len(car_fw), ecu_responses=list(ecu_rx_addrs), vin_rx_addr=vin_rx_addr, fingerprints=finger, - error=True) + fw_query_time=fw_query_time, error=True) return car_fingerprint, finger, vin, car_fw, source, exact_match From ed6e72ae1fbc5605cac693d58b3143dd33c0d6fc Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 25 Aug 2023 00:43:29 -0700 Subject: [PATCH 158/159] car/__init__: missing ending newline --- selfdrive/car/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py index c5f4a41520..773d990fac 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -232,4 +232,4 @@ class CanSignalRateCalculator: self.previous_counter = current_counter self.previous_value = current_value - return self.rate \ No newline at end of file + return self.rate From c0b9458a45f208c9773f859169a7de56d19b1bec Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Fri, 25 Aug 2023 01:41:04 -0700 Subject: [PATCH 159/159] CI: move cache dir to workspace directory (#29622) * comma dir * mkdir * fix issues * test * fix that * fix * do the other ones too * missed that * fix * fix pr comments by moving into two different directories * fix location * fix that * only change current * fix --- .github/workflows/badges.yaml | 2 +- .github/workflows/selfdrive_tests.yaml | 12 +++++++----- .github/workflows/setup/action.yaml | 11 ++++++++--- .github/workflows/tools_tests.yaml | 4 ++-- .gitignore | 1 + 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/badges.yaml b/.github/workflows/badges.yaml index 581c88be15..2ab3bded6a 100644 --- a/.github/workflows/badges.yaml +++ b/.github/workflows/badges.yaml @@ -7,7 +7,7 @@ on: env: BASE_IMAGE: openpilot-base DOCKER_REGISTRY: ghcr.io/commaai - RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $DOCKER_REGISTRY/$BASE_IMAGE:latest /bin/sh -c + RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $DOCKER_REGISTRY/$BASE_IMAGE:latest /bin/sh -c jobs: badges: diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index a046250ec2..911060b05d 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -19,11 +19,11 @@ env: DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} BUILD: selfdrive/test/docker_build.sh base - RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c + RUN: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c BUILD_CL: selfdrive/test/docker_build.sh cl - RUN_CL: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c + RUN_CL: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c UNIT_TEST: coverage run --append -m unittest discover @@ -88,7 +88,7 @@ jobs: uses: actions/cache/save@v3 if: github.ref == 'refs/heads/master' with: - path: ~/scons_cache + path: .ci_cache/scons_cache key: scons-${{ env.CACHE_COMMIT_DATE }}-${{ github.sha }} build_mac: @@ -294,7 +294,7 @@ jobs: id: dependency-cache uses: actions/cache@v3 with: - path: ~/comma_download_cache + path: .ci_cache/comma_download_cache key: proc-replay-${{ hashFiles('.github/workflows/selfdrive_tests.yaml', 'selfdrive/test/process_replay/ref_commit') }} - name: Build openpilot run: | @@ -369,7 +369,7 @@ jobs: id: dependency-cache uses: actions/cache@v3 with: - path: ~/comma_download_cache + path: .ci_cache/comma_download_cache key: car_models-${{ hashFiles('selfdrive/car/tests/test_models.py', 'selfdrive/car/tests/routes.py') }}-${{ matrix.job }} - name: Build openpilot run: ${{ env.RUN }} "scons -j$(nproc)" @@ -401,9 +401,11 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + path: current - name: Save car docs diff id: save_diff run: | + cd current ${{ env.RUN }} "scons -j$(nproc)" output=$(${{ env.RUN }} "python selfdrive/debug/print_docs_diff.py --path /tmp/openpilot_cache/base_car_info") output="${output//$'\n'/'%0A'}" diff --git a/.github/workflows/setup/action.yaml b/.github/workflows/setup/action.yaml index 1181008f7e..12cded493d 100644 --- a/.github/workflows/setup/action.yaml +++ b/.github/workflows/setup/action.yaml @@ -27,11 +27,16 @@ runs: - id: restore-scons-cache uses: actions/cache/restore@v3 with: - path: ~/scons_cache + path: .ci_cache/scons_cache key: scons-${{ env.CACHE_COMMIT_DATE }}-${{ github.sha }} restore-keys: | scons-${{ env.CACHE_COMMIT_DATE }}- scons- + # if we didn't get a cache hit, make the directory manually so it doesn't fail on future steps + - id: scons-cache-setup + shell: bash + if: steps.restore-scons-cache.outputs.cache-hit != 'true' + run: mkdir -p $GITHUB_WORKSPACE/.ci_cache/scons_cache # as suggested here: https://github.com/moby/moby/issues/32816#issuecomment-910030001 - id: normalize-file-permissions shell: bash @@ -47,6 +52,6 @@ runs: shell: bash if: ${{ inputs.setup_docker_scons_cache == 'true' }} run: | - cp selfdrive/test/Dockerfile.scons_cache ~ - cd ~ + cp selfdrive/test/Dockerfile.scons_cache $GITHUB_WORKSPACE/.ci_cache + cd $GITHUB_WORKSPACE/.ci_cache DOCKER_BUILDKIT=1 docker build -t scons-cache -f Dockerfile.scons_cache . \ No newline at end of file diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index e1ad67f930..0ce1e39861 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -17,11 +17,11 @@ env: BUILD: selfdrive/test/docker_build.sh base - RUN: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c + RUN: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/sh -c BUILD_CL: selfdrive/test/docker_build.sh cl - RUN_CL: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v ~/scons_cache:/tmp/scons_cache -v ~/comma_download_cache:/tmp/comma_download_cache -v ~/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c + RUN_CL: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c jobs: diff --git a/.gitignore b/.gitignore index a7c8c1c6f0..a0c8df3142 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ venv/ .venv/ +.ci_cache .env .clang-format .DS_Store
%1%2 %4%5