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

项目:FRC-2017-Command    文件:DriveEncoders.java   
/**
 * Constructs left and right encoders to be used by the subsystem
 * @param leftChannelA DIO port for the left encoder and channel a
 * @param leftChannelB DIO port for the left encoder and channel b
 * @param rightChannelA DIO port for the right encoder and channel a
 * @param rightChannelB DIO port for the right encoder and channel b
 * @param maxPeriod max period to be considered stopped
 * @param minRate max rate to be considered stopped
 * @param distancePerPulse value to convert a pulse into a distance. This is based on encoder resolution and wheel size.
 * @param reverseDirection should the encoder direction be reversed
 * @param samplesToAverage number of samples to average to calculate period
 */
public DriveEncoders(int leftChannelA, int leftChannelB, int rightChannelA,int rightChannelB,
                     double maxPeriod, int minRate, double distancePerPulse, boolean reverseDirection,int samplesToAverage) {

    encoderLeft  = new Encoder(leftChannelA, leftChannelB, reverseDirection, Encoder.EncodingType.k4X);
    encoderRight  = new Encoder(rightChannelA, rightChannelB, reverseDirection, Encoder.EncodingType.k4X);

    encoderLeft.setMaxPeriod(maxPeriod);
    encoderLeft.setMinRate(minRate);
    encoderLeft.setDistancePerPulse(distancePerPulse);
    encoderLeft.setSamplesToAverage(samplesToAverage);
    encoderRight.setMaxPeriod(maxPeriod);
    encoderRight.setMinRate(minRate);
    encoderRight.setDistancePerPulse(distancePerPulse);
    encoderRight.setSamplesToAverage(samplesToAverage);
}
项目:2017    文件:Drive.java   
/**
 * Initializes all the encoders. Is called in the constructor and can
 * be called outside the class.
 *
 * @param _leftFrontEncoder
 *            The front left encoder
 * @param _rightFrontEncoder
 *            The front right encoder
 * @param _leftRearEncoder
 *            The back left encoder
 * @param _rightRearEncoder
 *            The back right encoder
 */
public void initEncoders (Encoder _leftFrontEncoder,
        Encoder _rightFrontEncoder, Encoder _leftRearEncoder,
        Encoder _rightRearEncoder)
{
    // tell the class we have the encoders ready to go!
    isUsingEncoders = true;
    // Actually set up the local encoder objects
    this.leftFrontEncoder = _leftFrontEncoder;
    this.rightFrontEncoder = _rightFrontEncoder;
    this.leftRearEncoder = _leftRearEncoder;
    this.rightRearEncoder = _rightRearEncoder;
    // Set the encoder distance per pulse to a default value so we have it.
    // TODO call with correct value in robot init, possibly remove here
    this.setEncoderDistancePerPulse(DEFAULT_DISTANCE_PER_PULSE);
}
项目:2017    文件:Drive.java   
/**
 * Checks to see if either side of encoders has changed direction since the last
 * call.
 * 
 * @param leftEncoder
 *            The left encoder to check for direction.
 * @param rightEncoder
 *            The right encoder to check for direction.
 * @return
 *         True if either drive train has changed direction since the last call.
 */
public boolean directionChanged (Encoder leftEncoder,
        Encoder rightEncoder)
{
    // if /Encoder/ - distance from previous call is less than 0
    //
    if (Math.abs(leftEncoder.getDistance())
            - this.brakePreviousDistanceL < 0
            && Math.abs(rightEncoder.getDistance())
                    - this.brakePreviousDistanceR < 0)
        {
        // set brakePreviousDistance to 0 and return true
        this.brakePreviousDistanceL = 0;
        this.brakePreviousDistanceR = 0;
        return true;
        }
    // set brakePreviousDistance to the encoder value
    brakePreviousDistanceL = Math.abs(leftEncoder.getDistance());
    brakePreviousDistanceR = Math.abs(rightEncoder.getDistance());
    return false;
}
项目:2017    文件:Transmission_old.java   
/**
 * Constructor for a four-wheel drive transmission class with
 * already-initialized encoders
 *
 * @param rightFrontSpeedController
 * @param rightRearSpeedController
 * @param leftFrontSpeedController
 * @param leftRearSpeedController
 * @param rightFrontEncoder
 * @param rightRearEncoder
 * @param leftFrontEncoder
 * @param leftRearEncoder
 */
public Transmission_old (
        final SpeedController rightFrontSpeedController,
        final SpeedController rightRearSpeedController,
        final SpeedController leftFrontSpeedController,
        final SpeedController leftRearSpeedController,
        Encoder rightFrontEncoder, Encoder rightRearEncoder,
        Encoder leftFrontEncoder, Encoder leftRearEncoder)
{
    this.isFourWheel = true;
    this.oneOrRightSpeedController = rightFrontSpeedController;
    this.leftSpeedController = leftFrontSpeedController;
    this.rightRearSpeedController = rightRearSpeedController;
    this.leftRearSpeedController = leftRearSpeedController;

    this.initEncoders(rightFrontEncoder, rightRearEncoder,
            leftFrontEncoder, leftRearEncoder);

    this.initPIDControllers();

    this.init();

}
项目:2017    文件:Transmission_old.java   
public boolean directionChanged (Encoder leftEncoder,
        Encoder rightEncoder)
{
    // if /Encoder/ - distance from previous call is less than 0
    //
    if (Math.abs(leftEncoder.getDistance())
            - this.brakePreviousDistanceL < 0
            && Math.abs(rightEncoder.getDistance())
                    - this.brakePreviousDistanceR < 0)
        {
        // set brakePreviousDistance to 0 and return true
        this.brakePreviousDistanceL = 0;
        this.brakePreviousDistanceR = 0;
        return true;
        }

        {
        // set brakePreviousDistance to the encoder value
        brakePreviousDistanceL = Math.abs(leftEncoder.getDistance());
        brakePreviousDistanceR = Math.abs(rightEncoder.getDistance());
        return false;
        }
}
项目:MinuteMan    文件:HardwareAdaptor.java   
private HardwareAdaptor(){
    pdp = new PowerDistributionPanel();
    comp = new Compressor();
    shifter = new DoubleSolenoid(SolenoidMap.SHIFTER_FORWARD, SolenoidMap.SHIFTER_REVERSE);

    navx = new AHRS(CoprocessorMap.NAVX_PORT);

    dtLeftEncoder = new Encoder(EncoderMap.DT_LEFT_A, EncoderMap.DT_LEFT_B, EncoderMap.DT_LEFT_INVERTED);
    S_DTLeft.linkEncoder(dtLeftEncoder);
    dtRightEncoder = new Encoder(EncoderMap.DT_RIGHT_A, EncoderMap.DT_RIGHT_B, EncoderMap.DT_RIGHT_INVERTED);
    S_DTRight.linkEncoder(dtRightEncoder);

    dtLeft = S_DTLeft.getInstance();
    dtRight = S_DTRight.getInstance();
    S_DTWhole.linkDTSides(dtLeft, dtRight);
    dtWhole = S_DTWhole.getInstance();

    arduino = S_Arduino.getInstance();
}
项目: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);
   }
项目:frc-2016    文件:Shooter.java   
public Shooter() {

        shooterLeftSide = new Talon(RobotMap.Pwm.LeftShooterMotor);
        shooterRightSide = new Talon(RobotMap.Pwm.RightShooterMotor);

        encoderLeft = new Encoder(RobotMap.Digital.ShooterLeftChannelA, RobotMap.Digital.ShooterLeftChannelB);
        encoderRight = new Encoder(RobotMap.Digital.ShooterRightChannelA, RobotMap.Digital.ShooterRightChannelB);

        encoderLeft.setPIDSourceType(PIDSourceType.kRate);
        encoderRight.setPIDSourceType(PIDSourceType.kRate);
        encoderLeft.setDistancePerPulse(distancePerPulse);
        encoderRight.setDistancePerPulse(distancePerPulse);

        // leftPID = new PIDSpeedController(encoderLeft, shooterLeftSide, "Shooter", "Left Wheel");
        // rightPID = new PIDSpeedController(encoderRight, shooterRightSide, "Shooter", "Right Wheel");

    }
项目:2016    文件:Transmission_old.java   
/**
 * Constructor for a four-wheel drive transmission class with
 * already-initialized encoders
 *
 * @param rightFrontSpeedController
 * @param rightRearSpeedController
 * @param leftFrontSpeedController
 * @param leftRearSpeedController
 * @param rightFrontEncoder
 * @param rightRearEncoder
 * @param leftFrontEncoder
 * @param leftRearEncoder
 */
public Transmission_old (
        final SpeedController rightFrontSpeedController,
        final SpeedController rightRearSpeedController,
        final SpeedController leftFrontSpeedController,
        final SpeedController leftRearSpeedController,
        Encoder rightFrontEncoder, Encoder rightRearEncoder,
        Encoder leftFrontEncoder, Encoder leftRearEncoder)
{
    this.isFourWheel = true;
    this.oneOrRightSpeedController = rightFrontSpeedController;
    this.leftSpeedController = leftFrontSpeedController;
    this.rightRearSpeedController = rightRearSpeedController;
    this.leftRearSpeedController = leftRearSpeedController;

    this.initEncoders(rightFrontEncoder, rightRearEncoder,
            leftFrontEncoder, leftRearEncoder);

    this.initPIDControllers();

    this.init();

}
项目:2016    文件:Transmission_old.java   
public boolean directionChanged (Encoder leftEncoder,
        Encoder rightEncoder)
{
    // if /Encoder/ - distance from previous call is less than 0
    //
    if (Math.abs(leftEncoder.getDistance())
            - this.brakePreviousDistanceL < 0
            && Math.abs(rightEncoder.getDistance())
                    - this.brakePreviousDistanceR < 0)
        {
        // set brakePreviousDistance to 0 and return true
        this.brakePreviousDistanceL = 0;
        this.brakePreviousDistanceR = 0;
        return true;
        }
    else
        {
        // set brakePreviousDistance to the encoder value
        brakePreviousDistanceL = Math.abs(leftEncoder.getDistance());
        brakePreviousDistanceR = Math.abs(rightEncoder.getDistance());
        return 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);
   }
项目:snobot-2017    文件:SnobotDriveTrainWithEncoders.java   
/**
   * @param aLeftMotor
   *                  The First Left Motor
   * @param aLeftMotorB
   *                   The Second Left Motor
   * @param aRightMotor
   *                   The First Right Motor
   * @param aRightMotorB
   *                    The Second Right Motor
   * @param aDriverJoyStick
   *                       The Driver Joystick
   * @param aLogger
   *               The Logger
   *               
    */
   public SnobotDriveTrainWithEncoders(
        SpeedController aLeftMotor, 
        SpeedController aLeftMotorB, 
        SpeedController aRightMotor, 
        SpeedController aRightMotorB, 
        Encoder aLeftEncoder, 
        Encoder aRightEncoder,
IDriverJoystick aDriverJoyStick, Logger aLogger)
   {
       super(aLeftMotor, aLeftMotorB, aRightMotor, aRightMotorB, aDriverJoyStick, aLogger);

       mLeftEncoder = aLeftEncoder;
       mRightEncoder = aRightEncoder;

       mLeftEncoder.setDistancePerPulse(Properties2016.sLEFT_ENCODER_DIST_PER_PULSE.getValue());
       mRightEncoder.setDistancePerPulse(Properties2016.sRIGHT_ENCODER_DIST_PER_PULSE.getValue());

   }
项目: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;
}
项目:FRC2549-2016    文件:DrivetrainSubsystem.java   
public DrivetrainSubsystem(){
    leftMotor = RobotMap.leftDriveMotor.getController();
    rightMotor = RobotMap.rightDriveMotor.getController();
    drive = new RobotDrive(leftMotor, rightMotor);

    accelerometer = new IntegratedBuiltinAccelerometer(Range.k2G);

    leftEncoder = new Encoder(RobotMap.leftEncoder[0], RobotMap.leftEncoder[1]);
    rightEncoder = new Encoder(RobotMap.rightEncoder[0], RobotMap.rightEncoder[1]);
    leftEncoder.setReverseDirection(true);
    rightEncoder.setReverseDirection(true);

    driveGyro = new AnalogGyro(RobotMap.driveGyroPort);
    driveGyro.reset();
    driveGyro.setSensitivity(0.007);


}
项目: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;
}
项目:SwerveDrive    文件:SwervePod.java   
public SwervePod(SpeedController turningMotor, SpeedController driveMotor, Encoder encoder, double encoderDistancePerTick, AngularSensor directionSensor) {
    // Initialize motors //
    _turningMotor = turningMotor;
    _driveMotor = driveMotor;

    // Initialize sensors //
    _encoder = encoder;
    _encoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate);
    _encoder.setDistancePerPulse(encoderDistancePerTick);
    _encoder.start();
    _directionSensor = directionSensor;

    // Initialize PID loops //
    // Turning //
    PIDTurning = new PIDController(Kp_turning, Ki_turning, Kd_turning, _directionSensor, _turningMotor);
    PIDTurning.setOutputRange(minSpeed, maxSpeed);
    PIDTurning.setContinuous(true);
    PIDTurning.setAbsoluteTolerance(tolerance_turning);
    PIDTurning.enable();

    // Linear driving //
    PIDDriving = new PIDController(Kp_driving, Ki_driving, Kd_driving, _encoder, _driveMotor);
    PIDDriving.setOutputRange(minSpeed, maxSpeed);
    PIDDriving.disable(); //TODO: Enable
}
项目:ParadigmShift-2014    文件:DriveTrain.java   
public DriveTrain(OperatorInputs _operatorInputs) {
    this.operatorInputs = _operatorInputs;
    this.leftTalons = new Talon(LEFT_PORT);
    this.rightTalons = new Talon(RIGHT_PORT);
    this.gearShiftLow = new Solenoid(SHIFT_MODULE, SHIFT_PORT_LOW);
    this.gearShiftHigh = new Solenoid(SHIFT_MODULE, SHIFT_PORT_HIGH);
    this.leftEncoder = new Encoder(3, 4);
    this.rightEncoder = new Encoder(5, 6);
    this.timer = new Timer();
    //Start all wheels off
    leftTalons.set(0);
    rightTalons.set(0);
    //Starts in low gear
    gearShiftLow.set(isHighGear);
    gearShiftHigh.set(!isHighGear);
    leftEncoder.setDistancePerPulse(-DISTANCE_PER_PULSE);
    rightEncoder.setDistancePerPulse(DISTANCE_PER_PULSE);

}
项目:PainTrain    文件:PainTrain.java   
public PainTrain(){
    m_leftGearbox   = new ThreeCimBallShifter(  new Victor(1),
                                                new Victor(2),
                                                new Victor(3),
                                                new DoubleSolenoid (1,2) );

    m_rightGearbox  = new ThreeCimBallShifter(  new Victor(4),
                                                new Victor(5),
                                                new Victor(6));

    m_shooter       = new Shooter(7,8,7,8,9);
    m_intake        = new Intake( 3,
                                  5,
                                  10 );
    m_encodeLeft = new Encoder(2,3);
    m_encodeRight = new Encoder(5,6);

    m_compressor    = new Compressor(1,4);
    m_compressor.start();
}
项目:649code2014    文件:DriveTrainSubsystem.java   
public DriveTrainSubsystem() {
    motors = new SpeedController[RobotMap.DRIVE_TRAIN.MOTORS.length];
    for (int i = 0; i < RobotMap.DRIVE_TRAIN.MOTORS.length; i++) {
        motors[i] = new Victor(RobotMap.DRIVE_TRAIN.MOTORS[i]);
    }
    doubleSidedPid = new PIDController649(EncoderBasedDriving.AUTO_DRIVE_P, EncoderBasedDriving.AUTO_DRIVE_I, EncoderBasedDriving.AUTO_DRIVE_D, this, this);
    doubleSidedPid.setAbsoluteTolerance(EncoderBasedDriving.ABSOLUTE_TOLERANCE);
    doubleSidedPid.setOutputRange(-EncoderBasedDriving.MAX_MOTOR_POWER, EncoderBasedDriving.MAX_MOTOR_POWER);
    encoders = new Encoder[RobotMap.DRIVE_TRAIN.ENCODERS.length / 2];
    for (int x = 0; x < RobotMap.DRIVE_TRAIN.ENCODERS.length; x += 2) {
        encoders[x / 2] = new Encoder(RobotMap.DRIVE_TRAIN.ENCODERS[x], RobotMap.DRIVE_TRAIN.ENCODERS[x + 1], x == 0, EncodingType.k2X);
        encoders[x / 2].setDistancePerPulse(EncoderBasedDriving.ENCODER_DISTANCE_PER_PULSE);
    }
    lastRates = new Vector();
    shifterSolenoid = new DoubleSolenoid(RobotMap.DRIVE_TRAIN.FORWARD_SOLENOID_CHANNEL, RobotMap.DRIVE_TRAIN.REVERSE_SOLENOID_CHANNEL);
}
项目:FRCTesting    文件:QuadratureEncoder.java   
/**
 * Creates an encoder using the two SIG inputs (A and B).
 * Also allows the encoder to be reversed.
 * Can also control the difference between getRaw and get values.
 * pulsesPerRev is used for getDistance() methods.
 * @param channelA I/0 SIG A.
 * @param channelB I/O SIG B.
 * @param isReversed When true, returned values are inverted.
 * @param scaleValue getRaw() values are divided by multiples of 1, 2, or 4 to increase accuracy.
 * @param pulsesPerRev Number of pulses for a revolution of the motor (look at instance variable).
 */
public QuadratureEncoder(int channelA, int channelB, boolean isReversed,
                        int scaleValue, double pulsesPerRev)
{
    CounterBase.EncodingType encType = CounterBase.EncodingType.k4X;

    if (scaleValue == 1)
        encType = CounterBase.EncodingType.k1X;
    else if (scaleValue == 2)
        encType = CounterBase.EncodingType.k2X;
    else if (scaleValue == 4)
        encType = CounterBase.EncodingType.k4X;

    enc = new Encoder(channelA, channelB, isReversed, encType);

    pulsesPerRevolution = pulsesPerRev;
    enc.start();
}
项目: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);
}
项目:NR-2014-CMD    文件:Drive.java   
private Drive()
{
    drive = new RobotDrive(new Talon(1),new Talon(2),new Talon(3),new Talon(4));
    drive.setSafetyEnabled(false);


    e1 = new Encoder(RobotMap.ENCODER_1_A, RobotMap.ENCODER_1_B, false, CounterBase.EncodingType.k4X);
    e2 = new Encoder(RobotMap.ENCODER_2_A, RobotMap.ENCODER_2_B, false, CounterBase.EncodingType.k4X);

    //A calculated constant to convert from encoder ticks to feet on 4 inch diameter wheels
    e1.setDistancePerPulse(0.0349065850388889/12);
    e2.setDistancePerPulse(0.0349065850388889/12);
    startEncoders();

    drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);      
    drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);

    sonic = new Ultrasonic(RobotMap.ULTRASONIC_A, RobotMap.ULTRASONIC_B);
    sonic.setAutomaticMode(true);
    sonic.setEnabled(true);


    shifter = new DoubleSolenoid(RobotMap.SHIFTER_ENGAGE, RobotMap.SHIFTER_DISENGAGE);
}
项目:RobotCode2013    文件:Shooter.java   
public Shooter() {
    arduinoPins = new DigitalOutput[3];
    arduinoPins[0] = new DigitalOutput(RobotMap.SHOOTER_ARDUINO_PIN1);
    arduinoPins[1] = new DigitalOutput(RobotMap.SHOOTER_ARDUINO_PIN2);
    arduinoPins[2] = new DigitalOutput(RobotMap.SHOOTER_ARDUINO_PIN3);

    angleEncoder.setReverseDirection(true);
    angleEncoder.setDistancePerPulse(1);
    angleEncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance);
    angleEncoder.start();
    //SmartDashboard.putBoolean("Shooter Angle PID", true);
    anglePID.setInputRange(0, 1400);
    anglePID.setPercentTolerance(1);
    anglePID.setContinuous(true);
    angleSetToPoint(new ShooterPoint("FULL_DOWN"));
    photocoder.start(); // ADDED 
    photocoderPower.set(true);
}
项目:RobotBlueTwilight2013    文件:DriveTrain.java   
public DriveTrain(boolean isCan)
{

    shifter = new Piston(SHIFTER_EXTEND_PORT, SHIFTER_RETRACT_PORT);
    left = new BTMotor(LEFT_JAG_PORT, isCan, isVoltage);
    left_2 = new BTMotor(LEFT_JAG_PORT_2, isCan, isVoltage);
    right = new BTMotor(RIGHT_JAG_PORT, isCan, isVoltage);
    right_2 = new BTMotor(RIGHT_JAG_PORT_2, isCan, isVoltage);
    shiftSpeed = new Encoder(DRIVE_ENCODER_A_PORT, DRIVE_ENCODER_B_PORT, true, CounterBase.EncodingType.k1X);
    shiftSpeed.setDistancePerPulse(distance);
    shiftSpeed.start();
    shiftSpeed.reset();

    left.setBTVoltageRampRate(ramprate);
    left_2.setBTVoltageRampRate(ramprate);
    right.setBTVoltageRampRate(ramprate);
    right_2.setBTVoltageRampRate(ramprate);
}
项目:frc-3186    文件:ShooterMotorControl.java   
public ShooterMotorControl() {
    super("ShooterControl", Kp, Ki, Kd);
    Encoder topEncoder = new Encoder(RobotMap.topEncoderChannelA, RobotMap.topEncoderChannelB);
    Encoder bottomEncoder = new Encoder(RobotMap.bottomEncoderChannelA, RobotMap.bottomEncoderChannelB);

    try {
                    shooterJagTop = new CANJaguar(RobotMap.shooterJagTopID);
                    shooterJagBottom = new CANJaguar(RobotMap.shooterJagBottomID);
    } catch (CANTimeoutException e) {
        e.printStackTrace();
    }
    // Use these to get going:
    // setSetpoint() -  Sets where the PID controller should move the system
    //                  to
    // enable() - Enables the PID controller.
    enable();
}
项目:EventBasedWiredCats    文件:ControllerDrive.java   
public ControllerDrive(int limit)
{
    super(limit);
    //TODO
    leftEncoder = new Encoder(3,4);  //competition: 3,4 / practice: 8,7
    rightEncoder = new Encoder(2,1); //competition: 2,1 / practice: 6,5
    gyro = new Gyro(2);

    leftEncoderDistance = 0;
    rightEncoderDistance = 0;
    lastLeftEncoderDistance = 0;
    lastRightEncoderDistance = 0;

    timer = new Timer();
    timer.start();

    lastGyroValue = 0;
    System.out.println("[WiredCats] Drive Controller Initialized.");
}
项目:frc1675-2013    文件:TankDrivePIDSubsystem.java   
public TankDrivePIDSubsystem(double p, double i, double d, 
        DriveSideWrapper motors, 
        int encoderAChannel, int encoderBChannel, 
        double distancePerPulse) {
    super("LeftTankDrivePIDSubsystem", p, i, d);

    // Use these to get going:
    // setSetpoint() -  Sets where the PID controller should move the system
    //                  to
    // enable() - Enables the PID controller.

    this.motors = motors;
    encoder = new Encoder(encoderAChannel, encoderBChannel);
    encoder.start();
    encoder.setDistancePerPulse(distancePerPulse);

    rampTimer = new Timer();
    rampTimer.start();
}
项目:frc1675-2013    文件:RightTankDrivePIDSubsystem.java   
public RightTankDrivePIDSubsystem() {
    super("LeftTankDrivePIDSubsystem", Kp, Ki, Kd);

    // Use these to get going:
    // setSetpoint() -  Sets where the PID controller should move the system
    //                  to
    // enable() - Enables the PID controller.
    frontRightMotor = new Victor(RobotMap.FRONT_RIGHT_DRIVE_MOTOR);
    backRightMotor = new Victor(RobotMap.BACK_RIGHT_DRIVE_MOTOR);

    rightEncoder = new Encoder(RobotMap.FRONT_RIGHT_ENCODER_A, RobotMap.FRONT_RIGHT_ENCODER_B);
    rightEncoder.start();
    rightEncoder.setDistancePerPulse(1.0);

    rampTimer = new Timer();
    rampTimer.start();
}
项目:frc1675-2013    文件:LeftTankDrivePIDSubsystem.java   
public LeftTankDrivePIDSubsystem() {
    super("LeftTankDrivePIDSubsystem", Kp, Ki, Kd);

    // Use these to get going:
    // setSetpoint() -  Sets where the PID controller should move the system
    //                  to
    // enable() - Enables the PID controller.
    frontLeftMotor = new Victor(RobotMap.FRONT_LEFT_DRIVE_MOTOR);
    backLeftMotor = new Victor(RobotMap.BACK_LEFT_DRIVE_MOTOR);

    leftEncoder = new Encoder(RobotMap.FRONT_LEFT_ENCODER_A, RobotMap.FRONT_LEFT_ENCODER_B);
    leftEncoder.start();
    leftEncoder.setDistancePerPulse(1.0);

    rampTimer = new Timer();
    rampTimer.start();
}
项目:Hyperion3360-2012    文件:DriveTrain.java   
public DriveTrain() {
    mjGauche = JoystickDevice.GetTankDriveGauche();
    mjDroite = JoystickDevice.GetTankDriveDroite();
    mDriveTrain = new RobotDrive(PwmDevice.mMoteurGaucheAvant,
            PwmDevice.mMoteurGaucheArriere,
            PwmDevice.mMoteurDroiteAvant,
            PwmDevice.mMoteurDroiteArriere);


    msTransmissionHi = new Solenoid(SolenoidDevice.mTransmissionHi);
    msTransmissionLow = new Solenoid(SolenoidDevice.mTransmissionLow);
    meTransmissionGauche = new Encoder(DigitalDevice.mTransmissionGaucheEncodeurA,
            DigitalDevice.mTransmissionGaucheEncodeurB);
    mfMoteurGauche = new FiltrePasseBas(25);
    meTransmissionDroite = new Encoder(DigitalDevice.mTransmissionDroiteEncodeurA,
            DigitalDevice.mTransmissionDroiteEncodeurB);
    mfMoteurDroite = new FiltrePasseBas(25);

    msTransmissionHi.set(false);
    msTransmissionLow.set(true);
}
项目:2017    文件:Drive.java   
/**
 * @method isStopped
 * @return Returns false if chosen encoders are not stopped
 * @author Eli Neagle
 * @author ASHLEY ESPELAND FRICKIN COMMENTED ALL THIS CODE I DESERVE
 *         SOME CREDIT
 * @param leftEncoder
 * @param rightEncoder
 * @written Sep 1, 2016
 */

// TODO stop, stop while turning, stop on a hill, get out of stop function past
// a certain time
public boolean isStopped (Encoder leftEncoder, Encoder rightEncoder)
{

    // if the difference between the current encoder value and the encoder
    // value from the last time we called this function is equal to 0
    if (Math.abs(leftEncoder.getDistance())
            - this.brakePreviousDistanceL == 0
            && Math.abs(rightEncoder.getDistance())
                    - this.brakePreviousDistanceR == 0)
        {
        if (this.getDebugStatus() == true)
            {
            // Tell the programmer the change in each encoder side since our
            // last run of this method
            System.out.println(
                    "Left Delta: "
                            + (Math.abs(leftEncoder.getDistance())
                                    - this.brakePreviousDistanceL));
            System.out.println(
                    "Right Delta: "
                            + (Math.abs(rightEncoder.getDistance())
                                    - this.brakePreviousDistanceR));
            }
        // then set the brakePreviousDistance to 0, and return true
        this.brakePreviousDistanceL = 0;
        this.brakePreviousDistanceR = 0;
        return true;
        }
    // else set brakePreviousDistance to the current encoder value,
    // and return false
    brakePreviousDistanceL = Math.abs(leftEncoder.getDistance());
    brakePreviousDistanceR = Math.abs(rightEncoder.getDistance());

    return false;
}
项目:2017    文件:Transmission_old.java   
/**
 * Initializes our four encoders for PID use.
 * Used if we didn't initialize them in the constructor.
 *
 * @param leftFrontEncoder
 * @param leftRearEncoder
 * @param rightFrontEncoder
 * @param rightRearEncoder
 */
public void initEncoders (Encoder rightFrontEncoder,
        Encoder rightRearEncoder, Encoder leftFrontEncoder,
        Encoder leftRearEncoder)
{
    this.leftMotorEncoder = leftFrontEncoder;
    this.leftRearMotorEncoder = leftRearEncoder;
    this.oneOrRightMotorEncoder = rightFrontEncoder;
    this.rightRearMotorEncoder = rightRearEncoder;
}
项目:2017    文件:Transmission_old.java   
/**
 * @method isStopped
 * @return Returns false if chosen encoders are not stopped
 * @author Eli Neagle
 * @author ASHLEY ESPELAND FRICKIN COMMENTED ALL THIS CODE I DESERVE
 *         SOME CREDIT
 * @param leftEncoder
 * @param rightEncoder
 * @written Sep 1, 2016
 */

// TODO stop, stop while turning, stop on a hill, get out of stop function past
// a certain time
public boolean isStopped (Encoder leftEncoder, Encoder rightEncoder)
{
    // Print statements for current distance brakePreviousDistance_ variables
    // System.out.println("left encoder current distance is: " +
    // leftEncoder.getDistance());
    // System.out.println("brakePreviousDistanceL is: " +
    // this.brakePreviousDistanceL);
    // System.out.println("right encoder current distance is: " +
    // rightEncoder.getDistance());
    // System.out.println("brakePreviousDistanceR is: " +
    // this.brakePreviousDistanceR);

    // if the difference between the current encoder value and the encoder
    // value from the last time we called this function is equal to 0
    if (Math.abs(leftEncoder.getDistance())
            - this.brakePreviousDistanceL == 0
            && Math.abs(rightEncoder.getDistance())
                    - this.brakePreviousDistanceR == 0)
        {
        // then set the brakePreviousDistance to 0, and return true
        this.brakePreviousDistanceL = 0;
        this.brakePreviousDistanceR = 0;
        return true;
        }
    // else set brakePreviousDistance to the current encoder value,
    // and return false
    brakePreviousDistanceL = Math.abs(leftEncoder.getDistance());
    brakePreviousDistanceR = Math.abs(rightEncoder.getDistance());

    return false;
}
项目:MinuteMan    文件:S_DTSide.java   
public S_DTSide(int[] motorIDs, boolean[] motorInversions, Encoder encoder) {
    for(int motorNum = 0; motorNum < MOTOR_NUM; motorNum++){
        this.motorControllers[motorNum] = new CANTalon(motorIDs[motorNum]);
        this.motorControllers[motorNum].setInverted(motorInversions[motorNum]);
    }
    this.encoder = encoder;
}
项目:R2017    文件:DriveTrain.java   
public DriveTrain () {
    rightMotors = new VictorSP(Constants.DRIVETRAIN_RIGHT);
    leftMotors = new VictorSP(Constants.DRIVETRAIN_LEFT);

    rightMotors.setInverted(rightInverted);
    leftMotors.setInverted(leftInverted);

    encLeft = new Encoder(Constants.ENCODER_LEFT_1, Constants.ENCODER_LEFT_2);
    encLeft.setDistancePerPulse(Constants.DRIVEWHEEL_CIRCUMFERENCE / Constants.DRIVE_PULSES_PER_REVOLUTION);

    encRight = new Encoder(Constants.ENCODER_RIGHT_1, Constants.ENCODER_RIGHT_2);
    encRight.setDistancePerPulse(Constants.DRIVEWHEEL_CIRCUMFERENCE / Constants.DRIVE_PULSES_PER_REVOLUTION);
}
项目:swerve-code    文件:Robot.java   
public void robotInit() {
    this.mod1Spin = new TalonSRX(Constants.MOD1SPIN);
    this.mod1Drive = new TalonSRX(Constants.MOD1DRIVE);
    this.spinEncoder1 = new Encoder(0, 0); //Needs real values
    this.driveEncoder1 = new Encoder(0, 0); //Needs real values

    this.mod2Spin = new TalonSRX(Constants.MOD2SPIN);
    this.mod2Drive = new TalonSRX(Constants.MOD2DRIVE);
    this.spinEncoder2 = new Encoder(0, 0); //Needs real values
    this.driveEncoder2 = new Encoder(0, 0); //Needs real values

    this.mod3Spin = new TalonSRX(Constants.MOD3SPIN);
    this.mod3Drive = new TalonSRX(Constants.MOD3DRIVE);
    this.spinEncoder3 = new Encoder(0, 0); //Needs real values
    this.driveEncoder3 = new Encoder(0, 0); //Needs real values

    this.mod4Spin = new TalonSRX(Constants.MOD4SPIN);
    this.mod4Drive = new TalonSRX(Constants.MOD4DRIVE);
    this.spinEncoder4 = new Encoder(0, 0); //Needs real values
    this.driveEncoder4 = new Encoder(0, 0); //Needs real values

    this.xboxDrive = new Joystick(Constants.XBOXDRIVEPORT);

    this.frontLeft = new SwerveModule("frontLeft", mod1Drive, mod1Spin, spinEncoder1, driveEncoder1); // needs completion0
    this.backLeft = new SwerveModule("backLeft", mod2Drive, mod2Spin, spinEncoder2, driveEncoder2);
    this.frontRight = new SwerveModule("frontRight", mod3Drive, mod3Spin, spinEncoder3, driveEncoder3);
    this.backRight = new SwerveModule("backRight", mod4Drive, mod4Spin, spinEncoder4, driveEncoder4);

    this.swerveDrive = new SwerveDrive(this.frontLeft, this.backLeft, this.frontRight, this.backRight, 25, 25);

    crab = new CrabDrive(swerveDrive, xboxDrive, "crabDrive", 1);
    spin = new SpinDrive(swerveDrive, xboxDrive, "spinDrive", 2);
    unicorn = new UnicornDrive(swerveDrive, xboxDrive, "unicornDrive", 3);
    drive = new DriveBase(crab, spin, unicorn, "driveBase", 0);
    drive.init();
}
项目:swerve-code    文件:SwerveModule.java   
/**
 * Swerve Module basic constructor without drive PID
 * 
 * @param _spinController
 * @param _driveController
 * @param _spinEncoder
 */
public SwerveModule(SpeedController _spinController, SpeedController _driveController, Encoder _spinEncoder) {
    this.name = "";
    this.spinController = _spinController;
    this.driveController = _driveController;
    this.spinEncoder = _spinEncoder;
    this.driveEncoder = null;
    spinLoop = new PIDLoop("" + this.spinController.toString(), .1, .1, 0, new PIDEncoder(this.spinEncoder)); // generic PID values in here, they need to be tuned or input
}
项目:swerve-code    文件:SwerveModule.java   
/**
 * Swerve Module basic constructor
 * 
 * @param _spinController SpeedController of the spin motor
 * @param _driveController SpeedController of the drive motor
 * @param _spinEncoder Encoder to tell the angle of the drive wheel (may be changed to a Potentiometer)
 * @param _driveEncoder Encoder to tell the position of the drive wheel (may be changed to a Potentiometer)
 */
public SwerveModule(SpeedController _spinController, SpeedController _driveController, Encoder _spinEncoder, Encoder _driveEncoder) {
    this.name = "";
    this.spinController = _spinController;
    this.driveController = _driveController;
    this.spinEncoder = _spinEncoder;
    this.driveEncoder = _driveEncoder;
    spinLoop = new PIDLoop("" + this.spinController.toString(), .1, .1, 0, new PIDEncoder(this.spinEncoder)); // generic PID values in here, they need to be tuned or input
    driveLoop = new PIDLoop("" + this.driveController.toString(), .1, 0, .1, new PIDEncoder(this.driveEncoder));
}
项目:swerve-code    文件:SwerveModule.java   
/**
 * Swerve Module constructor with a name
 * 
 * @param _name the name of the module
 * @param _spinController SpeedController of the spin motor
 * @param _driveController SpeedController of the drive motor
 * @param _spinEncoder Encoder to tell the angle of the drive wheel (may be changed to a Potentiometer)
 * @param _driveEncoder Encoder to tell the position of the drive wheel (may be changed to a Potentiometer)
 */
public SwerveModule(String _name, SpeedController _spinController, SpeedController _driveController, Encoder _spinEncoder, Encoder _driveEncoder) {
    this.name = _name;
    this.spinController = _spinController;
    this.driveController = _driveController;
    this.spinEncoder = _spinEncoder;
    this.driveEncoder = _driveEncoder;
    spinLoop = new PIDLoop(this.name + "spin", .1, .1, 0, new PIDEncoder(this.spinEncoder)); // generic PID values in here, they need to be tuned or input
    driveLoop = new PIDLoop(this.name + "drive", .1, 0, .1, new PIDEncoder(this.driveEncoder));
}
项目:swerve-code    文件:SwerveModule.java   
/**
 * Get a reference to the drive Encoder
 * 
 * @return a reference to the drive Encoder
 */
public Encoder getDriveEncoder() {
    if (this.driveEncoder == null) {
        return null;
    } else {
        return this.driveEncoder;
    }
}