本文整理汇总了Java中edu.wpi.first.wpilibj.DoubleSolenoid类的典型用法代码示例。如果您正苦于以下问题:Java DoubleSolenoid类的具体用法?Java DoubleSolenoid怎么用?Java DoubleSolenoid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DoubleSolenoid类属于edu.wpi.first.wpilibj包,在下文中一共展示了DoubleSolenoid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shift
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
/**
* Shifts the gearboxes up or down.
*
* @param shiftType whether to shift up or down
*/
public void shift(ShiftType shiftType) {
logger.info(String.format("Shifting, type=%s, shifter state=%s", shiftType.toString(),
shiftingSolenoid.get().toString()));
if (pcmPresent) {
if (shiftType == ShiftType.TOGGLE) {
if (shiftingSolenoid.get() == DoubleSolenoid.Value.kReverse) {
shiftingSolenoid.set(DoubleSolenoid.Value.kForward);
SmartDashboard.putBoolean("Drive_Shift", true);
} else {
shiftingSolenoid.set(DoubleSolenoid.Value.kReverse);
SmartDashboard.putBoolean("Drive_Shift", false);
}
} else if (shiftType == ShiftType.UP) {
shiftingSolenoid.set(DoubleSolenoid.Value.kForward);
SmartDashboard.putBoolean("Drive_Shift", true);
} else {
shiftingSolenoid.set(DoubleSolenoid.Value.kReverse);
SmartDashboard.putBoolean("Drive_Shift", false);
}
}
}
示例2: Robot
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
public Robot() {
stick = new Joystick(0);
driveLeftFront = new Victor(LEFT_FRONT_DRIVE);
driveLeftRear = new Victor(LEFT_REAR_DRIVE);
driveRightFront = new Victor(RIGHT_FRONT_DRIVE);
driveRightRear = new Victor(RIGHT_REAR_DRIVE);
enhancedDriveLeft = new Victor(ENHANCED_LEFT_DRIVE);
enhancedDriveRight = new Victor(ENHANCED_RIGHT_DRIVE);
gearBox = new DoubleSolenoid(GEAR_BOX_PART1, GEAR_BOX_PART2);
climber1 = new Victor(CLIMBER_PART1);
climber2 = new Victor(CLIMBER_PART2);
vexSensorBackLeft = new Ultrasonic(0, 1);
vexSensorBackRight = new Ultrasonic(2, 3);
vexSensorFrontLeft = new Ultrasonic(4, 5);
vexSensorFrontRight = new Ultrasonic(6, 7);
Skylar = new RobotDrive(driveLeftFront, driveLeftRear, driveRightFront, driveRightRear);
OptimusPrime = new RobotDrive(enhancedDriveLeft, enhancedDriveRight);
}
示例3: HardwareAdaptor
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
private HardwareAdaptor(){
pdp = new PowerDistributionPanel();
comp = new Compressor();
shifter = new DoubleSolenoid(SolenoidMap.SHIFTER_FORWARD, SolenoidMap.SHIFTER_REVERSE);
navx = new AHRS(CoprocessorMap.NAVX_PORT);
dtLeftEncoder = new Encoder(EncoderMap.DT_LEFT_A, EncoderMap.DT_LEFT_B, EncoderMap.DT_LEFT_INVERTED);
S_DTLeft.linkEncoder(dtLeftEncoder);
dtRightEncoder = new Encoder(EncoderMap.DT_RIGHT_A, EncoderMap.DT_RIGHT_B, EncoderMap.DT_RIGHT_INVERTED);
S_DTRight.linkEncoder(dtRightEncoder);
dtLeft = S_DTLeft.getInstance();
dtRight = S_DTRight.getInstance();
S_DTWhole.linkDTSides(dtLeft, dtRight);
dtWhole = S_DTWhole.getInstance();
arduino = S_Arduino.getInstance();
}
示例4: update
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
@Override
public void update(Commands commands, RobotState robotState) {
switch (commands.wantedSpatulaState) {
case UP:
mOutput = DoubleSolenoid.Value.kReverse;
mState = SpatulaState.UP;
break;
case DOWN:
mOutput = DoubleSolenoid.Value.kForward;
mState = SpatulaState.DOWN;
break;
}
mDv.updateValue(mOutput.toString() == "kReverse" ? "UP" : "DOWN");
DashboardManager.getInstance().publishKVPair(mDv);
}
示例5: testOutput
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
@Test
public void testOutput() {
Commands commands = Robot.getCommands();
Flippers flippers = Flippers.getInstance();
Flippers.FlipperSignal desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kForward, DoubleSolenoid.Value.kForward);
commands.wantedFlipperSignal = desired;
flippers.update(commands, Robot.getRobotState());
assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired));
desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kForward, DoubleSolenoid.Value.kReverse);
commands.wantedFlipperSignal = desired;
flippers.update(commands, Robot.getRobotState());
assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired));
desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kReverse, DoubleSolenoid.Value.kForward);
commands.wantedFlipperSignal = desired;
flippers.update(commands, Robot.getRobotState());
assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired));
desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kReverse, DoubleSolenoid.Value.kReverse);
commands.wantedFlipperSignal = desired;
flippers.update(commands, Robot.getRobotState());
assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired));
}
示例6: ShiftComponent
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
/**
* Default constructor.
*
* @param otherShiftables All objects that should be shifted when this component's piston is.
* @param piston The piston that shifts.
* @param startingGear The gear to start in. Can be null, and if it is, the starting gear is gotten from the
* piston's position.
*/
@JsonCreator
public ShiftComponent(@NotNull @JsonProperty(required = true) List<Shiftable> otherShiftables,
@NotNull @JsonProperty(required = true) MappedDoubleSolenoid piston,
@Nullable Shiftable.gear startingGear) {
this.otherShiftables = otherShiftables;
this.piston = piston;
if (startingGear != null) {
this.currentGear = startingGear.getNumVal();
} else {
//Get the starting gear from the piston's position if it's not provided
this.currentGear = piston.get() == DoubleSolenoid.Value.kForward ? Shiftable.gear.LOW.getNumVal() : Shiftable.gear.HIGH.getNumVal();
}
//Set all the shiftables to the starting gear.
for (Shiftable shiftable : otherShiftables) {
shiftable.setGear(currentGear);
}
}
示例7: changeIntakePosition
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
public static void changeIntakePosition(){
if(CMap.auxJoystick.getTrigger()){
if(!intakeBeenPressed){
if(intakePosition == "up"){
intakePosition = "down";
System.out.println("Intake Position set to " + intakePosition + " at " + CMap.teleopTimer.get() + " seconds.");
} else if(intakePosition == "down"){
intakePosition = "up";
}
}
intakeBeenPressed = true;
} else {
intakeBeenPressed = false;
}
if(intakePosition == "up"){
CMap.intakeSolenoid.set(DoubleSolenoid.Value.kReverse);
} else if(intakePosition == "down"){
CMap.intakeSolenoid.set(DoubleSolenoid.Value.kForward);
}
}
示例8: ShooterControl
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的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;
}
示例9: HandleStateRelease
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
private void HandleStateRelease()
{
if (!m_gearReleased)
{
// set the gear in neutral
m_gearControl.set(DoubleSolenoid.Value.kForward);
m_gearReleased = true;
}
if(!m_latchReleased)
{
//release the latch
m_latchReleaseServo.set(1);
Timer.delay(0.5);
m_latchReleased = true;
}
m_isPulledBack = false;
m_currentState = SHOOTER_CONTROL_STATE_WAIT;
}
示例10: Winch
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
public Winch() {
winchMotor = new CANTalon(RobotMap.WINCH_MOTOR);
winchBrake = new DoubleSolenoid(RobotMap.WINCH_STOPPER_CHANNEL_A, RobotMap.WINCH_STOPPER_CHANNEL_B);
this.winchMotor.enableBrakeMode(false);
this.winchMotor.changeControlMode(TalonControlMode.Voltage);
this.putBrakeOff();
}
示例11: toggleManipulator
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
public void toggleManipulator() {
Value solenoidVal = manipulatorSolenoid.get();
if (solenoidVal == Value.kForward) {
manipulatorSolenoid.set(DoubleSolenoid.Value.kReverse);
} else {
manipulatorSolenoid.set(DoubleSolenoid.Value.kForward);
manipulatorMotor.set(0.5);
}
}
示例12: setLock
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
/**
*
* @param value sets the solenoid state
*/
public void setLock(boolean value){
if(value){
sol.set(DoubleSolenoid.Value.kForward);
}else{
sol.set(DoubleSolenoid.Value.kReverse);
}
SmartDashboard.putBoolean("Winch Cylinder", value);
}
示例13: CANObject
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
/**
* Creates CAN Pnuematics Control Module object
*
* @param newdoubleSolenoid
* the CAN Pnuematics Control Module associated with this object
* @param newCanId
* the ID of the CAN object
*/
public CANObject (final DoubleSolenoid newdoubleSolenoid, int newCanId)
{
doubleSolenoid = newdoubleSolenoid;
canId = newCanId;
typeId = 3;
// if(useDebug == true)
// {
// System.out.println("The Double Solenoid is " + doubleSolenoid);
// System.out.println("The canId of the DoubleSolenoid is " + canId);
// System.out.println("The type Id of the DoubleSolenoid is " + typeId);
// }
}
示例14: getdoubleSolenoid
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的package包/类
/**
* Checks if the CAN Device is a Pnuematic Control Module
*
* @return Returns Pnuematic Control Module if type ID is 3, if not returns null
*/
public DoubleSolenoid getdoubleSolenoid ()
{
if (typeId == 3)
{
return doubleSolenoid;
}
return null;
}
示例15: init
import edu.wpi.first.wpilibj.DoubleSolenoid; //导入依赖的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
}