Searching didn’t help much, mainly because I didn’t know how to phrase the query…
But what I want to know is, how could I program a specific button input on the controller? i.e., programming the trigger to activate a motor when pressed…
I know I’m being a little vague but I don’t really know how to phrase this question :\
In WindRiver, you can use joystickname.GetTrigger() and joystickname.GetTop() for the trigger and the top. You can then use joystickname.GetRawButton(button number).
Replace joystickname with the name of your joystick variable. Replace button number with the number of the button (each button is labelled by number on the kit joysticks).
GetTrigger, GetTop, and GetRawButton return true or false.
How about in LabView?
Thanks for the quick reply, btw
Now, you haven’t mentioned if you use LabView or C, but for LabView this is what you would do:
Use the “Joystick -> Get” VI. It’s under WPI libraries -> RobotDrive-> Joysticks -> Get
You first need to open a “channel” to that joystick. Then pass in the JoystickDevRef from the OPEN to GET
There are two outputs, one for axis and one for buttons. You need a “Unbundle” vi. It’s in Programming->Clusters->Unbundle (you have two choices, by name or just by blocks)
Then you can select which button to read and it will give you a true or a false.
edit: wow you guys respond fast (while I was typing he mentioned that he used labview)
I have only worked for a bit in LabView, but I believe you could just use the blocks that are available in the WPILib. It has all the same functions available, but everything is a block, not actual code. You should be able to “wire” everything in LabView so that if one of the functions returns “true,” it turns on the motor. If “false,” it turns it off.
Sorry I cannot give more specific instructions than this. Perhaps someone who has worked more with LabView would be able to help.
Edit: keehun just posted the appropriate instructions above.
Also, it is possible to make a subVI that lets you select a single button output. Here’s a copy of a subVI that I threw together (Sorry, haven’t really tested it that much, let me know how it works!). You have to use an unsigned 16-bit int for the “index” pin, can’t seem to figure out why (It says “wire enumeration conflict”). I guess speed of recursions doesn’t really matter, but it’s theoretically slightly faster than using the Joystick Get VI.
Joystick Get Button.vi (18 KB)
Joystick Get Button.vi (18 KB)
Keehun, I tried what you said and I’ve gotten this far:
After this, I’m confused… how do I specify button from axis…?
(btw, rookie team/freshman)
EDIT: I cleaned up the wire so I’m not opening two channels for the same USB and the joystick get just comes off of the same wire now, I was just too lazy to retake the SS, so I don’t need comments on how that’s messed up
I think I have to solution to what you are trying to do posted in another thread. Check it out HERE.
I hope it’s what you’re looking for.
Thanks! Your post with diagrams really helped!
If I have any other questions about it, (which I probably will :P) I’ll ask.