本文整理匯總了Java中edu.wpi.first.wpilibj.DriverStation.Alliance方法的典型用法代碼示例。如果您正苦於以下問題:Java DriverStation.Alliance方法的具體用法?Java DriverStation.Alliance怎麽用?Java DriverStation.Alliance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.wpi.first.wpilibj.DriverStation
的用法示例。
在下文中一共展示了DriverStation.Alliance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: teleopPeriodic
import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
* Called during teleop whenever a new driver station packet arrives (about
* every 1/50 of a second).q
*/
public void teleopPeriodic() {
// Runs commands & stuff
Scheduler.getInstance().run();
DriverStation.Alliance color = DriverStation.getInstance().getAlliance();
if (color == DriverStation.Alliance.kBlue){
SmartDashboard.putBoolean("Blue Alliance?", true);
staticleds.setRed((short) 0);
staticleds.setGreen((short) 0);
staticleds.setBlue((short) 255);
} else if (color == DriverStation.Alliance.kRed){
SmartDashboard.putBoolean("Blue Alliance?", false);
staticleds.setRed((short) 255);
staticleds.setGreen((short) 0);
staticleds.setBlue((short) 0);
} else {
SmartDashboard.putBoolean("Blue Alliance?", false);
staticleds.setRed((short) 255);
staticleds.setGreen((short) 0);
staticleds.setBlue((short) 255);
}
}
示例2: disabledPeriodic
import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
/**
* Called during disabled whenever a new driver station packet arrives
* (about every 1/50 of a second). We only have it overridden so we don't
* get "Override me!" messages.
*/
public void disabledPeriodic() {
sendSensorData();
DriverStation.Alliance color = DriverStation.getInstance().getAlliance();
if (color == DriverStation.Alliance.kBlue){
staticleds.setRed((short) 0);
staticleds.setGreen((short) 0);
staticleds.setBlue((short) (255 * Math.sin(pulseCount)));
} else if (color == DriverStation.Alliance.kRed){
staticleds.setRed((short) (255 * Math.sin(pulseCount)));
staticleds.setGreen((short) 0);
staticleds.setBlue((short) 0);
} else {
staticleds.setRed((short) (255 * Math.sin(pulseCount)));
staticleds.setGreen((short) 0);
staticleds.setBlue((short) (255 * Math.sin(pulseCount)));
}
pulseCount += Math.PI / 200; //Should take 8 seconds to pulse on and off
}
示例3: BumperLedStrip
import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public BumperLedStrip(DriverStation.Alliance alliance) {
this.alliance = alliance;
}
示例4: update
import edu.wpi.first.wpilibj.DriverStation; //導入方法依賴的package包/類
public void update() {
// Get all inputs relevant to the LEDs
boolean isRobotEnabled = DriverStation.getInstance().isEnabled();
boolean isRobotTeleop = DriverStation.getInstance().isOperatorControl();
boolean isRobotAuton = DriverStation.getInstance().isAutonomous();
DriverStation.Alliance alliance = DriverStation.getInstance().getAlliance();
if (isRobotEnabled) {
if (isRobotTeleop) {
//Do nothing, handled in acceptNotification
} else if (isRobotAuton) {
//--------------------------------------------------------------
// Handle Autonomous signalling here
//--------------------------------------------------------------
//One send and one send only.
//Don't take time in auto sending LED cmds.
if (!autoDataSent) {
autoDataSent = sendData(autoCmd);
}
}
} else {
//------------------------------------------------------------------
// Handle Disabled signalling here
//------------------------------------------------------------------
switch (alliance.value) {
case DriverStation.Alliance.kRed_val: {
if (!disableDataSent) {
disableDataSent = sendData(redCmd);
}
}
break;
case DriverStation.Alliance.kBlue_val: {
if (!disableDataSent) {
disableDataSent = sendData(blueCmd);
}
}
break;
default: {
disableDataSent = false;
}
break;
}
}
}