fubarlabs / foocars

Low Cost Racing Autonomous Vehicles: RC Cars to Power Wheels Racers
https://foocars.io
13 stars 14 forks source link

Running Docker and accessing the camera causes an error #97

Open ricklon opened 3 years ago

ricklon commented 3 years ago

Running Docker and accessing the camera causes an error. This error was fixed for running in Chi@Edge with the following line: device_profiles=["pi_camera"],

error.txt

root@80c023b09f3d:/foocars/cars/carservices# poetry run car_runner
Skipping virtualenv creation, as specified in config file.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/foocars/cars/carservices/carservices/carRunner.py", line 5, in <module>
    import picamera
  File "/usr/local/lib/python3.9/site-packages/picamera/__init__.py", line 72, in <module>
    from picamera.exc import (
  File "/usr/local/lib/python3.9/site-packages/picamera/exc.py", line 41, in <module>
    import picamera.mmal as mmal
  File "/usr/local/lib/python3.9/site-packages/picamera/mmal.py", line 47, in <module>
    from .bcm_host import VCOS_UNSIGNED
  File "/usr/local/lib/python3.9/site-packages/picamera/bcm_host.py", line 47, in <module>
    _lib = ct.CDLL('libbcm_host.so')
  File "/usr/local/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libbcm_host.so: cannot open shared object file: No such file or directory
ricklon commented 3 years ago

I found a decent article on the topic. It might help: https://www.losant.com/blog/how-to-access-the-raspberry-pi-camera-in-docker

ricklon commented 3 years ago

sudo vim /etc/udev/rules.d/99-camera.rules

Add: SUBSYSTEM=="vchiq",MODE="0666"

Access the device in Docker this way: --device /dev/vchiq

Example: docker run --rm --device /dev/vchiq -it --entrypoint=/bin/bash rianders/car:ec807b5

ricklon commented 3 years ago

Update: docker run --rm --device /dev/vchiq -v /opt/vc:/opt/vc --env LD_LIBRARY_PATH=/opt/vc/lib -it --entrypoint=/bin/bash rianders/car:ec807b5

This is not working so I might be thinking about this wrong.

ricklon commented 3 years ago

The library is still not found. What I found in the /opt/vc was nothing on the host machine. That's where this library is supposed to be for the camera on raspberry pi. How might I can the files in that spot?