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