Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Logitech Dual Action Setup for 2 Axis help please? (http://www.chiefdelphi.com/forums/showthread.php?t=89490)

robotic321 18-01-2011 15:44

Logitech Dual Action Setup for 2 Axis help please?
 
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

Re: Logitech Dual Action Setup for 2 Axis help please?
 
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. (and VIA link from that thread here, too)

JewishDan18 18-01-2011 22:16

Re: Logitech Dual Action Setup for 2 Axis help please?
 
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

Re: Logitech Dual Action Setup for 2 Axis help please?
 
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

Re: Logitech Dual Action Setup for 2 Axis help please?
 
Quote:

Originally Posted by Jared341 (Post 928506)
Quote:

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:

Code:

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

Re: Logitech Dual Action Setup for 2 Axis help please?
 
Quote:

Originally Posted by robotic321 (Post 1003528)
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

Code:

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

Re: Logitech Dual Action Setup for 2 Axis help please?
 
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

Re: Logitech Dual Action Setup for 2 Axis help please?
 
in these examples what would have to be imported in order for these to be used?

Robby Unruh 24-01-2011 19:08

Re: Logitech Dual Action Setup for 2 Axis help please?
 
Quote:

Originally Posted by inkspell4 (Post 1007060)
in these examples what would have to be imported in order for these to be used?

In my code I usually just use:

Code:

import edu.wpi.first.wpilibj.*;
so it imports everything. But for Joystick's it's just:

Code:

import edu.wpi.first.wpilibj.Joystick;


All times are GMT -5. The time now is 10:39.

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