Go to Post I don't get what all you people have done wrong to make the drills have so many problems. - Cory [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 31-01-2015, 12:16
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
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);
            }
Reply With Quote
  #2   Spotlight this post!  
Unread 31-01-2015, 13:10
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
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.
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 31-01-2015, 16:51
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Xbox Axis Help

Quote:
Originally Posted by kinganu123 View Post
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;
            }
Reply With Quote
  #4   Spotlight this post!  
Unread 31-01-2015, 17:06
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
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.
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 31-01-2015, 17:37
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 988
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Xbox Axis Help

Quote:
Originally Posted by curtis0gj View Post
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.
Reply With Quote
  #6   Spotlight this post!  
Unread 31-01-2015, 19:22
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Xbox Axis Help

Quote:
Originally Posted by RufflesRidge View Post
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
Reply With Quote
  #7   Spotlight this post!  
Unread 31-01-2015, 20:44
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
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;
            }
Reply With Quote
  #8   Spotlight this post!  
Unread 31-01-2015, 21:18
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 988
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
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.
Reply With Quote
  #9   Spotlight this post!  
Unread 01-02-2015, 10:19
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: Xbox Axis Help

Check my second post.I've already put comments in there as to what you should change
__________________
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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