Fix merge conflicts.
authorRayan Hirech <ramine411@gmail.com>
Fri, 10 Feb 2017 02:18:34 +0000 (18:18 -0800)
committerRayan Hirech <ramine411@gmail.com>
Fri, 10 Feb 2017 02:18:34 +0000 (18:18 -0800)
src/org/usfirst/frc/team3501/robot/CameraFeeds.java
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/commands/accessories/ToggleCameraFeed.java

index f5d0384121d24ef8663d339f8e62ed8bb377f603..94501567cbac31e47e2ef70a9da5ae4815b3763b 100755 (executable)
@@ -17,21 +17,7 @@ public class CameraFeeds {
   private static CameraFeeds cameraFeeds = null;
 
   @SuppressWarnings("deprecation")
-  public CameraFeeds(/* Joystick Button */) {
-    // Get camera id by supplying camera name example 'cam0', found on roborio
-    // web
-    // interface
-    /*
-     * intakeCam =
-     * NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameCenter,
-     * NIVision.IMAQdxCameraControlMode.CameraControlModeController); climberCam
-     * = NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameRight,
-     * NIVision.IMAQdxCameraControlMode.CameraControlModeController); curCam =
-     * intakeCam; // Image that will contain camera image frame =
-     * NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0); // Server that
-     * we'll give the image to server = CameraServer.getInstance();
-     * server.setSize(Constants.CameraFeeds.imgQuality);
-     */
+  private CameraFeeds(/* Joystick Button */) {
 
     usbCamName = intakeCam.getName();
     axisCamName = climberCam.getName();
@@ -39,10 +25,9 @@ public class CameraFeeds {
     climberCam = server.addAxisCamera(axisCamName, "10.35.1.11");
     intakeCam = server.startAutomaticCapture();
     curCam = intakeCam;
-
-    // server = CameraServer.getInstance();
-    // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
-    // cameraFeeds = new CameraFeeds();
+    curCam = climberCam;
+    usbCamName = intakeCam.getName();
+    axisCamName = climberCam.getName();
   }
 
   public static CameraFeeds getCameraFeeds() {
@@ -58,6 +43,7 @@ public class CameraFeeds {
   }
 
   public void toggleCamera() {
+    System.out.println("enter toggleCamer");
     if (curCam.equals(intakeCam)) {
       // changeCam(climberCam);
       curCam = climberCam;
@@ -90,5 +76,12 @@ public class CameraFeeds {
       System.out.println("Switching to intake camera.");
       return;
     }
+    System.out.println("change camera");
+    server.removeCamera(curCam.getName());
+    server.addCamera(cam);
+  }
+
+  public String getCurrentCamName() {
+    return curCam.getName();
   }
 }
index a40334d01c5bdfc3cbd6eda96790d9e001ab6cce..6c3a6adabe85c45964c0fceb3a202557af99cd55 100644 (file)
@@ -20,7 +20,7 @@ public class Constants {
 
     public final static int TOGGLE_GEAR_PORT = 0;
 
-    public static final int TOGGLE_CAMERA_FEEDS = 4;
+    public static final int TOGGLE_CAMERA_FEEDS = 1;
 
   }
 
index 65f555e15b5b181cc001231c9be31e73e277c51f..42a01369f5fae3ff15cfde14f648ad55fc2a3b9a 100644 (file)
@@ -1,7 +1,6 @@
 package org.usfirst.frc.team3501.robot;
 
 import org.usfirst.frc.team3501.robot.commands.accessories.ToggleCameraFeed;
-import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
 
 import edu.wpi.first.wpilibj.Joystick;
 import edu.wpi.first.wpilibj.buttons.Button;
@@ -23,22 +22,22 @@ public class OI {
   public OI() {
     leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
     rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
-    toggleWinch = new JoystickButton(leftJoystick,
-        Constants.OI.TOGGLE_WINCH_PORT);
-    toggleIndexWheel = new JoystickButton(leftJoystick,
-        Constants.OI.TOGGLE_INDEXWHEEL_PORT);
-    toggleFlyWheel = new JoystickButton(leftJoystick,
-        Constants.OI.TOGGLE_FLYWHEEL_PORT);
-
-    toggleGear = new JoystickButton(leftJoystick,
-        Constants.OI.TOGGLE_GEAR_PORT);
-    toggleGear.whenPressed(new ToggleGear());
+    /*
+     * toggleWinch = new JoystickButton(leftJoystick,
+     * Constants.OI.TOGGLE_WINCH_PORT); toggleIndexWheel = new
+     * JoystickButton(leftJoystick, Constants.OI.TOGGLE_INDEXWHEEL_PORT);
+     * toggleFlyWheel = new JoystickButton(leftJoystick,
+     * Constants.OI.TOGGLE_FLYWHEEL_PORT);
+     * 
+     * toggleGear = new JoystickButton(leftJoystick,
+     * Constants.OI.TOGGLE_GEAR_PORT); toggleGear.whenPressed(new ToggleGear());
+     */
 
     toggleCameraFeeds = new JoystickButton(leftJoystick,
         Constants.OI.TOGGLE_CAMERA_FEEDS);
 
     toggleCameraFeeds.whenReleased(new ToggleCameraFeed());
-
+    System.out.println("toggle ready");
   }
 
   public static OI getOI() {
index 9efe44f0480b4291a5e9aa5c8275847745b856b1..e7c5e5b1928398f30bc31fd42c0c5bc43f87634f 100644 (file)
@@ -25,12 +25,25 @@ public class Robot extends IterativeRobot {
     oi = OI.getOI();
     shooter = Shooter.getShooter();
     intake = Intake.getIntake();
-
     cameraServer2 = CameraServer.getInstance();
     axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
-
     cameraFeeds = new CameraFeeds();
+    cameraFeeds = CameraFeeds.getCameraFeeds();
+
+    // usbCamera = CameraServer.getInstance().startAutomaticCapture();
+
+    // cameraServer2 = CameraServer;getInstance();
+    // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
 
+    // cameraServer2 = CameraServer.getInstance();
+    // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
+
+    // usbCamera = CameraServer.getInstance().startAutomaticCapture();
+    // CameraServer.getInstance().startAutomaticCapture();
+    // cameraServer2 = CameraServer.getInstance();
+    // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
+
+    // cameraFeeds = new CameraFeeds();
   }
 
   public static DriveTrain getDriveTrain() {
@@ -41,6 +54,10 @@ public class Robot extends IterativeRobot {
     return Shooter.getShooter();
   }
 
+  public static CameraFeeds getCameraFeeds() {
+    return cameraFeeds;
+  }
+
   public static OI getOI() {
     return OI.getOI();
   }
@@ -64,7 +81,6 @@ public class Robot extends IterativeRobot {
 
   @Override
   public void teleopInit() {
-    cameraFeeds.init();
   }
 
   @Override
index b42b961da06db003f116382fdbda8a61c66b8884..4515b8284b74218ac3e8f48532ef17d5486cc217 100644 (file)
@@ -1,20 +1,24 @@
 package org.usfirst.frc.team3501.robot.commands.accessories;
 
 import org.usfirst.frc.team3501.robot.CameraFeeds;
+import org.usfirst.frc.team3501.robot.Robot;
 
 import edu.wpi.first.wpilibj.command.Command;
 
 public class ToggleCameraFeed extends Command {
 
-       public void init() {
-               CameraFeeds cf = CameraFeeds.getCameraFeeds();
-               
-               cf.toggleCamera();
-       }
-       
-       @Override
-       protected boolean isFinished() {
-               return true;
-       }
+  @Override
+  protected void execute() {
+    CameraFeeds cf = Robot.getCameraFeeds();
+    System.out.println(cf.getCurrentCamName());
+    cf.toggleCamera();
+    System.out.println(cf.getCurrentCamName());
+
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
 
 }