![]() |
commands activated by trigger, how?
I have recently begun learning Java as my team is in need of a programmer next year and have hit a road block. I am trying to make the trigger on the standard joystick run a specific command when pressed. The tutorials I have been following so far are these. My initial thoughts were it would be very similar to making a button run a specific command however I can't seem to get it to work. I have searched the web high and low but can't find anything useful.
|
Re: commands activated by trigger, how?
Quote:
|
Re: commands activated by trigger, how?
Is is a boolean trigger or a variable one? If it's variable, like the triggers on an xBox controller, it's called as a separate joystick axis. Which joystick are you using?
|
Re: commands activated by trigger, how?
Some of the code that I have tried thus far is:
Code:
//code trial 1As for the Joystick, I am trying to get the trigger off of an attack 3 Logitech joystick(so it's a Boolean trigger). |
Re: commands activated by trigger, how?
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 [edit] F310 [/edit](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. |
Re: commands activated by trigger, how?
Quote:
To use the trigger treat it exactly like a button. |
Re: commands activated by trigger, how?
Quote:
Well what I posted earlier is applicable to using using axes as buttons if anyone needs that lol. |
Re: commands activated by trigger, how?
Quote:
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. |
Re: commands activated by trigger, how?
Quote:
|
Re: commands activated by trigger, how?
Quote:
|
Re: commands activated by trigger, how?
There is online documentation for CommandBased programming, in particular this link shows how to attach commands to a joystick.
Code:
Joystick DriveStick = new Joystick(1);In addition to the online documentation, you might find these videos helpful if you're having trouble understanding CommandBasedProgram.: CommandBased Programming with RobotBuilder: http://www.youtube.com/watch?v=k7PaY...lgn vhGObeKzp CommandBased Programming without RobotBuilder: http://www.youtube.com/watch?v=v0vt9yKLxUQ |
| All times are GMT -5. The time now is 22:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi