Go to Post Karthik is afraid of the day he can't agasabapathy. - DesignComp [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 02-02-2012, 17:34
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Drive Motor With Throttle on Logitech Attack 3

Hello all, my team wants to drive a motor via a jaguar using the throttle on the Logitech attack 3 joystick. I'm assuming I'm going to have to use getRawAxis but I don't know what axis port I have to put in or what I need to use to pass that through to the motor.

Can anyone offer insight? Any help is appreciated, thanks!
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2012, 18:42
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: Drive Motor With Throttle on Logitech Attack 3

Not completely sure, but I don't think WPI library has the code for the throttle, at least they didn't when I last checked. We haven't used the Attack 3 joystick since almost last 2-3 years.

They might have added it, you can just check all of the axis' by printing their values to either console, SmartDashboard or User Messages.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2012, 18:48
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: Drive Motor With Throttle on Logitech Attack 3

I believe for the Attack 3, the axis number is 3, so you'd do joystick.getRawAxis(3) and it'd return the axis value from -1 to 1. You might have to invert the output, though, as I can't remember whether full up is 1 or -1, and vice-versa for down.
__________________
Attending: MN Duluth Regional
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2012, 19:36
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
I tried to use the getRawAxis(3) earlier and it didn't work. I actually just took a look at the WPI library and it has a getThrottle() function under the library class. I didn't know this existed so I'm gonna try it later. I didn't have internet access when I was coding earlier so I couldn't access the library.

I'll post back how it work when I get a chance to change my code.

Just for my knowledge, how would I go about inverting it? And also if we only need to drive the motor one direction (it's just a spinning wheel) is there a way to have it only go from 0 to 1 or 0 to -1?
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver

Last edited by touchdownjesus4 : 02-02-2012 at 19:40.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2012, 21:00
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: Drive Motor With Throttle on Logitech Attack 3

Quote:
Originally Posted by touchdownjesus4 View Post
I tried to use the getRawAxis(3) earlier and it didn't work. I actually just took a look at the WPI library and it has a getThrottle() function under the library class. I didn't know this existed so I'm gonna try it later. I didn't have internet access when I was coding earlier so I couldn't access the library.

I'll post back how it work when I get a chance to change my code.

Just for my knowledge, how would I go about inverting it? And also if we only need to drive the motor one direction (it's just a spinning wheel) is there a way to have it only go from 0 to 1 or 0 to -1?
getThrottle() uses raw axis 4. To scale the throttle value from 0 - 1, you could do something like this: (simple math)

Code:
	public double scaleThrottle(double x) {
		return (x + 1) / 2;
	}
*** The code has not been tested. I just wrote that and to me, it looks like it should work.

You shouldn't need an internet connection to look at the library. You should be able to access it from your IDE, Eclipse or Netbeans. You could also just go to the sunspotfrcsdk folder and find it.

Last edited by neal : 02-02-2012 at 21:11. Reason: code not tested
Reply With Quote
  #6   Spotlight this post!  
Unread 02-02-2012, 21:02
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: Drive Motor With Throttle on Logitech Attack 3

Didn't see the inverting part earlier. To invert it, you could just multiply it by -1.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-02-2012, 22:13
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: Drive Motor With Throttle on Logitech Attack 3

The "throttle" on our joysticks are accessed with getZ()
Reply With Quote
  #8   Spotlight this post!  
Unread 02-02-2012, 22:37
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: Drive Motor With Throttle on Logitech Attack 3

Quote:
Originally Posted by touchdownjesus4 View Post
I tried to use the getRawAxis(3) earlier and it didn't work.
getRawAxis(3) works for us. make sure your joystick object is initialized

Some sample code assuming you're using simpleRobot or equivalent.

place this is your class:
Code:
Joystick joy1; //define a variable accessible to all methods in your class
Add this to your init method
Code:
joy1 = new Joystick(1); // make a new joystick object on port 1
Add this to whereever you're trying to read the joystick (teleop?)
Code:
joy1.getRawAxis(3);
That returns a double, store it in a variable for use or manipulate it directly...


Quote:
Just for my knowledge, how would I go about inverting it? And also if we only need to drive the motor one direction (it's just a spinning wheel) is there a way to have it only go from 0 to 1 or 0 to -1?
Inverting would be multiply by -1
scaling in the case you asked would be (value + 1) / 2

Any data manipulation in FRC, you should be able to get a decent implementation using high school math courses( algebra, geometry, ...maybe some calc) - yea there is actually a practical use for that stuff you're required to learn
__________________
http://team2168.org
Reply With Quote
  #9   Spotlight this post!  
Unread 02-02-2012, 23:56
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: Drive Motor With Throttle on Logitech Attack 3

Also, you may want to handle throttle == 0 as a special case. The throttle is 0 at the MIDDLE of its range. So for us, that originally translated to 50% power. Since the robot assumes the joystick values are 0 until messed with, our motor would fire up at half speed any time the robot was reset and enabled, til I added code to handle this.
Reply With Quote
  #10   Spotlight this post!  
Unread 03-02-2012, 19:55
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Re: Drive Motor With Throttle on Logitech Attack 3

thanks everyone, I'll give your suggestions a try tomorrow morning when we have our build session and see if it works.
Reply With Quote
  #11   Spotlight this post!  
Unread 05-02-2012, 15:00
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
I managed to get it working yesterday. I had to use getZ() and then it all worked fine. Thanks everyone
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver
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:46.

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