|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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! |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
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? Last edited by touchdownjesus4 : 02-02-2012 at 19:40. |
|
#5
|
||||
|
||||
|
Re: Drive Motor With Throttle on Logitech Attack 3
Quote:
Code:
public double scaleThrottle(double x) {
return (x + 1) / 2;
}
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 |
|
#6
|
||||
|
||||
|
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.
|
|
#7
|
|||
|
|||
|
Re: Drive Motor With Throttle on Logitech Attack 3
The "throttle" on our joysticks are accessed with getZ()
|
|
#8
|
||||
|
||||
|
Re: Drive Motor With Throttle on Logitech Attack 3
Quote:
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 Code:
joy1 = new Joystick(1); // make a new joystick object on port 1 Code:
joy1.getRawAxis(3); Quote:
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 |
|
#9
|
|||
|
|||
|
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.
|
|
#10
|
||||
|
||||
|
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.
|
|
#11
|
||||
|
||||
|
I managed to get it working yesterday. I had to use getZ() and then it all worked fine. Thanks everyone
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|