Modifying python code for Picar-V

I have installed the picar-V (via github) software onto a raspberry pi 4 and setup a startup script for the django server in etc/rc.local on bootup. I want to make some enhancements to the python code but am unsure what source code to update. The *.py and *.pyc files seem to be scattered across multiple directories on the raspberry pi. So I am asking how to make python programing modifications and re-deploy. I am confused as to the multiple locations and copies of the various files.

Thank You


If you want to modify the content of the remote control part, you can modify

I want to add functions like sensors and I2C devices. I am trying to do this by modifying ~/SunFounder_PiCar-V/client/ Is this the correct place?

There are copies of the code scattered everywhere:

(And many more places)

When I modify SunFounder_PiCar-V/client/, it only works running in the python IDE (Thonny) and not when run as a service. I believe the actual binary is executed from some other place.

I have also checked $PATH and nothing referenced there.


To add sensors, the I2C device should be changed in ~/SunFounder_PiCar-V/remote_control/remote_control/. You can see that the run function in will run different functions under different actions. The code inside is to do the client, that is, the control page, it is not recommended to implement the sensor function on this.

OK, I did a simple test by changing the camdown action to cam.turn_up and it worked. I understand to update the to add/change actions. But if I want to write a new subroutine action and use it, or modify an existing subroutine, where do I put that NEW/Mod subroutine? Do I look in the ./driver folder?

Thank You

Not quite understand what subroutine refers to, can you give me an example? /driver is a library, that is, some relatively complex operations are abstracted out of a library and put into the driver, in order to simplify the code of the views.

I’m sorry, I wasn’t using the correct Python term. I meant writing a new class object (instead of ‘subroutine’) , like you did with the I think I have it figured out. Thank You!!!

1 Like

If I want to add another keystroke function, should that be added to the keyPressEvent in /home/pi/SunFounder_PiCar-V/

If you want to add a keypress function, you can add it to /home/pi/SunFounder_PiCar-V/ in the keyPressEvent.
The code can only be modified on the Raspberry Pi system terminal.

Thank you for the reply. In previous comments I was told to also make changes in ~/SunFounder_PiCar-V/remote_control/remote_control/ in for additional function. I have done that successfully. I used a text editor or Thonny python to make those edits.

But this time you say code can only be modifed on the Raspberry Pi system terminal. I don’t understand what you mean…???

I just used a text editor, but the changes are not taking effect.
When I change the file, the changes are immediate, but changes to are not. Is there an additional step required? I also rebooted the pi after my changes.

[[ I should also mention:
1) I have /home/pi/SunFounder_PiCar-V/remote_control/start script running automatically at raspberry pi boot.
2) I am using method B to invoke the client - http://:8000 ]]


code can only be modifed on the Raspberry Pi system terminal
It means that you need to modify the on the Raspberry Pi to change the not on your computer.

The http::8000 you are accessing is the web client and the code is in SunFounder_PiCar-V/remote_control/remote_control at master · sunfounder/SunFounder_PiCar-V · GitHub templates/templates is in html because it is a web page.

The is a separate pyqt program and has nothing to do with the server side. after the code is modified, just close the and run it again.

I am not running the on the PC. I only use the PC for the Web Browser to access http:8000.
Now I understand your comment about using Raspberry Pi system terminal. (If I was using the PC for the client).

So when strictly using the server (running on the Raspberry Pi), I would need to update the Run.html in template to add another key function.

Thank You for your help thus far!

1 Like

I would like to add data to the running_screen.ui. For example provide some real-time feedback to the webpage. If I have an ultrasonic range sensor, how could I display the current range from an object on the webpage?

Our engineers are already working on your problem and it will take some time to get back to you.

As I said before, the code for the web client is in the remote_control/remote_control, not the client folder.

You will also need knowledge of simple html, and use of the django library if you want to add some live data from sensors. The process is as follows:

  1. You need to add a function to get the ultrasonic data in the remote_control/remote_control/ file, written with reference to the run function, return returns the ultrasonic reading value
  2. in remote_control/remote_control/
    You need to modify the remote_control/remote_control/templates/templates/run.html file to add a tag that displays the data. Then add a timer under the script, and every once in a while, through the interface written above, get the ultrasound data and assign it to the tag that displays the data on the page.