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


Java PIDController.setContinuous方法代碼示例

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


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

示例1: JsonAutonomous

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
 * Creates a JsonAutonomous from the specified file
 * @param file The location of the file to parse
 */
public JsonAutonomous(String file)
{
	ap_ds = DriverStation.getInstance();
	turn = new PIDController(0.02, 0, 0, Robot.navx, this);
	turn.setInputRange(-180, 180);
	turn.setOutputRange(-0.7, 0.7);
	turn.setAbsoluteTolerance(0.5);
	turn.setContinuous(true);
	
	straighten = new PIDController(0.01, 0, 0, Robot.navx, this);
	straighten.setInputRange(-180, 180);
	straighten.setOutputRange(-0.7, 0.7);
	straighten.setAbsoluteTolerance(0);
	straighten.setContinuous(true);
	
	turn.setPID(Config.getSetting("auto_turn_p", 0.02), 
			Config.getSetting("auto_turn_i", 0.00001),
			Config.getSetting("auto_turn_d", 0));
	straighten.setPID(Config.getSetting("auto_straight_p", 0.2), 
			Config.getSetting("auto_straight_i", 0),
			Config.getSetting("auto_straight_d", 0));
	parseFile(file);
}
 
開發者ID:RAR1741,項目名稱:RA17_RobotCode,代碼行數:28,代碼來源:JsonAutonomous.java

示例2: AutoTurnToPeg

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
 * Constructor specifying setpoint angle.
 * @param setPointAngle
 */
public AutoTurnToPeg(double setPointAngle) {
    requires(Robot.driveTrain);
    //requires(Robot.ultrasonics);
    //requires(Robot.visionTest);
    requires(Robot.navx);

    this.setPointAngle = setPointAngle;

    turnController = new PIDController(kP, kI, kD, Robot.navx.getAHRS(), new MyPidOutput());
    turnController.setInputRange(-180, 180);
    turnController.setOutputRange(-maxOutputRange, maxOutputRange);
    turnController.setAbsoluteTolerance(kToleranceDegrees);
    turnController.setContinuous(true);
    
    /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
    /* tuning of the Turn Controller's P, I and D coefficients.            */
    /* Typically, only the P value needs to be modified.                   */
    //LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
}
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:24,代碼來源:AutoTurnToPeg.java

示例3: AutoDriveDistance

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
* 
* @param distance target distance in inches
* @param timeOut time out in milliseconds
*/
  public AutoDriveDistance(double distance, long timeOut) {
      requires(Robot.driveTrain);
      //requires(Robot.ultrasonics);
      requires(Robot.navx);

      targetDistance = distance;
      timeMax = timeOut;

      turnController = new PIDController(kP, kI, kD, Robot.driveTrain, new MyPidOutput());
      //turnController.setInputRange(-180, 180);
      turnController.setOutputRange(-maxOutputRange, maxOutputRange);
      turnController.setAbsoluteTolerance(kToleranceDistance);
      turnController.setContinuous(true);
      
      /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
      /* tuning of the Turn Controller's P, I and D coefficients.            */
      /* Typically, only the P value needs to be modified.                   */
      LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
  }
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:25,代碼來源:AutoDriveDistance.java

示例4: AutoSteerDriveToPeg

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
private AutoSteerDriveToPeg() {
    requires(Robot.driveTrain);
    //requires(Robot.ultrasonics);
    //requires(Robot.visionTest);
    requires(Robot.navx);
    
    turnController = new PIDController(kP, kI, kD, Robot.navx.getAHRS(), new MyPidOutput());
    turnController.setInputRange(-maxAbsSetpoint, maxAbsSetpoint);
    turnController.setOutputRange(-maxOutputRange, maxOutputRange);
    turnController.setAbsoluteTolerance(kToleranceDegrees);
    turnController.setContinuous(true);
    
    /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
    /* tuning of the Turn Controller's P, I and D coefficients.            */
    /* Typically, only the P value needs to be modified.                   */
    LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
}
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:18,代碼來源:AutoSteerDriveToPeg.java

示例5: AutoTurnByVision

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
* 
* @param speed forward speed is positive volts
*/
  public AutoTurnByVision(double speed) {
      requires(Robot.driveTrain);
      //requires(Robot.ultrasonics);
      requires(Robot.visionTest);
      requires(Robot.navx);

      forwardSpeed = -speed;
      turnController = new PIDController(kP, kI, kD, Robot.navx.getAHRS()/*Robot.visionTest*/, new MyPidOutput());
      turnController.setInputRange(-180, 180);
      turnController.setOutputRange(-maxOutputRange, maxOutputRange);
      turnController.setAbsoluteTolerance(kToleranceDegrees);
      turnController.setContinuous(true); // TODO is this what we want???
      
      /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
      /* tuning of the Turn Controller's P, I and D coefficients.            */
      /* Typically, only the P value needs to be modified.                   */
      LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
  }
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:23,代碼來源:AutoTurnByVision.java

示例6: Drivetrain

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public Drivetrain()
{
	backModule = new SwerveModule(RobotMap.backWheelEncoder, RobotMap.backModulePot, RobotMap.backWheelMotor, RobotMap.backModuleMotor, RobotMap.WHEEL_TOP_ABSOLUTE_SPEED, 0, -32.5, "backModule");
	leftModule = new SwerveModule(RobotMap.leftWheelEncoder, RobotMap.leftModulePot, RobotMap.leftWheelMotor, RobotMap.leftModuleMotor, RobotMap.WHEEL_TOP_ABSOLUTE_SPEED, -17.25, 0, "leftModule");
	rightModule = new SwerveModule(RobotMap.rightWheelEncoder, RobotMap.rightModulePot, RobotMap.rightWheelMotor, RobotMap.rightModuleMotor, RobotMap.WHEEL_TOP_ABSOLUTE_SPEED, 17.25, 0, "rightModule");
	swerves = new SwerveModule[3];
	swerves[0] = backModule;
	swerves[1] = leftModule;
	swerves[2] = rightModule;
	
	odometry = new Odometry();
    
    absoluteTwistPID = new PIDController(RobotMap.ABSOLUTE_TWIST_kP, RobotMap.ABSOLUTE_TWIST_kI, RobotMap.ABSOLUTE_TWIST_kD, RobotMap.navX, absoluteTwistPIDOutput);
    absoluteTwistPID.setInputRange(-180, 180);
    absoluteTwistPID.setOutputRange(-RobotMap.WHEEL_TOP_ABSOLUTE_SPEED, RobotMap.WHEEL_TOP_ABSOLUTE_SPEED);
    absoluteTwistPID.setContinuous();
    absoluteTwistPID.setAbsoluteTolerance(1);
    
    absoluteCrabPID = new PIDController(RobotMap.ABSOLUTE_CRAB_kP, RobotMap.ABSOLUTE_CRAB_kI, RobotMap.ABSOLUTE_CRAB_kD, odometry, absoluteCrabPIDOutput);
    absoluteCrabPID.setAbsoluteTolerance(.2);
    
    (new Thread(odometry)).start();
}
 
開發者ID:246overclocked,項目名稱:scorpion,代碼行數:24,代碼來源:Drivetrain.java

示例7: 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);
    
    }
 
開發者ID:FRC2832,項目名稱:Robot_2015,代碼行數:22,代碼來源:Rotate.java

示例8: 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
}
 
開發者ID:Whillikers,項目名稱:SwerveDrive,代碼行數:26,代碼來源:SwervePod.java

示例9: 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);
	}
 
開發者ID:frc-4931,項目名稱:2014-Robot,代碼行數:22,代碼來源:DriveToRange.java

示例10: SpinRPM

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
/**
 * Requires flywheel, meter
 * @param rpm revs per min to spin shooter to
 */
public SpinRPM(double rpm){
	rpm = rpm/60;
    requires(Robot.flywheel);
    requires(Robot.meter);
	enc.setMaxPeriod(0.1);
	enc.setMinRate(10);
	enc.setDistancePerPulse(0.05);
	enc.setReverseDirection(true);
	enc.setSamplesToAverage(7);
    pid = new PIDController(0.27, 0, 0, enc, new pidOutput());
    pid.setAbsoluteTolerance(100);
    pid.setSetpoint(rpm);
    pid.setContinuous();
}
 
開發者ID:mr-glt,項目名稱:FRC-2017-Command,代碼行數:19,代碼來源:SpinRPM.java

示例11: RotateWithPIDTankDrive

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
public RotateWithPIDTankDrive(double targetAngleDegrees) {
      requires(Robot.driveTrain);
      
/*      try {
			*//***********************************************************************
			 * navX-MXP: - This is all defined in NavX Subsystem.
			 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
			 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
			 * 
			 * navX-Micro:
			 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
			 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
			 * 
			 * Multiple navX-model devices on a single robot are supported.
			 ************************************************************************//*
  		
      //ahrs = new AHRS(SerialPort.Port.kUSB); 
      } catch (RuntimeException ex ) {
          DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
      }*/
      
      this.targetAngleDegrees=targetAngleDegrees;
      turnController2 = new PIDController(kP, kI, kD, kF, NavX.ahrs, this);
      turnController2.setInputRange(-180.0f,  180.0f);
      //turnController2.setOutputRange(-1.0, 1.0);
      turnController2.setOutputRange(-0.7, 0.7);
      turnController2.setAbsoluteTolerance(kToleranceDegrees);
      turnController2.setContinuous(true);
      turnController2.disable();
    }
 
開發者ID:FRC2832,項目名稱:Robot_2017,代碼行數:31,代碼來源:RotateWithPIDTankDrive.java

示例12: initDefaultCommand

import edu.wpi.first.wpilibj.PIDController; //導入方法依賴的package包/類
@Override
protected void initDefaultCommand() {
	turnController = new PIDController(kP, kI, kD, kF, ahrs, this);
	turnController.setInputRange(-180.0f,  180.0f);
	turnController.setOutputRange(-1.0, 1.0);
	turnController.setAbsoluteTolerance(kToleranceDegrees);
	turnController.setContinuous(true);
	
}
 
開發者ID:FRC2832,項目名稱:Robot_2017,代碼行數:10,代碼來源:NavX.java

示例13: 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;
}
 
開發者ID:RAR1741,項目名稱:RA17_RobotCode,代碼行數:38,代碼來源:SwerveModule.java

示例14: 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);
}
 
開發者ID:Team334,項目名稱:R2017,代碼行數:12,代碼來源:GyroPID.java

示例15: 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);
}
 
開發者ID:Team334,項目名稱:R2017,代碼行數:12,代碼來源:VisionAreaPID.java


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