private void a() {
      Iterator var1 = this.hardwareMap.servoController.iterator();

      while (var1.hasNext()) {
        ServoController var2 = (ServoController) var1.next();
        var2.pwmDisable();
      }

      var1 = this.hardwareMap.dcMotorController.iterator();

      while (var1.hasNext()) {
        DcMotorController var3 = (DcMotorController) var1.next();
        var3.setMotorControllerDeviceMode(DeviceMode.WRITE_ONLY);
      }

      var1 = this.hardwareMap.dcMotor.iterator();

      while (var1.hasNext()) {
        DcMotor var4 = (DcMotor) var1.next();
        var4.setPower(0.0D);
        var4.setChannelMode(RunMode.RUN_WITHOUT_ENCODERS);
      }

      var1 = this.hardwareMap.lightSensor.iterator();

      while (var1.hasNext()) {
        LightSensor var5 = (LightSensor) var1.next();
        var5.enableLed(false);
      }
    }
 public void shutdownServoControllers() {
   for (Entry entry : this.f17h.servoController.entrySet()) {
     String str = (String) entry.getKey();
     ServoController servoController = (ServoController) entry.getValue();
     DbgLog.msg("Stopping Servo Controller " + str);
     servoController.close();
   }
 }
  /* Initialize standard Hardware interfaces */
  public void init(HardwareMap ahwMap) {

    // Initialize base Motor and Servo objects
    super.init(ahwMap);

    /*
     * Matrix controllers are special.
     *
     * A Matrix controller is one controller with both motors and servos
     * but software wants to treat it as two distinct controllers, one
     * DcMotorController, and one ServoController.
     *
     * We accomplish this by initializing Motor and Servo controller with the same name
     * given in the configuration.  In the example below the name of the controller is
     * "MatrixController"
     *
     * Normally we don't need to access the controllers themselves, we deal directly with
     * the Motor and Servo objects, but the Matrix interface is different.
     *
     * In order to activate the servos, they need to be enabled on the controller with
     * a call to pwmEnable() and disabled with a call to pwmDisable()
     *
     * Also, the Matrix Motor controller interface provides a call that enables all motors to
     * updated simultaneously (with the same value).
     */

    // Initialize Matrix Motor and Servo objects
    matrixMotorController =
        (MatrixDcMotorController) ahwMap.dcMotorController.get("matrix controller");
    matrixServoController = ahwMap.servoController.get("matrix controller");

    // Enable Servos
    matrixServoController.pwmEnable(); // Don't forget to enable Matrix Output
  }
Example #4
0
  public void init() {
    motorRight = hardwareMap.dcMotor.get("motor_2");
    motorLeft = hardwareMap.dcMotor.get("motor_1");

    motorLeft.setDirection(DcMotor.Direction.REVERSE);

    gyro = hardwareMap.gyroSensor.get("gyro");
    gyro.calibrate();
    while (gyro.isCalibrating()) {
      try {
        wait(20);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

    drive = new ArcadeDrive(motorRight, motorLeft, gyro);
    components.add(drive);

    servoController = hardwareMap.servoController.get("Servo Controller 1");
    servoController.pwmEnable();

    servo = new NormalServo(servoController, 1);
    components.add(servo);
  }
  @Override
  public void init() {
    motor1 = hardwareMap.dcMotor.get("motor_1");
    motor2 = hardwareMap.dcMotor.get("motor_2");
    motor3 = hardwareMap.dcMotor.get("motor_3");
    motor4 = hardwareMap.dcMotor.get("motor_4");

    /*
     * A set of motors to use with the Matrix motor controller's
     * pending feature.  See example below.  Note that this is
     * completely optional.
     */
    motorSet.add(motor1);
    motorSet.add(motor2);
    motorSet.add(motor3);
    motorSet.add(motor4);

    servo1 = hardwareMap.servo.get("servo_1");
    servo2 = hardwareMap.servo.get("servo_2");
    servo3 = hardwareMap.servo.get("servo_3");
    servo4 = hardwareMap.servo.get("servo_4");

    /*
     * Matrix controllers are special.
     *
     * A Matrix controller is one controller with both motors and servos
     * but software wants to treat it as two distinct controllers, one
     * DcMotorController, and one ServoController.
     *
     * We accomplish this by appending Motor and Servo to the name
     * given in the configuration.  In the example below the name
     * of the controller is "MatrixController" so the motor controller
     * instance is "MatrixControllerMotor" and the servo controller
     * instance is "MatrixControllerServo".
     */
    mc = (MatrixDcMotorController) hardwareMap.dcMotorController.get("MatrixController");
    motor1.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    motor2.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    motor3.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);
    motor4.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS);

    /*
     * Servos are not enabled by default.  Software must call pwmEnable()
     * for servos to function.
     */
    sc = hardwareMap.servoController.get("MatrixController");
    sc.pwmEnable();
  }
 @Override
 public void stop() {
   /*
    * An example of setting power for individual motors as normal.
    *
    * For the Matrix controller, the methods take effect immediately
    * as each call to setPower(), or any other method that interacts
    * with the controller, is transformed into an i2c transaction and
    * queued.  A separate thread is processing the queue.
    *
    * In practice this means that the first call to setPower will
    * be applied 20 to 40 milliseconds before the last call as the
    * processing thread works through the queue.  Testing
    * has shown that this latency is not large enough to have any
    * real world negative impacts, however teams may choose to use
    * the controller's setMotorPower() method if they desire precise
    * simultaneous motor operations.  See example in handleMotors().
    */
   motor1.setPower(0.0);
   motor2.setPower(0.0);
   motor3.setPower(0.0);
   motor4.setPower(0.0);
   sc.pwmDisable();
 }