本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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());
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}