當前位置: 首頁>>代碼示例>>Java>>正文


Java Encoder.setPIDSourceParameter方法代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.Encoder.setPIDSourceParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java Encoder.setPIDSourceParameter方法的具體用法?Java Encoder.setPIDSourceParameter怎麽用?Java Encoder.setPIDSourceParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.wpi.first.wpilibj.Encoder的用法示例。


在下文中一共展示了Encoder.setPIDSourceParameter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: init

import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    driveTrainleftFrontTalon0 = new TalonSRX(0);
    LiveWindow.addActuator("DriveTrain", "leftFrontTalon0", (TalonSRX) driveTrainleftFrontTalon0);
    
    driveTrainleftBackTalon1 = new TalonSRX(1);
    LiveWindow.addActuator("DriveTrain", "leftBackTalon1", (TalonSRX) driveTrainleftBackTalon1);
    
    driveTrainrightFrontTalon2 = new TalonSRX(2);
    LiveWindow.addActuator("DriveTrain", "rightFrontTalon2", (TalonSRX) driveTrainrightFrontTalon2);
    
    driveTrainrightBackTalon3 = new TalonSRX(3);
    LiveWindow.addActuator("DriveTrain", "rightBackTalon3", (TalonSRX) driveTrainrightBackTalon3);
    
    driveTrainRobotDrive = new RobotDrive(driveTrainleftFrontTalon0, driveTrainleftBackTalon1,
          driveTrainrightFrontTalon2, driveTrainrightBackTalon3);
    
    driveTrainRobotDrive.setSafetyEnabled(true);
    driveTrainRobotDrive.setExpiration(0.1);
    driveTrainRobotDrive.setSensitivity(0.5);
    driveTrainRobotDrive.setMaxOutput(1.0);

    driveTraingyro = new Gyro(0);
    LiveWindow.addSensor("DriveTrain", "gyro", driveTraingyro);
    driveTraingyro.setSensitivity(0.007);
    driveTrainleftFrontEncoder = new Encoder(17, 18, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "leftFrontEncoder", driveTrainleftFrontEncoder);
    driveTrainleftFrontEncoder.setDistancePerPulse(1.0);
    driveTrainleftFrontEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainleftBackEncoder = new Encoder(19, 20, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "leftBackEncoder", driveTrainleftBackEncoder);
    driveTrainleftBackEncoder.setDistancePerPulse(1.0);
    driveTrainleftBackEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainrightFrontEncoder = new Encoder(21, 22, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "rightFrontEncoder", driveTrainrightFrontEncoder);
    driveTrainrightFrontEncoder.setDistancePerPulse(1.0);
    driveTrainrightFrontEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainrightBackEncoder = new Encoder(23, 24, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "rightBackEncoder", driveTrainrightBackEncoder);
    driveTrainrightBackEncoder.setDistancePerPulse(1.0);
    driveTrainrightBackEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
 
開發者ID:sfhsfembot,項目名稱:RecycledRushDriveTrain,代碼行數:45,代碼來源:RobotMap.java

示例3: init

import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public static void init() {
            
    //initialize encoders
    frontWheelEncoder = new Encoder(1, 1, 1, 2, false, CounterBase.EncodingType.k2X);
    frontWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK);
    frontWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance
    frontWheelEncoder.start();
    LiveWindow.addSensor("Drivetrain", "frontWheelEncoder", frontWheelEncoder);
    leftWheelEncoder = new Encoder(1, 3, 1, 4, false, CounterBase.EncodingType.k2X);
    leftWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); 
    leftWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance
    leftWheelEncoder.start();
    LiveWindow.addSensor("Drivetrain", "leftWheelEncoder", leftWheelEncoder);
    backWheelEncoder = new Encoder(1, 5, 1, 6, false, CounterBase.EncodingType.k2X);
    backWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); 
    backWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance
    backWheelEncoder.start();
    LiveWindow.addSensor("Drivetrain", "backWheelEncoder", backWheelEncoder); 
    rightWheelEncoder = new Encoder(1, 7, 1, 8, false, CounterBase.EncodingType.k2X);
    rightWheelEncoder.setDistancePerPulse(WHEEL_ENCODER_DISTANCE_PER_TICK); 
    rightWheelEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kRate); // have encoder measure rate, not distance
    rightWheelEncoder.start();
    LiveWindow.addSensor("Drivetrain", "rightWheelEncoder", rightWheelEncoder); 
    
    frontModuleEncoder = new Encoder(2, 1, 2, 2, false, CounterBase.EncodingType.k2X);
    frontModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); 
    frontModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance
    frontModuleEncoder.start();
    LiveWindow.addSensor("Drivetrain", "frontModuleEncoder", frontModuleEncoder);
    leftModuleEncoder = new Encoder(2, 7, 2, 8, false, CounterBase.EncodingType.k2X);
    leftModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); 
    leftModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance
    leftModuleEncoder.start();
    LiveWindow.addSensor("Drivetrain", "leftModuleEncoder", leftModuleEncoder);
    backModuleEncoder = new Encoder(2, 5, 2, 6, false, CounterBase.EncodingType.k2X);
    backModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); 
    backModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance
    backModuleEncoder.start();
    LiveWindow.addSensor("Drivetrain", "backModuleEncoder", backModuleEncoder);
    rightModuleEncoder = new Encoder(2, 3, 2, 4, false, CounterBase.EncodingType.k2X);
    rightModuleEncoder.setDistancePerPulse(MODULE_ENCODER_DISTANCE_PER_TICK); 
    rightModuleEncoder.setPIDSourceParameter(PIDSource.PIDSourceParameter.kDistance); // have encoder measure rate, not distance
    rightModuleEncoder.start();
    LiveWindow.addSensor("Drivetrain", "rightModuleEncoder", rightModuleEncoder);
        
    //initialize motors
    frontWheelMotor = new Victor246(1,1);
    LiveWindow.addActuator("Drivetrain", "frontWheelMotor", (Victor) frontWheelMotor);
    leftWheelMotor = new Victor246(1,2);
    LiveWindow.addActuator("Drivetrain", "leftWheelMotor", (Victor) leftWheelMotor);
    backWheelMotor = new Victor246(1,3);
    LiveWindow.addActuator("Drivetrain", "backWheelMotor", (Victor) backWheelMotor);
    rightWheelMotor = new Victor246(1,4);
    LiveWindow.addActuator("Drivetrain", "rightWheelMotor", (Victor) rightWheelMotor);
    
    frontModuleMotor = new Jaguar246(2,1);
    LiveWindow.addActuator("Drivetrain", "frontModuleMotor", (Jaguar) frontModuleMotor);
    leftModuleMotor = new Jaguar246(2,2);
    LiveWindow.addActuator("Drivetrain", "leftModuleMotor", (Jaguar) leftModuleMotor);
    backModuleMotor = new Jaguar246(2,3);
    LiveWindow.addActuator("Drivetrain", "backModuleMotor", (Jaguar) backModuleMotor);
    rightModuleMotor = new Jaguar246(2,4);
    LiveWindow.addActuator("Drivetrain", "rightModuleMotor", (Jaguar) rightModuleMotor);
    
    //initialize limit switch
    angleZeroingButton = new DigitalInput(1,9);
    LiveWindow.addSensor("Drivetrain", "encoderZeroingSwitch", angleZeroingButton);
}
 
開發者ID:246overclocked,項目名稱:rover,代碼行數:69,代碼來源:RobotMap.java


注:本文中的edu.wpi.first.wpilibj.Encoder.setPIDSourceParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。