本文整理匯總了Java中edu.wpi.first.wpilibj.PIDController.setPercentTolerance方法的典型用法代碼示例。如果您正苦於以下問題:Java PIDController.setPercentTolerance方法的具體用法?Java PIDController.setPercentTolerance怎麽用?Java PIDController.setPercentTolerance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.wpi.first.wpilibj.PIDController
的用法示例。
在下文中一共展示了PIDController.setPercentTolerance方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DriveTrain
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public DriveTrain() {
// TODO: would be nice to migrate stuff from RobotMap here.
// m_turnPID is used to improve accuracy during auto-turn operations.
m_imu = new IMUPIDSource();
m_turnPID = new PIDController(turnKp, turnKi, turnKd, turnKf,
m_imu,
new PIDOutput() {
public void pidWrite(double output) {
// output is [-1, 1]... we need to
// convert this to a speed...
Robot.driveTrain.turn(output * MAXIMUM_TURN_SPEED);
// robotDrive.tankDrive(-output, output);
}
});
m_turnPID.setOutputRange(-1, 1);
m_turnPID.setInputRange(-180, 180);
m_turnPID.setPercentTolerance(2);
// m_turnPID.setContuous?
}
示例2: Drivetrain
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public Drivetrain() {
leftWheelsPIDSource = new EncoderPIDSource(RobotMap.driveEncoderLeft, 1.0 / 14.0, PIDSourceType.kDisplacement);
//rightWheelsPIDSource = new EncoderPIDSource(RobotMap.driveEncoderRight, -1.0 / 14.0, PIDSourceType.kDisplacement);
rightWheelsPIDSource = new EncoderPIDSource(RobotMap.driveEncoderRight, ((-1.0 / 360.0) * 250.0) * (1.0 / 14.0), PIDSourceType.kDisplacement);
compassPID = new PIDController(0.1, 0, 0, new CompassPIDSource(), new DummyPIDOutput());
gyroPID = new PIDController(0.01, 0.0001, 0.00001, new GyroPIDSource(), new DummyPIDOutput());
leftWheelsPID = new PIDController(0.02, 0.0004, 0, leftWheelsPIDSource, new DummyPIDOutput());
rightWheelsPID = new PIDController(0.02, 0.0004, 0, rightWheelsPIDSource, new DummyPIDOutput());
compassPID.disable();
compassPID.setOutputRange(-1.0, 1.0); // Set turning speed range
compassPID.setPercentTolerance(5.0); // Set tolerance of 5%
gyroPID.disable();
gyroPID.setOutputRange(-1.0, 1.0); // Set turning speed range
gyroPID.setPercentTolerance(5.0); // Set tolerance of 5%
leftWheelsPID.disable();
leftWheelsPID.setOutputRange(-1.0, 1.0);
rightWheelsPID.disable();
rightWheelsPID.setOutputRange(-1.0, 1.0);
}
示例3: DriveToRange
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
* Constructs the command with the given sensor and range.
* @param sensor the Sensor to read.
* @param range the target value.
*/
public DriveToRange(Ranger sensor, double range) {
CompetitionRobot.output("Driving to range "+range);
pid = Subsystems.pid;
stablizer = new PIDController(0.04,0,0, Subsystems.imu, new PIDTurnInterface());
// pid = new PIDController(01d,0,0,sensor,new PIDDriveInterface());
targetRange = range;
// pid.setOutputRange(-1*SPEED, SPEED);
pid.setOutputRange(-1*SmartDashboard.getNumber("MaxApproachSpeed"), SmartDashboard.getNumber("MaxApproachSpeed"));
pid.setInputRange(0, 2.5);
pid.setPercentTolerance(1.0d);
pid.setContinuous(false);
stablizer.setOutputRange(-0.2, 0.2);
stablizer.setInputRange(0,360);
stablizer.setPercentTolerance(1.0);
stablizer.setContinuous(true);
}
示例4: 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();
}
示例5: 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;
}
示例6: 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();
}
示例7: Tilter
import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的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);
}