Quote:
Originally Posted by Ether
Just to be clear: There is a divide-by-4 (which divides all 4 terms) in the original equations I posted:
|
Yes... I've changed my equation to do the divide last, as this is more efficient. One thing I wanted to point out is that these equations can work with linear velocity instead of angular, but more importantly which ever it is all the variables must be the same... This caught me off guard in my debugging as my RCW needed to be converted to linear velocity, and my omega needed to be converted back:
So I do this
Code:
//const double R = sqrt((L*L)+(W*W));
const double R = GetWheelDimensions().length();
double RCW=GetAngularVelocity(); //in radians
double RPS=RCW / Pi2;
RCW=RPS * (PI * R); //R is really diameter
//and this:
AngularVelocity=(omega / (PI * D)) * Pi2;
I have made a better demo today after fixing a lot of bugs from the first one here:
http://www.termstech.com/files/SwerveDriveDemo2.wmv
I was able to use similar equations for the tank drive:
Code:
m_LeftLinearVelocity = FWD + RCW;
m_RightLinearVelocity = FWD - RCW;
//const double FWD = (LeftLinearVelocity*cos(1.0)+RightLinearVelocity*cos(1.0))/2.0;
const double FWD = (LeftLinearVelocity + RightLinearVelocity) / 2.0;
//const double STR = (LeftLinearVelocity*sin(0.0)+ RightLinearVelocity*sin(0.0))/2.0;
const double STR = 0.0;
const double omega = ((LeftLinearVelocity) + (RightLinearVelocity*-1))/2.0;
And so now the tank drives much better too!