sunfounder / SunFounder_PiCar-V

Smart Video Car Kit V2.0 for Raspberry Pi from SunFounder
GNU General Public License v2.0
111 stars 175 forks source link

Remote Control - Import Errors for cam, fw and bw #53

Open axi0m opened 3 years ago

axi0m commented 3 years ago

I have run the ./install_dependencies shell script under the folder SunFounder_PiCar-V

pi@raspberrypi:~ $ ls -l SunFounder_PiCar-V/
total 56
drwxr-xr-x 2 pi pi  4096 Nov 13 16:01 ball_track
drwxr-xr-x 2 pi pi  4096 Nov 13 16:01 datasheet
drwxr-xr-x 2 pi pi  4096 Nov 13 16:01 docs
-rw-r--r-- 1 pi pi  3740 Nov 13 16:01 i2cHelper.py
-rw-r--r-- 1 pi pi     0 Nov 13 16:01 __init__.py
-rwxr-xr-x 1 pi pi  5219 Nov 13 17:48 install_dependencies
-rw-r--r-- 1 pi pi 15518 Nov 13 16:01 LICENSE
drwxr-xr-x 3 pi pi  4096 Nov 13 16:01 mjpg-streamer
-rw-r--r-- 1 pi pi  3536 Nov 13 16:01 README.md
drwxr-xr-x 4 pi pi  4096 Nov 17 17:34 remote_control
-rw-r--r-- 1 pi pi  1131 Nov 13 16:01 show

No errors were identified during the install script.

However when I navigate to /home/pi/SunFounder_PiCar-V/remote-control/ and run sudo ./start

I get the following tracebacks, the django UI is up and functioning but it seem the camera module isn't working and the wheels are not calibrating.

Internal Server Error: /run/
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/pi/SunFounder_PiCar-V/remote_control/remote_control/views.py", line 70, in run
    bw.ready()
NameError: name 'bw' is not defined
[17/Nov/2020 18:20:56] "GET /run/?action=bwready HTTP/1.1" 500 59969
Internal Server Error: /run/
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/pi/SunFounder_PiCar-V/remote_control/remote_control/views.py", line 87, in run
    fw.ready()
NameError: name 'fw' is not defined
[17/Nov/2020 18:20:57] "GET /run/?action=fwready HTTP/1.1" 500 59936
Internal Server Error: /run/
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/pi/SunFounder_PiCar-V/remote_control/remote_control/views.py", line 100, in run
    cam.ready()
NameError: name 'cam' is not defined
axi0m commented 3 years ago

Update: I purged all dependencies and started over from scratch.

Still had problems with numpy dependency, unable to import cv2?

Referenced this page: https://www.raspberrypi.org/forums/viewtopic.php?t=211859

Did the following: sudo apt install libatlas3-base libsz2 libharfbuzz0b libtiff5 libjasper1 libilmbase12 libopenexr22 libilmbase12 libgstreamer1.0-0 libavcodec57 libavformat57 libavutil55 libswscale4 libqtgui4 libqt4-test libqtcore4 sudo pip3 install opencv-contrib-python

I can at least see the camera output to the web interface after running sudo ./start but the controls for the wheels and camera servos don't seem to function via the webapp, no errors in the terminal but will dig into the dev console on brower and turn on debug logs in the django webapp later.

axi0m commented 3 years ago

Update2: I'm still unable to get the servos to react physically, I installed i2c-tools and can see the various boards at different i2c addresses. In addition I turned on all debug modes in several python files but there is no Django error. Far as I can tell the logs indicate that commands are received by Django API but no idea why the servos are not responding.

axi0m commented 3 years ago

Update3 If I plugin the 5.5V DC power (battery operated) while I run picar servo-install it functions, all the servos adjust to 90 degrees successfully. If I run the remote control wrapper sudo ./start all components function.

Question: If I run picar servo-install and then sudo ./start and disconnect from the micro USB power adapter and the batteries die, will I have to re-run picar servo-install? And if so, do I need to disassemble the entire front wheel assembly to unhook/unscrew all the servos each time the battery dies? My understanding reading the PDF guide, is the servo-install command must be run every time power to the PCA9685 controller is lost.

Thank you for your assistance