Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Need to invert Joystick axis output (http://www.chiefdelphi.com/forums/showthread.php?t=131176)

W_Yingst 18-11-2014 11:22

Need to invert Joystick axis output
 
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

Re: Need to invert Joystick axis output
 
Quote:

Originally Posted by W_Yingst (Post 1409049)
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:

Code:

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

dash121 18-11-2014 11:46

Re: Need to invert Joystick axis output
 
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

Re: Need to invert Joystick axis output
 
Quote:

Originally Posted by dash121 (Post 1409054)
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

Re: Need to invert Joystick axis output
 
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

Re: Need to invert Joystick axis output
 
notmattlythgoe, thanks so much that method worked perfectly. Problem solved.

Ether 19-11-2014 11:17

Re: Need to invert Joystick axis output
 
Quote:

Originally Posted by W_Yingst (Post 1409178)
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

Re: Need to invert Joystick axis output
 
Quote:

Originally Posted by Ether (Post 1409182)
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.


All times are GMT -5. The time now is 22:38.

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