コード例 #1
0
ファイル: Shooter.java プロジェクト: inceptus/Robot2013
  public Shooter() throws CANTimeoutException {

    loadingStick = new CANJaguar(5);
    // http://www.chiefdelphi.com/forums/showthread.php?t=101737
    // Configuring firstShootMotor in order to control speed with encoder
    firstShootingMotor = new CANJaguar(6, CANJaguar.ControlMode.kSpeed);
    firstShootingMotor.configEncoderCodesPerRev(256);
    firstShootingMotor.enableControl();
    firstShootingMotor.changeControlMode(CANJaguar.ControlMode.kVoltage);
    firstShootingMotor.enableControl();

    // Configuring secondShootMotor in order to control speed with encoder
    secondShootingMotor = new CANJaguar(7, CANJaguar.ControlMode.kSpeed);
    secondShootingMotor.configEncoderCodesPerRev(256);
    secondShootingMotor.enableControl();
    secondShootingMotor.changeControlMode(CANJaguar.ControlMode.kVoltage);
    secondShootingMotor.enableControl();

    angleMotor = new CANJaguar(8);

    frontSwitch = new DigitalInput(1);
    backSwitch = new DigitalInput(1);

    table = NetworkTable.getTable("shooter");

    table.putNumber("firstSpeed", 0);
    table.putNumber("angle", 0);
  }
コード例 #2
0
  public void robotInit() {
    try {
      drive_control = new Joystick(1);
      control = new Joystick(2);
      drive = new Drive();
      station = DriverStationLCD.getInstance();
      camera = AxisCamera.getInstance();
      camera.writeResolution(AxisCamera.ResolutionT.k320x240);
      camera.writeBrightness(0);
      camera.writeMaxFPS(10);
      launcher = new CANJaguar(7);
      belt1 = new Relay(1);
      // belt1.setDirection(Relay.Direction.kBoth);
      belt2 = new CANJaguar(8);
      turret = new Victor(4);

      /*launcher.setPID(0.5, 0.001, 0.0);
      launcher.configEncoderCodesPerRev(360);
      launcher.changeControlMode(CANJaguar.ControlMode.kSpeed);
      launcher.enableControl();*/
      launcher.configEncoderCodesPerRev(360);
      launcher.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
      launcher.setPositionReference(CANJaguar.PositionReference.kQuadEncoder);
      /*wheelEncoder = new Encoder(1, 2, true, CounterBase.EncodingType.k4X);
      wheelEncoder.setDistancePerPulse(1);
      wheelEncoder.setReverseDirection(true);
      wheelEncoder.start();*/
      csc = new CANSpeedController(.02, 0, 0, launcher);
      csc.setInputRange(0, 3000);
      csc.enable();

      timer = new Timer();
      // tracking = new EagleEye();
      lights = new Relay(3);
      /*try {
          serial = new SerialPort(115200);
      } catch (Exception ex) {
          System.out.println("Cannot open serial connection " + ex);
      }*/

    } catch (CANTimeoutException ex) {
      System.out.println(ex);
    }

    wedge = new wedge(2, 1, 2);
    // servo1 = new Servo(1);
    // servo2 = new Servo(2);
    // wedge = new Relay(2);
  }
コード例 #3
0
ファイル: Climber.java プロジェクト: jbdman/frc-88
  public Climber() {

    try {
      ClimbJag = new CANJaguar(Wiring.climberCANID);

      if (ClimbJag != null) {
        // encoder configuration
        ClimbJag.configEncoderCodesPerRev(ENCODER_LINES);
        ClimbJag.setPositionReference(CANJaguar.PositionReference.kQuadEncoder);
        ClimbJag.configNeutralMode(CANJaguar.NeutralMode.kBrake);
        // We need this ramp rate. Without it rapid reversal causes transients
        ClimbJag.setVoltageRampRate(20);
      }
    } catch (CANTimeoutException ex) {
      m_fault = true;
      System.out.println("*** Climber CAN Error ***");
    }

    calibrateEncoder();
  }
コード例 #4
0
  public CANJaguar construct() {
    CANJaguar jag = null;
    try {
      jag = new CANJaguar(channel, controlMode);
      //            System.out.println("-----------CREATING JAGUAR AT CHANNEL " + channel +
      // "----------------");
      //            System.out.println("Control Mode:\t\t" + controlMode);

      if (usingPID) {
        //                System.out.println("Speed Reference:\t\t" + speedReference);
        jag.setSpeedReference(speedReference);
        //                System.out.println("Encoder Codes Per Rev:\t\t" + encoderCodesPerRev);
        jag.configEncoderCodesPerRev(encoderCodesPerRev);
        //                System.out.println("P:\t\t" + p);
        //                System.out.println("I:\t\t" + i);
        //                System.out.println("D:\t\t" + d);
        //                System.out.println("Verifying PID:");
        //                System.out.println("P:\t\t" + jag.getP());
        //                System.out.println("I:\t\t" + jag.getI());
        //                System.out.println("D:\t\t" + jag.getD());
        jag.setPID(p, i, d);
        jag.enableControl();

        if (p == 0) {
          System.out.println("[WARNING] Created a CANJaguar with P=0!");
        }

        if (encoderCodesPerRev == 0) {
          System.out.println("[WARNING] Created a CANJaguar with encoder codes per revolution=0!");
        }
      }

      //            System.out.println("-----------Motor Create Complete----------");
    } catch (CANTimeoutException e) {
      e.printStackTrace();
    }

    return jag;
  }