Go to Post Wisdom is knowing the difference between "the way to do things" and "the right way to do things." Just because an action may be physically possible does not mean that it is smart to do. - dlavery [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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)
__________________
 


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 15:31.

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