|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: XBox controller
Quote:
Oh, you will still need to do all the code you had before, I just wrote up the portion that you need to add/replace. |
|
#2
|
||||
|
||||
|
Re: XBox controller
I haven't been back to this thread in a while, so I haven't had a chance to say THANK YOU ALL SO MUCH! I really appreciate it! I just had a few more questions...
THe code provided by Toa works, but I had a few questions about how exactly it works. It only references Code:
leftStick->GetRawAxis(1), leftStick->GetRawAxis(2) Code:
rightStick = new Joystick(2); |
|
#3
|
||||||
|
||||||
|
Re: XBox controller
Quote:
There are several different methods provided by RobotDrive, including ArcadeDrive and Drive. They are described in the "WPI Robotics Library User’s Guide". You should pick the one that does what you want, or experiment and try them all. |
|
#4
|
||||
|
||||
|
Re: XBox controller
We had fresh controllers as well (ie just out of the box). The thing we were worried about is a situation where the analog stick just isn't 100%, and sometimes would actually rest on what would be .25. Also, we didn't want to run it full power anyway, thinking about it now, because it would jump at the slightest touch.
We can look at it again and re-evaluate the need, but it worked for us. |
|
#5
|
||||
|
||||
|
Re: XBox controller
Hey CD! I've had an epiphany! XBox is actually spelled xBox, just like Ipod is actually spelled iPod! I've taken into consideration all the information I received from this thread and the example code, and have constructed this:
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot
{
Joystick *xboxStickManip;
Joystick *leftStick;
Joystick *rightStick;
Jaguar *leftDrive;
Jaguar *rightDrive;
RobotDrive *myRobot;
public:
DefaultRobot(void)
{
xboxStickManip = new Joystick(1);
leftStick = new Joystick(2);
rightStick = new Joystick(3);
leftDrive = new Jaguar(1);
rightDrive = new Jaguar(2);
myRobot = new RobotDrive(leftDrive, rightDrive);
}
void Autonomous(void)
{
while(IsAutonomous())
{
}
}
void OperatorControl(void)
{
myRobot->TankDrive(0.0, 0.0);
while (IsOperatorControl())
{
float leftStickYAxis = leftStick->GetY();
float rightStickYAxis = rightStick->GetY();
myRobot->TankDrive(-leftStickYAxis, -rightStickYAxis);
}
}
};
START_ROBOT_CLASS(DefaultRobot);
|
|
#6
|
|||
|
|||
|
Re: XBox controller
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! |
|
#7
|
||||
|
||||
|
Re: XBox controller
Quote:
Ex. Code:
public OI() {
leftTank = driverXbox.getRawAxis(2);
rightTank = driverXbox.getRawAxis(5);
}
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;
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). Last edited by F22Rapture : 12-01-2013 at 16:27. |
|
#8
|
||||
|
||||
|
Re: XBox controller
No, the labview code works in the same way. One joystick, with 6 axis and 10-ish buttons. Maybe he was thinking in the was the triggers work? (They're an axis, with the left trigger -1 and the right trigger +1. Both triggers are 0).
|
|
#9
|
||||
|
||||
|
Re: XBox controller
Does anyone happen to know the button mapping for the Logitech Gamepad F310 and/or Logitech Attack3 joystick? Is the gamepad mapping the same as the xBox controller? We'll be using the Attack3 joysticks until we order some sort of gamepad, probably the Logitech F310 gamepad, based on F22Rapture's testimony. Thanks!
|
|
#10
|
||||
|
||||
|
Re: XBox controller
Windows has a tool that shows you the state of any joystick you have plugged in (ie, what axis are where, what buttons are pressed). You can find it under control panel > Devices. Look for "Set up Game controllers", then press advanced on whichever connected game controller you want to inspect.
|
|
#11
|
||||
|
||||
|
Re: XBox controller
Quote:
Code:
//Axis Indexes
public static final int
X_AXIS = 1,
Y_AXIS = 2,
THROTTLE = 3;
//Buttons
public static final int
//Buttons on joystick
TRIGGER = 1,
//POV buttons on head of stick
BUTTON_SOUTH = 2,
BUTTON_NORTH = 3,
BUTTON_WEST = 4,
BUTTON_EAST = 5,
//Pair of buttons left of stick
BUTTON_BASE_WNW = 6,
BUTTON_BASE_WSW = 7,
//Pair of buttons below stick
BUTTON_BASE_SSW = 8,
BUTTON_BASE_SSE = 9,
//Pair of buttons right of stick
BUTTON_BASE_ESE = 10,
BUTTON_BASE_ENE = 11;
|
|
#12
|
||||
|
||||
|
Re: XBox controller
The Attack3's buttons are numbered on the controller and they do correspond correctly in software.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|