Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Xbox Controller Axis 3 (http://www.chiefdelphi.com/forums/showthread.php?t=115883)

tuXguy15 08-04-2013 21:55

Xbox Controller Axis 3
 
Hello. My team has decided that we are using the xbox controller for our regional competition. I have it all done except one thing that i cant quite get to work right. The two trigger buttons at the top back of the xbox controller I believe is Axis 3. We are trying to get the left side to activate one solenoid and the right side to activate the other. Is this possible since its not like a normal button that is a boolean and if so how can I go about this? Thansk.

joelg236 08-04-2013 22:23

Re: Xbox Controller Axis 3
 
Code:

    solenoid.set(controller.getRawAxis(3) < -0.7)

ekapalka 08-04-2013 22:52

Re: Xbox Controller Axis 3
 
If you're not entirely sure what axis it is, go to Run and type "joy.cpl" without quotes. There should be a mapping under the Properties tab (while the controller is plugged in). The triggers together are actually one axis, with the left side being zero through negative one and the right side being zero through positive one. That way, synchronous triggers always equal 0 (both pressed, neither pressed, both half-pressed, and so on). I think you would probably be better off with the bumpers (because they're boolean, like solenoids; on or off) for your purpose. Just my thoughts :P

Code:

//pseudocode
if (triggeraxis > 0)//Room for error? change 0 to 0.5
{
    //solenoid 1
}
else if (triggeraxis < 0) //should be some room for error, like -0.5
{
    //solenoid 2
}
else
{
  //set solenoid 1 and 2 to off
}


gixxy 08-04-2013 23:06

Re: Xbox Controller Axis 3
 
In my XboxController class I have it setup so that the trigger axis pretends to be buttons. You can even use them with the Button class to start commands in the CommandBased Structure:

XboxController.java

tuXguy15 10-04-2013 19:11

Re: Xbox Controller Axis 3
 
nothing is working

ekapalka 10-04-2013 19:47

Re: Xbox Controller Axis 3
 
joy.cpl
Is it communicating with your computer? Are the drivers installed? If joy.cpl shows it's not working, it's not the code.

tuXguy15 10-04-2013 21:05

Re: Xbox Controller Axis 3
 
It is communicating.

Johnbot 10-04-2013 22:23

Re: Xbox Controller Axis 3
 
Are you pressing both triggers at the same time? Because if so, that won't work.

What our team did to test the xbox controllers was something along the lines of this code:
Code:

for (int i = 1; i <= 6; i ++)
{
System.out.println("AXIS "+i +" READS "+joystick.getRawAxis(i);
}

If you run this in your teleop code, and monitor the NetConsole, you should see Axis 3 read a value of near 0when neither trigger is pressed, a value of near 1 when one trigger is pressed, and a value of near -1 when the other is pressed.
If you can confirm that Axis3 does behave in that manner, then joelg236's code should work with the addition of setting another solenoid when the value is > 0.7.

gixxy 10-04-2013 22:56

Re: Xbox Controller Axis 3
 
It would help if we could see your code.

tuXguy15 13-04-2013 20:50

Re: Xbox Controller Axis 3
 
Sorry guys. The code was right, but wasn't working because the solenoid wires got crushed and needed rewired. Thanks for your help.

gixxy 14-04-2013 17:44

Re: Xbox Controller Axis 3
 
Glad to hear your problem was resolved!


All times are GMT -5. The time now is 11:31.

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