We have recently encountered this problem, our joystick command did not work. We tried Joystick USB1 = new Joystick(1); in our program. In our driver Station under set up it is reading the joysticks as a button press causes the joystick color tab to change in the DS. Has anyone encountered this problem if so how did you fix the problem.
What exactly isn’t working? What error(s) are you getting?
How are you linking a command to a button press? And where do these calls reside in your code (which method(s)?)
Share your code and elaborate.
As is you haven’t provided enough info for anyone to troubleshoot the problem.
We are using this code to do the drive on our base robot. It has worked in the past with our actual robot and connected the same way our actual robot is wired. I have uploaded the code to the basebot and it seems to not work. All of our jaguars have a solid light indicating a pwm signal and the joystick does not work on commanding the robot. When ever I connect the joystick the button the joystick color on the setup is different indicating the DS is reading the joystick. Does anyone know any solution?
[public class TankDrive extends Thread {
public void run(){
while(true){
Joystick USB1 = new Joystick(1);
RobotDrive drive = new RobotDrive(2,3,1,4);
drive.tankDrive(USB1.getRawAxis(2), USB1.getRawAxis(4));
}
}}
]
You’re creating the Joystick and RobotDrive object once every loop. Construct objects outside of your loop. (in the class)
Construct objects outside of your loop. (in the class)
public class TankDrive extends Thread {
Joystick USB1 = new Joystick(1);
RobotDrive drive = new RobotDrive(2,3,1,4);
public void run(){
while(true){
drive.tankDrive(USB1.getRawAxis(2), USB1.getRawAxis(4));
}
}
}
Note, you shouldn’t need to command the drivetrain in its own thread though…
Also, verify with your controller, but typically the y axis on the right analog stick of a joystick is on axis 5 (you are using 4 above). If you find that the right side of your drivetrain doesn’t move as expected, this is likely your problem.
My bad. Looked different without formatting.
No you were right, I was just showing what you suggested as a modification to their code.