Go to Post Representing data in a good way is an art in its own right. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-01-2012, 13:55
NS_Radication's Avatar
NS_Radication NS_Radication is offline
Student
AKA: Marco Schoener
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Tampa
Posts: 88
NS_Radication is an unknown quantity at this point
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!
__________________
Team 1369
Senior
Head Programmer (Java)
Head Electrician
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2012, 14:21
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
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.
__________________
Attending: MN Duluth Regional
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2012, 18:12
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Logitech Controller Programming

I have a convenient class for you.

Created after some extensive testing:

https://github.com/FRCTeam4069/Robot...ontroller.java
Reply With Quote
  #4   Spotlight this post!  
Unread 29-01-2012, 23:06
nickpeq nickpeq is offline
Turing-complete
FRC #1255 (Blarglefish)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Baytown, TX
Posts: 60
nickpeq is an unknown quantity at this point
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-02-2012, 01:12
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
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
__________________
http://team2168.org
Reply With Quote
  #6   Spotlight this post!  
Unread 01-02-2012, 07:35
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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);

Last edited by neal : 01-02-2012 at 07:37. Reason: Added how to call it.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-02-2012, 21:17
NS_Radication's Avatar
NS_Radication NS_Radication is offline
Student
AKA: Marco Schoener
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Tampa
Posts: 88
NS_Radication is an unknown quantity at this point
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!
__________________
Team 1369
Senior
Head Programmer (Java)
Head Electrician
Reply With Quote
  #8   Spotlight this post!  
Unread 04-02-2012, 03:23
Demonix_Fox's Avatar
Demonix_Fox Demonix_Fox is offline
Registered User
AKA: Nathan
FRC #4520 (Roboteknix)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Post Falls Idaho
Posts: 1
Demonix_Fox is an unknown quantity at this point
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!
Reply With Quote
  #9   Spotlight this post!  
Unread 06-05-2012, 11:34
2185Bilal's Avatar
2185Bilal 2185Bilal is offline
Driver, Ld. Programmer, Electrical
AKA: Bilal Majeed
FRC #2185 (Ramazoidz)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Toronto, Canada
Posts: 110
2185Bilal will become famous soon enough
Post 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
__________________
RAMAZOIDZ

2009 Toronto West Regional - Regional Winners
2009 Waterloo Regional - Regional Winners
Reply With Quote
  #10   Spotlight this post!  
Unread 18-08-2012, 23:54
kdehaan42 kdehaan42 is offline
Registered User
FRC #2874 (Eagles)
Team Role: Leadership
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Grain Valley
Posts: 15
kdehaan42 is an unknown quantity at this point
Re: Logitech Controller Programming

Quote:
Originally Posted by 2185Bilal View Post
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
To use the controller in labview use the normal getJoystick and then unBundle both the axis and buttons.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:37.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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