Picar-x Sunfounder App

For Picar-x Raspberry PI 5
I assembled the car ok, but, there are a few issues.

  1. When I image a new storage card with the latest Picobricks code, the card will not boot.
  2. When I try the Sunfounder app, it will not connect. I have verified that both are on the same network and I can even connect via SSH on my phone. When I add the code and run the example, I get the following errors:
    ~/picar-x/example $ sudo python3 13.app_control.py
    vilib 0.3.8 launching …
    picamera2 0.3.22
    websocket server start at port 8765
    Traceback (most recent call last):
    File “/home/daryl/picar-x/example/13.app_control.py”, line 19, in
    px = Picarx()
    ^^^^^^^^
    File “/usr/local/lib/python3.11/dist-packages/picarx-2.0.3-py3.11.egg/picarx/picarx.py”, line 48, in init
    self.config_flie = fileDB(config, 777, os.getlogin())
    ^^^^^^^^^^^^^
    OSError: [Errno 6] No such device or address

Any help is greatly appreciated.

Hey there,

I don’t know the product nor anything about the code that comes along with it but I noticed a potential typo in your code.
Not sure if this was a copy/paste error or not but ….
self.config_flie shouldn’t that be file instead?

omg! never saw that!. And,when I go to edit the file, it has a lot of references that use flie. Will take a while to fix.
This is a big fail on Sunfounder. And I have to wonder, what else is wrong. They need to first fix their documents.

After fixing the typos, I get this now when running the same command;

~/picar-x/example $ sudo python3 13.app_control.py
vilib 0.3.8 launching …
picamera2 0.3.22
websocket server start at port 8765
Traceback (most recent call last):
File “/home/daryl/picar-x/example/13.app_control.py”, line 19, in
px = Picarx()
^^^^^^^^
File “/usr/local/lib/python3.11/dist-packages/picarx-2.0.3-py3.11.egg/picarx/picarx.py”, line 48, in init
self.config_file = fileDB(config, 777, os.getlogin())
^^^^^^^^^^^^^
OSError: [Errno 6] No such device or address

Not sure if this helps, but something similar has been asked previously here…

What system are you currently using, and what version is it?
Did you encounter any errors while installing all the library code? If so, please provide a screenshot of the error to help us analyze and resolve the issue.

All modules installed just fine, no errors encountered
Here is my system; output of uname -a Linux darylpi 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt2 (2024-10-01) aarch64 GNU/Linux

Also note, some of the examples work just fine, like moving etc. However, the camera isn’t working;

sudo python3 7.display.py
vilib 0.3.8 launching …
picamera2 0.3.22
Local display failed, because there is no gui.

Web display on:Exception in thread vilib:

Traceback (most recent call last):
File “/usr/lib/python3.11/threading.py”, line 1038, in _bootstrap_inner
self.run()
File “/usr/lib/python3.11/threading.py”, line 975, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/lib/python3.11/dist-packages/vilib-0.3.8-py3.11.egg/vilib/vilib.py”, line 229, in camera
picam2 = Picamera2()
^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/picamera2/picamera2.py”, line 257, in init
camera_num = self.global_camera_info()[camera_num][‘Num’]

IndexError: list index out of range
[http://10.1.10.193:9000/mjpg](http://10.1.10.193:9000/mjpg)

Starting web streaming ...

Input key to call the function!
q: Take photo
1: Color detect : red
2: Color detect : orange
3: Color detect : yellow
4: Color detect : green
5: Color detect : blue
6: Color detect : purple
0: Switch off Color detect
r: Scan the QR code
f: Switch ON/OFF face detect
s: Display detected object information

* Serving Flask app 'vilib.vilib'
* Debug mode: off
Traceback (most recent call last):
File "/home/daryl/picar-x/example/[7.display.py](http://7.display.py)", line 134, in <module>
main()
File "/home/daryl/picar-x/example/[7.display.py](http://7.display.py)", line 98, in main
take_photo()
File "/home/daryl/picar-x/example/[7.display.py](http://7.display.py)", line 60, in take_photo
Vilib.take_photo(name, path)
File "/usr/local/lib/python3.11/dist-packages/vilib-0.3.8-py3.11.egg/vilib/vilib.py", line 415, in take_photo
status = cv2.imwrite(path + '/' + photo_name +'.jpg', Vilib.img)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'imwrite'

We recommend that you reinstall the vilib library using the following commands:

cd ~/vilib
git pull
sudo python3 install.py

Please pay close attention to any error messages during the installation process. If you encounter any errors, kindly provide us with screenshots.

Run the command libcamera-hello to test the camera and send us the printed information for analysis.

Please check the camera wiring to ensure it is correct. We also suggest providing images of the camera connections for our review.

~/vilib $ git pull
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 34 (delta 19), reused 34 (delta 19), pack-reused 0 (from 0)
Unpacking objects: 100% (34/34), 18.89 KiB | 1.35 MiB/s, done.
From https://github.com/sunfounder/vilib

  • [new branch] multiPool → origin/multiPool
    Already up to date.

~/vilib $ libcamera-hello
[0:03:02.891092671] [2284] INFO Camera camera_manager.cpp:325 libcamera v0.3.2+ 27-7330f29b
[0:03:02.898670264] [2290] INFO RPI pisp.cpp:695 libpisp version v1.0.7 28196ed 6edcf 29-08-2024 (16:33:32)
[0:03:02.915931716] [2290] INFO RPI pisp.cpp:1154 Registered camera /base/axi/p cie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media2 and ISP device /dev /media0 using PiSP variant BCM2712_C0
Preview window unavailable
Mode selection for 1296:972:12:P
SGBRG10_CSI2P,640x480/0 - Score: 3296
SGBRG10_CSI2P,1296x972/0 - Score: 1000
SGBRG10_CSI2P,1920x1080/0 - Score: 1349.67
SGBRG10_CSI2P,2592x1944/0 - Score: 1567
Stream configuration adjusted
[0:03:02.917480541] [2284] INFO Camera camera.cpp:1197 configuring streams: (0) 1296x972-YUV420 (1) 1296x972-GBRG_PISP_COMP1
[0:03:02.917608919] [2290] INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000 /rp1/i2c@80000/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selec ted CFE format: 1296x972-PC1g
#0 (0.00 fps) exp 33222.00 ag 7.56 dg 1.06
#1 (30.01 fps) exp 33222.00 ag 7.62 dg 1.05
#2 (30.00 fps) exp 33222.00 ag 7.62 dg 1.05
#3 (30.01 fps) exp 33222.00 ag 7.81 dg 1.02
#4 (30.01 fps) exp 33222.00 ag 7.81 dg 1.02
#5 (30.01 fps) exp 33222.00 ag 7.88 dg 1.02
#6 (30.01 fps) exp 33222.00 ag 7.94 dg 1.01
#7 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#8 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#9 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00
#10 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00

.
.
.

#141 (30.02 fps) exp 33222.00 ag 8.00 dg 1.00

This camera test code worked and produced an image within VNC;
from picamera2 import Picamera2, Preview
import time
picam2 = Picamera2()
camera_config = picam2.create_preview_configuration()
picam2.configure(camera_config)
picam2.start_preview(Preview.QTGL)
picam2.start()
time.sleep(2)
picam2.capture_file(“test.jpg”)

So, with the fixes to the typos in picarx.py the camera is now working.
However, the Sunfounder App for Android (Galaxy s23) won’t connect. Both are on the same LAN and I can connect to the Raspberry PI via an SSH app on the phone.

Suggest you provide a video of the issue to help us analyze and resolve it.

If the video file is large, please upload it to OneDrive and share the link with us, along with access permissions.

Not sure how, but, I can successfully connect to the app.
However, there is no ‘Picar-x’ applet. So, I don’t know what widgets to add and their values.
I did try the other car applet, but, got this error;

/picar-x/example $ sudo python3 13.app_control.py
vilib 0.3.8 launching …
picamera2 0.3.22
websocket server start at port 8765
ip : 10.1.10.193

Web display on:
client (0, ‘10.1.10.85’) conneted
http://10.1.10.193:9000/mjpg

Starting web streaming …

  • Serving Flask app ‘vilib.vilib’
  • Debug mode: off
    stop and exit
    camera close
    Traceback (most recent call last):
    File “/home/daryl/picar-x/example/13.app_control.py”, line 207, in
    main()
    File “/home/daryl/picar-x/example/13.app_control.py”, line 183, in main
    pan = min(90, max(-90, Joystick_Q_Val[0]))
TypeError: 'int' object is not subscriptable

After successfully connecting to the app, click on “Create Remote.” In the presets section, you can swipe to the right to see the PiCar-X preset templates. Just click on “Use” to proceed.

Please refer to the video for more details.