POV button programming

Hello there. Our team want to program a lot of servos. There are a lot of them so we haven’t enought buttons. And we can’t get POV buttons ID. Pls help us.

POVButton UpPov = new POVButton(driverController, ???);

The POV buttons are referred to by the angle. Up is 0, right is 90, down is 180, and left is 270.

@railroad890 Is correct. (Beat me to it.)
Here is an example that we used in our code this last season. It creates all 8 directions at once.

Edit: The above assumes your controller dpad maps the same as ours, always remember to test and adjust accordingly.
To clarify, the code we used came from 1747’s public 2017 library. The original can be found here.

Unofficial, How did using the non-Cardinal directions work for you? My experience with these indicates that it asks for a bit too much finger precision from a driver. I would only consider using the cardinal directions that Railroad mentions.

All I would recommend would be using two of them. Just 0 and 180 for to control something that moves up and down or 90 and 270 to control something that moves right and left.

Steve

That code was from a controller class that we are planning to written once, and not touch except for teaching purposes. While there are non-cardinal mapped, we probably wouldn’t ever use them. We ended up using 3, UP, DOWN, and RIGHT. The operator of our robot uses them to switch between the different states of our arm (UP, DOWN, and Manual respectively).

I would be hesitant to give a driver any function that requires them to no longer be in contact their main driving Joysticks. Dpads work well for an operators because they don’t have that constraint.

Thanks for the info. I agree, with the the driver vs operator distinction.

Steve

Be wary that a bug still exists where if the controller is not plugged in the POV button will always return 0, or UP, so always make sure to check if the controllers are plugged in to prevent unwanted and sudden robot movements when enabling.

This has been fixed for 2020: https://github.com/wpilibsuite/allwpilib/pull/1852

2 Likes

We created a class that creates a button out of the pov buttons (Link) we used this in our OI class just like you would use the button class.

Last year, the POVButton class was added to wpilib, which does the same thing. That’s what the earlier discussion in this thread is about.