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


Java PIDController.setSetpoint方法代码示例

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


在下文中一共展示了PIDController.setSetpoint方法的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: SetDistanceToBox

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
public SetDistanceToBox(double distance) {
	requires(Robot.drivetrain);
	pid = new PIDController(-2, 0, 0, new PIDSource() {
		PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

		public double pidGet() {
			return Robot.drivetrain.getDistanceToObstacle();
		}

		@Override
		public void setPIDSourceType(PIDSourceType pidSource) {
			m_sourceType = pidSource;
		}

		@Override
		public PIDSourceType getPIDSourceType() {
			return m_sourceType;
		}
	}, new PIDOutput() {
		public void pidWrite(double d) {
			Robot.drivetrain.drive(d, d);
		}
	});
	pid.setAbsoluteTolerance(0.01);
	pid.setSetpoint(distance);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:27,代码来源:SetDistanceToBox.java

示例4: DriveStraight

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
public DriveStraight(double distance) {
    requires(Robot.drivetrain);
    pid = new PIDController(4, 0, 0,
            new PIDSource() {
                PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

                public double pidGet() {
                    return Robot.drivetrain.getDistance();
                }

                @Override
                public void setPIDSourceType(PIDSourceType pidSource) {
                  m_sourceType = pidSource;
                }

                @Override
                public PIDSourceType getPIDSourceType() {
                    return m_sourceType;
                }
            },
            new PIDOutput() { public void pidWrite(double d) {
                Robot.drivetrain.drive(d, d);
            }});
    pid.setAbsoluteTolerance(0.01);
    pid.setSetpoint(distance);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:27,代码来源:DriveStraight.java

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

示例6: unwindWheel

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
private boolean unwindWheel(AnalogChannelVolt wheel, PIDController pid) {
    double temp;
    double turns = wheel.getTurns();
    if (turns > 1) {
        temp = wheel.getAverageVoltage() - 1.0;
        if (temp < 0.0) {
            temp = 5.0 + temp;
        }
        pid.setSetpoint(temp);
        return true;
    } else if (turns < -1) {
        temp = wheel.getAverageVoltage() + 1.0;
        if (temp > 5.0) {
            temp = temp - 5.0;
        }
        pid.setSetpoint(temp);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:FRC-Team-4143,项目名称:SwerveDriveTest,代码行数:22,代码来源:SwerveDrive.java

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

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

示例9: DriveUntil

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
/**
 * Requires gyro, ultrasonic, drive train
 * @param setpoint distance away in inches
 */
public DriveUntil(double setpoint){
    requires(Robot.drivetrain);
    requires(Robot.gyro);
    requires(Robot.ultrasonic);
    pid = new PIDController(0.27, 0, 0, Robot.ultrasonic.getUltrasonic(), new pidOutput());
    pid.setAbsoluteTolerance(2);
    pid.setSetpoint(setpoint);
}
 
开发者ID:mr-glt,项目名称:FRC-2017-Command,代码行数:13,代码来源:DriveUntil.java

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

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

示例12: DriveDistanceFast

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
/**
 * Requires DriveTrain, DriveEncoders, Gyro, Ultrasonic
 * @param setpoint distance to drive in inches
 */
public DriveDistanceFast(double setpoint){
    requires(Robot.drivetrain);
    requires(Robot.driveEncoders);
    requires(Robot.gyro);
    requires(Robot.ultrasonic);
    this.setpoint=setpoint;
    pid = new PIDController(0.27, 0, 0, Robot.driveEncoders.getEncoderLeft(), new pidOutput());
    pid.setAbsoluteTolerance(1);
    pid.setSetpoint(setpoint);
}
 
开发者ID:mr-glt,项目名称:FRC-2017-Command,代码行数:15,代码来源:DriveDistanceFast.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: DriveToPeg

import edu.wpi.first.wpilibj.PIDController; //导入方法依赖的package包/类
public DriveToPeg(){		
	double distance = .2;
	
	requires(Robot.driveBase);
	double kP = -.4;
	double kI = 1;
	double kD = 5;
	
	pid = new PIDController(kP, kI, kD, new PIDSource() {
		PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

		@Override
		public double pidGet() {
			return Robot.driveBase.getDistanceAhead();
		}

		@Override
		public void setPIDSourceType(PIDSourceType pidSource) {
			m_sourceType = pidSource;
		}

		@Override
		public PIDSourceType getPIDSourceType() {
			return m_sourceType;
		}
	}, new PIDOutput() {
		@Override
		public void pidWrite(double d) {
			Robot.driveBase.driveForward(d);
			System.out.println(d);
		}
	});
	pid.setAbsoluteTolerance(0.01);
	pid.setSetpoint(distance);
	pid.setOutputRange(0, .35);
	
	SmartDashboard.putData("driveToPeg", pid);
}
 
开发者ID:FRC-6413,项目名称:steamworks-java,代码行数:39,代码来源:DriveToPeg.java

示例15: 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);
}
 
开发者ID:Team334,项目名称:R2017,代码行数:12,代码来源:VisionOffsetPID.java


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