views:

53

answers:

2

I have a differential drive robot, using odometery to infer its position.

I am using the standard equations:

WheelBase = 35.5cm;
WheelRadius = 5cm;
WheelCircumference = (WheelRadius * 2 * Math.PI);
WheelCircumferencePerEncoderClick = WheelCircumference / 360;

DistanceLeft = WheelCircumferencePerEncoderClick * EncoderCountLeft
DistanceRight = WheelCircumferencePerEncoderClick * EncoderCountRight

DistanceTravelled = (DistanceRight + DistanceLeft) / 2
AngleChange (Theta) = (DistanceRight - DistanceLeft) / WheelBase

My (DIY) chassis has as a slight feature, where over the course of the wheel base (35.5cm), the wheels are misaligned, in that the left wheel is 6.39mm (I'm a software person not a hardware person!) more 'forwards' than the right wheel. (The wheels are the middle of the robot.)

I'm unsure how to calculate what I must add to my formulas to give me the correct values.. It doesn't affect the robot much, unless it does on the spot turns, and my values are way off, I think this is causing it.

My first thought was to plot the wheel locations on a grid, and calculate the slope of the line of their positions, and use that to multiply... something.

Am I on the right track? Can someone lend a hand? I've looked around for this error, and most people seem to ignore it (since they are using professional chassis).

A: 

If I'm reading this right, the problem is that because the left wheel is ahead of the right, when they turn at different rates they cannot roll without slipping. The greater the difference in turning rates, the worse the problem gets, which is probably why it shows up while "turning on a dime", when the rotations are opposed.

I think the way to solve it is to consider a related problem: two wheels located correctly, but both skewed a little to the left (which is exactly the situation you're in, thinking of the diagonal between the wheels as the "wheelbase"). The motion can then be broken into two components, the major forward-back component, which acts normally, and the minor sideways component which causes no angle change and depends only on the sum of the wheel rotations.

I'll see if I can come up with some math that makes sense...

Beta
+1  A: 

The correction must be made to the formula for AngleChanged, as follows:

Take L and R to be the distances traveled by the left and right wheels, respectively, in one tick.
Let B denote the length of the nominal wheelbase (not the length of your skewed one).
Let E represent the left wheel error. That is, the distance the left wheel is offset forward from its ideal position.
We seek to find θ, the change in the angle of the wheelbase in one tick.

First, (pre)-calculate the angle between the skewed wheelbase and the ideal wheelbase:

φ = arctan(E / B).

Using some elementary geometry (I can post details if you desire), we may calculate theta as follows:

σ = arctan( ( E+ L - R) / B )
θ = φ - σ

Seeing as this reduces to your previous implementation when E=0, and has intuitively understandable results as E -> +inf., our formula seems correct.

NOTE:
You probably want to do away with that computationally ugly arctangent in your calculation of σ (sigma). In situations as these, it's common practice (indeed, you used it in your previous formulas) to use the approximation arctan(x) = x, for small x.
The problem here is that while the quantity (L-R)/B is likely to be quite small, the error addition E/B may grow unacceptably large. You can try calculating sigma by just doing away with the arctan and using sigma = (E+L-R)/B, but if you want a better approximation you should use the first-order taylor series for arctan(a+x) around 0:

arctan(a+x) = arctan(a) + x/(1 + a^2)

Applied to the calculation of sigma, the approximation now looks such:

σ = arctan(E / B) + (L - R) / (B + E^2 / B)

Notice that the arctan(E / B) has already been precalculated as φ. This is a much better approximation for sigma, which should yield more exact calculations for theta.

Preetum Nakkiran
I am following your thinking and your instructions, I believe I can implement this. However (I'm not a Maths person) I fail to understand your thoughts when you say 'You probably want to do away with that computationally ugly arctangent'. Are you referring to the fact I am doing Theta = (DistanceRight - DistanceLeft) / WheelBase, without the ArcTan wrapped around it?What effect does this have on the actual result? Sorry for being a bit slow! To clarify, one tick, is one observation of the sensors (multiple encoder clicks)?
James
I am now totally confused about ArcTan, if I do it without arctan, on the spot, i get:(20- -20) / 35 radians to degrees = 65 degreesarctan((20- -20) / 35) radians to degrees = 49 degreesWhich of these is correct??
James
Okay I see, so if I plug in small distances, like 1cm in my original Theta calculation, the change is very small when using arctan than not.
James
This worked a treat - I'm getting much better values. I still have more calibration to do, but this should confuse my poor particles a bit less!
James