View Single Post
  #2   Spotlight this post!  
Unread 12-02-2014, 11:12
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: Rookie Java FRC programming buttons

Quote:
Originally Posted by DomenicR View Post
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)
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)

Last edited by seg9585 : 12-02-2014 at 11:16.
Reply With Quote