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!

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.

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.

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)


	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.

Didn’t see the inverting part earlier. To invert it, you could just multiply it by -1.

The “throttle” on our joysticks are accessed with getZ()

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:

Joystick joy1; //define a variable accessible to all methods in your class

Add this to your init method

joy1 = new Joystick(1); // make a new joystick object on port 1

Add this to whereever you’re trying to read the joystick (teleop?)

joy1.getRawAxis(3);

That returns a double, store it in a variable for use or manipulate it directly…

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

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.

thanks everyone, I’ll give your suggestions a try tomorrow morning when we have our build session and see if it works.

I managed to get it working yesterday. I had to use getZ() and then it all worked fine. Thanks everyone