Help with programming new controllers, please.

Hello,
I need help programming in new controllers for our robot. I don’t know much about programming so I’m pretty confused on where to even start. The new controllers both have the right serial ports and that stuff. But they have a lot more buttons so I am not sure of how this will work. Not to mention one of them can twist so it adds a type of z-axis to it almost. But if someone can help me it would be greatly appreciated. I looked around and I didn’t find anything that, I thought, helped me. But I was hoping to have some kind of answer to this by tomorrow, or Saturday, just so the higher ups don’t cause pain.

Sincerely yours
Me

Maximum number of controls allowed for standard gameport: 4 axes and 4 buttons. Any more than that will require specific drivers for the device, and will likely not work with the FRC RC/OI.

By controllers i’m presuming you are referring to joysticks, if not, then completely disregard this.

The controlers give input to the OI, which sends whatever data you want it to sends it’s data to the RC, which uses whatever data you want to use.

In the default code, under the IFI_Aliases file, IFI makes you some nice aliases for the various buttons. The obvious ones r the x and y axies, p1_x and p1_y. The number can vary based on where on the OI the controller is plugged into (port 1, 2, 3, or 4). This returns a value between 0 and 255.

The z axis, i’m guessing, is the aux wheel. On the old controllers, it was that wheel on the left side of the joystick (not the calibration one). It returns a value between 0 and 255.

Then, there are the buttons. There is a top button, and a trigger button (for all IRI is concerned, that’s what they call them). There are also 2 aux buttons, which can be located anywhere (effectively). Hooking up the OI to a computer makes it easy to determine which button on the controller is which data bit. When the buttons are pressed, they return a 1, when they are not pressed, they return a 0.

And, here’s a programing tip: Make your own Aliases file, call it “team#_aliases.h” and include it into your user routines file. In the aliases file, define your own aliases. For example, if the p1_y is the left drive, put this into the code:

#define STICK_LEFT_DRIVE       p1_y

Use of aliases will make life easier when trying to remember which stick does what.

If there’s anything else you don’t understand, PM me and i’ll clarify asap.

Just put the robot up on blocks and put print statements in the code for each of the joystick variables (p1_y p1_x …etc) and record what changes as you move the joystick.

If you have a dashboard program then you don’t even need to put print statements in the code, you can just run the code with the dash board hooked up to it.

If you need more help than this let me know

James

Thanks for the help guys. It seems I won’t be able to use the one joystick because it has about 6 buttons and I a few different axis. But the other is pretty simple so I’ll try that first. But As for the drivers thing for joysticks, how would that work if I wanted to try?
Well thanks for all the help, I’m off to try it now.

Adding a new driver to the RC/OI would be difficult. Somewhere in one of the default files it uses one of the data bytes from the OI which is sent in via. one of the serial ports. If you are tricky enough, it might be possible to add additional code in there (maybe?). Ive never tried, and it’s unlikely I ever will.

It would be complicated at best, and impossible at worst.

If you really wanted to use everything on that joystick, you could make some sort of ‘reverse y’ to connect that joystick to two of the inputs on the OI. As Adam said, there’s a maximum of 4 analog and 4 digital inputs on each port, times 4 ports, 16 analogs and 16 digitals max. Each axis of movement on the joystick is read by a potentiometer, which gives an analog value. Each button gives a digital value, 0 or 1. However, I believe the 4-way thumb-stick on the KOP joysticks gives an analog value, with a specific number for each position. I’m not 100% sure on this, though.

Last season, we made a 4 way y-splitter to connect all four CH sticks to one port, since we only wanted/needed the y-axis and one button on each joystick, that left three other ports open for anything else we wanted to put on. You would be going the other way around, connecting one stick to two ports.

Just an idea.

Good luck!
-Chris