I’m having trouble implementing the NIVision wrappers for FRC (I’m choosing to use the NIVision libraries because in the pass we have used them to use two usb cameras on the robot with relative ease). When I try to use them however I get an error on the Riolog looking like this:
java.lang.UnsatisfiedLinkError: /usr/local/frc/lib/libniVisionJNI.so: libHALAthena.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.ni.vision.NIVision.<clinit>(NIVision.java:22)
at org.usfirst.frc.team3205.robot.commands.cameraOneInit.<init>(cameraOneInit.java:19)
at org.usfirst.frc.team3205.robot.OI.<init>(OI.java:140)
at org.usfirst.frc.team3205.robot.Robot.robotInit(Robot.java:44)
at edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:31)
at edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:250)
I checked the location for which the library is located and I see the .so file that the error is referring to. How exactly do I fix this?
NIVision was removed from WPILib. You can use the CameraServer class to easily stream multiple USB cameras to the driver station.
This is typically done with
UsbCamera camera = CameraServer.getInstance().startAutomaticCapture("A Camera", 0);
camera.setResolution(160, 90); // Or whatever resolution you want to stream
camera.setFps(10); // Or whatever FPS you want to stream at
The same code can be reused for another camera. Just use a different name and device number to identify it
MjpegServer server = new MjpegServer("Robot camera", 1189);
UsbCamera camera1 = new UsbCamera("<name>", 0);
UsbCamera camera2 = new UsbCamera("<name>", 1);
// set up the cameras...
// The condition can look at a button press in teleopPeriodic,
// or this can be run in a command to switch the streams
if (useCamera1) {
server.setSource(camera1);
} else {
server.setSource(camera2);
}
I’d personally put the toggling in a command. That makes it easier to use in the command-based framework