Skip to content

Commit

Permalink
Move camerad to system/ (commaai#24836)
Browse files Browse the repository at this point in the history
* mv camerad

* add hardware symlink

* fix unit tests
  • Loading branch information
spektor56 committed Jul 1, 2022
1 parent 07dc49a commit ce60ff7
Show file tree
Hide file tree
Showing 66 changed files with 74 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/selfdrive_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ jobs:
./selfdrive/loggerd/tests/test_logger &&\
./system/proclogd/tests/test_proclog && \
./selfdrive/ui/replay/tests/test_replay && \
./selfdrive/camerad/test/ae_gray_test && \
./camerad/test/ae_gray_test && \
coverage xml"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ selfdrive/loggerd/loggerd
selfdrive/loggerd/bootlog
selfdrive/sensord/_gpsd
selfdrive/sensord/_sensord
selfdrive/camerad/camerad
selfdrive/camerad/test/ae_gray_test
system/camerad/camerad
system/camerad/test/ae_gray_test
selfdrive/modeld/_modeld
selfdrive/modeld/_dmonitoringmodeld
/src/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ repos:
entry: cppcheck
language: system
types: [c++]
exclude: '^(third_party/)|(pyextra/)|(cereal/)|(opendbc/)|(panda/)|(tools/)|(selfdrive/modeld/thneed/debug/)|(selfdrive/modeld/test/)|(selfdrive/camerad/test/)/|(installer/)'
exclude: '^(third_party/)|(pyextra/)|(cereal/)|(opendbc/)|(panda/)|(tools/)|(selfdrive/modeld/thneed/debug/)|(selfdrive/modeld/test/)|(system/camerad/test/)/|(installer/)'
args:
- --error-exitcode=1
- --language=c++
Expand Down
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ pipeline {
steps {
phone_steps("eon-party", [
["build", "cd selfdrive/manager && ./build.py"],
["test camerad", "python selfdrive/camerad/test/test_camerad.py"],
["test exposure", "python selfdrive/camerad/test/test_exposure.py"],
["test camerad", "python system/camerad/test/test_camerad.py"],
["test exposure", "python system/camerad/test/test_exposure.py"],
])
}
}
Expand All @@ -204,8 +204,8 @@ pipeline {
steps {
phone_steps("tici-party", [
["build", "cd selfdrive/manager && ./build.py"],
["test camerad", "python selfdrive/camerad/test/test_camerad.py"],
["test exposure", "python selfdrive/camerad/test/test_exposure.py"],
["test camerad", "python system/camerad/test/test_camerad.py"],
["test exposure", "python system/camerad/test/test_exposure.py"],
])
}
}
Expand Down
4 changes: 2 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ if arch == "aarch64" or arch == "larch64":
"/usr/lib/aarch64-linux-gnu"
]
cpppath += [
"#selfdrive/camerad/include",
"#system/camerad/include",
]
cflags = ["-DQCOM2", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"]
Expand Down Expand Up @@ -424,7 +424,7 @@ SConscript(['third_party/SConscript'])
SConscript(['common/kalman/SConscript'])
SConscript(['common/transformations/SConscript'])

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

SConscript(['selfdrive/controls/lib/cluster/SConscript'])
Expand Down
45 changes: 23 additions & 22 deletions release/files_common
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore
selfdrive/controls/lib/lateral_mpc_lib/*
selfdrive/controls/lib/longitudinal_mpc_lib/*

selfdrive/hardware
selfdrive/hardware/__init__.py
selfdrive/hardware/base.h
selfdrive/hardware/base.py
Expand Down Expand Up @@ -316,28 +317,28 @@ selfdrive/ui/replay/*.h
selfdrive/ui/qt/maps/*.cc
selfdrive/ui/qt/maps/*.h

selfdrive/camerad/SConscript
selfdrive/camerad/main.cc

selfdrive/camerad/snapshot/*
selfdrive/camerad/include/*
selfdrive/camerad/cameras/camera_common.h
selfdrive/camerad/cameras/camera_common.cc
selfdrive/camerad/cameras/camera_qcom.cc
selfdrive/camerad/cameras/camera_qcom.h
selfdrive/camerad/cameras/debayer.cl
selfdrive/camerad/cameras/sensor_i2c.h
selfdrive/camerad/cameras/sensor2_i2c.h

selfdrive/camerad/transforms/rgb_to_yuv.cc
selfdrive/camerad/transforms/rgb_to_yuv.h
selfdrive/camerad/transforms/rgb_to_yuv.cl
selfdrive/camerad/transforms/rgb_to_yuv_test.cc

selfdrive/camerad/imgproc/conv.cl
selfdrive/camerad/imgproc/pool.cl
selfdrive/camerad/imgproc/utils.cc
selfdrive/camerad/imgproc/utils.h
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/camera_qcom.cc
system/camerad/cameras/camera_qcom.h
system/camerad/cameras/debayer.cl
system/camerad/cameras/sensor_i2c.h
system/camerad/cameras/sensor2_i2c.h

system/camerad/transforms/rgb_to_yuv.cc
system/camerad/transforms/rgb_to_yuv.h
system/camerad/transforms/rgb_to_yuv.cl
system/camerad/transforms/rgb_to_yuv_test.cc

system/camerad/imgproc/conv.cl
system/camerad/imgproc/pool.cl
system/camerad/imgproc/utils.cc
system/camerad/imgproc/utils.h

selfdrive/manager/__init__.py
selfdrive/manager/build.py
Expand Down
6 changes: 3 additions & 3 deletions release/files_tici
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ system/timezoned.py
selfdrive/assets/navigation/*
selfdrive/assets/training_wide/*

selfdrive/camerad/cameras/camera_qcom2.cc
selfdrive/camerad/cameras/camera_qcom2.h
selfdrive/camerad/cameras/real_debayer.cl
system/camerad/cameras/camera_qcom2.cc
system/camerad/cameras/camera_qcom2.h
system/camerad/cameras/real_debayer.cl

selfdrive/ui/qt/spinner_larch64
selfdrive/ui/qt/text_larch64
2 changes: 1 addition & 1 deletion selfdrive/athena/athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def getNetworks():

@dispatcher.add_method
def takeSnapshot():
from selfdrive.camerad.snapshot.snapshot import jpeg_write, snapshot
from system.camerad.snapshot.snapshot import jpeg_write, snapshot
ret = snapshot()
if ret is not None:
def b64jpeg(x):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/loggerd/loggerd.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "cereal/services.h"
#include "cereal/visionipc/visionipc.h"
#include "cereal/visionipc/visionipc_client.h"
#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"
#include "common/params.h"
#include "common/swaglog.h"
#include "common/timing.h"
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/manager/process_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def logging(started, params, CP: car.CarParams) -> bool:
procs = [
DaemonProcess("manage_athenad", "selfdrive.athena.manage_athenad", "AthenadPid"),
# due to qualcomm kernel bugs SIGKILLing camerad sometimes causes page table corruption
NativeProcess("camerad", "selfdrive/camerad", ["./camerad"], unkillable=True, callback=driverview),
NativeProcess("camerad", "system/camerad", ["./camerad"], unkillable=True, callback=driverview),
NativeProcess("clocksd", "system/clocksd", ["./clocksd"]),
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], enabled=(not PC or WEBCAM), callback=driverview),
NativeProcess("logcatd", "system/logcatd", ["./logcatd"]),
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/test/process_replay/test_debayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def unbzip_frames(url):
def init_kernels(frame_offset=0):
ctx = cl.create_some_context(interactive=False)

with open(os.path.join(BASEDIR, 'selfdrive/camerad/cameras/real_debayer.cl')) as f:
with open(os.path.join(BASEDIR, 'system/camerad/cameras/real_debayer.cl')) as f:
build_args = ' -cl-fast-relaxed-math -cl-denorms-are-zero -cl-single-precision-constant' + \
f' -DFRAME_STRIDE={FRAME_STRIDE} -DRGB_WIDTH={FRAME_WIDTH} -DRGB_HEIGHT={FRAME_HEIGHT} -DFRAME_OFFSET={frame_offset} -DCAM_NUM=0'
if PC:
build_args += ' -DHALF_AS_FLOAT=1 -cl-std=CL2.0'
debayer_prg = cl.Program(ctx, f.read()).build(options=build_args)

with open(os.path.join(BASEDIR, 'selfdrive/camerad/transforms/rgb_to_yuv.cl')) as f:
with open(os.path.join(BASEDIR, 'system/camerad/transforms/rgb_to_yuv.cl')) as f:
build_args = f' -cl-fast-relaxed-math -cl-denorms-are-zero -DWIDTH={FRAME_WIDTH} -DHEIGHT={FRAME_HEIGHT}' + \
f' -DUV_WIDTH={UV_WIDTH} -DUV_HEIGHT={UV_HEIGHT} -DRGB_STRIDE={FRAME_WIDTH*3}' + \
f' -DRGB_SIZE={FRAME_WIDTH*FRAME_HEIGHT}'
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/qt/widgets/cameraview.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QOpenGLWidget>
#include <QThread>
#include "cereal/visionipc/visionipc_client.h"
#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"
#include "selfdrive/ui/ui.h"

const int FRAME_BUFFER_SIZE = 5;
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/replay/logreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#endif

#include "cereal/gen/cpp/log.capnp.h"
#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"
#include "selfdrive/ui/replay/filereader.h"

const CameraType ALL_CAMERAS[] = {RoadCam, DriverCam, WideRoadCam};
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"

#include <unistd.h>

Expand All @@ -10,7 +10,7 @@
#include "libyuv.h"
#include <jpeglib.h>

#include "selfdrive/camerad/imgproc/utils.h"
#include "system/camerad/imgproc/utils.h"
#include "common/clutil.h"
#include "common/modeldata.h"
#include "common/swaglog.h"
Expand All @@ -19,12 +19,12 @@

#ifdef QCOM
#include "CL/cl_ext_qcom.h"
#include "selfdrive/camerad/cameras/camera_qcom.h"
#include "system/camerad/cameras/camera_qcom.h"
#elif QCOM2
#include "CL/cl_ext_qcom.h"
#include "selfdrive/camerad/cameras/camera_qcom2.h"
#include "system/camerad/cameras/camera_qcom2.h"
#else
#include "selfdrive/camerad/test/camera_test.h"
#include "system/camerad/test/camera_test.h"
#endif

ExitHandler do_exit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "cereal/visionipc/visionbuf.h"
#include "cereal/visionipc/visionipc.h"
#include "cereal/visionipc/visionipc_server.h"
#include "selfdrive/camerad/transforms/rgb_to_yuv.h"
#include "system/camerad/transforms/rgb_to_yuv.h"
#include "common/mat.h"
#include "common/queue.h"
#include "common/swaglog.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/cameras/camera_qcom.h"
#include "system/camerad/cameras/camera_qcom.h"

#include <fcntl.h>
#include <poll.h>
Expand All @@ -14,11 +14,11 @@
#include <cutils/properties.h>
#include <linux/media.h>

#include "selfdrive/camerad/cameras/sensor_i2c.h"
#include "selfdrive/camerad/include/msm_cam_sensor.h"
#include "selfdrive/camerad/include/msmb_camera.h"
#include "selfdrive/camerad/include/msmb_isp.h"
#include "selfdrive/camerad/include/msmb_ispif.h"
#include "system/camerad/cameras/sensor_i2c.h"
#include "system/camerad/include/msm_cam_sensor.h"
#include "system/camerad/include/msmb_camera.h"
#include "system/camerad/include/msmb_isp.h"
#include "system/camerad/include/msmb_ispif.h"
#include "selfdrive/common/clutil.h"
#include "selfdrive/common/params.h"
#include "selfdrive/common/swaglog.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

#include "cereal/messaging/messaging.h"
#include "cereal/visionipc/visionbuf.h"
#include "selfdrive/camerad/cameras/camera_common.h"
#include "selfdrive/camerad/imgproc/utils.h"
#include "selfdrive/camerad/include/msm_cam_sensor.h"
#include "selfdrive/camerad/include/msmb_camera.h"
#include "selfdrive/camerad/include/msmb_isp.h"
#include "selfdrive/camerad/include/msmb_ispif.h"
#include "system/camerad/cameras/camera_common.h"
#include "system/camerad/imgproc/utils.h"
#include "system/camerad/include/msm_cam_sensor.h"
#include "system/camerad/include/msmb_camera.h"
#include "system/camerad/include/msmb_isp.h"
#include "system/camerad/include/msmb_ispif.h"
#include "selfdrive/common/mat.h"
#include "selfdrive/common/util.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/cameras/camera_qcom2.h"
#include "system/camerad/cameras/camera_qcom2.h"

#include <fcntl.h>
#include <poll.h>
Expand All @@ -20,7 +20,7 @@
#include "media/cam_sensor_cmn_header.h"
#include "media/cam_sync.h"
#include "common/swaglog.h"
#include "selfdrive/camerad/cameras/sensor2_i2c.h"
#include "system/camerad/cameras/sensor2_i2c.h"

// For debugging:
// echo "4294967295" > /sys/module/cam_debug_util/parameters/debug_mdl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <media/cam_req_mgr.h>

#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"
#include "common/util.h"

#define FRAME_BUF_COUNT 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/cameras/camera_replay.h"
#include "system/camerad/cameras/camera_replay.h"

#include <cassert>
#include <thread>
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.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/imgproc/utils.h"
#include "system/camerad/imgproc/utils.h"

#include <algorithm>
#include <cassert>
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.
2 changes: 1 addition & 1 deletion selfdrive/camerad/main.cc → system/camerad/main.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"

#include <cassert>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion selfdrive/camerad/snapshot/snapshot.py → system/camerad/snapshot/snapshot.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from selfdrive.controls.lib.alertmanager import set_offroad_alert
from selfdrive.manager.process_config import managed_processes

LM_THRESH = 120 # defined in selfdrive/camerad/imgproc/utils.h
LM_THRESH = 120 # defined in system/camerad/imgproc/utils.h

VISION_STREAMS = {
"roadCameraState": VisionStreamType.VISION_STREAM_RGB_ROAD,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cstring>

#include "common/util.h"
#include "selfdrive/camerad/cameras/camera_common.h"
#include "system/camerad/cameras/camera_common.h"

int main() {
// set up fake camerabuf
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.
2 changes: 1 addition & 1 deletion selfdrive/camerad/test/test_exposure.py → system/camerad/test/test_exposure.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np

from selfdrive.test.helpers import with_processes
from selfdrive.camerad.snapshot.snapshot import get_snapshots
from system.camerad.snapshot.snapshot import get_snapshots

from system.hardware import EON, TICI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "selfdrive/camerad/transforms/rgb_to_yuv.h"
#include "system/camerad/transforms/rgb_to_yuv.h"

#include <cassert>
#include <cstdio>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <CL/cl.h>

#include "libyuv.h"
#include "selfdrive/camerad/transforms/rgb_to_yuv.h"
#include "system/camerad/transforms/rgb_to_yuv.h"
#include "common/clutil.h"

static inline double millis_since_boot() {
Expand Down
4 changes: 2 additions & 2 deletions tools/webcam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ git clone https://github.com/commaai/openpilot.git
```
cd ~/openpilot
```
- check out selfdrive/camerad/cameras/camera_webcam.cc lines 72 and 146 before building if any camera is upside down
- check out system/camerad/cameras/camera_webcam.cc lines 72 and 146 before building if any camera is upside down
```
USE_WEBCAM=1 scons -j$(nproc)
```

## Connect the hardware
- Connect the road facing camera first, then the driver facing camera
- (default indexes are 1 and 2; can be modified in selfdrive/camerad/cameras/camera_webcam.cc)
- (default indexes are 1 and 2; can be modified in system/camerad/cameras/camera_webcam.cc)
- Connect your computer to panda

## GO
Expand Down

0 comments on commit ce60ff7

Please sign in to comment.