Raspberry Pi: Running Vision Code

Hi there,
Our team is using a raspberry pi for vision and we need to run our vision code and send values to our robot through network tables. How can we start the python code on the pi as soon as our robot starts or autonomous starts running?
Note: We are not using frc’s linux image as we were unable to install it


I would seriously recommend using the FRCVision image if you’re using a Raspberry Pi, as it drastically simplifies the setup required.

Otherwise, probably the simplest distribution to get running on a Raspberry Pi with a prebuilt robotpy-cscore package is Fedora. You could then write a systemd service like my team did last year.

I would highly recommend using the FRC Vision image as well. http://wpilib.screenstepslive.com/s/currentCS/m/85074/c/279377

We deploy to the Raspberry Pi using Gradle with the 2019 GradleRIO plugin and the FRC Vision image. In deploy you can set a target:

targets {
    target('frcvision') {
        directory = '/home/myuser'  
        locations {
            ssh {
                address = "address"
                user = "pi"            
                password = "raspberry"               

and then add the artifacts:

artifacts {
    fileTreeArtifact("fileTreeGoesHere") {
        targets << "frcvision"
        files = fileTree(dir: "src") // file directory to be deployed

        predeploy << {
            execute("sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot")

        postdeploy << {
            execute("chmod +x main.py")
            execute("rm -f /home/pi/runCamera")
            execute("ln -s /home/pi/myuser/resources/runCamera /home/pi/runCamera")

This sets the the RPi to read/write before the deploy, then after the deploy, the script executes the commands in postdeploy.


What issue did you run into?

Your Pi should power on and autologon when it is powered. You can setup a crontab job to automatically start your scripts on reboot. For my slightly different situation (I’m using a Jetson, not a raspberry pi), I’m using the following crontab job to start my scripts:

@reboot sleep 10 && cd /home/nvidia/GnomeVision && ./scripts/leftcam.sh 2> leftcamerr.out && ./scripts/rightcam.sh 2> rightcamerr.out && ./GnomeVisionTest.sh > gnomevision.out 2> gnomeerror.out

The sleep allows the processes to stabilize, and I’m running three scritps for left/right cameras and the main camera with vision processing.

Let me know if this helps

While running the image for the first time, we are unable to connect to frcvision.local/ and we went on this link on the computer the raspberry pi is connected to

There can be many reasons for this. How are you connected to the Pi? Do you have a mDNS responder installed? (iTunes, or NI update suite) If you’re connected point-to-point with Ethernet, what’s the IP address showing up on your computer?

Our pi was connected to the computer using ethernet. There was no ip address showing up on our computer. mDNS responder on the Pi or the computer?

On the computer. No IP address on the computer for the ethernet means that it’s not seeing an Ethernet connection. Have you tried hooking up a HDMI monitor to the Pi to see that it’s booting okay?

ya we’ve connected to an hdmi everytime and it boots with the wifi country being disabled. What do you mean by ip address showing up on computer?

If you go to a command prompt and type ipconfig /all, what’s the output shown for your Ethernet adapter?

If you have a keyboard hooked up to the Pi as well, you can log in as “pi”, password “raspberry”, and run ifconfig -a to get the Pi’s IP address.

If your computer and the Pi have IP addresses on the same subnet, your program is mDNS. You can work around the lack of mDNS by typing the Pi’s IP address into the browser instead of frcvision.local.

what if we don’t get the same IP addresses?

The computer and the Pi should not be the same IP address, they just need to be on a common subnet (to avoid going into too much detail, the first few 2 or 3 numbers between the dots should match).

1 Like