Hey there, try adding or modifying your subsystem to this
Code:
public class Pnuematics extends Subsystem {
public boolean toggle;
public void solenoidIn() {
ds1.set(DoubleSolenoid.Value.kReverse);
toggle = true;
}
public void solenoidOut(){
ds1.set(DoubleSolenoid.Value.kForward);
toggle = false;
}
}
these are two methods which when called will set the solenoid in a direction then flip the state of the boolean
then your Command to this
Code:
public class toggleSolenoid extends Command {
public toggleSolenoid() {
requires(Robot.pnue);
}
protected void initialize() {
if (Robot.pnue.toggle == true)
{
Robot.pnue.solenoidOut();
}
else if(Robot.pnue.toggle == false){
Robot.pnue.solenoidIn();
}
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return true;
}
// Called once after isFinished returns true
protected void end() {
}
protected void interrupted() {
end();
}
}
since solenoids retain their "state" when switched, they do not need to be told continuously what do do. they are set to forward or reverse one time in the "initialize" part of the command depending on the state of the boolean. Then the command finishes immediately.
the OI should be
Code:
toggleSolenoid.whenPressed(new toggleSolenoid());
Best of luck, hope this helps. Once mastered, command based is the way to go!
Also there may be other ways to acheive a "toggle" but this has worked for us in the past. I did see a "toggle option" in the OI this year but have yet to test it.
__________________

2010-2017 Mentor Team 319
2012 - Rockwell Automation Award Winner
2014 - Xerox Creativity in Engineering Winner, Archimedes Division
2015 - Rockwell Automation and Gracious Proffesionalism Winner, Tesla Division
2016 - North Shore and UNH District Event Winner, Carson Division
http://www.frc319.com