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


Java Preferences类代码示例

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


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

示例1: CenterGearAutonomous

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
public CenterGearAutonomous() {

		double centerGearAutoSpeed = Preferences.getInstance().getDouble(RobotMap.centerGearAutoSpeed, 0.0);
		double centerGearAutoDistance = Preferences.getInstance().getDouble(RobotMap.centerGearAutoDistance, 0.0);
		double autoWaitTime = Preferences.getInstance().getDouble(RobotMap.autoWaitTime, 0.0);
		double wiggleForward = Preferences.getInstance().getDouble(RobotMap.wiggleForward, 0.0);

		addSequential(new DriveStraightAuto(centerGearAutoDistance, centerGearAutoSpeed));
		addSequential(new TurnAngle(3));
		addSequential(new TurnAngle(-6));
		addSequential(new TurnAngle(3));
		addSequential(new DriveStraightAuto(wiggleForward, centerGearAutoSpeed));
		addSequential(new WaitCommand(autoWaitTime));
		addParallel(new DownManipulator());
		addParallel(new ReverseManipulatorMotors());
		// addSequential(new WaitCommand(autoWaitTime));
		addSequential(new DriveStraightAuto(centerGearAutoDistance / 2, -centerGearAutoSpeed));
		addSequential(new WaitCommand(autoWaitTime / 2));
		addSequential(new DriveStraightAuto(centerGearAutoDistance / 3, centerGearAutoSpeed));
		addSequential(new ManipulatorMotorOff());
		addSequential(new UpManipulator());
	}
 
开发者ID:chopshop-166,项目名称:frc-2017,代码行数:23,代码来源:CenterGearAutonomous.java

示例2: teleopPeriodic

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
 * This function is called periodically during operator control
 */
public void teleopPeriodic()
{
    double speed = Preferences.getInstance().getDouble("Motor One Speed", .5);

    if (mJoystick1.getRawButton(1))
    {
        mTestMotor1.set(1);
    }
    else
    {
        mTestMotor1.set(0);
    }

    SmartDashboard.putNumber("Motor 1", mTestMotor1.get());
    SmartDashboard.putNumber("Analog Angle", mAnalogGryo.getAngle());
    SmartDashboard.putNumber("SPI Angle", mSpiGryo.getAngle());
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:21,代码来源:Snobot.java

示例3: initialize

import edu.wpi.first.wpilibj.Preferences; //导入依赖的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

示例4: DebugHardware

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
*Contains a variety of debugging functions. 
*Mostly affects the SmartDashboard.
*/
  public DebugHardware() {
  	motorSelector = new SendableChooser();
  	motorSelector.addDefault("None", 0);
  	motorSelector.addObject("Left Front", 1);
  	motorSelector.addObject("Right Front", 2);
  	motorSelector.addObject("Right Rear", 3);
  	motorSelector.addObject("Left Rear", 4);
  	motorSelector.addObject("Winch", 5);
  	motorSelector.addObject("Left Roller", 6);
  	motorSelector.addObject("Right Roller", 7);
  	SmartDashboard.putData("Debug Motor", motorSelector);
  	
  	Preferences.getInstance().putDouble("setWinch",RobotMap.forkliftMotor.getPosition());
  	
  	Preferences.getInstance().putDouble("WheelSpeed", speed);
  	RobotMap.forkliftMotor.enableControl();
  }
 
开发者ID:FRC2832,项目名称:Robot_2015,代码行数:22,代码来源:DebugHardware.java

示例5: getEncoderDistance

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
 * This method gets encoder distance; it <b>does not work with strafe on mecanum!!!</b>
 * @param initialVals The values of the encoders, as read from getInitialEncoderValues
 * @return The encoder distance
 * @see getInitialEncoderValues
 */
public static double getEncoderDistance(ArrayList<Double> initialVals) {
	ArrayList<Double> vals = new ArrayList<>();
	
	vals.add(  (RobotMap.driveBaseLeftFrontMotor.getEncPosition()  / RobotMap.ENCODER_PULSE_PER_METER) - initialVals.get(0));  
	vals.add(  (RobotMap.driveBaseLeftRearMotor.getEncPosition()   / RobotMap.ENCODER_PULSE_PER_METER) - initialVals.get(1));  
	vals.add(-((RobotMap.driveBaseRightFrontMotor.getEncPosition() / RobotMap.ENCODER_PULSE_PER_METER) - initialVals.get(2))); 
	vals.add(-((RobotMap.driveBaseRightRearMotor.getEncPosition()  / RobotMap.ENCODER_PULSE_PER_METER) - initialVals.get(3))); 
   	
	Preferences.getInstance().putDouble("LFencoder", vals.get(0));    
	Preferences.getInstance().putDouble("LRencoder", vals.get(1));  
	Preferences.getInstance().putDouble("RFencoder", vals.get(2));    
	Preferences.getInstance().putDouble("RRencoder", vals.get(3));  
	
	Collections.sort(vals);
   	return (vals.get(1) + vals.get(2))/2;
   }
 
开发者ID:FRC2832,项目名称:Robot_2015,代码行数:23,代码来源:DriveEncoders.java

示例6: robotInit

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
 * Called when the robot first starts, (only once at power-up).
 */
public void robotInit() {
    //NetworkTable.setTeam(1259); adding the setTeam() method will cause the robot to encounter a thread error
    //NetworkTable.setIPAddress("10.12.59.2");
    operatorInputs = new OperatorInputs();
    drive = new DriveTrain(operatorInputs);
    prefs = Preferences.getInstance();
    pickerPID = new PickerPID();
    shoot = new Shooter(operatorInputs);
    pick = new Picker(operatorInputs, pickerPID, shoot);
    compressor = new Compressor(PRESSURE_SWITCH_CHANNEL, COMPRESSOR_RELAY_CHANNEL);
    colwellContraption1 = new Solenoid(1, 3);
    colwellContraption2 = new Solenoid(1, 4);
    colwellContraption2.set(true);

    this.autoTimer = new Timer();
    drive.leftEncoder.start();
    drive.rightEncoder.start();
    drive.timer.start();
    autoTimer.start();
}
 
开发者ID:pewaukeerobotics,项目名称:ParadigmShift-2014,代码行数:24,代码来源:Rafiki_Atlas.java

示例7: robotInit

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
    * This function is run when the robot is first started up and should be
    * used for any initialization code.
    */
   public void robotInit() {
       
RobotMap.init();
       autoChooser = new SendableChooser();
       autoChooser.addDefault("Simple Autonomous", new SimpleAutonomous());
       //autoChooser.addObject("name", );
       //autoChooser.addObject("name", );
       SmartDashboard.putData("Autonomous Chooser", autoChooser);
       shooterFan = new ShooterFan();
       eightBallGrabber = new EightBallGrabber();
       prefs = Preferences.getInstance();

       // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
   // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
       // This MUST be here. If the OI creates Commands (which it very likely
       // will), constructing it during the construction of CommandBase (from
       // which commands extend), subsystems are not guaranteed to be
       // yet. Thus, their requires() statements may grab null pointers. Bad
       // news. Don't move it.
       oi = new OI();
       
   // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
       
       // Setup compass to stream data
   }
 
开发者ID:Tmm2471,项目名称:Swerve,代码行数:30,代码来源:Robot.java

示例8: driveForwardAuto

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
     * moves 3 ft during autonomous
     * @author cathy
     */
    public void driveForwardAuto (){
        switch(step) {
            case 0:
//                drive.getChassis().drive(.5, 0);
//                try{
//                    Thread.sleep(4000);
//                } catch (InterruptedException e){
//                    e.printStackTrace();
//                }
                if(drive.drive(.5, Preferences.getInstance().getDouble("driveForwardDistance", 48)))
                    step++;
                break;
            
            default:
                drive.drive(0, 0);
                System.out.println("stopped");
                break;
        }
    }
 
开发者ID:FRC-Team-2403,项目名称:2014-robot,代码行数:24,代码来源:Autonomous.java

示例9: straightDriveEnc

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
public boolean straightDriveEnc(double power, double leftRate, double rightRate) {
	double kp = Preferences.getInstance().getDouble("kp", 0.1);
	if (power != 0) {
		double lspeed, rspeed;
		lspeed = rspeed = 0;
		
		rspeed = lspeed = curveInput(power,2);
		if (Math.abs(leftRate) > Math.abs(rightRate)) {
			lspeed -= (leftRate-rightRate)*kp;
		} else {
			rspeed -= (rightRate-leftRate)*kp;
		}

		tankDrive(lspeed,rspeed);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:dkess,项目名称:ReboundRumbleJava,代码行数:20,代码来源:Drive.java

示例10: DropManipulatorReverseMotor

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
public DropManipulatorReverseMotor() {

		double reverseFromPegDistance = Preferences.getInstance().getDouble(RobotMap.reverseFromPegDistance, 0.0);
		double reverseFromPegSpeed = Preferences.getInstance().getDouble(RobotMap.reverseFromPegSpeed, 0.0);

		addSequential(new ReverseManipulatorMotors());
		addSequential(new DownManipulator());
		addSequential(new DriveDistance(-Math.abs(reverseFromPegDistance), -Math.abs(reverseFromPegSpeed)));
		addSequential(new ManipulatorMotorOff());
		addSequential(new UpManipulator());

	}
 
开发者ID:chopshop-166,项目名称:frc-2017,代码行数:13,代码来源:DropManipulatorReverseMotor.java

示例11: robotInit

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
 * This function is run when the robot is first started up and should be used for any initialization code.
 */
@Override
public void robotInit() {
	drive = new Drive();
	gearManipulator = new GearManipulator();
	intake = new Intake();
	shooter = new Shooter();
	storage = new Storage();
	climber = new Climber();
	elevator = new Elevator();
	vision = new Vision();
	visionProcessing = new LiveUsbCamera();
	oi = new OI();
	Robot.gearManipulator.gearManipulatorUp();
	chooser.addDefault("Center Gear Auto", new CenterGearAutonomous());
	chooser.addObject("Base Line Autonomous", new BaseLineAutonomous());
	chooser.addObject("Boiler side Blue auto", new BoilerSideBlueAuto());
	chooser.addObject("Boiler side Red auto", new BoilerSideRedAuto());
	chooser.addObject("Do Nothing Autonomous", null);

	double speed = Preferences.getInstance().getDouble(RobotMap.centerGearAutoSpeed, 0);
	double distance = Preferences.getInstance().getDouble(RobotMap.centerGearAutoDistance, 0);

	SmartDashboard.putData("Auto Mode", chooser);
	// xboxLeftTrigger.whileActive(new ClimberTriggerOn());
	xboxRightTrigger.whileActive(new RunShooter());

	visionProcessing.runUsbCamera();
}
 
开发者ID:chopshop-166,项目名称:frc-2017,代码行数:32,代码来源:Robot.java

示例12: zeroAzimuthEncoders

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
/**
 * Set wheels' azimuth relative offset from zero based on the current absolute position. This uses
 * the physical zero position as read by the absolute encoder and saved during the wheel alignment
 * process.
 *
 * @see #saveAzimuthPositions()
 */
public void zeroAzimuthEncoders() {
  Preferences prefs = Preferences.getInstance();
  for (int i = 0; i < WHEEL_COUNT; i++) {
    int position = prefs.getInt(getPreferenceKeyForWheel(i), 0);
    wheels[i].setAzimuthZero(position);
    logger.info("azimuth {}: loaded zero = {}", i, position);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:16,代码来源:SwerveDrive.java

示例13: initialize

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
protected void initialize() {
	
	SPEED = Preferences.getInstance().getDouble("Expel Speed", 0.3);
	BallMotors.expel(SPEED);
	Kicker.launch();
	//record time of command start
	timeStart = System.currentTimeMillis();
	Robot.isExpelling = true;
	
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:11,代码来源:Expel.java

示例14: loadPreferences

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
public static void loadPreferences() {
	UP_PID_P = Preferences.getInstance().getDouble("Aimer Up kP", 1.0);
	UP_PID_I = Preferences.getInstance().getDouble("Aimer Up kI", 0.001);
	UP_PID_D = Preferences.getInstance().getDouble("Aimer Up kD", 0.0);
	DOWN_PID_P = Preferences.getInstance().getDouble("Aimer Down kP", 0.5);
	DOWN_PID_I = Preferences.getInstance().getDouble("Aimer Down kI", 0.02);
	DOWN_PID_D = Preferences.getInstance().getDouble("Aimer Down kD", 0.0);
	
	MOVE_SPEED_UP = Preferences.getInstance().getInt("Aimer Up Speed", 300);
	MOVE_SPEED_DOWN = Preferences.getInstance().getInt("Aimer Down Speed",-175);
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:12,代码来源:Aimer.java

示例15: holdElbowPosition

import edu.wpi.first.wpilibj.Preferences; //导入依赖的package包/类
public static int holdElbowPosition() {
	Preferences prefs = Preferences.getInstance();
	if (!prefs.containsKey("holdElbowPosition")) {
		prefs.putInt("holdElbowPosition", 3589);
	}
	return prefs.getInt("holdElbowPosition", 3589);
}
 
开发者ID:Woodland4678,项目名称:Cybercavs2016Code,代码行数:8,代码来源:Robot.java


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