本文整理汇总了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);
}
示例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
}
示例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);
}