-
Notifications
You must be signed in to change notification settings - Fork 0
Raspberry Pi
The Raspberry Pi is just a little larger than an Arduino, and also comparably affordable, but runs a fully functional operating system (Linux), can connect to HDMI displays, keyboard, mouse, WiFi. Similar to the Arduino and RoboRIO it also offers some I/O pins for connecting LEDs etc.
It can be used for all sorts of hobby projects, for example DIY Bluetooth Speakers
FRC WPIlib supports Using a Raspberry PI as a video coprocessor.
When directly connecting the Pi to a laptop via ethernet, you may not be able to reach the Pi via http://frcvision.local because there is no name server (DNS).
Connect the Pi to HDMI and keyboard.
Log in (pi, raspberry) and invoke /sbin/ifconfig
to see what IP address the Pi is using.
Then, on the laptop, connect to that address via a web browser, e.g. http://169.254.68.53/
You can also reach its console via ssh [email protected]
from the git-bash.
On the console, run usb-devices
to check for connected cameras. One camera might show up as two video interfaces, or even 2 video plus 2 audio interfaces.
Key steps on the FRCVision web page of the Pi:
- Select "Writable" mode on top
- Vision Settings:
- Turn "Client" off when there's no RoboRIO
- If no camera is listed, "Add Connected Camera" and select the first one, e.g.
/dev/video0
, in case a camera is listed with more than one/dev/video
entries. - Press "Save".
- Wait about 5 seconds, then "Open Stream". If the stream page fails to open, try again a little later. Camera restart after each "Save" needs some time, in fact you'll see "Waiting 5 seconds..." in the "Vision Status" console after each start.
- The camera stream page should show controls, but might not show an image, yet. Note one of the supported video modes, like "YUYV 320 x 240 at 30 fps", and enter that in the camera config, save, wait a little, then "Open Stream".
- On the stream page, adjust brightness etc., then use `Copy Source Config From Camera" and "Save" to persist these settings.
- Select "Readable" mode before shutdown
On http://frcvision.local (or using the IP address if the name doesn't work, example http://169.254.68.53), "Vision Settings", "Camera", "Open Stream" opens a page http://frcvision.local:1181 (or http://169.254.68.53:1181) with camera controls. To see just the image, right-click on the image and select "View Image", which will lead to a URL like http://frcvision.local:1181/stream.mjpg (or http://169.254.68.53:1181/stream.mjpg).
When we later add software to publish a processed image, or there are multiple cameras, you can reach these by incrementing the port number:
Source | Controls | Just Video |
---|---|---|
1st Camera | http://frcvision.local:1181 | http://frcvision.local:1181/stream.mjpg |
2nd | http://frcvision.local:1182 | http://frcvision.local:1182/stream.mjpg |
3rd | http://frcvision.local:1183 | http://frcvision.local:1183/stream.mjpg |
... | ... and so on ... | ... |
When the Pi is simply powered off while it's in the middle of writing to its SD memory card, the card can be corrupted and then you need to start over by writing a fresh Pi image to the card.
Therefore set the Pi to "Read Only" in the web interface when done
changing things.
Then remove power, or, for the paranoid, shut down via ssh console sudo shutdown now
.
On the Pi, there are example programs in /home/pi/zips
.
Can be viewed there via unzip
, then vi
or nano
,
but more comfortably fetched to the laptop in git bash:
cd git
scp [email protected]:~/zips/java-multiCameraServer.zip .
unzip java-multiCameraServer.zip
Now use File
, Open Folder
in VS Code to view and edit the source code.
For example, at the very end of Main.java, add a printout:
for (;;)
{
// Blasto, new printout so we can tell that it's our program
System.out.println("Running my camera server");
try
{
Thread.sleep(10000);
}
catch (InterruptedException ex)
{
return;
}
}
At this time, there is no convenient "Deploy" command in VS Code that would compile the code for the Pi and upload it.
Instead, this is a two-step process:
-
Compile the code on the laptop. Open a
cmd
command window.Run this once to get the FRC setup for Java:
\Users\Public\frc2019\frccode\frcvars2019.bat
Go to the folder that holds the code we want to build:
cd git cd java-multiCameraServer
Completely rebuild the software:
gradlew.bat clean build
From now on, when you changed the software and want to rebuild:
gradlew.bat build
Result is a file `build/libs/java-multiCameraServer-all.jar".
-
Upload via Pi's FRCVision web page.
"Application" tab, select the "Uploaded Java jar"
- Use the "Browse..." button that just appeared and select the
build/libs/...-all.jar
file. - Click "Upload and Save"
- Check the "Vision Status" tab for console output.
- Use the "Browse..." button that just appeared and select the
If "Upload and Save" is disabled, check that the Pi is "Writable". When done, consider making it "Read-Only".