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


Java DriverStation.getInstance方法代碼示例

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


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

示例1: JsonAutonomous

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的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: FrcJoystick

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public FrcJoystick(
        final String instanceName,
        final int port,
        ButtonHandler buttonHandler)
{
    super(port);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(
                moduleName + "." + instanceName,
                false,
                TrcDbgTrace.TraceLevel.API,
                TrcDbgTrace.MsgLevel.INFO);
    }

    this.port = port;
    this.buttonHandler = buttonHandler;
    ds = DriverStation.getInstance();
    prevButtons = ds.getStickButtons(port);
    ySign = 1;
    TrcTaskMgr.getInstance().registerTask(
            instanceName,
            this,
            TrcTaskMgr.TaskType.PREPERIODIC_TASK);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:27,代碼來源:FrcJoystick.java

示例3: FrcJoystick

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
 * Constructor: Create an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param port specifies the joystick port ID.
 * @param buttonHandler specifies the object that will handle the button events. If none provided, it is set to
 *        null.
 */
public FrcJoystick(final String instanceName, final int port, ButtonHandler buttonHandler)
{
    super(port);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    this.instanceName = instanceName;
    this.port = port;
    this.buttonHandler = buttonHandler;
    ds = DriverStation.getInstance();
    prevButtons = ds.getStickButtons(port);
    ySign = 1;
    TrcTaskMgr.getInstance().registerTask(instanceName, this, TrcTaskMgr.TaskType.PREPERIODIC_TASK);
}
 
開發者ID:trc492,項目名稱:Frc2017FirstSteamWorks,代碼行數:26,代碼來源:FrcJoystick.java

示例4: TCPCameraSensor

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
 * 
 * @param port
 *            which is to be used to Listen for incoming TCP connections on
 *            the FRC bot.
 */
public TCPCameraSensor(int port, long requestPeriod) {
	this.requestPeriod = requestPeriod;


	size = 6;
	
	// initialize data messageOut 
	dataReceived = new String[size];

	dataReceived[0] = "0";
	dataReceived[1] = "0";
	dataReceived[2] = "0";
	dataReceived[3] = "0";
	dataReceived[4] = "0";
	dataReceived[5] = "0";

	// setup socket to listen on
	this.port = port;
	addressIn = "socket://:" + port;

	ds = DriverStation.getInstance();

}
 
開發者ID:Team2168,項目名稱:2014_Main_Robot,代碼行數:30,代碼來源:TCPCameraSensor.java

示例5: CasseroleHourmeter

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
 * Initialize the hourmeter. Will read from disk to get the most recent values for the
 * hourmeter, and start updating the file periodically. If the file does not exist, it will be
 * created initially. This is all you really need to do, unless you happen to want to read the
 * numbers back over smartdashboard or something like that.
 */
public CasseroleHourmeter() {
    int ret_val;
    isRunning = false;

    updater = new java.util.Timer("Hourmeter Update");
    updater_task = new HourmeterUpdater();

    ds = DriverStation.getInstance();

    prev_call_time_sec = Timer.getFPGATimestamp();
    prev_state = OperationState.UNKNOWN;

    // create new file if it doesn't exist, checking errors along the way.
    if (!checkHourmeterFileExists()) {
        ret_val = makeHourmeterDirectories();
        if (ret_val == 0) {
            ret_val = initNewHourmeterFile();
        }
    } else {
        ret_val = readCurrentValuesFromHourmeterFile();
        if (ret_val != 0) {
            System.out.println("ERROR: Parse error while reading initial values from hourmeter file.");
        }
    }

    // Presuming we were able to initialize the hourmeter, kick off the periodic update.
    if (ret_val != 0) {
        System.out.println("ERROR: Cannot initialize hourmeter. Not starting it.");
    } else {
        updater.scheduleAtFixedRate(updater_task, 0, HOURMETER_UPDATE_RATE_MS);
        isRunning = true;
    }
}
 
開發者ID:RobotCasserole1736,項目名稱:CasseroleLib,代碼行數:40,代碼來源:CasseroleHourmeter.java

示例6: GamepadReal

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
GamepadReal(int port) {
	// Initialization of variable values:
	this.port = port;
	driverStation = DriverStation.getInstance();
	lastPress = new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false };
	lastPOV = -1;
}
 
開發者ID:FRC1076,項目名稱:FRC1076-2015-Competition_Robot,代碼行數:8,代碼來源:GamepadReal.java

示例7: isRopeLowered

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
 * Returns if there is less than 30 seconds left in the match.
 */
public boolean isRopeLowered() {
	DriverStation ds = DriverStation.getInstance();
	if(ds.isFMSAttached()) {
		return ds.getMatchTime() < 30;
	}
	return true;
}
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:11,代碼來源:BlastoiseClimber.java

示例8: setup

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
 * Setup Match
 */
public static void setup() {
	DriverStation driverStation = DriverStation.getInstance();

	// Reset all variables
	SmartDashboard.putBoolean("BrownOut", false);
	SmartDashboard.putString("RobotState", "DISABLED");
	SmartDashboard.putNumber("LeftAxis", 0.0);
	SmartDashboard.putNumber("RightAxis", 0.0);


	new Timer().schedule(new TimerTask() {
		@Override
		public void run() {
			if(driverStation.isBrownedOut()){
				// Something really, really bad has happened
				SmartDashboard.putBoolean("BrownOut", true);
			} else {
				SmartDashboard.putBoolean("BrownOut", false);
			}

			// Show alliance
			DriverStation.Alliance alliance = driverStation.getAlliance();
			if(alliance == DriverStation.Alliance.Blue) SmartDashboard.putString("Alliance", "BLUE");
			else if(alliance == DriverStation.Alliance.Red) SmartDashboard.putString("Alliance", "RED");
			else SmartDashboard.putString("Alliance", "NONE");

			// Show DS Number
			SmartDashboard.putNumber("Location", driverStation.getLocation());

			// Show Timer and Battery
			SmartDashboard.putNumber("Time", driverStation.getMatchTime());
			SmartDashboard.putNumber("Battery", driverStation.getBatteryVoltage());
		}
	}, 0, 100);
}
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:39,代碼來源:TurtleDashboard.java

示例9: robotInit

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
 *
 */
public void robotInit() {
    // instantiate the command used for the autonomous period
    DriveTrain = new DriveTrain();
    launchercontroller = new Launcher();
    rollerSubsystem = new Roller();
    display = DriverStationLCD.getInstance();
    compressor = new Compressor(RobotMap.PressureSwitchDigitalInput, RobotMap.CompressorRelay);
    compressor.start();
    
    DriveTrain.shiftHighGear();

    OI.initialize();


    autonomousCommand = new Autonomous();
    
    arduino = new ArduinoConnection();
    arduino.setPattern("4");
    pattern = 0;
    driverStation = DriverStation.getInstance();
    alliance = driverStation.getAlliance().value;
    digital1 = driverStation.getDigitalIn(1);
    digital2 = driverStation.getDigitalIn(2);
    digital3 = driverStation.getDigitalIn(3);
    // Initialize all subsystems.
    // Subsystems: a self-contained system within a larger system. 
    CommandBase.init();
}
 
開發者ID:CarmelRobotics,項目名稱:aeronautical-facilitation,代碼行數:32,代碼來源:AeronauticalFacilitation.java

示例10: createGamePacket

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
private static byte [] createGamePacket() {
	DriverStation ds = DriverStation.getInstance();
	float matchTime = (float)ds.getMatchTime();
	float batteryVoltage = (float)ds.getBatteryVoltage();
	byte dsNumber = (byte)ds.getLocation();
	int teamNumber = ds.getTeamNumber();
	byte [] matchTimeRaw = intToByteArray(Float.floatToIntBits(matchTime));
	byte [] batteryVoltageRaw = intToByteArray(Float.floatToIntBits(batteryVoltage));
	byte [] teamNumberRaw = intToByteArray(teamNumber);
	byte miscData = 0;
	final byte [] ref = {(byte)0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
	miscData ^= (ds.getAlliance().value==Alliance.kBlue_val)?ref[0]:0; //(Blue, Red)(True, False)
	miscData ^= !ds.isEnabled() ? ref[1] : 0; // (Disabled, Enabled)
	miscData ^= ds.isAutonomous()? ref[2] : 0; // (Autonomous, )
	miscData ^= ds.isOperatorControl() ? ref[3] : 0; // (Operator Control, )
	miscData ^= ds.isTest() ? ref[4] : 0; // (Test, )
	miscData ^= ds.isFMSAttached() ? ref[5] : 0; // (FMS, )
	byte [] data = new byte[14 + headerSize];
	int pos = 0;
	generateHeader(data, 0, headerSize, 0);
	pos += headerSize;
	System.arraycopy(matchTimeRaw, 0, data, pos, 4); pos += 4;
	System.arraycopy(batteryVoltageRaw, 0, data, pos, 4); pos += 4;
	data[pos] = dsNumber; pos++;
	System.arraycopy(teamNumberRaw, 0, data, pos, 4); pos += 4;
	data[pos] = miscData; pos++;
	return data;
}
 
開發者ID:Team-2502,項目名稱:RobotCode2014,代碼行數:29,代碼來源:BlackBoxSubPacket.java

示例11: put

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public static void put() {
	//Shooter diagnostics:
	SmartDashboard.putNumber("shooter WINCH CURRENT", RobotShoot.getCurrent());
	SmartDashboard.putBoolean("shooter IS AT BACK", !RobotSensors.shooterAtBack.get());
	SmartDashboard.putNumber("shooter EXPECT CURRENT", RobotShoot.getEncoder() * 0.01);
	SmartDashboard.putNumber("shooter ENCODER", RobotShoot.getEncoder());
	SmartDashboard.putBoolean("shooter MANUAL", RobotShoot.isManual());
	SmartDashboard.putBoolean("shoter TARGET MANUAL", MainRobot.targetInManualMode);
	//Pickup diagnostics:
	SmartDashboard.putNumber("pickup ARM ANGLE", RobotPickup.getArmAngleAboveHorizontal());
	SmartDashboard.putNumber("pickup ARM ANGLE TARGET", RobotPickup.getArmTargetAngle());
	
	SmartDashboard.putBoolean("pickup TRUSS POSITION", RobotPickup.isPickupInTrussPosition());
	SmartDashboard.putBoolean("pickup ARM LIMIT UPPER", RobotPickup.isUpperLimitReached());
	SmartDashboard.putBoolean("pickup ARM LIMIT LOWER", RobotPickup.isLowerLimitReached());
	//Drive
	//SmartDashboard.putBoolean("drive ESTOP",RobotDrive.isStopped());
	//General status
	DriverStation driverStation = DriverStation.getInstance();
	SmartDashboard.putNumber("status BATTERY", driverStation.getBatteryVoltage());
	SmartDashboard.putNumber("vision RED DISTANCE", RobotVision.redDistance());
	SmartDashboard.putNumber("vision BLUE DISTANCE", RobotVision.blueDistance());
	SmartDashboard.putNumber("vision DISTANCE", RobotVision.getDistance());

	SmartDashboard.putNumber("vision HOT NUMBER", RobotVision.getNumber("hot")); //this is on the robot

	// TESTING VARIABLES
	SmartDashboard.putNumber("pickup POTENTIOMETER", RobotSensors.pickupPotentiometer.get());
}
 
開發者ID:Nathan-Fenner,項目名稱:AdamBots-2014-FRC-Programming,代碼行數:30,代碼來源:DashboardPut.java

示例12: robotInit

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/** 
 * Robot Initialization upon boot
 */
protected void robotInit() {
    System.out.println("RobotInit...");
    ds = DriverStation.getInstance();
    dt.setMotorsInverted();

    thrower.setStowSpeed(-0.35);
    thrower.initThrower();
}
 
開發者ID:FRC4564,項目名稱:AerialAssist,代碼行數:12,代碼來源:Natasha2014.java

示例13: Collector

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public Collector() {
    //initializing everything
    leftCollector = new DoubleSolenoid(1, 2);
    rightCollector = new DoubleSolenoid(3, 4);
    collectorMotor = new Talon(3);
    collectMotorCommand = false;
    collectorInCommand = false;
    collectorOutCommand = false;
    passMotorCommand = false;
    driverStation = DriverStation.getInstance();
}
 
開發者ID:FRCTeam3182,項目名稱:FRC2014,代碼行數:12,代碼來源:Collector.java

示例14: Shooter

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public Shooter(Collector collector) {
    //initializing everything
    shooterMotors = new Talon(4);
    shootCommand = false;
    compressor = new Compressor(7, 1);
    compressor.start();
    driverStation = DriverStation.getInstance();
    this.collector = collector;
}
 
開發者ID:FRCTeam3182,項目名稱:FRC2014,代碼行數:10,代碼來源:Shooter.java

示例15: ArduinoLights

import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public ArduinoLights(Sensors sensors) {
    //initializing everything
    arduinoSignal = new DigitalOutput(5); //data line
    arduinoSignifier = new DigitalOutput(6);//tells arduino when to read data
    driverStation = DriverStation.getInstance();
    this.sensors = sensors;
    Timer.delay(.5);
}
 
開發者ID:FRCTeam3182,項目名稱:FRC2014,代碼行數:9,代碼來源:ArduinoLights.java


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