![]() |
Pnuematics Toggle Code Issue
Okay so when I press the button associated with the toggleSolenoid command the cylinder occasionally actually toggles back and forth at the touch of the button - but more often than not it just spazzes back and forth repeatedly.
What is wrong?? Pnuematics Subsystem: Code:
package org.usfirst.frc.team4623.robot.subsystems;Code:
package org.usfirst.frc.team4623.robot.commands;Code:
toggleSolenoid.whileActive(new toggleSolenoid()); |
Re: Pnuematics Toggle Code Issue
My team has just switched over to Java from C++ this year, so I'm a little unsure of myself, but I think I know what your issue is. Using whileActive to toggle your solenoid will result in the toggleSolenoid() function running repeatedly as long as the button is held (assuming I'm understanding this right). If there's a function you can use that will only run once when the button is pressed instead of whileActive, that would be best. Otherwise, you can look into using a timer to run the function at most once every half second or so, which would keep it from freaking out.
|
Re: Pnuematics Toggle Code Issue
Hey there, try adding or modifying your subsystem to this
Code:
public class Pnuematics extends Subsystem {then your Command to this Code:
public class toggleSolenoid extends Command {the OI should be Code:
toggleSolenoid.whenPressed(new toggleSolenoid());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. |
Re: Pnuematics Toggle Code Issue
Okay using your code I got it to work - thanks so much!:)
|
| All times are GMT -5. The time now is 08:26 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi