View Single Post
  #7   Spotlight this post!  
Unread 07-04-2004, 14:55
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: trentonDrive.c: our joystick/wheel drive code

Quote:
Originally Posted by maxlobovsky
I'm writing code for a drivetrain that absolutely needs an accurate velocity control (with a linear curve for inputs to outputs) for each wheel so i was planning on using a PID loop and encoders to get the velocity correct. I think the PID feedback loop would be more effective if the voltage was nearer to linear to speed. This way, the system could be made very responsive by having PID coefficients that work for the whole range, not a set of coefficients designed to work over a wide range of non linear values (probably a large proportional coefficient would do that). I would do the squaring right before the PID loop (and after a bunch of trigonometry, limiting, deadbanding, etc...) So basically, im asking why exactly the squaring would be bad with a PID loop?
After I posted my long note last night I asked myself the same question, and then did a little math and decided I was wrong, and that squaring the motor values would still be legit. Here's my reasoning.

The main feature of trentonDrive() is that the turning radius is independent of overall speed. The x-axis sets the turning radius, the y axis sets the speed. For a turning radius to be independent of speed, the ratio of the inner and outer wheel speeds must be constant:

outer = faster * yAxis;
inner = slower * yAxis;

where 'faster' is, say, (1+x) and 'slower' is (1-x), where x runs from -1 to +1. But that doesn't matter, because what we care about is that the Yaxis term drops out of the ratio of outer to inner:

outer / inner = (faster*yAxis) / (slower*yAxis)
= faster / slower;

So the ratio is independent of the yAxis.

Now, intuitively, I suspected that squaring outer and inner would bring the yAxis into the ratio, but I was wrong:

outer^2 = (faster*yAxis)^2 ;
= faster^2 * yAxis^2;

inner^2 = (slower*yAxis)^2 ;
= slower^2 * yAxis^2;

So the ratio would be:
(faster^2 * yAxis^2) / ( slower^2 * yAxis^2 )

and the yAxis^2 terms once again cancel. So it's still okay to square the wheel values even if you have dead accurate speed control of the motors. trentonDrive() should work very well with such a system.
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.

Last edited by gnormhurst : 07-04-2004 at 14:58.