Java 类edu.wpi.first.wpilibj.Preferences 实例源码

项目:frc-2017    文件:CenterGearAutonomous.java   
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());
    }
项目:snobot-2017    文件:Snobot.java   
/**
 * 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());
}
项目:Robot_2015    文件:Rotate.java   
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);

    }
项目:Robot_2015    文件:DebugHardware.java   
/**
*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();
  }
项目:Robot_2015    文件:DriveEncoders.java   
/**
 * 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;
   }
项目:ParadigmShift-2014    文件:Rafiki_Atlas.java   
/**
 * 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();
}
项目:Swerve    文件:Robot.java   
/**
    * 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
   }
项目:2014-robot    文件:Autonomous.java   
/**
     * 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;
        }
    }
项目:ReboundRumbleJava    文件:Drive.java   
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;
    }
}
项目:Swerve    文件:Robot.java   
/**
    * 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
   }
项目:frc-2017    文件:DropManipulatorReverseMotor.java   
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());

    }
项目:frc-2017    文件:Robot.java   
/**
 * 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();
}
项目:thirdcoast    文件:SwerveDrive.java   
/**
 * 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);
  }
}
项目:Robot_2016    文件:Expel.java   
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;

}
项目:Robot_2016    文件:Aimer.java   
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);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static int holdElbowPosition() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("holdElbowPosition")) {
        prefs.putInt("holdElbowPosition", 3589);
    }
    return prefs.getInt("holdElbowPosition", 3589);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static int holdWristPosition() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("holdWristPosition")) {
        prefs.putInt("holdWristPosition", 2027);
    }
    return prefs.getInt("holdWristPosition", 2027);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double latchReadyPosition() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("latchReadyPostion")) {
        prefs.putDouble("latchReadyPostion", 0.32);
    }
    return prefs.getDouble("latchReadyPostion", 0.32);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double latchShootPosition() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("latchShootPosition")) {
        prefs.putDouble("latchShootPosition", 1.0);
    }
    return prefs.getDouble("latchShootPosition", 1.0);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double latchLockPosition() { //position to lower server after latch to ensure it doesn't launch prematurely
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("latchLockPosition")) {
        prefs.putDouble("latchLockPosition", 0.01);
    }
    return prefs.getDouble("latchLockPosition", 0.01);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double winchPower() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("winchPower")) {
        prefs.putDouble("winchPower", 1.0);
    }
    return prefs.getDouble("winchPower", 1.0);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double winchWoundDistance() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("winchWoundDistance")) {
        prefs.putDouble("winchWoundDistance", 1);
    }
    return prefs.getDouble("winchWoundDistance", 1);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double winchUnwoundDistance() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("winchUnwoundDistance")) {
        prefs.putDouble("winchUnwoundDistance", 4.6);
    }
    return prefs.getDouble("winchUnwoundDistance", 4.6);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double pickupWheelsPower() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("pickupWheelsPower")) {
        prefs.putDouble("pickupWheelsPower", -12);
    }
    return prefs.getDouble("pickupWheelsPower", -12);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double pixelsPerEncoderChange() {
    Preferences prefs = Preferences.getInstance();
       if (!prefs.containsKey("pixelsPerEncoderChange")) {
           prefs.putDouble("pixelsPerEncoderChange", 0.735);
       }
       return prefs.getDouble("pixelsPerEncoderChange", 0.735);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static int manipulatorWristRestPosition() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("manipulatorWristRestPosition")) {
        prefs.putInt("manipulatorWristRestPosition", 2100);
    }
    return prefs.getInt("manipulatorWristRestPosition", 2100);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static int manipulatorElbowRestPosition() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("manipulatorElbowRestPosition")) {
        prefs.putInt("manipulatorElbowRestPosition", 1900);
    }
    return prefs.getInt("manipulatorElbowRestPosition", 1900);
}
项目:Cybercavs2016Code    文件:Robot.java   
public static double pixToTurnMax() {
    Preferences prefs = Preferences.getInstance();
    if (!prefs.containsKey("pixToTurnMax")) {
        prefs.putDouble("pixToTurnMax", 1.0);
    }
    return prefs.getDouble("pixToTurnMax", 1.0);
}
项目:frc-2016    文件:BatterShot.java   
public BatterShot() {
    addSequential(new DriveDistance(-.4, 26));
    addSequential(new UnlockShooter());
    addSequential(new LowerRake());
    addSequential(new SetShooterSpeed(Preferences.getInstance().getDouble("ShooterSpeed", 0.0)));
    addSequential(new AimToAngle(61));
    addSequential(new WaitCommand(1.0));
    addSequential(new MoveBallIntoShooter());
    addSequential(new WaitCommand(1.0));
    addSequential(new SetShooterSpeed(0.0));
    addSequential(new RaiseRake());

}
项目:frc-2016    文件:AimShooter.java   
private void updatePIDConstants() {

        double AngleP = Preferences.getInstance().getDouble(RobotMap.Prefs.ShooterAngleP, 0);
        double AngleI = Preferences.getInstance().getDouble(RobotMap.Prefs.ShooterAngleI, 0);
        double AngleD = Preferences.getInstance().getDouble(RobotMap.Prefs.ShooterAngleD, 0);
        double AngleF = Preferences.getInstance().getDouble(RobotMap.Prefs.ShooterAngleF, 0);
        anglePID.setConstants(AngleP, AngleI, AngleD, AngleF);
    }
项目:snobot-2017    文件:Snobot.java   
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit()
{
    // PWM's
    mTestMotor1 = new Talon(0);
    mTestMotor2 = new Jaguar(1);
    mServo = new Servo(2);

    // Digital IO
    mDigitalOutput = new DigitalOutput(0);
    mRightEncoder = new Encoder(4, 5);
    mLeftEncoder = new Encoder(1, 2);
    mUltrasonic = new Ultrasonic(7, 6);

    // Analog IO
    mAnalogGryo = new AnalogGyro(0);
    mPotentiometer = new AnalogPotentiometer(1);

    // Solenoid
    mSolenoid = new Solenoid(0);

    // Relay
    mRelay = new Relay(0);

    // Joysticks
    mJoystick1 = new Joystick(0);
    mJoystick2 = new XboxController(1);

    // SPI
    mSpiGryo = new ADXRS450_Gyro();

    // Utilities
    mTimer = new Timer();
    mPDP = new PowerDistributionPanel();

    Preferences.getInstance().putDouble("Motor One Speed", .5);
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public Double getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getDouble(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putDouble(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public Integer getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getInt(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putInt(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public String getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getString(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putString(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public Boolean getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getBoolean(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putBoolean(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public Double getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getDouble(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putDouble(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public Integer getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getInt(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putInt(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public String getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getString(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putString(mKey, mDefault);
    return mDefault;
}
项目:snobot-2017    文件:PropertyManager.java   
@Override
public Boolean getValue()
{
    if (Preferences.getInstance().containsKey(mKey))
    {
        return Preferences.getInstance().getBoolean(mKey, mDefault);
    }

    sPropertyAdded = true;
    Preferences.getInstance().putBoolean(mKey, mDefault);
    return mDefault;
}
项目:FB2016    文件:RobotMap.java   
/**
 * Retrieve numbers from the preferences table. If the specified key is in
 * the preferences table, then the preference value is returned. Otherwise,
 * return the backup value, and also start a new entry in the preferences
 * table.
 */
public static double getPreferencesDouble(String key, double backup) {
    Preferences preferences = Preferences.getInstance();
    if (!preferences.containsKey(key)) {
        preferences.putDouble(key, backup);
    }
    return preferences.getDouble(key, backup);
}