View Single Post
  #4   Spotlight this post!  
Unread 18-03-2012, 13:48
BigJ BigJ is offline
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 944
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: driving with an xbox360 controller

1675 started using Xbox controller this year. I just put an inital commit of our code on Github last night (WARNING: SUPER GROSS, NEEDS CLEANING AND REORGANIZING). Here's a link to our wrapper class for the controller. We use Java but it is essentially the same for C++.

https://github.com/pordonj/frc1675-2...ontroller.java

Caveats:
  • The trigger buttons are their own axis. It stays at 0.0, one trigger makes it go up, one makes it go down. So you can't really tell whether a number is a mix of the 2 triggers or not. We don't use them on the robot right now but this code treats a push of the trigger as a boolean button based on whether the axis went up or down. If you use this the triggers will have to be pushed mutually exclusively for intended functionality. (If both are pushed the same amount, neither will evaluate to true).
  • The D-pad has left and right as an axis, and we couldn't seem to access the up/down D-pad buttons. Our code uses them like buttons because pressing the D-pad buttons makes the axis go to 1.0 / -1.0
  • We found it more intuitive to make up on the Y axis be positive, so all Y axes are flipped in this class.
  • We have an implicit 10% deadzone on all analog stick axes.
  • The "bumpers" are the shoulder buttons.
  • We didn't program in the Start/Back/Center(XBox Logo) buttons, I just realized.

Last edited by BigJ : 18-03-2012 at 14:05. Reason: cleaned up code a bit and realzied additional caveat
Reply With Quote