Skip to content

Commit

Permalink
move all third party stuff into third_party/ (commaai#26853)
Browse files Browse the repository at this point in the history
* mv fastcluster

* move msm_kgsl.h

* camerad include

* update path

* mv pyextra

* fix tici build

* add acados_template to release build

Co-authored-by: Comma Device <[email protected]>
  • Loading branch information
adeebshihadeh and Comma Device authored Jan 1, 2023
1 parent 304796b commit cd8e03d
Show file tree
Hide file tree
Showing 107 changed files with 37 additions and 50 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
rev: v4.1.0
hooks:
- id: check-ast
exclude: '^(pyextra)/'
exclude: '^(third_party)/'
- id: check-json
- id: check-xml
- id: check-yaml
Expand All @@ -19,7 +19,7 @@ repos:
rev: v2.2.1
hooks:
- id: codespell
exclude: '^(pyextra/)|(third_party/)|(body/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)|(include/)|(selfdrive/ui/translations/.*.ts)|(selfdrive/controls/lib/cluster)'
exclude: '^(third_party/)|(body/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)|(selfdrive/ui/translations/.*.ts)'
args:
# if you've got a short variable name that's getting flagged, add it here
- -L bu,ro,te,ue,alo,hda,ois,nam,nams,ned,som,parm,setts,inout,warmup
Expand All @@ -31,12 +31,12 @@ repos:
entry: mypy
language: system
types: [python]
exclude: '^(pyextra/)|(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)'
exclude: '^(third_party/)|(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)'
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(selfdrive/debug/)/'
exclude: '^(third_party/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(selfdrive/debug/)/'
additional_dependencies: ['flake8-no-implicit-concat']
args:
- --indent-size=2
Expand All @@ -51,7 +51,7 @@ repos:
entry: pylint
language: system
types: [python]
exclude: '^(pyextra/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)'
exclude: '^(third_party/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)'
args:
- -j0
- -rn
Expand All @@ -64,7 +64,7 @@ repos:
entry: cppcheck
language: system
types: [c++]
exclude: '^(third_party/)|(pyextra/)|(cereal/)|(body/)|(rednose/)|(rednose_repo/)|(opendbc/)|(panda/)|(tools/)|(selfdrive/modeld/thneed/debug/)|(selfdrive/modeld/test/)|(selfdrive/camerad/test/)|(installer/)'
exclude: '^(third_party/)|(cereal/)|(body/)|(rednose/)|(rednose_repo/)|(opendbc/)|(panda/)|(tools/)|(selfdrive/modeld/thneed/debug/)|(selfdrive/modeld/test/)|(selfdrive/camerad/test/)|(installer/)'
args:
- --error-exitcode=1
- --language=c++
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.openpilot
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ WORKDIR ${OPENPILOT_PATH}

COPY SConstruct ${OPENPILOT_PATH}

COPY ./pyextra ${OPENPILOT_PATH}/pyextra
COPY ./third_party ${OPENPILOT_PATH}/third_party
COPY ./site_scons ${OPENPILOT_PATH}/site_scons
COPY ./laika ${OPENPILOT_PATH}/laika
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ Directory Structure
├── opendbc # Files showing how to interpret data from cars
├── panda # Code used to communicate on CAN
├── third_party # External libraries
├── pyextra # Extra python packages
└── system # Generic services
├── camerad # Driver to capture images from the camera sensors
├── clocksd # Broadcasts current time
Expand Down
5 changes: 2 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ if arch == "aarch64" and AGNOS:
lenv = {
"PATH": os.environ['PATH'],
"LD_LIBRARY_PATH": [Dir(f"#third_party/acados/{arch}/lib").abspath],
"PYTHONPATH": Dir("#").abspath + ":" + Dir("#pyextra/").abspath,
"PYTHONPATH": Dir("#").abspath,

"ACADOS_SOURCE_DIR": Dir("#third_party/acados/include/acados").abspath,
"ACADOS_PYTHON_INTERFACE_PATH": Dir("#pyextra/acados_template").abspath,
"ACADOS_PYTHON_INTERFACE_PATH": Dir("#third_party/acados/acados_template").abspath,
"TERA_PATH": Dir("#").abspath + f"/third_party/acados/{arch}/t_renderer"
}

Expand Down Expand Up @@ -422,7 +422,6 @@ SConscript(['common/transformations/SConscript'])

SConscript(['selfdrive/modeld/SConscript'])

SConscript(['selfdrive/controls/lib/cluster/SConscript'])
SConscript(['selfdrive/controls/lib/lateral_mpc_lib/SConscript'])
SConscript(['selfdrive/controls/lib/longitudinal_mpc_lib/SConscript'])

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ clean:

@echo "Building rst files..."
sphinx-apidoc -o "$(DOCSBUILDDIR)" ../ \
../xx ../laika_repo ../rednose_repo ../pyextra ../notebooks ../panda_jungle \
../xx ../laika_repo ../rednose_repo ../notebooks ../panda_jungle \
../third_party \
../panda/examples \
../scripts \
Expand Down
1 change: 0 additions & 1 deletion docs/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ WORKDIR ${OPENPILOT_PATH}

COPY SConstruct ${OPENPILOT_PATH}

COPY ./pyextra ${OPENPILOT_PATH}/pyextra
COPY ./third_party ${OPENPILOT_PATH}/third_party
COPY ./site_scons ${OPENPILOT_PATH}/site_scons
COPY ./laika ${OPENPILOT_PATH}/laika
Expand Down
2 changes: 1 addition & 1 deletion launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function launch {

# handle pythonpath
ln -sfn $(pwd) /data/pythonpath
export PYTHONPATH="$PWD:$PWD/pyextra"
export PYTHONPATH="$PWD"

# hardware specific init
agnos_init
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
python_version = 3.8
plugins = numpy.typing.mypy_plugin
files = body, common, docs, scripts, selfdrive, site_scons, system, tools
exclude = ^(pyextra/)|(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)
exclude = ^(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)

; third-party packages
ignore_missing_imports = True
Expand Down
11 changes: 4 additions & 7 deletions release/files_common
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ selfdrive/controls/lib/pid.py
selfdrive/controls/lib/radar_helpers.py
selfdrive/controls/lib/vehicle_model.py

selfdrive/controls/lib/cluster/*

selfdrive/controls/lib/lateral_mpc_lib/.gitignore
selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore
selfdrive/controls/lib/lateral_mpc_lib/*
Expand Down Expand Up @@ -328,7 +326,6 @@ system/camerad/SConscript
system/camerad/main.cc

system/camerad/snapshot/*
system/camerad/include/*
system/camerad/cameras/camera_common.h
system/camerad/cameras/camera_common.cc
system/camerad/cameras/sensor2_i2c.h
Expand Down Expand Up @@ -384,7 +381,6 @@ selfdrive/modeld/thneed/thneed.h
selfdrive/modeld/thneed/thneed_common.cc
selfdrive/modeld/thneed/thneed_qcom2.cc
selfdrive/modeld/thneed/serialize.cc
selfdrive/modeld/thneed/include/*

selfdrive/modeld/runners/snpemodel.cc
selfdrive/modeld/runners/snpemodel.h
Expand Down Expand Up @@ -412,8 +408,11 @@ selfdrive/assets/offroad/*
selfdrive/assets/sounds/*
selfdrive/assets/training/*

third_party/.gitignore
third_party/SConscript

third_party/cluster/*

third_party/linux/**
third_party/opencl/**

Expand All @@ -436,15 +435,13 @@ third_party/snpe/dsp**
third_party/acados/x86_64/**
third_party/acados/larch64/**
third_party/acados/include/**
third_party/acados/acados_template/**

third_party/qt5/larch64/bin/**

scripts/update_now.sh
scripts/stop_updater.sh

pyextra/.gitignore
pyextra/acados_template/**

rednose/.gitignore
rednose/**
laika/**
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/controls/lib/lateral_mpc_lib/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ generated_files = [
] + build_files

acados_dir = '#third_party/acados'
acados_templates_dir = '#pyextra/acados_template/c_templates_tera'
acados_templates_dir = '#third_party/acados/acados_template/c_templates_tera'

source_list = ['lat_mpc.py',
f'{acados_dir}/include/acados_c/ocp_nlp_interface.h',
Expand All @@ -70,8 +70,8 @@ lib_solver = lenv.SharedLibrary(f"{gen}/acados_ocp_solver_lat",
LIBS=['m', 'acados', 'hpipm', 'blasfeo', 'qpOASES_e'])

# generate cython stuff
acados_ocp_solver_pyx = File("#pyextra/acados_template/acados_ocp_solver_pyx.pyx")
acados_ocp_solver_common = File("#pyextra/acados_template/acados_solver_common.pxd")
acados_ocp_solver_pyx = File("#third_party/acados/acados_template/acados_ocp_solver_pyx.pyx")
acados_ocp_solver_common = File("#third_party/acados/acados_template/acados_solver_common.pxd")
libacados_ocp_solver_pxd = File(f'{gen}/acados_solver.pxd')
libacados_ocp_solver_c = File(f'{gen}/acados_ocp_solver_pyx.c')

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/lib/lateral_mpc_lib/lat_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from selfdrive.modeld.constants import T_IDXS

if __name__ == '__main__': # generating code
from pyextra.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver
from 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 # pylint: disable=no-name-in-module, import-error

Expand Down
6 changes: 3 additions & 3 deletions selfdrive/controls/lib/longitudinal_mpc_lib/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ generated_files = [
] + build_files

acados_dir = '#third_party/acados'
acados_templates_dir = '#pyextra/acados_template/c_templates_tera'
acados_templates_dir = '#third_party/acados/acados_template/c_templates_tera'

source_list = ['long_mpc.py',
f'{acados_dir}/include/acados_c/ocp_nlp_interface.h',
Expand All @@ -77,8 +77,8 @@ lib_solver = lenv.SharedLibrary(f"{gen}/acados_ocp_solver_long",
LIBS=['m', 'acados', 'hpipm', 'blasfeo', 'qpOASES_e'])

# generate cython stuff
acados_ocp_solver_pyx = File("#pyextra/acados_template/acados_ocp_solver_pyx.pyx")
acados_ocp_solver_common = File("#pyextra/acados_template/acados_solver_common.pxd")
acados_ocp_solver_pyx = File("#third_party/acados/acados_template/acados_ocp_solver_pyx.pyx")
acados_ocp_solver_common = File("#third_party/acados/acados_template/acados_solver_common.pxd")
libacados_ocp_solver_pxd = File(f'{gen}/acados_solver.pxd')
libacados_ocp_solver_c = File(f'{gen}/acados_ocp_solver_pyx.c')

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from selfdrive.controls.lib.radar_helpers import _LEAD_ACCEL_TAU

if __name__ == '__main__': # generating code
from pyextra.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver
from 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 # pylint: disable=no-name-in-module, import-error

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/radard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from common.numpy_fast import interp
from common.params import Params
from common.realtime import Ratekeeper, Priority, config_realtime_process
from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid
from selfdrive.controls.lib.radar_helpers import Cluster, Track, RADAR_TO_CAMERA
from system.swaglog import cloudlog
from third_party.cluster.fastcluster_py import cluster_points_centroid


class KalmanParams():
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/tests/test_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from scipy.cluster import _hierarchy
from scipy.spatial.distance import pdist

from selfdrive.controls.lib.cluster.fastcluster_py import hclust, ffi
from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid
from third_party.cluster.fastcluster_py import hclust, ffi
from third_party.cluster.fastcluster_py import cluster_points_centroid


def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None):
Expand Down
2 changes: 0 additions & 2 deletions selfdrive/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
terms_version, training_version, is_tested_branch


sys.path.append(os.path.join(BASEDIR, "pyextra"))


def manager_init() -> None:
# update system time from panda
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/modeld/thneed/thneed.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <CL/cl.h>

#include "selfdrive/modeld/thneed/include/msm_kgsl.h"
#include "msm_kgsl.h"

using namespace std;

Expand Down
14 changes: 5 additions & 9 deletions system/camerad/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc')

libs = ['m', 'pthread', common, 'jpeg', 'OpenCL', 'yuv', cereal, messaging, 'zmq', 'capnp', 'kj', visionipc, gpucommon, 'atomic']

cenv = env.Clone()
cenv['CPPPATH'].append('include/')

camera_obj = cenv.Object(['cameras/camera_qcom2.cc', 'cameras/camera_common.cc', 'cameras/camera_util.cc'])
cenv.Program('camerad', [
camera_obj = env.Object(['cameras/camera_qcom2.cc', 'cameras/camera_common.cc', 'cameras/camera_util.cc'])
env.Program('camerad', [
'main.cc',
camera_obj,
], LIBS=libs)

if GetOption("test") and arch == "x86_64":
cenv.Program('test/ae_gray_test', [
'test/ae_gray_test.cc',
camera_obj,
], LIBS=libs)
env.Program('test/ae_gray_test',
['test/ae_gray_test.cc', camera_obj],
LIBS=libs)
File renamed without changes.
2 changes: 2 additions & 0 deletions third_party/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ env.Library('json11', ['json11/json11.cpp'], CCFLAGS=env['CCFLAGS'] + ['-Wno-unq
env.Append(CPPPATH=[Dir('json11')])

env.Library('kaitai', ['kaitai/kaitaistream.cpp'], CPPDEFINES=['KS_STR_ENCODING_NONE'])

SConscript(['cluster/SConscript'])
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions third_party/acados/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ mkdir -p $INSTALL_DIR

rm $DIR/acados_repo/lib/*.json

rm -rf $DIR/include
rm -rf $DIR/include $DIR/acados_template
cp -r $DIR/acados_repo/include $DIR
cp -r $DIR/acados_repo/lib $INSTALL_DIR
rm -rf $DIR/../../pyextra/acados_template
cp -r $DIR/acados_repo/interfaces/acados_template/acados_template $DIR/../../pyextra
cp -r $DIR/acados_repo/interfaces/acados_template/acados_template $DIR/
#pip3 install -e $DIR/acados/interfaces/acados_template

# build tera
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/gpstest/fuzzy_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_continuous_coords(lat, lon) -> Tuple[int, int]:
def exec_remote_checker(lat, lon, duration, ip_addr):
global rc_p
# TODO: good enough for testing
remote_cmd = "export PYTHONPATH=/data/pythonpath:/data/pythonpath/pyextra && "
remote_cmd = "export PYTHONPATH=/data/pythonpath && "
remote_cmd += "cd /data/openpilot && "
remote_cmd += f"timeout {duration} /usr/local/pyenv/shims/python tools/gpstest/remote_checker.py "
remote_cmd += f"{lat} {lon}"
Expand Down
1 change: 0 additions & 1 deletion tools/sim/Dockerfile.sim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUN mkdir -p $HOME/openpilot
COPY SConstruct $HOME/openpilot/

COPY ./third_party $HOME/openpilot/third_party
COPY ./pyextra $HOME/openpilot/pyextra
COPY ./site_scons $HOME/openpilot/site_scons
COPY ./rednose $HOME/openpilot/rednose
COPY ./laika $HOME/openpilot/laika
Expand Down

0 comments on commit cd8e03d

Please sign in to comment.