View Full Version : getRawButton() problems
thetonio96
08-01-2015, 21:48
Hi everyone, our team is programming the robot with Java, but we are have a problem getting the boolean value of getRawButton() method. Does someone had a similar problem or knows how to fix it?
//Example
public void teleopPeriodic() {
if(stick.getRawButton(1)==true){
//Some Code
}
}
orangelight
08-01-2015, 22:00
Does anything else on the controller work?
thetonio96
08-01-2015, 22:04
Yes, the RobotDrive is getting the X and Y axis and they are both working.
orangelight
08-01-2015, 22:06
Did you look under the driver station joystick menu and see if the button is being read there?
thetonio96
08-01-2015, 22:08
Yes, also did that with each button and they all blink the green light in the driver station.
orangelight
08-01-2015, 22:10
Are you sure its the right port for the button? Do you mind sharing the rest of your code?
Ben Wolsieffer
08-01-2015, 22:11
Even though it is for C++, this problem sounds suspiciously similar: http://www.chiefdelphi.com/forums/showthread.php?threadid=132426
orangelight
08-01-2015, 22:16
It sounds like might be an issue just for that controller. Did you try other methods like getButton and getTrigger?
thetonio96
08-01-2015, 22:23
Ok, so this https://gist.github.com/antoniotorres/9f27a49be53daa4f6a18 is the test code that we are using to test the controller's buttons. The basic idea is that the spikes turns on, which it does on the autonomous mode.
BradAMiller
08-01-2015, 22:35
What model joystick is it? And can you try another joystick type to see if that works?
thetonio96
08-01-2015, 22:39
Yeah, we tried with the Logitech ATK3 and the Xbox Controller and both have the same issue.
nickmcski
09-01-2015, 00:21
public void teleopPeriodic() {
if(stick.getRawButton(1)==true){
//Some Code
}
}
Just remember that this should return a boolean, so you don't need the == true
just try, it simplifies the code and leaves less room for error.
public void teleopPeriodic() {
if(stick.getRawButton(1)){
//Some Code
}
}
notmattlythgoe
09-01-2015, 07:47
We ran into an issue like this yesterday. Make sure you have your joystick set on the right port. Everything shifted to a 0 index this year on the rio and the driver station.
Not sure if this is the case for the buttons and axis or not though.
Pratik Kunapuli
09-01-2015, 10:25
Something that our team found was that all of the axis and button numbers don't directly translate from the 2014 control system to the 2015 control system. We use Xbox controllers and previously, the left joystick Y axis was axis 5, but in the 2015 code it is recognized as axis 1. I would recommend making a test program and iteration through all the axis numbers and the button numbers and writing them all down for future use.
Joe Ross
09-01-2015, 11:34
I would recommend making a test program and iteration through all the axis numbers and the button numbers and writing them all down for future use.
Have you looked at the display on the USB tab of the driver station? It does the same thing.
thetonio96
09-01-2015, 15:20
Okay, the problem was resolved by using another laptop. Still, we don't know what caused the problem. This is the code that worked: https://github.com/team4635/FIRST-FRC-2015/blob/master/src/org/usfirst/frc/team4635/robot/Robot.java
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.