|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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);
}
|
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Re: Xbox Axis Help
Quote:
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;
}
|
|
#4
|
|||
|
|||
|
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;
}
|
|
#5
|
|||
|
|||
|
Re: Xbox Axis Help
Quote:
|
|
#6
|
|||
|
|||
|
Re: Xbox Axis Help
Quote:
|
|
#7
|
|||
|
|||
|
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;
}
|
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
|||
|
|||
|
Re: Xbox Axis Help
Check my second post.I've already put comments in there as to what you should change
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|