Log in

View Full Version : Need to invert Joystick axis output


W_Yingst
18-11-2014, 11:22
Our team is moving into Java for the first time this year, and we are creating our "Hello World" program (Simple driving). We are using the arcadeDrive method of a RobotDrive class object. It will drive forwards and backwards in the way we want, but the turning is inverted. Left joystick results in a right turn, and right joystick in a left. Inverting motors does not solve this problem, so I think we need to invert the x axis output from the joystick. Has anyone had this problem before? Any help inverting these values? Thanks.

notmattlythgoe
18-11-2014, 11:24
Our team is moving into Java for the first time this year, and we are creating our "Hello World" program (Simple driving). We are using the arcadeDrive method of a RobotDrive class object. It will drive forwards and backwards in the way we want, but the turning is inverted. Left joystick results in a right turn, and right joystick in a left. Inverting motors does not solve this problem, so I think we need to invert the x axis output from the joystick. Has anyone had this problem before? Any help inverting these values? Thanks.

All you need to do is place a "-" in front of the value coming out of the joystick going into the ardaceDrive() call. This will invert the value so -1 would become 1 and 1 would become -1. Something like this:


robotDrive.arcadeDrive(joystick.getY(), -joystick.getX());

dash121
18-11-2014, 11:46
Have you thought about looking in the driverstation and switching your joystick ports under the setup tab switching the joystick imports. Your java code calls for a joystick in port one or port two. Your computer doesn't have a USB port one or port two.. Thats where the FRC driverstation comes in.. to define what is port one and port two. You just need to switch the joystick ports. This method works better versus putting inverse in front of your code.

notmattlythgoe
18-11-2014, 11:50
Have you thought about looking in the driverstation and switching your joystick ports under the setup tab switching the joystick imports. Your java code calls for a joystick in port one or port two. Your computer doesn't have a USB port one or port two.. Thats where the FRC driverstation comes in.. to define what is port one and port two. You just need to switch the joystick ports. This method works better versus putting inverse in front of your code.

This would make sense if their robot was set up for tank style steering not arcade. I believe what is meant is that when the joystick is pushed left the robot is turning right and vise versa. I read this as there is only one joystick present.

W_Yingst
19-11-2014, 10:34
Yes, we only have one joystick. Everything works except we need to invert x. With the code notmattlythgoe showed, don't you normally use a normal joystick object? as in define the object and then just call it in? I haven't seen Joystick.getx and Joystick.gety before

W_Yingst
19-11-2014, 10:41
notmattlythgoe, thanks so much that method worked perfectly. Problem solved.

Ether
19-11-2014, 11:17
notmattlythgoe, thanks so much that method worked perfectly. Problem solved.

If you have some spare time, you might want to examine your wiring and your code to figure out why you had to do this. It could be an educational experience.

notmattlythgoe
19-11-2014, 11:27
If you have some spare time, you might want to examine your wiring and your code to figure out why you had to do this. It could be an educational experience.





I agree with Ether, this isn't something you normally have to do, so it could be an indication that something is backwards somewhere.