當前位置: 首頁>>代碼示例>>Java>>正文


Java Relay類代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.Relay的典型用法代碼示例。如果您正苦於以下問題:Java Relay類的具體用法?Java Relay怎麽用?Java Relay使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Relay類屬於edu.wpi.first.wpilibj包,在下文中一共展示了Relay類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Vision

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
/**
 * Creates the instance of VisionSubsystem.
 */
public Vision() {
  logger.trace("Initialize");

  ledRing0 = new Relay(RobotMap.RELAY_LED_RING_0);
  ledRing1 = new Relay(RobotMap.RELAY_LED_RING_1);

  gearVision.table = NetworkTable.getTable("Vision_Gear");
  boilerVision.table = NetworkTable.getTable("Vision_Boiler");

  initPhoneVars(gearVision, DEFAULT_GEAR_TARGET_WIDTH, DEFAULT_GEAR_TARGET_HEIGHT);
  initPhoneVars(boilerVision, DEFAULT_BOILER_TARGET_WIDTH, DEFAULT_BOILER_TARGET_HEIGHT);

  Thread forwardThread = new Thread(this::packetForwardingThread);
  forwardThread.setDaemon(true);
  forwardThread.setName("Packet Forwarding Thread");
  forwardThread.start();

  Thread dataThread = new Thread(this::dataThread);
  dataThread.setDaemon(true);
  dataThread.setName("Vision Data Thread");
  dataThread.start();
}
 
開發者ID:ligerbots,項目名稱:Steamworks2017Robot,代碼行數:26,代碼來源:Vision.java

示例2: disabledPeriodic

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public void disabledPeriodic() {
    RobotMap.lightRing.set(Relay.Value.kOff);
    Scheduler.getInstance().run();
    
    recordedID = (String) (oi.index.getSelected());
    recordedAuton = SmartDashboard.getBoolean("Use Recorded Autonomous");
    
    Aimer.toPositionMode();
    RobotMap.winchMotor.setEncPosition(0);
    RobotMap.winchMotor.setPosition(0);
    RobotMap.winchMotor.set(0);
    DashboardOutput.putPeriodicData();

    isBlue = (DriverStation.getInstance().getAlliance() == Alliance.Blue);
      
    sendStateToLights(false, false);
}
 
開發者ID:FRC2832,項目名稱:Robot_2016,代碼行數:18,代碼來源:Robot.java

示例3: ShooterControl

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
ShooterControl(Encoder encoder, SpeedController pullBackSpeedController, double speedControllerMaxRpm,
               DigitalInput limitSwitch, DoubleSolenoid gearControl, Servo latchServo,
               Relay angleControl)
{
    m_latchReleaseServo = latchServo;
    m_currentState = SHOOTER_CONTROL_STATE_WAIT;
    m_encoder = encoder;
    m_pullBackSpeedController = pullBackSpeedController;
    m_angleControl = angleControl;
    m_speedControllerMaxRpm = speedControllerMaxRpm;
    m_limitSwitch = limitSwitch;
    m_pullBackEncoderRpm = new EncoderRPM();
    m_pullBackEncoderRpm.Init(m_pullBackSpeedController, m_encoder, (-1)*m_speedControllerMaxRpm, m_speedControllerMaxRpm, 0.05, 100, m_limitSwitch);
    m_releaseFromMidptEncoderRpm = new EncoderRPM();
    m_releaseFromMidptEncoderRpm.Init(m_pullBackSpeedController, m_encoder,(-1)*m_speedControllerMaxRpm/4,m_speedControllerMaxRpm,0.05, 3);
    m_gearControl = gearControl;
    m_latchReleased = false;
    m_gearReleased = false;
    m_isPulledBack = false;
}
 
開發者ID:Dinoyan,項目名稱:FRC-2014-robot-project,代碼行數:21,代碼來源:ShooterControl.java

示例4: tick

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
@Override
public void tick() {
	double horizontalRotationDegrees = (double) this.getDataKey(CameraSubsystemDataKey.HORIZONTAL_ROTATION_DEGREES);
	double verticalRotationDegrees = (double) this.getDataKey(CameraSubsystemDataKey.VERTICAL_ROTATION_DEGREES);
	
	double horizontalValue = WarriorMath.map(horizontalDegrees[1], horizontalDegrees[0], horizontalRotationDegrees, 0.0, 1.0);
	double verticalValue = WarriorMath.map(verticalDegrees[1], verticalDegrees[0], verticalRotationDegrees, 0.0, 1.0);
	
	Relay.Value lightsValue = null;
	
	if((boolean) this.getDataKey(CameraSubsystemDataKey.LIGHTS) == true) {
		lightsValue = Relay.Value.kOn;
	} else {
		lightsValue = Relay.Value.kOff;
	}
	
	this._horizontal.set(horizontalValue);
	this._vertical.set(verticalValue);
	this._lights.set(lightsValue);
}
 
開發者ID:frc2503,項目名稱:r2016,代碼行數:21,代碼來源:CameraSubsystem.java

示例5: acceptNotification

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public void acceptNotification(Subject subjectThatCaused)
    {
        if(((BooleanSubject) subjectThatCaused).getValue())
        {
//            if(subjectThatCaused.getType() == JoystickDPadButtonEnum.MANIPULATOR_D_PAD_BUTTON_DOWN)
//            {
//                SmartDashboard.putBoolean("Looking For Hot Goal", true);
//                SmartDashboard.putBoolean("Found Hot Goal", this.checkForHotGoal());
//                SmartDashboard.putBoolean("Looking For Hot Goal", false);
//            }
            if(subjectThatCaused.getType() == JoystickDPadButtonEnum.MANIPULATOR_D_PAD_BUTTON_RIGHT)
            {
                ledState = (ledState == Relay.Value.kOff ? Relay.Value.kOn : Relay.Value.kOff);
            }
        }
    }
 
開發者ID:wildstang111,項目名稱:2014_software,代碼行數:17,代碼來源:HotGoalDetector.java

示例6: OutputManager

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
/**
 * Constructor for OutputManager.
 *
 * All new output elements need to be added in the constructor as well as
 * having a key value added above.
 */

protected OutputManager() {
    //Add the facade data elements
    outputs.addToIndex(UNKNOWN_INDEX, new NoOutput());
    outputs.addToIndex(RIGHT_DRIVE_SPEED_INDEX, new WsDriveSpeed("Right Drive Speed", 3, 4));
    outputs.addToIndex(LEFT_DRIVE_SPEED_INDEX, new WsDriveSpeed("Left Drive Speed", 1, 2));
    outputs.addToIndex(SHIFTER_INDEX, new WsDoubleSolenoid("Shifter", 1, 1, 2));
    outputs.addToIndex(LIGHT_CANNON_RELAY_INDEX, new WsRelay(1, 5, Relay.Direction.kForward));
    outputs.addToIndex(WINGS_SOLENOID_INDEX, new WsDoubleSolenoid("Wings Solenoid1", 1, 3, 4));
    outputs.addToIndex(LANDING_GEAR_SOLENOID_INDEX, new WsDoubleSolenoid("Landing Gear Solenoid", 1, 7, 8));
    outputs.addToIndex(CATAPAULT_SOLENOID_INDEX, new WsSolenoid("Arm Catapult Solenoid", 1, 5));
    outputs.addToIndex(FRONT_ARM_VICTOR_INDEX, new WsVictor("Front Arm Victor", 5));       
    outputs.addToIndex(BACK_ARM_VICTOR_INDEX, new WsVictor("Back Arm Victor", 6));
    outputs.addToIndex(FRONT_ARM_ROLLER_VICTOR_INDEX, new WsVictor("Front Arm Roller Victor",7));
    outputs.addToIndex(BACK_ARM_ROLLER_VICTOR_INDEX, new WsVictor("Back Arm Roller Victor", 8));
    outputs.addToIndex(LATCH_SOLENOID_INDEX, new WsSolenoid("Latch Solenoid", 1, 6));
    outputs.addToIndex(LEFT_EAR_SERVO_INDEX, new WsServo("Left Ear Servo", 9));
    outputs.addToIndex(RIGHT_EAR_SERVO_INDEX, new WsServo("Right Ear Servo", 10));
    outputs.addToIndex(CAMERA_LED_SPIKE_INDEX, new WsRelay(1, 2, Relay.Direction.kForward));
}
 
開發者ID:wildstang111,項目名稱:2014_software,代碼行數:27,代碼來源:OutputManager.java

示例7: collectorToggle

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public static void collectorToggle() {
    
    boolean buttonPressed = Driverstation.operator.getRawButton(5);
    if (buttonPressed && !collectorStatus) {
        shootMotorStatus = !shootMotorStatus;
        
    }
    if(shootMotorStatus) {
        Collect.set(Relay.Value.kReverse);
        collectorDashboard = true;
    }
    else {
        Collect.set(Relay.Value.kOff);
        collectorDashboard = false;
    }
    collectorStatus = buttonPressed;
      
}
 
開發者ID:first-team-58,項目名稱:2014-Krugelfang,代碼行數:19,代碼來源:Motors.java

示例8: setReverse

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
/**
 * Set the state of the reverse channel.
 * The center pin (B) on the Relay connector is "reverse".
 * This method will not affect the state of the forward channel.
 * 
 * @param val true if on, false if off
 */
public void setReverse(boolean revVal) {
	Relay.Value currentValue = this.get(),
		    newValue = currentValue;

if(currentValue == Relay.Value.kForward) {
	if(revVal)
		newValue = Relay.Value.kOn;
} else if(currentValue == Relay.Value.kOff) {
	if(revVal)
		newValue = Relay.Value.kReverse;
} else if(currentValue == Relay.Value.kOn) {
	if(!revVal)
		newValue = Relay.Value.kForward;
} else if(currentValue == Relay.Value.kReverse) {
	if(!revVal)
		newValue = Relay.Value.kOff;
}

this.set(newValue);
}
 
開發者ID:Team2168,項目名稱:2014_Main_Robot,代碼行數:28,代碼來源:BitRelay.java

示例9: Collector

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public static void Collector() {
    //Collector bring in ball
    if (Driverstation.operator.getRawButton(5)) {
        Collect.set(Relay.Value.kForward);

    } //Collector release ball
    else if (Driverstation.operator.getRawButton(3)) {
        Collect.set(Relay.Value.kReverse);

    } //Off
    else {
        Collect.set(Relay.Value.kOff);
    }
    //Switch to brake mode
    SetBrakes(!Driverstation.operator.getRawButton(2));
}
 
開發者ID:first-team-58,項目名稱:2014-Krugelfang,代碼行數:17,代碼來源:Motors.java

示例10: Launcher

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
/**
 * Constructs a new Launcher, with two Talons for winding, a release relay,
 * and a limit switch for winding regulation based on input from a
 * MaxbotixUltrasonic rangefinder.
 */
public Launcher() {
    super("Launcher");

    winderL = new Talon(RobotMap.WIND_LEFT_PORT);
    winderR = new Talon(RobotMap.WIND_RIGHT_PORT);

    releaseMotor = new Relay(RobotMap.RELAY_PORT);
    
    camera = new AxisCameraM1101();
    rangefinder = new MaxbotixUltrasonic(RobotMap.ULTRASONIC_RANGEFINDER);

    limitSwitch = new DigitalInput(RobotMap.LIMIT_SWITCH);
    counter = new Counter(limitSwitch);

    counterInit(counter);
}
 
開發者ID:bethpage-robotics,項目名稱:Aerial-Assist,代碼行數:22,代碼來源:Launcher.java

示例11: setForward

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
/**
 * Set the state of the forward channel.
 * The innermost pin (A) on the Relay connector is "forward".
 * This method will not affect the state of the reverse channel.
 * 
 * @param val true if on, false if off
 */
public void setForward(boolean fwdVal) {
	Relay.Value currentValue = this.get(),
			    newValue = currentValue;
	
	if(currentValue == Relay.Value.kForward) {
		if(!fwdVal)
			newValue = Relay.Value.kOff;
	} else if(currentValue == Relay.Value.kOff) {
		if(fwdVal)
			newValue = Relay.Value.kForward;
	} else if(currentValue == Relay.Value.kOn) {
		if(!fwdVal)
			newValue = Relay.Value.kReverse;
	} else if(currentValue == Relay.Value.kReverse) {
		if(fwdVal)
			newValue = Relay.Value.kOn;
	}
	
	this.set(newValue);
}
 
開發者ID:Team2168,項目名稱:2014_Main_Robot,代碼行數:28,代碼來源:BitRelay.java

示例12: SetBumpersColor

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public void SetBumpersColor(){
    
    double ColorValue = 0;
    try {
        ColorValue = DriverStation.getInstance().getEnhancedIO().getAnalogIn(6);
    } catch (DriverStationEnhancedIO.EnhancedIOException ex) {
        ex.printStackTrace();
    }
    
    if(ColorValue > 1.5){
        
        ColorLedsRelay.set(Relay.Value.kForward);
    }
    else{
        ColorLedsRelay.set(Relay.Value.kReverse);
    }
    
}
 
開發者ID:Hyperion3360,項目名稱:HyperionRobot2014,代碼行數:19,代碼來源:LedsSetter.java

示例13: test

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
@Test
public void test() {

	// pretext
	Assert.assertEquals(doubleSolenoide.isDefaultState(), true);

	// test toggle
	doubleSolenoide.toggle();
	Assert.assertEquals(relay1, Relay.Value.kForward);
	Assert.assertEquals(relay2, Relay.Value.kOff);

	doubleSolenoide.toggle();
	Assert.assertEquals(relay1, Relay.Value.kOff);
	Assert.assertEquals(relay2, Relay.Value.kForward);

}
 
開發者ID:Impact2585,項目名稱:aerbot-junit,代碼行數:17,代碼來源:DoubleSolenoidTest.java

示例14: init

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public static void init() {
      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
  	compressor = new Compressor();
  	
      driveTrainLeftFront = new CANTalon(1);
      LiveWindow.addActuator("DriveTrain", "LeftFront", driveTrainLeftFront);
      driveTrainRightFront = new CANTalon(3);
      LiveWindow.addActuator("DriveTrain", "RightFront", driveTrainRightFront);
      driveTrainLeftRear = new CANTalon(2);
      driveTrainLeftRear.changeControlMode(TalonControlMode.Follower);
      driveTrainLeftRear.set(driveTrainLeftFront.getDeviceID());
      LiveWindow.addActuator("DriveTrain", "LeftRear", driveTrainLeftRear);
      driveTrainRightRear = new CANTalon(4);
      driveTrainRightRear.changeControlMode(TalonControlMode.Follower);
      driveTrainRightRear.set(driveTrainRightFront.getDeviceID());
      driveTrainRightRear.reverseOutput(false);
      LiveWindow.addActuator("DriveTrain", "RightRear", driveTrainRightRear);
      
      driveTrainLeftFront.setInverted(true);
      driveTrainRightFront.setInverted(true);
      driveTrainLeftRear.setInverted(true);
      driveTrainRightRear.setInverted(true);
      
      driveTrainRobotDrive41 = new RobotDrive(driveTrainRightFront, driveTrainLeftFront);
driveTrainRobotDrive41.setSafetyEnabled(true);
driveTrainRobotDrive41.setExpiration(0.1);
driveTrainRobotDrive41.setSensitivity(0.5);
driveTrainRobotDrive41.setMaxOutput(1.0);
      
      climbMotor = new CANTalon(5);
      LiveWindow.addActuator("Climbing", "Motor", climbMotor);
      
      lightsLightEnable = new Relay(0);
      LiveWindow.addActuator("Lights", "LightEnable", lightsLightEnable);
      
      gearIntakeRamp = new DoubleSolenoid(1, 0);
      LiveWindow.addActuator("GearIntake", "IntakeRamp", gearIntakeRamp);

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
  }
 
開發者ID:FRC2832,項目名稱:Robot_2017,代碼行數:41,代碼來源:RobotMap.java

示例15: init

import edu.wpi.first.wpilibj.Relay; //導入依賴的package包/類
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    motorRelayMotorRelay1 = new Relay(0);
    LiveWindow.addActuator("MotorRelay", "MotorRelay1", motorRelayMotorRelay1);

    lFront = new CANTalon(1);
    LiveWindow.addActuator("Wheels", "Speed Controller 1", (CANTalon) lFront);
    
    rFront = new CANTalon(3);
    LiveWindow.addActuator("Wheels", "Speed Controller 2", (CANTalon) rFront);
    
    lRear = new CANTalon(2);
    LiveWindow.addActuator("Wheels", "Speed Controller 3", (CANTalon) lRear);
    
    rRear = new CANTalon(4);
    LiveWindow.addActuator("Wheels", "Speed Controller 4", (CANTalon) rRear);
    
    driveSystem = new RobotDrive(lFront, lRear,
          rFront, rRear);
    
    driveSystem.setSafetyEnabled(true);
    driveSystem.setExpiration(0.1);
    driveSystem.setSensitivity(0.5);
    driveSystem.setMaxOutput(1.0);
    
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
 
開發者ID:FRC2832,項目名稱:Practice_Robot_Code,代碼行數:28,代碼來源:RobotMap.java


注:本文中的edu.wpi.first.wpilibj.Relay類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。