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

项目:SwerveDrive    文件:AbsoluteAnalogEncoder.java   
public AbsoluteAnalogEncoder(int channel, double minVoltage, double maxVoltage, double offsetDegrees) {
    super(channel);

    if (minVoltage >= maxVoltage) throw new IllegalArgumentException("Minimum voltage must be less than maximum voltage");
    if (offsetDegrees < 0 || offsetDegrees > 360) throw new IllegalArgumentException("Offset must be between 0 and 360 degrees");

    _channel = channel;
    _minVoltage = minVoltage;
    _maxVoltage = maxVoltage;
    _offsetDegrees = offsetDegrees;

    // Turn counter only ever stores 0 //
    _turnCounter = new Counter();
    _turnCounter.reset();
    _turnCounter.stop();
}
项目: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);
}
项目: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;
}
项目:FRC6414program    文件:USensor.java   
public USensor() {
    leftPulse = new DigitalOutput(RobotMap.LEFT_PULSE);
    left = new Counter(RobotMap.LEFT_ECHO);
    left.setMaxPeriod(1);
    left.setSemiPeriodMode(true);
    left.reset();

    rightPulse = new DigitalOutput(RobotMap.RIGHT_PULSE);
    right = new Counter(RobotMap.RIGHT_ECHO);
    right.setMaxPeriod(1);
    right.setSemiPeriodMode(true);
    right.reset();

    threadInit(() -> {
        leftPulse.pulse(RobotMap.US_PULSE);
        rightPulse.pulse(RobotMap.US_PULSE);

        do {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } while (left.get() < 2 || right.get() < 2);

        leftDistant = left.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;
        rightDistant = right.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;

        SmartDashboard.putNumber("left dis", leftDistant);
        SmartDashboard.putNumber("right dis", rightDistant);

        left.reset();
        right.reset();
    });
}
项目: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;
}
项目:R2017    文件:Shooter.java   
public Shooter() {
    shooterMotor = new VictorSP(Constants.SHOOTER);
    shooterMotor2 = new VictorSP(Constants.SHOOTER_2);

    shooterMotor.setInverted(true);
    shooterMotor2.setInverted(true);

    hallEffect = new Counter(Constants.HALL_EFFECT);
    hallEffect.setDistancePerPulse(1);
}
项目: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    文件: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    文件:TurtleHallSensor.java   
public TurtleHallSensor(int port, boolean countHighs) {
    c = new Counter();
    c.setUpSource(port);
    c.setUpDownCounterMode();
    c.setSemiPeriodMode(countHighs);
    c.setMaxPeriod(1);
    c.setDistancePerPulse(1);
    c.setSamplesToAverage(6);
}
项目: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    文件: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);

}
项目:SwerveDrive    文件:AbsoluteAnalogEncoder.java   
public AbsoluteAnalogEncoder(int channel, double minVoltage, double maxVoltage, double offsetDegrees, int analogSampleRate, double analogTriggerThresholdDifference) { //TODO: Implement direction
    super(channel);
    _channel = channel;
    if (minVoltage >= maxVoltage) throw new IllegalArgumentException("Minimum voltage must be less than maximum voltage");
    if (offsetDegrees < 0 || offsetDegrees > 360) throw new IllegalArgumentException("Offset must be between 0 and 360 degrees");

    // Initialize analog trigger //
    _analogTrigger = new AnalogTrigger(channel);
    _analogTrigger.setFiltered(true);
    _analogTrigger.setLimitsVoltage(minVoltage + analogTriggerThresholdDifference, maxVoltage - analogTriggerThresholdDifference);
    AnalogTriggerOutput _analogTriggerFalling = new AnalogTriggerOutput(_analogTrigger, AnalogTriggerOutput.Type.kFallingPulse);
    AnalogTriggerOutput _analogTriggerRising = new AnalogTriggerOutput(_analogTrigger, AnalogTriggerOutput.Type.kRisingPulse);

    // Set analog module sampling rate //        
    AnalogModule module = (AnalogModule) Module.getModule(ModulePresence.ModuleType.kAnalog, DEFAULT_ANALOG_MODULE);
    module.setSampleRate(analogSampleRate);

    // Initialize turn counter //
    _turnCounter = new Counter();
    _turnCounter.setUpDownCounterMode();
    _turnCounter.setUpSource(_analogTriggerRising);
    _turnCounter.setDownSource(_analogTriggerFalling);
    _turnCounter.start();

    _minVoltage = minVoltage;
    _maxVoltage = maxVoltage;
    _offsetDegrees = offsetDegrees;
}
项目:Aerial-Assist    文件:Launcher.java   
/**
 * Measures a physical switch press and translates it to virtual meaning. If
 * the winder motor is moving in the negative direction, the mechanism is
 * unwinding and so the switch press count should decrease, and if the motor
 * is moving in the positive direction, the mechanism is winding, and thus
 * the switch press count should increase.
 *
 * @param counter The Counter object that represents the physical limit
 * switch virtually. A physical switch press increments the counter value
 * twice: once on the press (by 4 - 10) and once on the release (by 1 - 3).
 * The code only acknowledges the presses by ignoring all increases that are
 * less than 4.
 */
private void isSwitchPressed(Counter counter) {
    if (counter.get() > 3) {
        if (winderL.get() <= -0.1) {
            currentClick--;
        } else if (winderL.get() >= 0.1) {
            currentClick++;
        } else {
            System.out.println("The switch should not have been pressed.");
        }

        clickTime = Timer.getFPGATimestamp();
    }
    counter.reset();
}
项目:2013_drivebase_proto    文件:FlywheelEncoders.java   
public void update (){ 
    enter_wheel_speed = ((Double) WsOutputManager.getInstance().getOutput(WsOutputManager.SHOOTER_VICTOR_ENTER).get((IOutputEnum) null));
    exit_wheel_speed = ((Double) WsOutputManager.getInstance().getOutput(WsOutputManager.SHOOTER_VICTOR_EXIT).get((IOutputEnum) null));



    //Use instanteous speed to update encoders
    if (enter_wheel_speed > 0) {
        enter_wheel_encoder+= AMOUNT_TO_CHANGE;
    } else {
        enter_wheel_encoder-= AMOUNT_TO_CHANGE;
        if (enter_wheel_encoder < 0){
            enter_wheel_encoder = 0 ;
        }
    }
    if (exit_wheel_speed > 0) {
        exit_wheel_encoder+= AMOUNT_TO_CHANGE;
    } else {
        exit_wheel_encoder-= AMOUNT_TO_CHANGE;
        if (exit_wheel_encoder < 0){
            exit_wheel_encoder = 0 ;
        }
    }

    ((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getEnterCounter()).set(enter_wheel_encoder);
    ((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getExitCounter()).set(exit_wheel_encoder);
}
项目:2014-robot-code    文件:ShootArm.java   
public ShootArm() {
    arm = new Talon(Ports.SHOOTER_LAUNCHER);
    arm.set(0);
    launcherEncoder = new Encoder(Ports.SHOOTER_ENCODER_1, Ports.SHOOTER_ENCODER_2, false, Encoder.EncodingType.k4X);
    launcherEncoder.start();
    launcherEncoder.setDistancePerPulse(0.96);
    launcherEncoder.setMinRate(1);

    armHome = new DigitalInput(Ports.SHOOTER_HOME);
    armCounter = new Counter(armHome);
    armCounter.start();
    state = 0;
}
项目:SwerveDriveTest    文件:AnalogChannelVolt.java   
public AnalogChannelVolt(int moduleNumber, int channel) {
    super(moduleNumber, channel);

    this.getModule().setSampleRate(1000);

    m_trig = new AnalogTrigger(moduleNumber, channel);
    m_trig.setFiltered(true);
    m_trig.setLimitsVoltage(1.35, 3.65);

    m_count = new Counter();
    m_count.setUpDownCounterMode();
    m_count.setUpSource(m_trig, AnalogTriggerOutput.Type.kFallingPulse);
    m_count.setDownSource(m_trig, AnalogTriggerOutput.Type.kRisingPulse);
    m_count.start();
}
项目:MOEnarch-Drive    文件:AnalogChannelVolt.java   
public AnalogChannelVolt(int moduleNumber, int channel) {
    super(moduleNumber, channel);

    this.getModule().setSampleRate(1000);

    m_trig = new AnalogTrigger(moduleNumber, channel);
    m_trig.setFiltered(true);
    m_trig.setLimitsVoltage(1.35, 3.65);

    m_count = new Counter();
    m_count.setUpDownCounterMode();
    m_count.setUpSource(m_trig, AnalogTriggerOutput.Type.kFallingPulse);
    m_count.setDownSource(m_trig, AnalogTriggerOutput.Type.kRisingPulse);
    m_count.start();
}
项目:RobotCode2013    文件:PhotoelectricSensor.java   
/**
 * Initializes important objects for the 
 */
private void initialize() {
    counter    = new Counter(input);
    counter.setSemiPeriodMode(false);
    rateCalc   = new RateCalculator(counter);
    rateThread = new Thread(rateCalc);
}
项目:RobotCode2013    文件:PhotoelectricSensor.java   
public RateCalculator(Counter c) {
    this.c       = c;
    lastRate     = 0;
    lastCount    = 0;
    lastTick     = System.currentTimeMillis();
    delayPerLoop = 10;
    updateRate   = 200;
}
项目:Zed-Java    文件:Auger.java   
public Auger(int augerRelay, int augerRotationSwitch, int augerTopSwitch) {
    super("Auger");
    auger = new Relay(augerRelay);
    augerRotateSwitch = new DigitalInput(augerRotationSwitch);
    augerTopLimitSwitch = new DigitalInput(augerTopSwitch);
    counter = new Counter(augerRotateSwitch);
    counter.setSemiPeriodMode(false);
    direction = AugerDirection.AUGER_STOP;
    counter.start();
}
项目:FRC2013    文件:Shooter.java   
private Shooter(int motorChannel, int loader, int tilter, int encoder) {
    motor = new Victor(motorChannel);
    loaderPiston = new Solenoid(loader);
    tilterPiston = new Solenoid(tilter);
    cntr = new Counter(encoder);
    //cntr.setSemiPeriodMode(true);
    cntr.start();
    new Thread(this).start();
}
项目:frc1675-2013    文件:EncoderShooter.java   
public EncoderShooter() {
    backMotor = new Victor(RobotMap.BACK_SHOOTER_MOTOR);
    frontMotor = new Victor(RobotMap.FRONT_SHOOTER_MOTOR);
    counter = new Counter(RobotMap.SHOOTER_ENCODER);
    counter.setUpDownCounterMode();
    counter.start();
    setpoint = RobotMap.DEFAULT_SETPOINT;
    backMotor.set(RobotMap.BACK_SHOOTING_SPEED);


}
项目:UltimateAscentCode    文件:ClimbingSystem.java   
public ClimbingSystem(RobotTemplate robo)            
{
    try 
    {
        up = new Solenoid(Wiring.CLIMB_SOLENOID_UP);
        down = new Solenoid(Wiring.CLIMB_SOLENOID_DOWN);
        forward = new Solenoid(Wiring.CLIMBING_SOLENOID_FORWARD);
        back = new Solenoid(Wiring.CLIMBING_SOLENOID_BACKWARD);
        home = new DigitalInput(Wiring.CYLINDER_HOME);
        part = new DigitalInput(Wiring.CYLINDER_PART);
        max = new DigitalInput(Wiring.CYLINDER_MAX);
        winch = new CANJaguar(Wiring.WINCH_MOTOR);
        countPart = new Counter(part);
        countPart.setUpSourceEdge(true, false);
        countPart.reset();
        countPart.start();
        winch.configMaxOutputVoltage(6.0);
        forward.set(true);
        back.set(false);
        this.robo = robo;
        time.start();
        typicalCurrent = 0;

    } 
    catch (CANTimeoutException ex) 
    {
        ex.printStackTrace();
    }
}
项目:UltimateAscentEnhancedButtonLogic    文件:ClimbingSystem.java   
public ClimbingSystem(RobotTemplate robo)            
{
    try 
    {
        up = new Solenoid(Wiring.CLIMB_SOLENOID_UP);
        down = new Solenoid(Wiring.CLIMB_SOLENOID_DOWN);
        forward = new Solenoid(Wiring.CLIMBING_SOLENOID_FORWARD);
        back = new Solenoid(Wiring.CLIMBING_SOLENOID_BACKWARD);
        home = new DigitalInput(Wiring.CYLINDER_HOME);
        part = new DigitalInput(Wiring.CYLINDER_PART);
        max = new DigitalInput(Wiring.CYLINDER_MAX);
        winch = new CANJaguar(Wiring.WINCH_MOTOR);
        countPart = new Counter(part);
        countPart.setUpSourceEdge(true, false);
        countPart.reset();
        countPart.start();
        winch.configMaxOutputVoltage(6.0);
        forward.set(true);
        back.set(false);
        this.robo = robo;
        time.start();
        typicalCurrent = 0;

    } 
    catch (CANTimeoutException ex) 
    {
        ex.printStackTrace();
    }
}
项目:2013_robot_software    文件:FlywheelEncoders.java   
public void update (){ 
    enter_wheel_speed = ((Double) WsOutputManager.getInstance().getOutput(WsOutputManager.SHOOTER_VICTOR_ENTER).get((IOutputEnum) null));
    exit_wheel_speed = ((Double) WsOutputManager.getInstance().getOutput(WsOutputManager.SHOOTER_VICTOR_EXIT).get((IOutputEnum) null));



    //Use instanteous speed to update encoders
    if (enter_wheel_speed > 0) {
        enter_wheel_encoder+= AMOUNT_TO_CHANGE;
    } else {
        enter_wheel_encoder-= AMOUNT_TO_CHANGE;
        if (enter_wheel_encoder < 0){
            enter_wheel_encoder = 0 ;
        }
    }
    if (exit_wheel_speed > 0) {
        exit_wheel_encoder+= AMOUNT_TO_CHANGE;
    } else {
        exit_wheel_encoder-= AMOUNT_TO_CHANGE;
        if (exit_wheel_encoder < 0){
            exit_wheel_encoder = 0 ;
        }
    }

    ((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getEnterCounter()).set(enter_wheel_encoder);
    ((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getExitCounter()).set(exit_wheel_encoder);
}
项目:StormRobotics2017    文件:HallEffectSensor.java   
public HallEffectSensor(int port){
    _hallEffect = new DigitalInput(port);
    _counter    = new Counter(_hallEffect);
}
项目:2013_drivebase_proto    文件:WsShooter.java   
public Counter getEnterCounter() {
    return counterEnter;
}
项目:2013_drivebase_proto    文件:WsShooter.java   
public Counter getExitCounter() {
    return counterExit;
}
项目:2013_drivebase_proto    文件:WsShooter.java   
public Counter getEnterCounterValue() {
    return counterEnter;
}
项目:2013_drivebase_proto    文件:WsShooter.java   
public Counter getExitCounterValue() {
    return counterExit;
}
项目:Storm2014    文件:HallEffectSpeedSensor.java   
public HallEffectSpeedSensor(int port) {
    _hallEffect = new DigitalInput(port);
    _counter = new Counter(_hallEffect);
    _counter.start();
}
项目:2015-frc-robot    文件:MecanumEncoder.java   
public MecanumEncoder(int pin) {
    encoder = new Counter(new DigitalInput(pin));
    encoder.setDistancePerPulse(this.distance_per_pulse);
    encoder.setMaxPeriod(this.max_period);
}
项目:2015-frc-robot    文件:MecanumEncoder.java   
public MecanumEncoder(int pin, double dist, double period) {
    encoder = new Counter(new DigitalInput(pin));
    encoder.setDistancePerPulse(dist);
    encoder.setMaxPeriod(period);
}
项目:Storm2013    文件:HallEffectSpeedSensor.java   
public HallEffectSpeedSensor(int port) {
    _hallEffect = new DigitalInput(port);
    _counter = new Counter(_hallEffect);
    _counter.start();
}
项目:wpilib-java    文件:FakeEncoderTest.java   
public void setup()
{
    counter = new Counter(DIOCrossConnectD1);
    fakeEncoder = new FakeCounterSource(2, DIOCrossConnectD2);
}
项目:wpilib-java    文件:FakeQuadEncoderTest.java   
public void setup()
{
    counter = new Counter(DIOCrossConnectA1);
    counter2 = new Counter(DIOCrossConnectB1);
    fakeQEncoder = new FakeEncoderSource(2, DIOCrossConnectA2, 2, DIOCrossConnectB2);
}
项目:wpilib-java    文件:JaguarTest.java   
public void setup() {
    victor = new Victor(2);
    gts = new Counter(2, GreyJagGearTooth); // need to encode this slot number
}