-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
camerad fails to start when trying to use webcam with openpilot on Ubuntu #34197
Comments
I would not expect this to work easily on WSL2, because host-attached USB devices are not passed through to WSL like they might be for traditional hypervisors like VMware Workstation. There's some workarounds with USB-over-IP, but setting it up is an extremely manual process that I'm not sure anyone has attempted with openpilot, and I'm not sure how well it would work with high-bandwidth devices like cameras. All that said, I'm leaving this bug open because webcam does look legitimately broken on baremetal Ubuntu. I was able to reproduce the described issue. I instrumented process.py to tell me what it was executing: diff --git a/system/manager/process.py b/system/manager/process.py
index 0e9c9b980..31a54a1b3 100644
--- a/system/manager/process.py
+++ b/system/manager/process.py
@@ -53,6 +53,7 @@ def nativelauncher(pargs: list[str], cwd: str, name: str) -> None:
# exec the process
os.chdir(cwd)
+ print(f"{cwd=} {pargs}")
os.execvp(pargs[0], pargs) Which obtained the following result:
The error comes from trying to start TL;DR: Don't use WSL2, but this is a real bug anyway. |
Thanks @jyoung8607 for digging in! Indeed getting USB cameras working on WSL2 was a big pain. It involved both:
Keep me posted if you make any more progress, I'll time-box poking around at this and if I can't get it going by the evening I'll find another issue to pick up. |
I may have made progress with The issue I have is:
Any idea how to resolve this? Looks maybe to be OpenCL-related and the error doesn't appear in the output shared above! To install OpenCL I downloaded and ran what was recommended by the readme. Potentially useful info for the root cause of the
|
I come across the same issue,which can be solved by running tools/webcam/start_camerad.sh first. In the bash script, the right number for the environment variables of each camera should be specified. Pay attention to the problem that the index number of /dev/video may change each time the camera is plugged. |
I had noticed that, specifically the @MikeBusuttil: Give that a try, and if you find a working path, feel free to file PRs against the README or anything else necessary to make this easier for new users. |
Tried it on 2 machines with different failures. Ubuntu 24.04 on old Dell i5 Laptop:(openpilot) willow@willow-Latitude-E5450:~/openpilot$ tools/webcam/start_camerad.sh
Traceback (most recent call last):
File "/home/willow/openpilot/tools/webcam/camerad.py", line 74, in <module>
main()
File "/home/willow/openpilot/tools/webcam/camerad.py", line 69, in main
camerad = Camerad()
^^^^^^^^^
File "/home/willow/openpilot/tools/webcam/camerad.py", line 33, in __init__
self.vipc_server.create_buffers(c.stream_type, 20, False, cam.W, cam.H)
File "msgq_repo/msgq/visionipc/visionipc_pyx.pyx", line 65, in msgq.visionipc.visionipc_pyx.VisionIpcServer.create_buffers
def create_buffers(self, VisionStreamType tp, size_t num_buffers, size_t width, size_t height):
TypeError: create_buffers() takes exactly 4 positional arguments (5 given)
terminate called after throwing an instance of 'std::system_error'
what(): Invalid argument
tools/webcam/start_camerad.sh: line 14: 3803 Aborted (core dumped) $DIR/camerad.py which is what I'd expect given the create_buffers interface void VisionIpcServer::create_buffers(VisionStreamType type, size_t num_buffers, size_t width, size_t height){ so I removed the 3rd argument from the offending line to make it now self.vipc_server.create_buffers(c.stream_type, 20, cam.W, cam.H) which results in (openpilot) willow@willow-Latitude-E5450:~/openpilot$ tools/webcam/start_camerad.sh
Traceback (most recent call last):
File "/home/willow/openpilot/tools/webcam/camerad.py", line 74, in <module>
main()
File "/home/willow/openpilot/tools/webcam/camerad.py", line 69, in main
camerad = Camerad()
^^^^^^^^^
File "/home/willow/openpilot/tools/webcam/camerad.py", line 28, in __init__
cam = Camera(c.msg_name, c.stream_type, c.cam_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/willow/openpilot/openpilot/tools/webcam/camera.py", line 13, in __init__
self.container = av.open("/dev/video0")
^^^^^^^^^^^^^^^^^^^^^^
File "av/container/core.pyx", line 420, in av.container.core.open
File "av/container/core.pyx", line 266, in av.container.core.Container.__cinit__
File "av/container/core.pyx", line 286, in av.container.core.Container.err_check
File "av/error.pyx", line 326, in av.error.err_check
av.error.OSError: [Errno 16] Device or resource busy: '/dev/video0'
terminate called after throwing an instance of 'std::system_error'
what(): Invalid argument
tools/webcam/start_camerad.sh: line 14: 3586 Aborted (core dumped) $DIR/camerad.py But WSL Ubuntu 24.04 on Dell XPS 17I can't get
despite having my environment setup properly (I thought) Will continue poking at 🤞 |
Got it working here, I think. To make sure you find your camera devices:
For me, on baremetal Ubuntu with my built-in camera and a single external Logitech Brio just for testing:
The multiple devices appear to be for metadata or IR capabilities for Windows Hello and the like. Then:
With the minimal fixes in #34211, This is, of course, not super awesome from a usability perspective. We should probably put some thought into making this Not Suck. We could put what we have in the README, but I think that |
Good stuff @jyoung8607 💪 Here's the draft PR to squash this bug: #34215 Will ping you when it's ready to rock |
Describe the bug
Following the steps in the webcam readme and running
NOSENSOR=1 USE_WEBCAM=1 system/manager/manager.py
appears to work. UI loads and all green in console:but then results in the following when pressing the
Driver Camera
Preview
button in the UI (redcamerad
anddmonitoringmodeld
in console):OS Version
Ubuntu 24.04
openpilot version or commit
57fc4f7
Additional info
system/camerad/cameras/camera_webcam.cc
which no longer exists.The text was updated successfully, but these errors were encountered: