Пример #1
0
  // static initializer
  public static void initialize() {
    if (!initialized) {

      gamepad = new Joystick(GAMEPAD_ID);

      initialized = true;
      teleopMode = false;

      // create and initialize arm motor
      frontArmMotor = new CANTalon(FRONT_ARM_MOTOR_ID);
      if (frontArmMotor != null) {

        System.out.println("Initializing front arm motor (position control)...");

        // VERY IMPORTANT - resets talon faults to render them usable again!!
        frontArmMotor.clearStickyFaults();
        frontArmMotor.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
        frontArmMotor.changeControlMode(CANTalon.TalonControlMode.PercentVbus);

        // set brake mode
        frontArmMotor.enableBrakeMode(true);

        // initializes encoder to zero
        frontArmMotor.setPosition(0);
      } else System.out.println("ERROR: Front Arm motor not initialized!");

      // create and initialize roller motor
      frontArmRollerMotor = new CANTalon(FRONT_ARM_ROLLER_ID);
      if (frontArmRollerMotor != null) {

        System.out.println("Initializing front arm roller motor (PercentVbus control)...");

        frontArmRollerMotor.clearStickyFaults();

        // set up roller motor for percent Vbus control mode
        frontArmRollerMotor.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
        frontArmRollerMotor.enableBrakeMode(false);

        // initializes speed of rollers to zero
        frontArmRollerMotor.set(0);

      } else System.out.println("ERROR: Front Arm roller motor not initialized!");
    }
  }
Пример #2
0
  public static void disabledInit() {
    if (!initialized) initialize();

    // if exiting from teleop mode (game is over)...
    if (teleopMode) {
      System.out.println("FrontArmAssembly: exiting teleop, moving to coast mode");
      // relax front arm motor (coast mode)
      frontArmMotor.enableBrakeMode(false);
    }
  }
 /**
  * This method enables/disables motor brake mode. In motor brake mode, set power to 0 would stop
  * the motor very abruptly by shorting the motor wires together using the generated back EMF to
  * stop the motor. When brakMode is false (i.e. float/coast mode), the motor wires are just
  * disconnected from the motor controller so the motor will stop gradually.
  *
  * @param brakeMode specifies true to enable brake mode, false otherwise.
  */
 public void setBrakeModeEnabled(boolean enabled) {
   super.enableBrakeMode(enabled);
 } // setBrakeModeEnabled
 @Override
 public TalonSRX enableBrakeMode(boolean brake) {
   talon.enableBrakeMode(brake);
   return this;
 }
 @Override
 public void stop() {
   talon.enableBrakeMode(true);
   talon.set(0);
 }
Пример #6
0
 public void setShooterBrakeMode(boolean on) {
   shooterMotor.enableBrakeMode(on);
 }