Chief Delphi

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

curtis0gj 31-01-2015 12:16

Xbox Axis Help
 
Howdy folks, I need some help with my Xbox 360 remote. Currently I am using the Buttons to send signals to victor motor controllers and spike relays, but I would like to switch over to the left axis for my victors and right axis for my relays. Here is my current code. Any help would be greatly appreciated.

Code:


    boolean buttonPressedForwardSpike = false; // these are in init.
 
    boolean buttonPressedForwardVictor = false; // init

            if (xbox.getRawButton(3)) {  // tele
                   
                    spike1.set(Relay.Value.kForward);
                    spike2.set(Relay.Value.kForward);
                    buttonPressedForwardSpike = true;
                   
                   
            } else if (buttonPressedForwardSpike = true) {
                   
                    spike1.set(Relay.Value.kOff);
                    spike2.set(Relay.Value.kOff);
                    buttonPressedForwardSpike = false;
            }
           
            if (xbox.getRawButton(2)) {
                   
                    spike1.set(Relay.Value.kReverse);
                    spike2.set(Relay.Value.kReverse);
                   
            }
           
           
            if (xbox.getRawButton(1)) {
                   
                    victor1.set(.50);
                    victor2.set(.50);
                    buttonPressedForwardVictor = true;
                   
            } else if (buttonPressedForwardVictor = true) {
                   
                    victor1.set(0);
                    victor2.set(0);
                    buttonPressedForwardVictor = false;
            }
           
            if (xbox.getRawButton(4)) {
                   
                    victor1.set(-.50);
                    victor2.set(-.50);
            }


kinganu123 31-01-2015 13:10

Re: Xbox Axis Help
 
Use the driver station to find the raw axis values of the individuals joysticks (it's on one of the tabs on the bottom left hand side). Then, just call getRawAxis() on that axis you find.
Also, I'm sure if you look around on chiefdelphi, you'll find that people have already posted up their xbox class.

curtis0gj 31-01-2015 16:51

Re: Xbox Axis Help
 
Quote:

Originally Posted by kinganu123 (Post 1436567)
Use the driver station to find the raw axis values of the individuals joysticks (it's on one of the tabs on the bottom left hand side). Then, just call getRawAxis() on that axis you find.
Also, I'm sure if you look around on chiefdelphi, you'll find that people have already posted up their xbox class.

Could I use this picture http://team358.org/files/programming...rolMapping.jpg for the values or do I need to check the actual readings?

Code:

boolean buttonPressedForwardSpike = false; // these are in init.
 
    boolean buttonPressedForwardVictor = false; // init

            if (xbox.getRawAxis(5)) {  // 5 being the Y axis on right stick
                   
                    spike1.set(Relay.Value.kForward);
                    spike2.set(Relay.Value.kForward);
                    buttonPressedForwardSpike = true;
                   
                   
            } else if (buttonPressedForwardSpike = true) {
                   
                    spike1.set(Relay.Value.kOff);
                    spike2.set(Relay.Value.kOff);
                    buttonPressedForwardSpike = false;
            }


kinganu123 31-01-2015 17:06

Re: Xbox Axis Help
 
Code:

boolean buttonPressedForwardSpike = false; // these are in init.
 
    boolean buttonPressedForwardVictor = false; // init
            // !!The below statement doesn't evaluate to a boolean
            if (xbox.getRawAxis(5)) {  // 5 being the Y axis on right stick
                   
                    spike1.set(Relay.Value.kForward);
                    spike2.set(Relay.Value.kForward);
                    buttonPressedForwardSpike = true;
                   
            // !!!!!!!!!!! The below staetment assigns instead of comparing
            } else if (buttonPressedForwardSpike = true) {
                   
                    spike1.set(Relay.Value.kOff);
                    spike2.set(Relay.Value.kOff);
                    buttonPressedForwardSpike = false;
            }

If that's the exact one, then yeah, it SHOULD be fine. Though I'd still recommend checking it, for sanity reasons.

RufflesRidge 31-01-2015 17:37

Re: Xbox Axis Help
 
Quote:

Originally Posted by curtis0gj (Post 1436674)
Could I use this picture http://team358.org/files/programming...rolMapping.jpg for the values or do I need to check the actual readings?

Check them. That picture looks like the old 2014 and earlier mapping.

curtis0gj 31-01-2015 19:22

Re: Xbox Axis Help
 
Quote:

Originally Posted by RufflesRidge (Post 1436701)
Check them. That picture looks like the old 2014 and earlier mapping.

Yeah it was, I found 2015 http://team358.org/files/programming...rolMapping.jpg

curtis0gj 31-01-2015 20:44

Re: Xbox Axis Help
 
I may need some further assistance the getRawAxis is giving me an error saying that it cannot covert from double to boolean.

Code:

boolean buttonPressedForwardSpike = false; // init
           
            if (xbox.getRawAxis(5)) {  // 5 being the Y axis on right stick
                   
                    spike1.set(Relay.Value.kForward);
                    spike2.set(Relay.Value.kForward);
                    buttonPressedForwardSpike = true;
                   
            } else if (buttonPressedForwardSpike = true) {
                   
                    spike1.set(Relay.Value.kOff);
                    spike2.set(Relay.Value.kOff);
                    buttonPressedForwardSpike = false;
            }


RufflesRidge 31-01-2015 21:18

Re: Xbox Axis Help
 
You will need to explain more about what you want the code to do. A joystick axis in WPILib returns a floating point value (double datatype) from -1.0 to 1.0. An if statement requires a boolean, true or false.

kinganu123 01-02-2015 10:19

Re: Xbox Axis Help
 
Check my second post.I've already put comments in there as to what you should change


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

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