Thread: XBox controller
View Single Post
  #14   Spotlight this post!  
Unread 12-01-2013, 16:20
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: XBox controller

Quote:
Originally Posted by Kit Fieldhouse View Post
Hello
i was wondering if anyone had figured out how to implement tank drive with an Xbox controller? Our team has gotten one joystick to work (using basically the code that's already here), but not both. One of our members who formerly programmed in LabView said that one of the Joysticks is recognized as a joystick and the other is recognized as a button (somehow). Is there some way to do this? Thanks!
That's not correct, I don't think. The entire Xbox controller is a Joystick, and each individual stick is a pair of axes. Perhaps the labview libraries work differently from the text languages in that regard, I don't know, but the C++ and Java libraries should consider both thumbsticks as 4 axes on the Joystick (left x-axis, left y-axis, etc).

Ex.

Code:
public OI() {                
        leftTank = driverXbox.getRawAxis(2);
        rightTank = driverXbox.getRawAxis(5);
}
with

Code:
// Axis indexes:
    public static final int
            LEFT_X_AXIS = 1,
            LEFT_Y_AXIS = 2,
            TRIGGERS = 3,
            RIGHT_X_AXIS = 4,
            RIGHT_Y_AXIS = 5,
            DPAD_LR = 6;
    
    // Button mappings:
    public static final int
            BUTTON_A = 1,
            BUTTON_B = 2,
            BUTTON_X = 3,
            BUTTON_Y = 4,
            BUMPER_L = 5,
            BUMPER_R = 6,
            BUTTON_BACK = 7,
            BUTTON_START = 8,
            LEFT_STICK_PRESS = 9,
            RIGHT_STICK_PRESS = 10;
As far as using an Xbox controller for tank drive, I don't recommend it. The fact that the thumbsticks are at different elevations vertically means it's going to be harder to operate it effectively. The Xbox controller also has a 20% deadzone in the center of the thumbsticks where you cannot accurately determine the position of the stick. This means that if you do not account for this, it will drift even when you're not touching it, and if you do, you will not be able to make movements of less than 20% power.

I would recommend the Logitech F310 instead, as both thumbsticks are at the same elevation, and the sticks themselves are more accurate (much less deadzone).
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional

Last edited by F22Rapture : 12-01-2013 at 16:27.
Reply With Quote