当前位置: 首页>>代码示例>>Java>>正文


Java Encoder.start方法代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.Encoder.start方法的典型用法代码示例。如果您正苦于以下问题:Java Encoder.start方法的具体用法?Java Encoder.start怎么用?Java Encoder.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.wpi.first.wpilibj.Encoder的用法示例。


在下文中一共展示了Encoder.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: QuadratureEncoder

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:OASTEM,项目名称:FRCTesting,代码行数:29,代码来源:QuadratureEncoder.java

示例2: DriveTrain

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
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);
}
 
开发者ID:IpFruion,项目名称:RobotBlueTwilight2013,代码行数:19,代码来源:DriveTrain.java

示例3: TankDrivePIDSubsystem

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
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();
}
 
开发者ID:frc1675,项目名称:frc1675-2013,代码行数:20,代码来源:TankDrivePIDSubsystem.java

示例4: RightTankDrivePIDSubsystem

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
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();
}
 
开发者ID:frc1675,项目名称:frc1675-2013,代码行数:18,代码来源:RightTankDrivePIDSubsystem.java

示例5: LeftTankDrivePIDSubsystem

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
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();
}
 
开发者ID:frc1675,项目名称:frc1675-2013,代码行数:18,代码来源:LeftTankDrivePIDSubsystem.java

示例6: Winch

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
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();
}
 
开发者ID:4500robotics,项目名称:4500-2014,代码行数:16,代码来源:Winch.java

示例7: initializeWinch

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
private void initializeWinch() {
	winchEncoder = new Encoder(RobotMap.SHOOTER_WINCH_ENCODER_A, RobotMap.SHOOTER_WINCH_ENCODER_B);
	winchEncoder.reset();
	winchEncoder.setDistancePerPulse(1);
	winchEncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance);
	winchEncoder.start();
	controller = new PIDController(P, I, D, winchEncoder, winch);
	controller.setOutputRange(-1, 1);
	controller.setPID(P, I, D);
}
 
开发者ID:Team-2502,项目名称:RobotCode2014,代码行数:11,代码来源:ShooterSubsystem.java

示例8: ShootArm

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
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;
}
 
开发者ID:Mercury1089,项目名称:2014-robot-code,代码行数:14,代码来源:ShootArm.java

示例9: Shooter

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public Shooter(int encoderA, int encoderB, int victor1, int victor2, int victor3) {
    m_encode = new Encoder(encoderA, encoderB);
    m_encode.start();
    m_encode.reset();
    m_motor1 = new Victor(victor1);
    m_motor2 = new Victor(victor2);
    m_motor3 = new Victor(victor3);
    m_shootTimer = new Timer();
    m_retractTimer = new Timer();

}
 
开发者ID:wsh32,项目名称:PainTrain,代码行数:12,代码来源:Shooter.java

示例10: Climber

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
private Climber()
{
    climberController = new Jaguar(BadRobotMap.climberArticulator);
    encoder = new Encoder(BadRobotMap.climberEncoderIn, BadRobotMap.climberEncoderOut, true);
    encoder.start();
    
    //controller = new EasyPID(.01, 0.0, 0.0, 0.0, "Climber Controller", encoder);
    //controller.controller.enable();
    //controller.setAbsoluteTolerance(8);
    //controller.enable();
    
}
 
开发者ID:BadRobots1014,项目名称:BadRobot2013,代码行数:13,代码来源:Climber.java

示例11: init

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
void init() {
    gy = new Gyro(RobotMap.gyroport);
    gy.reset();
    rotaryEncoder = new Encoder(1,2);
    rotaryEncoder.start();
    rotaryEncoder.reset();//Justin Case, attorney at law!
    feederLimit = new DigitalInput(14);
}
 
开发者ID:amesrobotics,项目名称:2013robot,代码行数:9,代码来源:SensorInput.java

示例12: GRTEncoder

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
/**
 * Instantiates an encoder on the default digital module.
 *
 * @param channelA digital channel for encoder channel A
 * @param channelB digital channel for encoder channel B
 * @param pulseDistance distance traveled for each pulse (typically 1 degree
 * of rotation per pulse)
 * @param reversed whether or not the encoder is reversed
 * @param name name of encoder
 */
public GRTEncoder(int channelA, int channelB,
        double pulseDistance, boolean reversed, String name) {
    super(name, NUM_DATA);
    
    //Create new encoder that does 1x encoding, as opposed to 4x.
    rotaryEncoder = new Encoder(channelA, channelB, reversed,
            CounterBase.EncodingType.k1X);  
    rotaryEncoder.start();

    encoderListeners = new Vector();
    distancePerPulse = pulseDistance;
    rotaryEncoder.setDistancePerPulse(distancePerPulse);
}
 
开发者ID:grt192,项目名称:2013ultimate-ascent,代码行数:24,代码来源:GRTEncoder.java

示例13: Tilter

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
private Tilter() {
    leadscrew = new BoundedTalon(Constants.TILTER_CHANNEL, Constants.TILTER_UPPER_LIMIT_SWITCH_CHANNEL, Constants.TILTER_LOWER_LIMIT_SWITCH_CHANNEL);
    accel = new ADXL345_I2C(Constants.ACCELEROMETER_CHANNEL, ADXL345_I2C.DataFormat_Range.k2G);
    accelMeasurements = new Vector();
    updateAccel();        
    pendulum = new AnalogChannel(Constants.PENDULUM_CHANNEL);
    enc = new Encoder(Constants.LEADSCREW_ENCODER_A_CHANNEL, Constants.LEADSCREW_ENCODER_B_CHANNEL);
    enc.setDistancePerPulse(Constants.TILTER_DISTANCE_PER_PULSE);
    enc.start();
    Thread t = new Thread(new Runnable() {
        public void run() {
            Tilter.net = new NetworkIO();
        }
    });
    t.start();
    controller = new PIDController(Constants.PVAL_T, Constants.IVAL_T, Constants.DVAL_T, enc, new PIDOutput() {
        public void pidWrite(double output) {
            setLeadscrewMotor(output);
        }
    }); 
    controller.setPercentTolerance(0.01);
    controller.disable();
    updatePID();
    initialReadingTimer = new Timer();
    initialReadingTimer.schedule(new TimerTask() {

        public void run() {
            initialLeadLength = calcLeadscrewLength(getAveragedAccelBasedAngle());
        }
    }, INITIAL_ANGLE_MEASUREMENT_DELAY);
}
 
开发者ID:Team694,项目名称:desiree,代码行数:32,代码来源:Tilter.java

示例14: WsDriveBase

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public WsDriveBase(String name) {
    super(name);

    WHEEL_DIAMETER_config = new DoubleConfigFileParameter(this.getClass().getName(), "wheel_diameter", 6);
    TICKS_PER_ROTATION_config = new DoubleConfigFileParameter(this.getClass().getName(), "ticks_per_rotation", 360.0);
    THROTTLE_LOW_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "throttle_low_gear_accel_factor", 0.250);
    HEADING_LOW_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "heading_low_gear_accel_factor", 0.500);
    THROTTLE_HIGH_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "throttle_high_gear_accel_factor", 0.125);
    HEADING_HIGH_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "heading_high_gear_accel_factor", 0.250);
    MAX_HIGH_GEAR_PERCENT_config = new DoubleConfigFileParameter(this.getClass().getName(), "max_high_gear_percent", 0.80);
    ENCODER_GEAR_RATIO_config = new DoubleConfigFileParameter(this.getClass().getName(), "encoder_gear_ratio", 7.5);
    DEADBAND_config = new DoubleConfigFileParameter(this.getClass().getName(), "deadband", 0.05);
    SLOW_TURN_FORWARD_SPEED_config = new DoubleConfigFileParameter(this.getClass().getName(), "slow_turn_forward_speed", 0.16);
    SLOW_TURN_BACKWARD_SPEED_config = new DoubleConfigFileParameter(this.getClass().getName(), "slow_turn_backward_speed", -0.19);
    FEED_FORWARD_VELOCITY_CONSTANT_config = new DoubleConfigFileParameter(this.getClass().getName(), "feed_forward_velocity_constant", 1.00);
    FEED_FORWARD_ACCELERATION_CONSTANT_config = new DoubleConfigFileParameter(this.getClass().getName(), "feed_forward_acceleration_constant", 0.00018);
    MAX_ACCELERATION_DRIVE_PROFILE_config = new DoubleConfigFileParameter(this.getClass().getName(), "max_acceleration_drive_profile", 600.0);
    MAX_SPEED_INCHES_LOWGEAR_config = new DoubleConfigFileParameter(this.getClass().getName(), "max_speed_inches_lowgear", 90.0);
    DECELERATION_VELOCITY_THRESHOLD_config = new DoubleConfigFileParameter(this.getClass().getName(), "deceleration_velocity_threshold", 48.0);
    DECELERATION_MOTOR_SPEED_config = new DoubleConfigFileParameter(this.getClass().getName(), "deceleration_motor_speed", 0.3);
    STOPPING_DISTANCE_AT_MAX_SPEED_LOWGEAR_config = new DoubleConfigFileParameter(this.getClass().getName(), "stopping_distance_at_max_speed_lowgear", 10.0);
    DRIVE_OFFSET_config = new AutonomousDoubleConfigFileParameter("DriveOffset", 1.00);
    USE_LEFT_SIDE_FOR_OFFSET_config = new AutonomousBooleanConfigFileParameter("UseLeftDriveForOffset", true);
    QUICK_TURN_CAP_config = new DoubleConfigFileParameter(this.getClass().getName(), "quick_turn_cap", 10.0);
    QUICK_TURN_ANTITURBO_config = new DoubleConfigFileParameter(this.getClass().getName(), "quick_turn_antiturbo", 10.0);

    //Anti-Turbo button
    registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_8);
    //Turbo button
    registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_7);
    //Shifter Button
    registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_6);
    //Left/right slow turn buttons
    registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_1);
    registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_3);

    //Initialize the drive base encoders
    leftDriveEncoder = new Encoder(2, 3, true, EncodingType.k4X);
    leftDriveEncoder.reset();
    leftDriveEncoder.start();
    rightDriveEncoder = new Encoder(4, 5, false, EncodingType.k4X);
    rightDriveEncoder.reset();
    rightDriveEncoder.start();

    //Initialize the gyro
    //@TODO: Get the correct port
    driveHeadingGyro = new Gyro(1);

    //Initialize the PIDs
    driveDistancePidInput = new WsDriveBaseDistancePidInput();
    driveDistancePidOutput = new WsDriveBaseDistancePidOutput();
    driveDistancePid = new WsPidController(driveDistancePidInput, driveDistancePidOutput, "WsDriveBaseDistancePid");

    driveHeadingPidInput = new WsDriveBaseHeadingPidInput();
    driveHeadingPidOutput = new WsDriveBaseHeadingPidOutput();
    driveHeadingPid = new WsPidController(driveHeadingPidInput, driveHeadingPidOutput, "WsDriveBaseHeadingPid");

    driveSpeedPidInput = new WsDriveBaseSpeedPidInput();
    driveSpeedPidOutput = new WsDriveBaseSpeedPidOutput();
    driveSpeedPid = new WsSpeedPidController(driveSpeedPidInput, driveSpeedPidOutput, "WsDriveBaseSpeedPid");
    continuousAccelerationFilter = new ContinuousAccelFilter(0, 0, 0);
    init();
}
 
开发者ID:wildstang111,项目名称:2013_drivebase_proto,代码行数:64,代码来源:WsDriveBase.java

示例15: robotInit

import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public void robotInit() {
    ds = DriverStation.getInstance();

    drive = new RobotDrive(Ports.DRIVE_LEFT, Ports.DRIVE_RIGHT);
    drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);
    drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
    drive.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
    drive.setInvertedMotor(RobotDrive.MotorType.kRearRight, true);

    leftDrive = new Encoder(3, 4, true, Encoder.EncodingType.k4X);
    rightDrive = new Encoder(5, 6, false, Encoder.EncodingType.k4X);
    leftDrive.setDistancePerPulse(6 * Math.PI / 360);
    rightDrive.setDistancePerPulse(6 * Math.PI / 360);
    leftDrive.start();
    rightDrive.start();

    compressor = new Relay(Ports.COMPRESSOR_RELAY);
    tankIsFull = new DigitalInput(Ports.COMPRESSOR_PRESSURE_SWITCH);

    leftStick = new Joystick(Ports.JOYSTICK_LEFT);
    rightStick = new Joystick(Ports.JOYSTICK_RIGHT);
    gamepad = new Joystick(Ports.JOYSTICK_GAMEPAD);
    left_stick_prev = new boolean[13];
    right_stick_prev = new boolean[13];
    gamepad_prev = new boolean[13];

    arm = new ShootArm();
    intake = new Intake();
    tusks = new Tusks();
    
    new Thread() {
        public void run() {
            while(true) {
                //run the right state machines
                tusks.runTusks();
                arm.runArm();

                //output to smartdash
                debug();
                try {
                    Thread.sleep(5);
                } catch(InterruptedException e) {}
            }
        }
    }.start();
}
 
开发者ID:Mercury1089,项目名称:2014-robot-code,代码行数:47,代码来源:Mercury2014_v2.java


注:本文中的edu.wpi.first.wpilibj.Encoder.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。