Logitech Controller Programming

My team does not have any Attack3 controllers for some reason, due to them getting lost. We did find and alternative as the Logitech controller for the FTC competitions. The issues are that the whole controller takes only one Joystick slot and I wanted to know if the there is code to separate the two joysticks on the controller for Tank Drive. And as a side question: Can you use XBOX or PS3 controllers for any movement.

Thanks in advanced!

As for the logitech controllers: Yes, there is code to separate the joysticks. However, you simply treat the whole controller as a single Joystick object.

Example:

Joystick logitechController = new Joystick(1);

//Read the y axis on the left joystick
logitechController.getRawAxis(leftYAxis); //<-- Experiment to find the exact //axis value

//Read the y axis on the right joystick
logitechController.getRawAxis(rightYAxis); // <-- find the right axis number

You’ll have to experiment a bit to find the correct axis numbers to make it work properly, and possibly invert the outputs (sometimes down is positive), but each joystick is really just two independent axis’ on the same “joystick” controller.

I have a convenient class for you.

Created after some extensive testing:

Also, you should be able to use any USB controller. Last year we used an XBOX controller. We just had to install a driver from the xbox/microsoft website.

We are using the logitech F310.

left Y axis is Axis 2, right Y axis is Axis 5

Joystick joy1 = new Joystick(1); // create a joystick on USB port 1 (configured through driverstation)

joy1.getRawAxis(2); //this will return the left stick Y value
joy1.getRawAxis(5); //this will return the right stick Y value

You could also make all the axis and buttons contants, so it’s easier for everyone to know what axis/button you’re calling.

Just add this to either the same file, or an interface:


	// Gamepad axis
	public static final int kGamepadAxisLeftStickX = 1;
	public static final int kGamepadAxisLeftStickY = 2;
	public static final int kGamepadAxisShoulder = 3;
	public static final int kGamepadAxisRightStickX = 4;
	public static final int kGamepadAxisRightStickY = 5;
	public static final int kGamepadAxisDpad = 6;

	// Gamepad buttons
	public static final int kGamepadButtonA = 1; // Bottom Button
	public static final int kGamepadButtonB = 2; // Right Button
	public static final int kGamepadButtonX = 3; // Left Button
	public static final int kGamepadButtonY = 4; // Top Button
	public static final int kGamepadButtonShoulderL = 5;
	public static final int kGamepadButtonShoulderR = 6;
	public static final int kGamepadButtonBack = 7;
	public static final int kGamepadButtonStart = 8;
	public static final int kGamepadButtonLeftStick = 9;
	public static final int kGamepadButtonRightStick = 10;
	public static final int kGamepadButtonMode = -1;
	public static final int kGamepadButtonLogitech = -1;

Sorry, -1 is because we haven’t tested what buttons those two are yet.

So if those are in an interface and you implement it, this is how you can call it:


joy1.getRawAxis(kGamepadAxisLeftStickY);
joy1.getRawAxis(kGamepadAxisRightStickY);

Thank you very much for the replies! We may end up buying Joysticks, but in the meantime, this may help us test out bot.

Thank you very much for your detail and input!

We were able to get to the right joystick on the controller by using

GetZ() for the X axis of the right stick

and

GetTwist() for the Y axis of the right stick.

Hope this helps!

Team 2185 is also looking forward at using the F310 controllers. But we are using labview. Could u help me in the lanugage of labview:eek:

To use the controller in labview use the normal getJoystick and then unBundle both the axis and buttons.