View Single Post
  #11   Spotlight this post!  
Unread 09-06-2013, 11:26
cad321 cad321 is offline
Jack of all trades, Master of none
AKA: Brian Wagg
FRC #2386 (Trojans)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Burlington, Ontario
Posts: 325
cad321 is just really nicecad321 is just really nicecad321 is just really nicecad321 is just really nice
Re: commands activated by trigger, how?

Quote:
Originally Posted by otherguy View Post
I don't think the getTrigger() method does what you are hoping it does.
If you take a look at the javadoc for the Joystick class, then look at the getTrigger() method, you'll see that it doesn't return a boolean value.

The triggers on the logitech (and xbox if I remember correctly) are on axis 3. Axes in the Joystick class return doubles, in this case, a numerical value from 1.0 to -1.0. So when one trigger is pulled all the way, axis 3 reads 1.0. When the other is pulled all the way, axis 3 reads -1.0. When they are both pulled simultaneously, the values are essentially added. So if you were to pull them both down all the way you would read 0.0 on axis three. This is important to understand. It is the reason why you wouldn't put two commands that needed to be used at the same time onto the same axis. Both triggers pressed looks the same as neither trigger pressed.

To get back to your question though... if you want to kick off commands from an analog axis on a joystick, then you need to turn that axis into a button. You need to turn a value of 1.0 to -1.0 (double) into true or false (boolean).

I developed a class for my team last year which does just this. I've tried to clean up the code and document how it should be used. It is available here. There is an example of its use in the comment at the top of the code.

Please let me know if you have any questions.
Thank you for the help, this is will be very useful for later on(as I think my team will be switching to Gamepads in the near future) however I think there has been a misunderstanding as to what I would like to control the robot with. I am trying to use the standard Attack 3 Joystick, not a gamepad like this one.

From what I can tell the attack 3 should be returning a Boolean as there is only one per joystick and there is only 2 states(pressed and not pressed). Please correct me if I am wrong as I know very little so far and could easily be mistaken.
Reply With Quote