当前位置: 首页>>代码示例>>Java>>正文


Java DriverStation.Alliance方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:2729StormRobotics,项目名称:Storm2014,代码行数:30,代码来源:Robot.java

示例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
}
 
开发者ID:2729StormRobotics,项目名称:Storm2014,代码行数:26,代码来源:Robot.java

示例3: BumperLedStrip

import edu.wpi.first.wpilibj.DriverStation; //导入方法依赖的package包/类
public BumperLedStrip(DriverStation.Alliance alliance) {
    this.alliance = alliance;
}
 
开发者ID:Team334,项目名称:R2017,代码行数:4,代码来源:BumperLedStrip.java

示例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;
        }
    }
}
 
开发者ID:wildstang111,项目名称:2014_software,代码行数:47,代码来源:LED.java


注:本文中的edu.wpi.first.wpilibj.DriverStation.Alliance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。