当前位置: 首页>>代码示例>>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;未经允许,请勿转载。