Beispiel #1
0
  /**
   * This function is run when the robot is first started up and should be used for any
   * initialization code.
   */
  public void robotInit() {
    black = new Jaguar(4, 1);
    red = new Jaguar(4, 2);
    leftEncoder = new Encoder(4, 5);
    rightEncoder = new Encoder(6, 7);
    left = new Joystick(1);
    right = new Joystick(2);
    gamePad = new Joystick(3);
    watchdog = Watchdog.getInstance();
    dsLCD = DriverStationLCD.getInstance();
    photoreceptorL = new DigitalInput(4, 1);
    photoreceptorM = new DigitalInput(4, 2);
    photoreceptorR = new DigitalInput(4, 3);
    camera = AxisCamera.getInstance();
    driveMode = 0; // 0 = Tank; 1 = Arcade; 2 = Kaj
    driveToggle = false;
    cruiseControl = false;

    camera.writeResolution(AxisCamera.ResolutionT.k160x120);
    camera.writeWhiteBalance(AxisCamera.WhiteBalanceT.hold);
    camera.writeExposureControl(AxisCamera.ExposureT.hold);
    camera.writeExposurePriority(AxisCamera.ExposurePriorityT.frameRate);

    leftEncoder.start();
    rightEncoder.start();
  }
Beispiel #2
0
 /** This function is called periodically during operator control */
 public void teleopInit() {
   ColorImage image;
   try {
     image = camera.getImage();
     image.write("unedited.jpg");
     BinaryImage bImage = image.thresholdRGB(160, 255, 160, 255, 160, 255);
     bImage.write("whitemask.jpg");
     MonoImage mImage = image.getLuminancePlane();
     mImage.write("luminancePlane.jpg");
     image.free();
     bImage.free();
   } catch (NIVisionException e) {
     System.out.println("Error retrieving image: NIVisionException");
     e.printStackTrace();
   } catch (AxisCameraException e) {
     System.out.println("Error retrieving image: AxisCameraException");
     e.printStackTrace();
   }
 }