Go to Post We love both AndyMark and Vex for everything they do. The work these folks put into their products is amazing. - marshall [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-11-2014, 11:22
W_Yingst W_Yingst is offline
Registered User
FRC #4553
 
Join Date: Nov 2014
Location: Columbus, MS
Posts: 3
W_Yingst is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 18-11-2014, 11:24
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Need to invert Joystick axis output

Quote:
Originally Posted by W_Yingst View Post
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());
Reply With Quote
  #3   Spotlight this post!  
Unread 18-11-2014, 11:46
dash121 dash121 is offline
Registered User
FRC #4085
 
Join Date: Oct 2014
Location: Reynoldsburg Ohio
Posts: 23
dash121 is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 18-11-2014, 11:50
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Need to invert Joystick axis output

Quote:
Originally Posted by dash121 View Post
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 19-11-2014, 10:34
W_Yingst W_Yingst is offline
Registered User
FRC #4553
 
Join Date: Nov 2014
Location: Columbus, MS
Posts: 3
W_Yingst is an unknown quantity at this point
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
Reply With Quote
  #6   Spotlight this post!  
Unread 19-11-2014, 10:41
W_Yingst W_Yingst is offline
Registered User
FRC #4553
 
Join Date: Nov 2014
Location: Columbus, MS
Posts: 3
W_Yingst is an unknown quantity at this point
Re: Need to invert Joystick axis output

notmattlythgoe, thanks so much that method worked perfectly. Problem solved.
Reply With Quote
  #7   Spotlight this post!  
Unread 19-11-2014, 11:17
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Need to invert Joystick axis output

Quote:
Originally Posted by W_Yingst View Post
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.



Reply With Quote
  #8   Spotlight this post!  
Unread 19-11-2014, 11:27
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Need to invert Joystick axis output

Quote:
Originally Posted by Ether View Post
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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