本文整理匯總了Java中edu.wpi.first.wpilibj.PIDController.enable方法的典型用法代碼示例。如果您正苦於以下問題:Java PIDController.enable方法的具體用法?Java PIDController.enable怎麽用?Java PIDController.enable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.wpi.first.wpilibj.PIDController
的用法示例。
在下文中一共展示了PIDController.enable方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
protected void initialize() {
pid = new PIDController(0.1, 0.1, 0, RobotMap.imu, new TurnController(), 0.01);
startingAngle = RobotMap.imu.getYaw();
double deltaAngle = angle + startingAngle;
// deltaAngle %= 360;
while (deltaAngle >= 180)
deltaAngle -= 360;
while (deltaAngle < -180)
deltaAngle += 360;
Preferences.getInstance().putDouble("YawSetpoint", deltaAngle);
pid.setAbsoluteTolerance(2);
pid.setInputRange(-180, 180);
pid.setContinuous(true);
pid.setOutputRange(-1 * rotateSpeed, 1 * rotateSpeed);
pid.setSetpoint(deltaAngle);
pid.enable();
//SmartDashboard.putData("PID", pid);
}
示例2: SwervePod
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
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
}
示例3: initialize
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
protected void initialize() {
translator = new PIDOutputTranslator();
//controller = new PIDController(0.00546875, 0, 0, driveTrain.gyro, translator);
// 2/14/13 we tested and got: P 0.005554872047244094 I 2.8125000000000003E-4
//THESE ARE SLIGHTLY TOO BIG!!!!!
controller = new PIDController((oi.getDriveyStickThrottle() + 1.0) * 0.00546875, (oi.getLeftStickThrottle() + 1.0) * 0.001, 0, driveTrain.gyro, translator);
// P = 0.00546875
initialAngle = driveTrain.getGyroAngle();
controller.setSetpoint(initialAngle + angle);
controller.setPercentTolerance(1);
controller.setInputRange(-360, 360);
controller.enable();
}
示例4: SwerveModule
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public SwerveModule(CANTalon d, CANTalon a, AnalogInput e, String name)
{
SpeedP = Config.getSetting("speedP",1);
SpeedI = Config.getSetting("speedI",0);
SpeedD = Config.getSetting("speedD",0);
SteerP = Config.getSetting("steerP",2);
SteerI = Config.getSetting("steerI",0);
SteerD = Config.getSetting("steerD",0);
SteerTolerance = Config.getSetting("SteeringTolerance", .25);
SteerSpeed = Config.getSetting("SteerSpeed", 1);
SteerEncMax = Config.getSetting("SteerEncMax",4.792);
SteerEncMax = Config.getSetting("SteerEncMin",0.01);
SteerOffset = Config.getSetting("SteerEncOffset",0);
MaxRPM = Config.getSetting("driveCIMmaxRPM", 4200);
drive = d;
drive.setPID(SpeedP, SpeedI, SpeedD);
drive.setFeedbackDevice(FeedbackDevice.QuadEncoder);
drive.configEncoderCodesPerRev(20);
drive.enable();
angle = a;
encoder = e;
encFake = new FakePIDSource(SteerOffset,SteerEncMin,SteerEncMax);
PIDc = new PIDController(SteerP,SteerI,SteerD,encFake,angle);
PIDc.disable();
PIDc.setContinuous(true);
PIDc.setInputRange(SteerEncMin,SteerEncMax);
PIDc.setOutputRange(-SteerSpeed,SteerSpeed);
PIDc.setPercentTolerance(SteerTolerance);
PIDc.setSetpoint(2.4);
PIDc.enable();
s = name;
}
示例5: GyroPID
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public GyroPID() {
gyroSource = new GyroSource();
defaultOutput = new DefaultOutput();
gyroPID = new PIDController(Constants.GYRO_P, Constants.GYRO_I, Constants.GYRO_D, gyroSource, defaultOutput);
gyroPID.setContinuous();
gyroPID.setOutputRange(-Constants.GYRO_CAP, Constants.GYRO_CAP);
gyroPID.enable();
SmartDashboard.putData("GryoPID", gyroPID);
}
示例6: VisionAreaPID
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public VisionAreaPID() {
visionAreaSource = new VisionAreaSource();
defaultOutput = new DefaultOutput();
areaPID = new PIDController(Constants.AREA_P, Constants.AREA_I, Constants.AREA_D, visionAreaSource, defaultOutput);
areaPID.setContinuous();
areaPID.setOutputRange(-Constants.AREA_CAP, Constants.AREA_CAP);
areaPID.enable();
SmartDashboard.putData("AreaPID", areaPID);
}
示例7: VisionOffsetPID
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public VisionOffsetPID() {
visionOffsetSource = new VisionOffsetSource();
defaultOutput = new DefaultOutput();
offsetPID = new PIDController(Constants.OFFSET_P, Constants.OFFSET_I, Constants.OFFSET_D, visionOffsetSource, defaultOutput);
offsetPID.setSetpoint(0);
offsetPID.setContinuous();
offsetPID.setOutputRange(-Constants.OFFSET_CAP, Constants.OFFSET_CAP);
offsetPID.enable();
SmartDashboard.putData("OffsetPID", offsetPID);
}
示例8: SpinningWheel
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public SpinningWheel(){
shootingWheelPIDController = new PIDController(0.045 / 1000.0, 0.000005 / 1000.0, 1.1 / 1000.0, new TalonPIDSource(), RobotMap.shootingWheelMotor);
shootingWheelPIDController.disable();
shootingWheelPIDController.setSetpoint(0);
shootingWheelPIDController.setContinuous(true);
shootingWheelPIDController.setOutputRange(0, 1);
shootingWheelPIDController.enable();
}
示例9: Hood
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public Hood() {
pidController = new PIDController(0.075, 0.0001, 0, RobotMap.hoodPIDSource, RobotMap.hoodMotor);
pidController.disable();
pidController.setSetpoint(0);
pidController.setContinuous(true);
pidController.enable();
}
示例10: SwerveDrive
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public SwerveDrive() {
turnPositionPID = new PIDController(-1.5, -0.0, -6.0, new PidTurnPositionSourceOutput(), new PidTurnPositionSourceOutput());
turnPositionPID.setInputRange( -Math.PI, Math.PI );
turnPositionPID.setContinuous( true );
turnPositionPID.setAbsoluteTolerance( Math.PI/180.0*5.0 );
turnPositionPID.setOutputRange(-1.0, 1.0);
turnPositionPID.enable();
SmartDashboard.putData("Turn Position PID", turnPositionPID);
accelerometerAngle = 0.0;
autoSteer = false;
fieldSteer = false;
fieldMove = true;
prevXVelocity = 0;
prevYVelocity = 0;
handsOffStarted = false;
timeHandsOffStarted = 0.0;
gyroAngle = 0.0;
gyroOffset = 0.0;
// resetDistance();
turnSpeed = 0;
turnSpeedPID = new PIDController(-0.05, -0.0, -0.0, new PidTurnSpeedSourceOutput(), new PidTurnSpeedSourceOutput());
turnSpeedPID.setInputRange( -6.0, 6.0 );
turnSpeedPID.setOutputRange(-1.0, 1.0);
turnSpeedPID.setAbsoluteTolerance( 0.01 );
turnSpeedFeed = 0.0;
turnSpeedSum = 0.0;
SmartDashboard.putData("Turn Speed PID", turnSpeedPID);
lrVect= new SwerveVector(RobotMap.leftRearSwerve, -16.0,-11.0, -Math.PI/4.0);
lfVect= new SwerveVector(RobotMap.leftFrontSwerve, -16.0,11.0, Math.PI/4.0);
rrVect= new SwerveVector(RobotMap.rightRearSwerve, 16.0,-11.0, Math.PI/4.0);
rfVect= new SwerveVector(RobotMap.rightFrontSwerve, 16.0,11.0, -Math.PI/4.0);
SmartDashboard.putData("Swerve Drive Subsystem", this);
}
示例11: initialize
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
protected void initialize() {
translator = new PIDOutputTranslator();
controller = new PIDController((oi.getDriveyStickThrottle() + 1.0) / 20.0, 0, 0, driveTrain.gyro, translator);
// P = 0.00546875
controller.setSetpoint(driveTrain.getGyroAngle() + angle);
controller.setPercentTolerance(1);
controller.setInputRange(-360, 360);
controller.enable();
}
示例12: enableWheelSpeedPIDs
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
* Enable and reset the wheel speed PIDs.
*
* If they are already enabled, this routine does nothing.
*/
private void enableWheelSpeedPIDs() {
for (PIDController wheelSpeedPID: wheelSpeedPIDArr) {
if (!wheelSpeedPID.isEnable()) {
wheelSpeedPID.reset();
wheelSpeedPID.enable();
}
}
}
示例13: onBuild
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
private void onBuild() {
leftEncoder.start();
rightEncoder.start();
StraightPID straight = new StraightPID();
straightPid = new PIDController(0.001, 0, 0.02, straight, straight);
SmartDashboard.putData("Straight PID", straightPid);
straightPid.enable();
new Thread(this).start();
}