当前位置: 首页>>代码示例>>Java>>正文


Java PIDController.setInputRange方法代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.PIDController.setInputRange方法的典型用法代码示例。如果您正苦于以下问题:Java PIDController.setInputRange方法的具体用法?Java PIDController.setInputRange怎么用?Java PIDController.setInputRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.wpi.first.wpilibj.PIDController的用法示例。


在下文中一共展示了PIDController.setInputRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DriveDistanceDiff

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
/**
 * Requires DriveTrain, DriveEncoders, Gyro, Ultrasonic
 * @param setpoint distance to move in inches
 */
public DriveDistanceDiff(double setpoint){
    requires(Robot.drivetrain);
    requires(Robot.driveEncoders);
    requires(Robot.ultrasonic);
    this.setpoint=setpoint;
    pid = new PIDController(0.1, 0, 0, Robot.driveEncoders.getEncoderLeft(), new pidOutput());
    pidRight = new PIDController(0.1,0,0,Robot.driveEncoders.getEncoderRight(),new pidOutputRight());
    if(setpoint>0){
        pid.setInputRange(0,setpoint+10);
        pidRight.setInputRange(0,setpoint+10);
    }else{
        pid.setInputRange(setpoint-10,0);
        pidRight.setInputRange(setpoint-10,0);
    }
    pid.setAbsoluteTolerance(0.5);
    pidRight.setAbsoluteTolerance(0.5);
    pid.setOutputRange(-0.6,0.6);
    pidRight.setOutputRange(-0.6,0.6);
    pid.setSetpoint(setpoint);
    pidRight.setSetpoint(setpoint);
}
 
开发者ID:mr-glt,项目名称:FRC-2017-Command,代码行数:26,代码来源:DriveDistanceDiff.java

示例2: DriveDistance

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
/**
 * Requires DriveTrain, DriveEncoders, Gyro, Ultrasonic
 * @param setpoint distance to move in inches
 */
public DriveDistance(double setpoint, boolean stoppable, double turn){
    requires(Robot.drivetrain);
    requires(Robot.driveEncoders);
    requires(Robot.gyro);
    requires(Robot.ultrasonic);
    this.setpoint=setpoint;
    this.stoppable=stoppable;
    this.turn=turn;
    pid = new PIDController(0.40, 0, 0, Robot.driveEncoders.getEncoderLeft(), new pidOutput());
    pidTurn = new PIDController(0.2, 0.02, 0.4, Robot.gyro.getGyro(), new pidOutputTurn());

    pidTurn.setOutputRange(-0.50,0.50);
    if(setpoint>0){
        pid.setInputRange(0,setpoint+10);
    }else{
        pid.setInputRange(setpoint-10,0);
    }
    pid.setAbsoluteTolerance(0.5);
    pid.setOutputRange(-0.6,0.6);
    pid.setSetpoint(setpoint);
    System.out.println("Driving Forward for:  " + setpoint);
}
 
开发者ID:mr-glt,项目名称:FRC-2017-Command,代码行数:27,代码来源:DriveDistance.java

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

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

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

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

示例7: 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?
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:21,代码来源:DriveTrain.java

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

示例9: Arm

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
public Arm() {
    shoulder = new PIDController(RobotMap.ARM_SHOULDER_kP, RobotMap.ARM_SHOULDER_kI, RobotMap.ARM_SHOULDER_kD, RobotMap.armShoulderPot, RobotMap.armShoulderMotor, .02);
    shoulder.setInputRange(RobotMap.ARM_SHOULDER_MIN, RobotMap.ARM_SHOULDER_MAX);
    shoulder.setOutputRange(-RobotMap.ARM_MAX_SPEED, RobotMap.ARM_MAX_SPEED);
    shoulder.setAbsoluteTolerance(5);
    elbow = new PIDController(RobotMap.ARM_ELBOW_kP, RobotMap.ARM_ELBOW_kI, RobotMap.ARM_ELBOW_kD, RobotMap.armElbowPot, RobotMap.armElbowMotor, .02);
    elbow.setInputRange(-180, 180);
    elbow.setOutputRange(-RobotMap.ARM_MAX_SPEED, RobotMap.ARM_MAX_SPEED);
    elbow.setAbsoluteTolerance(5);
    wrist = new PIDController(RobotMap.ARM_WRIST_kP, RobotMap.ARM_WRIST_kI, RobotMap.ARM_WRIST_kD, RobotMap.armWristPot, RobotMap.armWristMotor, .02);
    wrist.setInputRange(-180, 180);
    wrist.setOutputRange(-RobotMap.ARM_MAX_SPEED, RobotMap.ARM_MAX_SPEED);
    wrist.setAbsoluteTolerance(5);
    
    LiveWindow.addActuator("Arm", "shoulder", shoulder);
    LiveWindow.addActuator("Arm", "elbow", elbow);
    LiveWindow.addActuator("Arm", "wrist", wrist);
}
 
开发者ID:246overclocked,项目名称:scorpion,代码行数:19,代码来源:Arm.java

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

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

示例12: 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();
}
 
开发者ID:tglem89,项目名称:2013-code-v2,代码行数:17,代码来源:CloseLoopAngleDrive.java

示例13: RotateDriveTrain

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
/**
 *
 * @param theta degrees to rotate drive train.
 */
public RotateDriveTrain(double theta){
    requires(Robot.drivetrain);
    requires(Robot.driveEncoders);
    requires(Robot.gyro);
    this.theta=theta;
    pid = new PIDController(0.55, 0.002, 0.4, Robot.gyro.getGyro(), new pidOutput());
    pid.setAbsoluteTolerance(0.25);
    pid.setInputRange(-360,360);
    pid.setOutputRange(-0.65,0.65);
    pid.setSetpoint(theta);
}
 
开发者ID:mr-glt,项目名称:FRC-2017-Command,代码行数:16,代码来源:RotateDriveTrain.java

示例14: ArcDriveDistance

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
public ArcDriveDistance(double radius, boolean isRighthand){
    requires(Robot.drivetrain);
    requires(Robot.driveEncoders);
    requires(Robot.gyro);
    requires(Robot.ultrasonic);
    if (isRighthand){
        setpoint1 = 2*Math.PI*radius*(1/4);
        setpoint2 = 2*Math.PI*(radius-34)*(1/4);
    }else{
        setpoint1 = 2*Math.PI*(radius-34)*(1/4);
        setpoint2 = 2*Math.PI*radius*(1/4);
    }
    pidX= new PIDController(0.05, 0, 0, Robot.driveEncoders.getEncoderLeft(), new pidXOutput());
    if(setpoint1>0){
        pidX.setInputRange(0,setpoint1+10);
    }else{
        pidX.setInputRange(setpoint1-10,0);
    }
    pidX.setAbsoluteTolerance(0.5);
    pidX.setOutputRange(-0.6,0.6);
    pidX.setSetpoint(setpoint1);

    pidY = new PIDController(0.05, 0, 0, Robot.driveEncoders.getEncoderRight(), new pidYOutput());
    if(setpoint2>0){
        pidY.setInputRange(0,setpoint2+10);
    }else{
        pidY.setInputRange(setpoint2-10,0);
    }
    pidY.setAbsoluteTolerance(0.5);
    pidY.setOutputRange(-0.6,0.6);
    pidY.setSetpoint(setpoint2);
}
 
开发者ID:mr-glt,项目名称:FRC-2017-Command,代码行数:33,代码来源:ArcDriveDistance.java

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


注:本文中的edu.wpi.first.wpilibj.PIDController.setInputRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。