Quote:
Originally Posted by DomenicR
When using joysticks, I generally use the Joystick#getRawButton() method as opposed to the specialized methods.
|
According to the code above they are using the Joystick class, not Trigger (there is a "jButton" initialized but its not used). They are properly using the Joystick class. I will note that I have had trouble with the trigger in the past as well, and resort to just using buttons.
As a form of troubleshooting, why don't you use a Button instead to test and see if the Trigger is causing the issue?
In other news, I don't think the code you have there will do exactly what you want. When the trigger is pushed you will enter that for{} loop, but every 0.2001 seconds you will be re-entering that loop until the finger is taken off the trigger.
I assume you want to just toggle the valves 3 times and that's it when the button is pushed? If so, you'll need to add a little logic that checks whether the button has just been pressed. For example:
boolean triggered=false;
if(driveStick.getTrigger() && !triggered){
triggered=true;
for{} loop;}
else if(!driveStick.getTrigger()){
triggered=false;}
In other news, avoid using local for and while loops in SimpleRobot. While that loop is running, you will not get any Drive updates. For just 0.2 seconds maybe you can get away with it, but not good practice in general. Instead, you can either create a separate thread (See Thread class), or what I like to do is create a function that will track its own timing when called repeatedly and return a true or false boolean to indicate when it's done (use the Timer class)