|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
C++ Polar Coordinate Joystick
I've attached a new joystick class derived from the standard WPILib Joystick class with additional functionality.
For omni-directional control systems (such as mechanum, etc.), it may be beneficial to receive your input from a joystick as a polar coordinate (radius and angle/direction) as opposed to the standard cartesian coordinate (x and y values). Doing so presents a problem, however, as due to special right triangles, pushing the joystick into any of the corners generates a farther distance from the center than pushing the joystick to any of the sides (since a right triangle with two legs 1 unit long generates a hypotenuse of the square root of 2 units long). I've created a fix for this by writing an algorithm that "normalizes" the distance from the center. The algorithm takes the slope of the line that intersects the origin (the center point of the joystick) and the actual x-y coordinate of the joystick and uses this slope to project the line all the way to the edge of the joystick bounds. The length of this line is divided by the length of the line from the origin to the joystick coordinate. The end result of all this is that the polar coordinate generated remains at the maximum value while moving the joystick all the way around its bounds. Also included is a simpler function that gives the angle of the joystick (in degrees) from the center point. These two functions are used to derive the OmniJoystick class from the standard Joystick class. The OmniJoystick class has the functions GetAngle() and GetR() along with the standard GetX() and GetY() functions. |
|
#2
|
|||
|
|||
|
Re: C++ Polar Coordinate Joystick
This is awesome! I was just about to write this code myself and then I thought, "You know, this really ought to already be implemented on ChiefDelphi somewhere..." and, lo and behold, it was!
Thanks! -Matt Last edited by manderson5192 : 02-01-2009 at 20:11. Reason: Missed two of the code files...comment is innacurate :) |
|
#3
|
|||
|
|||
|
Re: C++ Polar Coordinate Joystick
That's super cool. Great thinking!
|
|
#4
|
||||
|
||||
|
Re: C++ Polar Coordinate Joystick
But you're required to use the Rover wheels which are non-omni.
|
|
#5
|
||||
|
||||
|
Re: C++ Polar Coordinate Joystick
This topic is originally from before kickoff.
|
|
#6
|
|||
|
|||
|
Re: C++ Polar Coordinate Joystick
Quote:
I would love to give a specific example of those "other" drive types, but my mechanical team leader would like to keep that a secret for just a few days longer . |
|
#7
|
||||
|
||||
|
Re: C++ Polar Coordinate Joystick
What's funny is that these wheels could probably act as omni. =]
|
|
#8
|
||||
|
||||
|
Re: C++ Polar Coordinate Joystick
Thanks i was just trying to write this in lapview, thanks for the jumping off point.
On a latter note: I like working in polar coordinates, i just seams simpler then the coorindates we had to work with last year. It also works better if you are tyring to write an accleration program to help you start and stop on a slick surface, with might come in handy, this year... |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The Polar Express [On ABC] | synth3tk | Chit-Chat | 2 | 01-12-2007 10:02 |
| Polar Bear Carictures! | Sister Grimm | Chit-Chat | 0 | 24-04-2005 19:49 |
| Polar direction between two cylinders | reilly | Pneumatics | 4 | 18-02-2005 11:38 |
| The Polar Express | sanddrag | Chit-Chat | 7 | 03-06-2004 00:52 |
| polar array in 3ds | Ghetto_Child | 3D Animation and Competition | 6 | 12-01-2002 18:55 |