I have a rasparm robot by adeept it has a power electronics unit provided by the company and it is connected to raspberry pi3b+. adeept has online tutorial to run the robots and already written python files which we need to run in raspberry pi in order to make the robot run.
Its running when I am running the python codes in raspberry pi.
But when I am running the same codes in pc via MATLAB its not working. I am calling the python codes provided by adeept from MATLAB and trying to run it, it showing some errors. I have already instled all the libraries which was required to run the code.
I want to use adafruit_pca9865 library and call it with MATLAB and deploy the code to raspberry to make it running.
But when I am calling the python code to run servo from MATLAB i am getting the error shown in screenshot.
when I am trying to run python code directly then also I am getting this error. I have also installed proc and cpuinfo library and added to the folders required.
screenshot of error
Related
I'm trying to use the VS Code remote debug feature (debugpy).
My problem is that my code to connect needs to be the client and VS Code needs to be the server.
Why? Because I can't modify the command line of my python "container" (It's an embedded version of python into another process). So I simply want to execute a command in my py code, which, then, connects to my debug server that has been startet in VS Code.
Is that possible? I know that this works in PyCharm professional, but I can't get it done in VS Code.
Thanks!
I am developing a python application to run on a raspberry pi. Obviously, I can't run visual studio on my raspberry pi. Is there any way to set up my pi (running raspbian) to be the debugging target, so that on my windows machine (with vs) I can write the code and get the output, but the code executes on the pi?
I've used visual studio to debug apps running on android, so I'm looking for something similar, and I would like if it were real time, so that debugging features such as breakpoints worked as well.
Edit for clarification: This already exists for c# and others, just looking for this for python: https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging?view=vs-2019
can you use putty on your windows machine to ssh connect to raspberry pi and run you code that way. You could use notepad++ or geanie to write your code on windows first or open the editor nano on raspberry pi to write your code.
I have been struggling for a while trying to make a .py file start on a raspberry pi bootup. the file includes opencv, tensorflow and picamera usage. When i try to start the program at boot using different methods it wont start.
The methods i've tried are:
/etc/rc.local (both trying to start the program directly or a .sh script that boots the program itself)
/home/pi/.config/autostart (either starting directly the program with "Exec= '/usr/bin/python3 /pathtoprogram.py') (or using an extern program called "xterm" to try and boot up the program but it fails to start the program)
.bashrc with (sudo python3 /pathtoprogram.py)
I'm atually looking for new methods. the program boots perfectly when i start it myself on the raspberry pi.
Additional info:
my program is a modified version of this one: https://www.tomshardware.com/how-to/raspberry-pi-facial-recognition
using the picam version.
Try systemd:
https://www.raspberrypi.org/documentation/linux/usage/systemd.md
"In order to have a command or program run when the Pi boots, you can add it as a service. Once this is done, you can start/stop enable/disable from the linux prompt."
So, I want to be able to write Python code in my Visual Studio Code on my Windows PC. On my network is a raspberry pi 4, which I would like to execute said code on and receive any errors or output from.
Is it possible for me to write some python code on my Windows PC, "run" it on the Raspberry pi, and receive any outputs of the program on my Windows PC?
The reason I wish to do this is that Visual Studio Code generally helps me write any code, and it is more time consuming for me to use other IDE's, and my code uses PyBluez, something I can't just test on my Windows PC (which has no Bluetooth module)
I hope my question is in the right format and such! This is my first time posting! Any comments appreciated!
Yes you can do that, but it might not be very straight forward. In order to achieve this, you need your Raspberry Pi to be on the same network as your Windows PC (i.e. on the same WiFi network or connected via Ethernet). Then you need to get the IP address of your Raspberry Pi through the following command:-
ifconfig -a
The IP address will be of the following format: W.X.Y.Z
Now from your Windows PC, you can send your python script/scripts through the following command from cmd:-
scp script.py pi#W.X.Y.Z:/home/
And then you can access your Raspberry Pi and run the program by sshing into it through the following commands from cmd:-
ssh pi#W.X.Y.Z
You'll need to enter the Raspberry Pi's password for both commands above, but after that you should have your script on your Pi and you should be able to run it there from your Windows PC.
The links below have more verbose explanation:-
https://www.raspberrypi.org/documentation/remote-access/ip-address.md
https://www.raspberrypi.org/documentation/remote-access/ssh/scp.md
https://www.raspberrypi.org/documentation/remote-access/ssh/
I hope this helps.
It seems that my answer was to use the Remote Development pack on Visual Studio Code (it's an extension) to ssh into my raspberry pi. It's worked well for me for the past few days, and I highly recommend it. It allowed me to access the entire sd card and access any files I need to, while also giving me an SSH terminal and run the program ON the other machine.
For anyone who does this; set up the whole ssh key thing, to stop having to give the password to the pi so often.
The scp command would also work, I think, but is more complex than what I want to do.
Thank you so much for the answer, JL Peyret!
I'm running a simple Node.js script and within this I am calling an python script using the npm python-shell package. This is all running on a Raspberry Pi 3 model B+ (Raspbian Buster).
The python script is a hand gesture recognition algorithm for a Raspberry pi and I want to receive a message in the Node.js file as soon as a certain gesture has been detected (The python script I'm executing is found here: https://github.com/MaxLell/Gesberry-Control/blob/master/GesBerry_Pi/GCI_classify.py , I adjusted the code so it doesn't ask for keyboard inputs anymore). The python script includes a while true: loop, as it is constantly scanning for gestures. For debugging, I set a print statement in every while loop iteration and it shows that when executing the python script from Node.js, the loop iterations are much slower than if I just execute the python script from the command line. Also, it seems that the iterations become slower and slower the longer I keep the script running from Node.js. The code I am using on the Node.js side is according to the python-shell documentation:
let {PythonShell} = require('python-shell');
let pyshell = new PythonShell('my_script.py');
pyshell.on('message', function (message) {
console.log(message);
});
Does anybody know why this is happening and how to fix it?