Change curCam to string to try to fix toggling problems.
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / CameraFeeds.java
CommitLineData
409d6878
ME
1package org.usfirst.frc.team3501.robot;
2
2ada01fd
RH
3import edu.wpi.cscore.AxisCamera;
4import edu.wpi.cscore.UsbCamera;
409d6878
ME
5import edu.wpi.first.wpilibj.CameraServer;
6
7public class CameraFeeds {
50a075d8
RH
8 // private final int intakeCam;
9 // private final int climberCam;
570ccbd9 10 private String curCam;
409d6878 11 private CameraServer server;
50a075d8
RH
12 private static UsbCamera intakeCam;
13 private static AxisCamera climberCam;
4dff9cc3
RH
14 private static String usbCamName;
15 private static String axisCamName;
4bc0cb18 16 private static CameraFeeds cameraFeeds = null;
409d6878 17
fbc1210e 18 @SuppressWarnings("deprecation")
9ea6a533 19 private CameraFeeds(/* Joystick Button */) {
55391ba3 20 System.out.println("Enter CameraFeeds constructor");
409d6878 21 server = CameraServer.getInstance();
6aa639be 22 climberCam = server.addAxisCamera("ClimberCam", "10.35.1.11");
4dff9cc3 23 intakeCam = server.startAutomaticCapture();
55391ba3
RH
24 usbCamName = intakeCam.getName();
25 axisCamName = climberCam.getName();
570ccbd9
RH
26 curCam = "intakeCam";
27 changeCam();
55391ba3 28 System.out.println("Leaving CameraFeeds constructor");
409d6878 29 }
7638f542 30
4bc0cb18 31 public static CameraFeeds getCameraFeeds() {
55391ba3 32 System.out.println("Enter CameraFeeds.getCameraFeeds");
7638f542
RH
33 if (cameraFeeds == null) {
34 cameraFeeds = new CameraFeeds();
35 }
55391ba3 36 System.out.println("Leaving CameraFeeds.getCameraFeeds");
7638f542 37 return cameraFeeds;
4bc0cb18 38 }
409d6878
ME
39
40 public void init() {
55391ba3 41 System.out.println("Initializing...");
409d6878
ME
42 }
43
4dff9cc3 44 public void toggleCamera() {
570ccbd9 45 changeCam();
409d6878
ME
46 }
47
48 /**
50a075d8 49 *
4bc0cb18 50 * Change the camera to get image from to a different one
409d6878 51 *
7638f542 52 * newId for camera
409d6878 53 */
570ccbd9
RH
54 public void changeCam() {
55 System.out.println("enter toggleCamera");
56 if (curCam == "intakeCam") {
57 server.getVideo(axisCamName);
58 curCam = "climberCam";
59 System.out.println("Switching to climber camera, curCam = " + curCam);
60 } else if (curCam == "climberCam") {
61 server.getVideo(usbCamName);
62 curCam = "intakeCam";
63 System.out.println("Switching to intake camera, curCam = " + curCam);
64 }
409d6878
ME
65 }
66}