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();
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() {
}
public void toggleCamera() {
+ System.out.println("enter toggleCamer");
if (curCam.equals(intakeCam)) {
// changeCam(climberCam);
curCam = climberCam;
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();
}
}
public final static int TOGGLE_GEAR_PORT = 0;
- public static final int TOGGLE_CAMERA_FEEDS = 4;
+ public static final int TOGGLE_CAMERA_FEEDS = 1;
}
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;
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() {
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() {
return Shooter.getShooter();
}
+ public static CameraFeeds getCameraFeeds() {
+ return cameraFeeds;
+ }
+
public static OI getOI() {
return OI.getOI();
}
@Override
public void teleopInit() {
- cameraFeeds.init();
}
@Override
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;
+ }
}