Go to Post What is this? PVC pirates with no visible PVC? (at least that I can see) IMPOSTORS! - theawesome1730 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-12-2008, 17:04
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
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.
Attached Files
File Type: zip OmniJoystick.zip (2.1 KB, 127 views)
__________________
  #2   Spotlight this post!  
Unread 02-01-2009, 20:00
manderson5192 manderson5192 is offline
Registered User
AKA: Matt Anderson
FRC #0948 (Newport Robotics Group: NRG (pronounced eNeRGy))
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Bellevue, WA
Posts: 62
manderson5192 is on a distinguished road
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   Spotlight this post!  
Unread 03-01-2009, 10:31
fixermark fixermark is offline
FIRST Robotics Alumnus
AKA: Mark T. Tomczak
None #0422 (Maggie Walker Mech Techs)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Richmond, VA
Posts: 9
fixermark is a name known to allfixermark is a name known to allfixermark is a name known to allfixermark is a name known to allfixermark is a name known to allfixermark is a name known to all
Send a message via AIM to fixermark
Re: C++ Polar Coordinate Joystick

That's super cool. Great thinking!
__________________
"There is a solution."
  #4   Spotlight this post!  
Unread 03-01-2009, 20:11
Red Mage's Avatar
Red Mage Red Mage is offline
Owner of Holistic Omniscience
FRC #1546 (Chaos Inc)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 35
Red Mage is on a distinguished road
Send a message via AIM to Red Mage
Re: C++ Polar Coordinate Joystick

But you're required to use the Rover wheels which are non-omni.
__________________
Don't Blink. Blink and you're dead. Don't turn your back. Don't look away. And don't Blink. Good Luck.
  #5   Spotlight this post!  
Unread 03-01-2009, 20:19
jtdowney jtdowney is offline
Boiler Up
AKA: John Downey
FRC #4302 (Robophins)
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2006
Location: Chicago
Posts: 300
jtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant future
Re: C++ Polar Coordinate Joystick

Quote:
Originally Posted by Red Mage View Post
But you're required to use the Rover wheels which are non-omni.
This topic is originally from before kickoff.
__________________
John Downey
Lead Robot Inspector - Purdue IndianaFIRST District
Whitney Young Magnet High School/Robophins (FRC 4302) - Mentor (2013-current)
Midwest Regional Planning Committee - Member (2012-current)
Boilermaker Regional Planning Committee - Member (2011-2014)
Robot Inspector (2008-current)
Purdue FIRST Programs - Staff Advisor (2008-2011)
Lafayette-Jefferson High School/Precision Guessworks (FRC 1646) - Mentor (2006-2011)
  #6   Spotlight this post!  
Unread 03-01-2009, 20:29
manderson5192 manderson5192 is offline
Registered User
AKA: Matt Anderson
FRC #0948 (Newport Robotics Group: NRG (pronounced eNeRGy))
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Bellevue, WA
Posts: 62
manderson5192 is on a distinguished road
Re: C++ Polar Coordinate Joystick

Quote:
Originally Posted by Red Mage View Post
But you're required to use the Rover wheels which are non-omni.
Ah, but who says this joystick class isn't applicable to other drive types than those with omni or mecanum wheels? The rover wheels are actually quite suitable for a holonomic setup (wheels are setup parallel to each side, with axles lined up like this: + ) and there are certainly other drive types out there that can use the rover wheels.

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   Spotlight this post!  
Unread 03-01-2009, 21:05
keehun's Avatar
keehun keehun is offline
Team Captain
AKA: Keehun Nam
FRC #2502 (EP Robotics)
Team Role: Leadership
 
Join Date: May 2008
Rookie Year: 2008
Location: Eden Priaire
Posts: 474
keehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond repute
Send a message via AIM to keehun
Re: C++ Polar Coordinate Joystick

What's funny is that these wheels could probably act as omni. =]
  #8   Spotlight this post!  
Unread 03-01-2009, 21:25
XXShadowXX's Avatar
XXShadowXX XXShadowXX is offline
They call me Cody.
no team (None currently :\)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Pontiac; MI
Posts: 408
XXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud of
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...
__________________
Is now an engineer thanks to FIRST.
Closed Thread


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

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


All times are GMT -5. The time now is 14:10.

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