Openpilot webcam support improved (#34215)

* control webcam with ENV vars

* WIP: actual instructions

* wording

* file no longer exists

* this is expected behavior, just untested

* more readable

* tested on fresh install

* wording tweaks

* explicit USE_WEBCAM toggle required

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* debug-ability improved

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* newline removed

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/34293/head
Mike Busuttil 4 months ago committed by GitHub
parent 9f3c2f0a37
commit 7a72e419fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      system/manager/process_config.py
  2. 28
      tools/webcam/README.md
  3. 15
      tools/webcam/camerad.py
  4. 14
      tools/webcam/start_camerad.sh

@ -63,7 +63,8 @@ def and_(*fns):
procs = [
DaemonProcess("manage_athenad", "system.athena.manage_athenad", "AthenadPid"),
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview),
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview, enabled=not WEBCAM),
PythonProcess("webcamerad", "tools.webcam.camerad", driverview, enabled=WEBCAM),
NativeProcess("logcatd", "system/logcatd", ["./logcatd"], only_onroad),
NativeProcess("proclogd", "system/proclogd", ["./proclogd"], only_onroad),
PythonProcess("logmessaged", "system.logmessaged", always_run),
@ -71,7 +72,7 @@ procs = [
PythonProcess("timed", "system.timed", always_run, enabled=not PC),
# TODO Make python process once TG allows opening QCOM from child proc
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], driverview, enabled=(not PC or WEBCAM)),
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], driverview, enabled=(WEBCAM or not PC)),
NativeProcess("encoderd", "system/loggerd", ["./encoderd"], only_onroad),
NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], notcar),
NativeProcess("loggerd", "system/loggerd", ["./loggerd"], logging),
@ -89,7 +90,7 @@ procs = [
PythonProcess("selfdrived", "selfdrive.selfdrived.selfdrived", only_onroad),
PythonProcess("card", "selfdrive.car.card", only_onroad),
PythonProcess("deleter", "system.loggerd.deleter", always_run),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(not PC or WEBCAM)),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(WEBCAM or not PC)),
PythonProcess("qcomgpsd", "system.qcomgpsd.qcomgpsd", qcomgps, enabled=TICI),
PythonProcess("pandad", "selfdrive.pandad.pandad", always_run),
PythonProcess("paramsd", "selfdrive.locationd.paramsd", only_onroad),

@ -1,7 +1,7 @@
# Run openpilot with webcam on PC
What's needed:
- Ubuntu 24.04
- Ubuntu 24.04 ([WSL2 is not supported](https://github.com/commaai/openpilot/issues/34216))
- GPU (recommended)
- Two USB webcams, at least 720p and 78 degrees FOV (e.g. Logitech C920/C615)
- [Car harness](https://comma.ai/shop/products/comma-car-harness) with black panda to connect to your car
@ -9,29 +9,27 @@ What's needed:
That's it!
## Setup openpilot
- Follow [this readme](../README.md) to install and build the requirements
- Install OpenCL Driver
```
cd ~
git clone https://github.com/commaai/openpilot.git
```
- Follow [this readme](https://github.com/commaai/openpilot/tree/master/tools) to install the requirements
- Install [OpenCL Driver](https://registrationcenter-download.intel.com/akdlm/irc_nas/vcp/15532/l_opencl_p_18.1.0.015.tgz)
## Build openpilot for webcam
```
cd ~/openpilot
USE_WEBCAM=1 scons -j$(nproc)
sudo apt install pocl-opencl-icd
```
## Connect the hardware
- Connect the road facing camera first, then the driver facing camera
- (default indexes are 1 and 2; can be modified in system/camerad/cameras/camera_webcam.cc)
- Connect your computer to panda
## GO
```
cd ~/openpilot/system/manager
NOSENSOR=1 USE_WEBCAM=1 ./manager.py
USE_WEBCAM=1 system/manager/manager.py
```
- Start the car, then the UI should show the road webcam's view
- Adjust and secure the webcams (you can run tools/webcam/front_mount_helper.py to help mount the driver camera)
- Adjust and secure the webcams.
- Finish calibration and engage!
## Specify Cameras
Use the `ROAD_CAM`, `DRIVER_CAM`, and optional `WIDE_CAM` environment variables to specify which camera is which (ie. `DRIVER_CAM=2` uses `/dev/video2` for the driver-facing camera):
```
USE_WEBCAM=1 ROAD_CAM=4 WIDE_CAM=6 system/manager/manager.py
```

@ -9,14 +9,14 @@ from cereal import messaging
from openpilot.tools.webcam.camera import Camera
from openpilot.common.realtime import Ratekeeper
DUAL_CAM = os.getenv("DUAL_CAMERA")
WIDE_CAM = os.getenv("WIDE_CAM")
CameraType = namedtuple("CameraType", ["msg_name", "stream_type", "cam_id"])
CAMERAS = [
CameraType("roadCameraState", VisionStreamType.VISION_STREAM_ROAD, os.getenv("CAMERA_ROAD_ID", "/dev/video0")),
CameraType("driverCameraState", VisionStreamType.VISION_STREAM_DRIVER, os.getenv("CAMERA_DRIVER_ID", "/dev/video1")),
CameraType("roadCameraState", VisionStreamType.VISION_STREAM_ROAD, os.getenv("ROAD_CAM", "0")),
CameraType("driverCameraState", VisionStreamType.VISION_STREAM_DRIVER, os.getenv("DRIVER_CAM", "2")),
]
if DUAL_CAM:
CAMERAS.append(CameraType("wideRoadCameraState", VisionStreamType.VISION_STREAM_WIDE_ROAD, DUAL_CAM))
if WIDE_CAM:
CAMERAS.append(CameraType("wideRoadCameraState", VisionStreamType.VISION_STREAM_WIDE_ROAD, WIDE_CAM))
class Camerad:
def __init__(self):
@ -25,8 +25,9 @@ class Camerad:
self.cameras = []
for c in CAMERAS:
print(f"opening {c.msg_name} at {c.cam_id}")
cam = Camera(c.msg_name, c.stream_type, c.cam_id)
cam_device = f"/dev/video{c.cam_id}"
print(f"opening {c.msg_name} at {cam_device}")
cam = Camera(c.msg_name, c.stream_type, cam_device)
self.cameras.append(cam)
self.vipc_server.create_buffers(c.stream_type, 20, cam.W, cam.H)

@ -1,14 +0,0 @@
#!/usr/bin/env bash
# export the block below when call manager.py
export BLOCK="${BLOCK},camerad"
export USE_WEBCAM="1"
# Change camera index according to your setting
export CAMERA_ROAD_ID="/dev/video0"
export CAMERA_DRIVER_ID="/dev/video1"
#export DUAL_CAMERA="/dev/video2" # optional, camera index for wide road camera
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
$DIR/camerad.py
Loading…
Cancel
Save