本文整理汇总了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;
}
}
}