Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Logitech Controller Programming (http://www.chiefdelphi.com/forums/showthread.php?t=101375)

NS_Radication 28-01-2012 13:55

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!

theprgramerdude 28-01-2012 14:21

Re: Logitech Controller Programming
 
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.

shuhao 28-01-2012 18:12

Re: Logitech Controller Programming
 
I have a convenient class for you.

Created after some extensive testing:

https://github.com/FRCTeam4069/Robot...ontroller.java

nickpeq 29-01-2012 23:06

Re: Logitech Controller Programming
 
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.

otherguy 01-02-2012 01:12

Re: Logitech Controller Programming
 
We are using the logitech F310.

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

Code:

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


neal 01-02-2012 07:35

Re: Logitech Controller Programming
 
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:

Code:

        // 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:
Code:

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


NS_Radication 03-02-2012 21:17

Re: Logitech Controller Programming
 
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!

Demonix_Fox 04-02-2012 03:23

Re: Logitech Controller Programming
 
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!

2185Bilal 06-05-2012 11:34

Re: Logitech Controller Programming
 
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:

kdehaan42 18-08-2012 23:54

Re: Logitech Controller Programming
 
Quote:

Originally Posted by 2185Bilal (Post 1167433)
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.


All times are GMT -5. The time now is 09:13.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi