Log in

View Full Version : Logitech Dual Action Setup for 2 Axis help please?


robotic321
18-01-2011, 15:44
Hey, im kinda new to FRC java and i need assitance in making a basic drive program that will work 2 joysticks on 1 controller. How would i set it up correctly?

Robby Unruh
18-01-2011, 16:34
You mean like tank drive on an Xbox or PS3 controller, right? I'd assume you'd use it like any joystick. Define it on whatever USB port and you should be set.

There's also a pretty good post about something like this here (http://www.chiefdelphi.com/forums/showpost.php?p=928506&postcount=4). (and VIA link from that thread here (http://www.chiefdelphi.com/forums/showpost.php?p=921551&postcount=4), too)

JewishDan18
18-01-2011, 22:16
You just declare it like any ordinary joystick, and read each axis from each joystick independantly. One stick will be axis 1 and 2, the other will be 3 and 4 (Unless there are other analog inputs). Also, make sure the DS has the proper drivers!

robotic321
19-01-2011, 12:58
alright, but how would i declare it? This is the way i thought it could work itself :


Joystick joy1 = new Joystick(1);


But, how would i refer to the axis number that i desire and not have it get a heart attack (stay away literal types (⌐_⌐v)

Robby Unruh
19-01-2011, 18:34
Axis indexes:
1 - LeftX
2 - LeftY
3 - Triggers (Each trigger = 0 to 1, axis value = right - left)
4 - RightX
5 - RightY
6 - DPad Left/Right

Button mapping matches Windows Control Panel>Game Pads display

To read an axis (like the left stick Y axis), simply do:


double axisValue = mXboxController.getRawAxis(2); // Where "2" is the index of the Y axis on the left stick (see above)



sums it up quite nicely.

JewishDan18
20-01-2011, 22:07
alright, but how would i declare it? This is the way i thought it could work itself :


Joystick joy1 = new Joystick(1);


But, how would i refer to the axis number that i desire and not have it get a heart attack (stay away literal types (⌐_⌐v)

Yes, thats exactly how to do it. As Robby Unruh said, you would them call

joy1.getRawAxis(1)

to get the value of the first axis, and you would use the proper index from the list that Robby Unruh posted. For a two sided drive system, I believe you would want 2 and 5.

wjbrauck
23-01-2011, 16:15
We just modified last years code yesterday to get this working. We found axis mapping to be
Axis indexes:
1 - Left joystick X
2 - Left joystick Y
3 - Right joystick X
4 - Right joystick Y
5 - DPad x
6 - DPad y

to stay with tank drive and use both joysticks from one game pad plugged into USB port 1, the code looked like

in the constructor
m_driveStick = new Joystick(1);

in the teleop section
m_robotDrive.tankDrive(m_driveStick, 4, m_driveStick, 2);

where 4 and 2 are the axis numbers assigned to the left and right joystick arguments.

wjb

inkspell4
24-01-2011, 08:07
in these examples what would have to be imported in order for these to be used?

Robby Unruh
24-01-2011, 19:08
in these examples what would have to be imported in order for these to be used?

In my code I usually just use:

import edu.wpi.first.wpilibj.*;

so it imports everything. But for Joystick's it's just:

import edu.wpi.first.wpilibj.Joystick;