Java 类edu.wpi.first.wpilibj.DigitalInput 实例源码

项目:thirdcoast    文件:DioSet.java   
@NotNull
List<DigitalInput> getDigitalInputs() {
  if (inputs.size() == 0) {
    telemetryService.stop();
    for (int i = 0; i < 10; i++) {
      if (outputs.contains(i)) {
        inputs.add(null); // outputs can't be inputs
      } else {
        DigitalInput input = new DigitalInput(i);
        inputs.add(input);
        telemetryService.register(new DigitalInputItem(input));
      }
    }
    telemetryService.start();
    logger.info("initialized inputs and restarted TelemetryService");
  }
  return Collections.unmodifiableList(inputs);
}
项目:2016-Robot-Final    文件:Arm.java   
public Arm() {
super("arm", kP, kI, kD);

motor = new Talon(RobotMap.ArmMap.PWM_MOTOR);
motor.setInverted(RobotMap.ArmMap.INV_MOTOR);

encoder = new Encoder(RobotMap.ArmMap.DIO_ENCODER_A, RobotMap.ArmMap.DIO_ENCODER_B);
encoder.setDistancePerPulse(RobotMap.ArmMap.DISTANCE_PER_PULSE);
encoder.setReverseDirection(RobotMap.ArmMap.INV_ENCODER);

upperLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_TOP);
bottomLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_BOTTOM);

setAbsoluteTolerance(0.05);
getPIDController().setContinuous(false);
   }
项目:2016-Robot    文件:Arm.java   
public Arm() {
super("arm", kP, kI, kD);

motor = new Talon(RobotMap.ArmMap.PWM_MOTOR);
motor.setInverted(RobotMap.ArmMap.INV_MOTOR);

encoder = new Encoder(RobotMap.ArmMap.DIO_ENCODER_A, RobotMap.ArmMap.DIO_ENCODER_B);
encoder.setDistancePerPulse(RobotMap.ArmMap.DISTANCE_PER_PULSE);
encoder.setReverseDirection(RobotMap.ArmMap.INV_ENCODER);

upperLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_TOP);
bottomLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_BOTTOM);

setAbsoluteTolerance(0.05);
getPIDController().setContinuous(false);
   }
项目:Stronghold2016-340    文件:Harvester.java   
public Harvester() {        

    //TODO: sync left/right motors
    tiltRight = new CANTalon(RobotMap.HARVESTER_AIMING_RIGHT);
    tiltLeft = new CANTalon(RobotMap.HARVESTER_AIMING_LEFT);

    //tiltLeft.setVoltageRampRate(5); // this might be a good way to solve our ramp rate issue IE smooth out the jerkiness
    //tiltRight.setVoltageRampRate(5); // this might be a good way to solve our ramp rate issue IE smooth out the jerkiness

    limitLeft = new DigitalInput(RobotMap.HARVESTER_LEFT_BUMP_BOTTOM);
    limitRight = new DigitalInput(RobotMap.HARVESTER_RIGHT_BUMP_BOTTOM);
    limitLeftTop = new DigitalInput(RobotMap.HARVESTER_LEFT_BUMP_TOP);
    limitRightTop = new DigitalInput(RobotMap.HARVESTER_RIGHT_BUMP_TOP);

    leftPot = new ZeroablePotentiometer(RobotMap.LEFT_AIM_POT, 250);
    rightPot = new ZeroablePotentiometer(RobotMap.RIGHT_AIM_POT, 250);
    leftPot.setInverted(true);
}
项目:FRC-2014-robot-project    文件:ShooterControl.java   
ShooterControl(Encoder encoder, SpeedController pullBackSpeedController, double speedControllerMaxRpm,
               DigitalInput limitSwitch, DoubleSolenoid gearControl, Servo latchServo,
               Relay angleControl)
{
    m_latchReleaseServo = latchServo;
    m_currentState = SHOOTER_CONTROL_STATE_WAIT;
    m_encoder = encoder;
    m_pullBackSpeedController = pullBackSpeedController;
    m_angleControl = angleControl;
    m_speedControllerMaxRpm = speedControllerMaxRpm;
    m_limitSwitch = limitSwitch;
    m_pullBackEncoderRpm = new EncoderRPM();
    m_pullBackEncoderRpm.Init(m_pullBackSpeedController, m_encoder, (-1)*m_speedControllerMaxRpm, m_speedControllerMaxRpm, 0.05, 100, m_limitSwitch);
    m_releaseFromMidptEncoderRpm = new EncoderRPM();
    m_releaseFromMidptEncoderRpm.Init(m_pullBackSpeedController, m_encoder,(-1)*m_speedControllerMaxRpm/4,m_speedControllerMaxRpm,0.05, 3);
    m_gearControl = gearControl;
    m_latchReleased = false;
    m_gearReleased = false;
    m_isPulledBack = false;
}
项目:frc-2015    文件:Lift.java   
public Lift(int motorChannel, int brakeChannelForward, int brakeChannelReverse, int encoderChannelA,
        int encoderChannelB, int boundaryLimitChannel, String subsystem) {
    motor = new Talon(motorChannel);
    brake = new DoubleSolenoid(RobotMap.solenoid.Pcm24, brakeChannelForward, brakeChannelReverse);
    encoder = new Encoder(encoderChannelA, encoderChannelB);
    boundaryLimit = new DigitalInput(boundaryLimitChannel);

    LiveWindow.addActuator(subsystem, "Motor", motor);
    LiveWindow.addActuator(subsystem, "Brake", brake);
    LiveWindow.addSensor(subsystem, "Encoder", encoder);
    LiveWindow.addSensor(subsystem, "Boundary Limit Switch", boundaryLimit);

    encoder.setPIDSourceType(PIDSourceType.kRate);
    pid = new PIDSpeedController(encoder, motor, subsystem, "Speed Control");
    subsystemName = subsystem;
}
项目:Aerial-Assist    文件:Launcher.java   
/**
 * Constructs a new Launcher, with two Talons for winding, a release relay,
 * and a limit switch for winding regulation based on input from a
 * MaxbotixUltrasonic rangefinder.
 */
public Launcher() {
    super("Launcher");

    winderL = new Talon(RobotMap.WIND_LEFT_PORT);
    winderR = new Talon(RobotMap.WIND_RIGHT_PORT);

    releaseMotor = new Relay(RobotMap.RELAY_PORT);

    camera = new AxisCameraM1101();
    rangefinder = new MaxbotixUltrasonic(RobotMap.ULTRASONIC_RANGEFINDER);

    limitSwitch = new DigitalInput(RobotMap.LIMIT_SWITCH);
    counter = new Counter(limitSwitch);

    counterInit(counter);
}
项目:2015-frc-robot    文件:SensorInput.java   
/**
 * Instantiates the Sensor Input module to read all sensors connected to the roboRIO.
 */
private SensorInput() { 
    limit_left = new DigitalInput(ChiliConstants.left_limit);
    limit_right = new DigitalInput(ChiliConstants.right_limit);
    accel = new BuiltInAccelerometer(Accelerometer.Range.k2G);
    gyro = new Gyro(ChiliConstants.gyro_channel);
    pdp = new PowerDistributionPanel();
    left_encoder = new Encoder(ChiliConstants.left_encoder_channelA, ChiliConstants.left_encoder_channelB, false);
    right_encoder = new Encoder(ChiliConstants.right_encoder_channelA, ChiliConstants.right_encoder_channelB, true);
    gyro_i2c = new GyroITG3200(I2C.Port.kOnboard);

    gyro_i2c.initialize();
    gyro_i2c.reset();
    gyro.initGyro();

    left_encoder.setDistancePerPulse(ChiliConstants.kDistancePerPulse);
    right_encoder.setDistancePerPulse(ChiliConstants.kDistancePerPulse);
}
项目:2014_Main_Robot    文件:Winch.java   
/**
 * A private constructor to prevent multiple instances from being created.
 */
private Winch(){
    winchMotor = new Talon(RobotMap.winchMotor.getInt());
    winchInputSwitch = new DigitalInput(RobotMap.winchLimitSwitch.getInt());
    winchSolenoid = new MomentaryDoubleSolenoid(
            RobotMap.winchExtPort.getInt(),RobotMap.winchRetPort.getInt());
    winchBallSensor = new AnalogChannel(RobotMap.winchBallSensorPort.getInt());
    intakeBallSensor = new AnalogChannel(RobotMap.intakeBallSensorPort.getInt());
    ballPresent = new Debouncer(RobotMap.ballPresentTime.getDouble());
    ballNotPresent = new Debouncer(RobotMap.ballPresentTime.getDouble());
    ballSettled = new Debouncer(RobotMap.ballSettleTime.getDouble());
    ballPresentOnWinch = new Debouncer(RobotMap.ballPresentOnWinchTime.getDouble());

    winchPotentiometer =
            new AnalogChannel(RobotMap.potentiometerPort.getInt());
    winchEncoder = new AverageEncoder(
            RobotMap.winchEncoderA.getInt(),
            RobotMap.winchEncoderB.getInt(),
            RobotMap.winchEncoderPulsePerRot,
            RobotMap.winchEncoderDistPerTick,
            RobotMap.winchEncoderReverse,
            RobotMap.winchEncodingType, RobotMap.winchSpeedReturnType,
            RobotMap.winchPosReturnType, RobotMap.winchAvgEncoderVal);
    winchEncoder.start();
}
项目:2012    文件:Loader.java   
public Loader()
{
    Conveyor = new Victor(ReboundRumble.LOADER_CONVEYOR_PWM);
    loaderInSolenoid = new Solenoid(ReboundRumble.LOADER_IN_SOLENOID_CHANNEL);
    loaderOutSolenoid = new Solenoid(ReboundRumble.LOADER_OUT_SOLENOID_CHANNEL);
    loaderUpSolenoid = new Solenoid(ReboundRumble.LOADER_UP_SOLENOID_CHANNEL);
    loaderDownSolenoid = new Solenoid(ReboundRumble.LOADER_DOWN_SOLENOID_CHANNEL);
    loaderIn = new DigitalInput(ReboundRumble.LOAD_IN_GPIO_CHANNEL);
    loaderOut = new DigitalInput(ReboundRumble.LOAD_OUT_GPIO_CHANNEL);
    loaderUp = new DigitalInput(ReboundRumble.LOAD_UP_GPIO_CHANNEL);
    loaderDown = new DigitalInput(ReboundRumble.LOAD_DOWN_GPIO_CHANNEL);
    loaderDownSolenoid.set(false);
    loaderUpSolenoid.set(true);
    loaderOutSolenoid.set(false);
    loaderInSolenoid.set(true);
}
项目:Woodchuck-2013    文件:Shooter.java   
public Shooter(Vision vision, JoystickControl controller)
{
    this.vision = vision;
    this.controller = controller;

    averageSpeed = new MovingAverage(ENCODER_AVERAGE_SAMPLES);

    feeder = new Relay(FEEDER_RELAY_CHANNEL);
    feeder.setDirection(Relay.Direction.kForward);
    feederSwitch = new DigitalInput(FEEDER_DIGITAL_SIDECAR_SLOT, FEEDER_DIGITAL_CHANNEL);

    encoderInput = new DigitalInput(ENCODER_DIGITAL_SIDECAR_SLOT, ENCODER_DIGITAL_CHANNEL);
    shooterEncoder = new Counter(encoderInput);
    shooterEncoder.setSemiPeriodMode(true);

    shooterMotor = new Motor(SHOOTER_JAGUAR_CHANNEL, SHOOTER_JAGUAR_INVERTED);

    cycleCounts = 0;
    rateCount = 0.0;
    prevTime = 0.0;
    currentSpeed = 0.0;
}
项目:GearBot    文件:RobotMap.java   
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    leftSideLeftPaddle = new Spark(0);
    LiveWindow.addActuator("LeftSide", "LeftPaddle", (Spark) leftSideLeftPaddle);

    leftSideLeftOut = new DigitalInput(0);
    LiveWindow.addSensor("LeftSide", "LeftOut", leftSideLeftOut);

    leftSideLeftIn = new DigitalInput(2);
    LiveWindow.addSensor("LeftSide", "LeftIn", leftSideLeftIn);

    rightSideRightPaddle = new Spark(1);
    LiveWindow.addActuator("RightSide", "RightPaddle", (Spark) rightSideRightPaddle);

    rightSideRightOut = new DigitalInput(1);
    LiveWindow.addSensor("RightSide", "RightOut", rightSideRightOut);

    rightSideRightIn = new DigitalInput(3);
    LiveWindow.addSensor("RightSide", "RightIn", rightSideRightIn);

    gearGate = new Spark(2);
    LiveWindow.addActuator("Gear", "Gate", (Spark) gearGate);

    gearGearIsIn = new DigitalInput(4);
    LiveWindow.addSensor("Gear", "GearIsIn", gearGearIsIn);


// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
项目:FlashLib    文件:FRCPulseCounter.java   
public FRCPulseCounter(DigitalInput port, boolean pulseLength) {
    counter = new Counter();

    if(pulseLength){
        counter.setPulseLengthMode(0.01);
    }else{
        counter.setUpSource(port);
        counter.setUpDownCounterMode();
        counter.setSemiPeriodMode(false);
    }

    quadrature = false;
}
项目:FlashLib    文件:FRCPulseCounter.java   
public FRCPulseCounter(DigitalInput upPort, DigitalInput downPort) {
    counter = new Counter();

    counter.setUpSource(upPort);
    counter.setDownSource(downPort);
    counter.setUpDownCounterMode();
    counter.setSemiPeriodMode(false);

    quadrature = true;
}
项目:thirdcoast    文件:DioSet.java   
void removeInput(int channel) {
  if (inputs.size() == 0) {
    logger.debug("removeInput: inputs not initialized, returning");
    return;
  }
  DigitalInput input = inputs.get(channel);
  if (input == null) {
    logger.info("input channel {} is already removed", channel);
    return;
  }
  input.free();
  inputs.set(channel, null);
  logger.info("removed input {}", channel);
}
项目:thirdcoast    文件:InspectDigitalInputsCommand.java   
@Override
public void perform() {
  PrintWriter writer = terminal.writer();
  writer.println(Messages.bold("\nDigital Input States"));
  for (int i = 0; i < 10; i++) {
    writer.print(Messages.bold(String.format("%2d  ", i)));
    DigitalInput input = dioSet.getDigitalInputs().get(i);
    if (input != null) {
      writer.println(input.get() ? "OFF" : Messages.boldGreen(" ON"));
    } else {
      writer.println("OUTPUT");
    }
  }
}
项目:2016-Robot-Final    文件:Intake.java   
public Intake() {
motor = new Spark(RobotMap.IntakeMap.PWM_MOTOR);
motor.setInverted(RobotMap.IntakeMap.INV_MOTOR);

limit = new DigitalInput(RobotMap.IntakeMap.DIO_LIMIT);
stop();
   }
项目:FRC-Robotics-2016-Team-2262    文件:Arm.java   
public Arm(int elbowChannel, int armRollerChannel, int topChannel) {

        elbow = new Talon(elbowChannel);
        roller = new Talon(armRollerChannel);

        limitSwitchTop = new DigitalInput(topChannel);
        //limitSwitchBottom = new DigitalInput(bottomChannel);
    }
项目:2016-Robot    文件:Intake.java   
public Intake() {
motor = new Spark(RobotMap.IntakeMap.PWM_MOTOR);
motor.setInverted(RobotMap.IntakeMap.INV_MOTOR);

limit = new DigitalInput(RobotMap.IntakeMap.DIO_LIMIT);
stop();
   }
项目:Stronghold2016-340    文件:Climber.java   
/**
     * Instantiate latch and sensor
     */
    public Climber() {
        armLatch = new Servo(RobotMap.CLIMBER_LATCH);
        dart = new Talon(4);
//      atBottom = new DigitalInput(RobotMap.ClimberBottomSensor);
        dartLimit = new DigitalInput(RobotMap.CLIMBER_DART_LIMIT);
        winchBanner = new DigitalInput(RobotMap.CLIMBER_BANNER);
    }
项目:Stronghold2016-340    文件:HarvesterRollers.java   
public HarvesterRollers() {
        shooterWheelA = new CANTalon(RobotMap.HARVESTER_SHOOTER_WHEEL_A);//Construct shooter A as CANTalon, this should have encoder into it
        shooterWheelB = new CANTalon(RobotMap.HARVESTER_SHOOTER_WHEEL_B);//Construct shooter B as CANTalon
//      shooterWheelB.changeControlMode(CANTalon.TalonControlMode.Follower);//turn shooter motor B to a slave
//      shooterWheelB.set(shooterWheelA.get());//slave shooter motor B to shooter motor A

        harvesterBallControl = new CANTalon(RobotMap.HARVESTER_BALL_CONTROL);

        ballSensorLeft = new DigitalInput(RobotMap.BALL_SENSOR_LEFT);
        ballSensorRight = new DigitalInput(RobotMap.BALL_SENSOR_RIGHT);
        pdp = new PowerDistributionPanel();
    }
项目:Stronghold2016-340    文件:ClawArm.java   
public ClawArm() {
    System.out.println("Claw arm constructor method called");
    armMotor = new TalonSRX(RobotMap.ClawArmMotor);

    clawPiston = new Solenoid(RobotMap.ClawPiston);

    armAngleSensor = new AnalogPotentiometer(RobotMap.ClawArmAngleSensor,270);
    bottomSwitch = new DigitalInput(RobotMap.ClawBottomSwitch);
    topSwitch = new DigitalInput(RobotMap.ClawTopSwitch);
    System.out.println("Claw arm constructor method complete.");
}
项目:FRC-2014-robot-project    文件:AutonomousModeHandler.java   
public AutonomousModeHandler(Encoder enc1, Encoder enc2, RobotDrivePID robotoDrive, AxisCamera cam, ConfigurableValues configurableValues,
                             IntakeControl frontIntake, IntakeControl backIntake, ShooterControl shooterControl, DigitalInput frontIntakeArmAngleDetector)
{
    m_configurableValues = configurableValues;
    m_shooterControl = shooterControl;
    m_robotDrivePid = robotoDrive;
    m_frontIntake = frontIntake;
    m_backIntake = backIntake;
    m_frontIntakeArmAngleDetector = frontIntakeArmAngleDetector;
    m_driveEncoder1 = enc1;
    m_driveEncoder2 = enc2;
    m_encoderAverager = new EncoderAverager(m_driveEncoder1, m_driveEncoder2);

    m_autonomousImageDetector = new AutonomousImageDetector(cam,m_configurableValues);
    m_nextStateArray= new byte[256];
    m_motorBrake = new MotorBrake();

    SetCurrentState(AUTONOMOUS_HANDLER_STATE_WAIT);
    SetNextStateArray(AUTONOMOUS_MODE_1_BALL_SHOOTING);

    m_overrideCoefficients = false;

    m_pidController = null;

    m_disabled = true;
    m_shootingBall = false;
    m_driving = false;
    m_braking = false;
    m_detectingImage = false;
    m_currentStateIndex = 0;
    m_loadingBall = false;
    m_shooterPullingBack = false;
}
项目:FRC-2014-robot-project    文件:EncoderRPM.java   
public void Init(SpeedController speedController,Encoder encoder, double rpm, double maxRpm, double error, double targetRotations, DigitalInput limitSwitch)
{

    m_speedController = speedController;
    m_encoder = encoder;
    m_targetRpm = rpm;
    m_maxRpm = maxRpm;
    m_errorPercent = error;
    m_lastValueSet = 0;
    m_targetRotations = targetRotations;
    m_switch = limitSwitch;
    m_encoder.reset();
    m_enabled = false;
    m_running = false;
}
项目:FRC-2016    文件:Turret.java   
/**
 * Constructor
 */
private Turret() {
    winch = new CANTalon(TURRET);
    winch.changeControlMode(PERCENT_VBUS_MODE);
    winch.enableBrakeMode(BRAKE_MODE);
    lower = new DigitalInput(0);
    upper = new DigitalInput(1);
    // winch.setFeedbackDevice(FeedbackDevice.CtreMagEncoder_Relative);
}
项目:r2016    文件:HookerSubsystem.java   
public HookerSubsystem(SpeedControllerSubsystemType type, final int speedControllerChannel, final DigitalInput _encoderAChannel, final DigitalInput _encoderBChannel, final int limitSwitchChannel) {
    super(type, speedControllerChannel);

    this._encoder = new Encoder(_encoderAChannel, _encoderBChannel);
    this._limitSwitch = new LimitSwitch(limitSwitchChannel);

    this.setDataKey(HookerSubsystemDataKey.POWER, 0.0d);
}
项目:FRC2549-2016    文件:ShooterSubsystem.java   
public ShooterSubsystem(){
    liftController=RobotMap.liftMotor.getController();
    wheelController=RobotMap.wheelMotor.getController();

    liftGyro = new AnalogGyro(RobotMap.liftGyroPort);
    liftGyro.reset();
    liftGyro.setSensitivity(0.007);

    limitSwitch = new DigitalInput(RobotMap.limitSwitch);
}
项目:Frc2017FirstSteamWorks    文件:GearPickup.java   
/**
 * Initialize the GearPickup class.
 */
public GearPickup()
{
    claw = new FrcPneumatic(
        "GearPickupClaw", RobotInfo.CANID_PCM1,
        RobotInfo.SOL_GEARPICKUP_CLAW_EXTEND, RobotInfo.SOL_GEARPICKUP_CLAW_RETRACT);
    arm = new FrcPneumatic(
        "GearPickupArm", RobotInfo.CANID_PCM1,
        RobotInfo.SOL_GEARPICKUP_ARM_EXTEND, RobotInfo.SOL_GEARPICKUP_ARM_RETRACT);
    gearSensor = new DigitalInput(RobotInfo.DIN_GEAR_SENSOR);
}
项目:RecycleRush2015    文件:WinchControl.java   
public WinchControl(SpeedController motor, double upSpeed, double downSpeed, DigitalInput upSwitch, DigitalInput downSwitch) {
    this.winchMotor = motor;
    this.upValue = upSpeed;
    this.downValue = downSpeed;
    this.upSwitch = upSwitch;
    this.downSwitch = downSwitch;
}
项目:RecycleRush2015    文件:WinchControl.java   
public DigitalInput setSwitch(Direction dir, DigitalInput newSwitch) {
    DigitalInput prev;

    if (dir == Direction.UPWARDS) {
        prev = this.upSwitch;
        this.upSwitch = newSwitch;
    } else {
        prev = this.downSwitch;
        this.downSwitch = newSwitch;
    }

    return prev;
}
项目:Stronghold-2016    文件:FlyWheels.java   
public FlyWheels() {
    left = new CANTalon(RobotMap.LEFT_SHOOTER_MOTOR);
    right = new CANTalon(RobotMap.RIGHT_SHOOTER_MOTOR);
    left.enableBrakeMode(true);
    right.enableBrakeMode(true);

    right.changeControlMode(CANTalon.TalonControlMode.Follower);
    right.reverseOutput(true);

    pusher = new DoubleSolenoid(RobotMap.PUSHER_OUT_PORT, RobotMap.PUSHER_IN_PORT);

    wheelSwitch = new DigitalInput(RobotMap.FLYWHEEL_ENCODER_SWITCH);
    counter = new Counter(wheelSwitch);
}
项目:Robot2015    文件:CopyOfToteElevatorSubsystem.java   
public CopyOfToteElevatorSubsystem() {
    // Add the safety elements to the elevator talon
    // Since negative power drives the motor up, the negative limit switch is the elevator upper limit switch
    elevatorMotor.setNegativeLimitSwitch(new DigitalInput(RobotMap.TOTE_ELEVATOR_UPPER_LIMIT_SWITCH));
    elevatorMotor.setPositiveLimitSwitch(floorSensor);
    elevatorMotor.setOverCurrentFuse(RobotMap.TOTE_ELEVATOR_POWER_DISTRIBUTION_PORT, SafeTalon.CURRENT_NO_LIMIT, 0);
}
项目:Robot2015    文件:SafeTalon.java   
/**
 * Set the negative limit switch for this Talon.  
 * <p>
 * This limit switch will stop the motor (set the talon to zero) if the limit switch
 * is engaged and the motor set value is negative (<0).  Any calls to {@link #pidWrite(double)}
 * or {@link #set(double)} that contain a negative value will be overridden to zero.  Positive
 * motor speeds will still be accepted.
 * 
 * @param negativeLimitSwitch - a digital input used for this limit switch.
 * @param defaultState - the default state for this limit switch. The value opposite of the default
 * state is used to determine if the switch is engaged.  
 */
public void setNegativeLimitSwitch(DigitalInput negativeLimitSwitch, boolean defaultState) {
    this.negativeLimitSwitch             = negativeLimitSwitch;
    this.negativeLimitSwitchDefaultState = defaultState;

    // If the default state is true, the counter should detect falling edges
    this.negativeLimitSwitchCounter = new Counter(this.negativeLimitSwitch);
    if (defaultState == false) {
        this.negativeLimitSwitchCounter.setUpSourceEdge(true, false);
    } else {
        this.negativeLimitSwitchCounter.setUpSourceEdge(false, true);
    }
    this.negativeLimitSwitchCounter.reset();
}
项目:Robot2015    文件:SafeTalon.java   
/**
 * Set the positive limit switch for this Talon.  
 * <p>
 * This limit switch will stop the motor (set the talon to zero) if the limit switch
 * is engaged and the motor set value is positive (>0).  Any calls to {@link #pidWrite(double)}
 * or {@link #set(double)} that contain a positive value will be overridden to zero.  Negative
 * motor speeds will still be accepted.
 * 
 * @param positiveLimitSwitch - a digital input used for this limit switch.
 * @param defaultState - the default state for this limit switch. The value opposite of the default
 * state is used to determine if the switch is engaged.  
 */
public void setPositiveLimitSwitch(DigitalInput positiveLimitSwitch, boolean defaultState) {
    this.positiveLimitSwitch             = positiveLimitSwitch;
    this.positiveLimitSwitchDefaultState = defaultState;

    // If the default state is true, the counter should detect falling edges
    this.positiveLimitSwitchCounter = new Counter(this.positiveLimitSwitch);
    if (defaultState == false) {
        this.positiveLimitSwitchCounter.setUpSourceEdge(true, false);
    } else {
        this.positiveLimitSwitchCounter.setUpSourceEdge(false, true);
    }
    this.positiveLimitSwitchCounter.reset();
}
项目:turtleshell    文件:Robot.java   
public Robot() {
    stick = new Joystick(0);
    try {
        /* Construct Digital I/O Objects */
        pwm_out_9 = new Victor(        getChannelFromPin( PinType.PWM,       9 ));
        pwm_out_8 = new Jaguar(        getChannelFromPin( PinType.PWM,       8 ));
        dig_in_7  = new DigitalInput(  getChannelFromPin( PinType.DigitalIO, 7 ));
        dig_in_6  = new DigitalInput(  getChannelFromPin( PinType.DigitalIO, 6 ));
        dig_out_5 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 5 ));
        dig_out_4 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 4 ));
        enc_3and2 = new Encoder(       getChannelFromPin( PinType.DigitalIO, 3 ),
                                       getChannelFromPin( PinType.DigitalIO, 2 ));
        enc_1and0 = new Encoder(       getChannelFromPin( PinType.DigitalIO, 1 ),
                                       getChannelFromPin( PinType.DigitalIO, 0 ));

        /* Construct Analog I/O Objects */
        /* NOTE:  Due to a board layout issue on the navX MXP board revision */
        /* 3.3, there is noticeable crosstalk between AN IN pins 3, 2 and 1. */
        /* For that reason, use of pin 3 and pin 2 is NOT RECOMMENDED.       */
        an_in_1   = new AnalogInput(   getChannelFromPin( PinType.AnalogIn,  1 ));
        an_trig_0 = new AnalogTrigger( getChannelFromPin( PinType.AnalogIn,  0 ));
        an_trig_0_counter = new Counter( an_trig_0 );

        an_out_1  = new AnalogOutput(  getChannelFromPin( PinType.AnalogOut, 1 ));
        an_out_0  = new AnalogOutput(  getChannelFromPin( PinType.AnalogOut, 0 ));

        /* Configure I/O Objects */
        pwm_out_9.setSafetyEnabled(false); /* Disable Motor Safety for Demo */
        pwm_out_8.setSafetyEnabled(false); /* Disable Motor Safety for Demo */

        /* Configure Analog Trigger */
        an_trig_0.setAveraged(true);
        an_trig_0.setLimitsVoltage(MIN_AN_TRIGGER_VOLTAGE, MAX_AN_TRIGGER_VOLTAGE);
    } catch (RuntimeException ex ) {
        DriverStation.reportError( "Error instantiating MXP pin on navX MXP:  " 
                                    + ex.getMessage(), true);
    }
}
项目:turtleshell    文件:Claw.java   
public Claw() {
      super();
      motor = new Victor(7);
      contact = new DigitalInput(5);

// Let's show everything on the LiveWindow
      LiveWindow.addActuator("Claw", "Motor", (Victor) motor);
      LiveWindow.addActuator("Claw", "Limit Switch", contact);
  }
项目:turtleshell    文件:Robot.java   
public Robot() {
    stick = new Joystick(0);
    try {
        /* Construct Digital I/O Objects */
        pwm_out_9 = new Victor(        getChannelFromPin( PinType.PWM,       9 ));
        pwm_out_8 = new Jaguar(        getChannelFromPin( PinType.PWM,       8 ));
        dig_in_7  = new DigitalInput(  getChannelFromPin( PinType.DigitalIO, 7 ));
        dig_in_6  = new DigitalInput(  getChannelFromPin( PinType.DigitalIO, 6 ));
        dig_out_5 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 5 ));
        dig_out_4 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 4 ));
        enc_3and2 = new Encoder(       getChannelFromPin( PinType.DigitalIO, 3 ),
                                       getChannelFromPin( PinType.DigitalIO, 2 ));
        enc_1and0 = new Encoder(       getChannelFromPin( PinType.DigitalIO, 1 ),
                                       getChannelFromPin( PinType.DigitalIO, 0 ));

        /* Construct Analog I/O Objects */
        /* NOTE:  Due to a board layout issue on the navX MXP board revision */
        /* 3.3, there is noticeable crosstalk between AN IN pins 3, 2 and 1. */
        /* For that reason, use of pin 3 and pin 2 is NOT RECOMMENDED.       */
        an_in_1   = new AnalogInput(   getChannelFromPin( PinType.AnalogIn,  1 ));
        an_trig_0 = new AnalogTrigger( getChannelFromPin( PinType.AnalogIn,  0 ));
        an_trig_0_counter = new Counter( an_trig_0 );

        an_out_1  = new AnalogOutput(  getChannelFromPin( PinType.AnalogOut, 1 ));
        an_out_0  = new AnalogOutput(  getChannelFromPin( PinType.AnalogOut, 0 ));

        /* Configure I/O Objects */
        pwm_out_9.setSafetyEnabled(false); /* Disable Motor Safety for Demo */
        pwm_out_8.setSafetyEnabled(false); /* Disable Motor Safety for Demo */

        /* Configure Analog Trigger */
        an_trig_0.setAveraged(true);
        an_trig_0.setLimitsVoltage(MIN_AN_TRIGGER_VOLTAGE, MAX_AN_TRIGGER_VOLTAGE);
    } catch (RuntimeException ex ) {
        DriverStation.reportError( "Error instantiating MXP pin on navX MXP:  " 
                                    + ex.getMessage(), true);
    }
}
项目:2015RobotCode    文件:ArmElevator.java   
@Override
public void initialize() {

    m_victor = new Victor(RobotMap.LIFT_MOTOR);
    m_victor.enableDeadbandElimination(true);
    m_victor.setExpiration(Victor.DEFAULT_SAFETY_EXPIRATION);

    m_encoder = new Encoder(RobotMap.ENCODER_DIO_PORTA,
            RobotMap.ENCODER_DIO_PORTB, true);
    m_encoder.setSamplesToAverage(10);

    m_maxLimit = new DigitalInput(RobotMap.LIMIT_DIO_PORT1);
    max_counter = new Counter(m_maxLimit);

}
项目:Swerve    文件:CompressorControl.java   
CompressorControl(int chanCompressor, int modComp, int modPS, int chanPS) {
    compressor = new Relay(modComp, chanCompressor, Relay.Direction.kForward);
    pressureSwitch = new DigitalInput(modPS, chanPS);

    // Start background task
    Thread t = new Thread(this);
    t.start();
}
项目:4500-2014    文件:Winch.java   
Winch(JoyStickCustom inStick){
    winchRelease=new Pneumatics(1,2);
    winch= new Victor(5);

    states[0]="WINDING";
    states[1]="RELEASING";
    states[2]="HOLDING";
    setState(HOLDING1);//same as holding used to be

    limitSwitch= new DigitalInput(4);

    secondStick = inStick;
    winchE= new Encoder(3,2);
    winchE.start();
}