# Knowing how many times the rear wheels have rotated, and the angle of the front wheels at every time interval, how do I find the location of a car?

I'm making a robot for the Sparkfun AVC. I was curious if I could use only the knowledge about

1. How the car is being steered at every time interval,

2. How many times the wheels have rotated,

to get a general sense of where the car is. I would use computer vision to avoid immediate dangers.

The biggest problem is any slipping causing false counts.

• I voted this question down because (no offense meant) it's actually a pretty simple geometrical/mathematical kind of question that can be easily solved with a little bit of calculus 3 knowledge. Seems more like the kind of question for a physics/math type site. – Rick supports Monica Jan 20 '15 at 23:26
• I don't now what is Sparkfun AVC, maybe a little bit of elaboration, and making your question title shorter and more informative, could help a lot. I think, it is an interesting question. – peterh Jan 20 '15 at 23:33
• You need a bit more info to answer this from a mechanical standpoint. First, which wheels are powered (front, rear, all four)? Second, if it's two-wheel drive, are the passive wheels connected or are they allowed to spin independently? These determine how complex it is, and how much slip you'll force onto the wheels. – Trevor Archibald Jan 21 '15 at 3:07
• Rear wheel drive with differential. Front wheel steering, allowed to spin independent. Fair enough, Peter. I guess I'm not really sure how a car rotates when the front wheels are turns. About which axis does a car rotate? – Daniel Sims Jan 21 '15 at 14:40
• @DanielSims: The axis of car rotation is the intersection of axis of the front and rear wheels. Nevertheless, slippage, lateral tire distortion (dependent on speed, load, surface angle) etc will quickly skew the measurement. Using integration to calculate location is very fault-prone. I've observed a displacement measurement project based on 3D accelerometer measurements; the results were very underwhelming. – SF. Jan 23 '15 at 13:08

Taking this in stages, initially lets consider only a single front wheel, with no slip in any direction, where we have an accurate continuous measure of both rotational position and absolute angle. In this case calculating current position (relative to our starting point) is a relatively straightforward trigonometry and calculus problem.

Unfortunately we don't know our absolute front wheel angle (unless we are free to equip it with a magnetometer or similar), instead we know our front wheel angle relative to the body of our vehicle. We can effectively define this as a bicycle type configuration, with a pivoting front wheel and a fixed rear wheel. The absolute angle of the front wheel can now be calculated from the absolute angle of the body (equal to the angle of the rear wheel) plus the relative angle of the front wheel to the body. An additional calculation is therefore required to determine the absolute angle of the rear wheel, based on our measurements from the front wheel. This will depend upon the distance between the front and rear wheels (consider the difference in turning circles between a single bike and a tandem to picture this). Again this is a trigonometry and calculus problem, this time in the reference frame of the vehicle.

Extending this to a four wheeled vehicle causes complications, as some of the wheels now have to slip. My mental image for this is two bicycles side-by-side, with bars connecting the frames together, and some mechanism ensuring that their steering is synchronised. If the bars connecting them are short then there is very little slip required. If they are very long (making the bikes far apart) then one or both of the front tyres will need to slip sideways to make tight turns. The distances travelled will also differ between the wheels.

Further physical analysis from this point is likely to get very involved, and will depend upon frictions and masses on each wheel. A practical approach might be to take measurements from the rotation of the two front wheels separately and then average at some point in the equations discussed above.

Further complications arise when rotational slip in any of the wheels on the ground is considered, or if any of our measures are subject to error. To incorporate these would require a very detailed model of your vehicle and a better approach would probably be to fuse an estimate from our simplified analysis above with information from other sensors using a Kalman filter or similar. In this case it may be worth considering what states are estimated in your filter, as including absolute orientation as an explicit state and using it within your calculations may give you a better overall estimate of position. A clever filter might also include an estimate of slip as part of its measurement uncertainty.

The main problem which I can see in your idea, that your system will have a cumulative error. Only calculating this won't be enough, you will have to find alternate solutions, too.

In similar (but maybe bigger) scenarios, for example for drones, there is a similar problem.

The solution is using the wheel rotation counters to get a fast, real-time, but buggy input data (which contains the cumulative error as well). In case of flying drones, this data is coming from gyros and accelerometers, your task is much simpler compared to their.

But, you should get an alternate information source, too! (In case of the drones it is normally the GPS). This can be GPS, or some other thing - there is a wide spectrum of possibilities. Visual image processing? Pre-calibrated ultrasound markers? Marker paintings on the floor?

If I suspect correctly the size of your experiment, maybe the last would be most promising to you.

• Right, not to mention the fact that real vehicles drift in addition to slippage. This means that the wheel direction is not alone enough to tell where the thing is going. You could increase the accuracy with a accelerometer etc. and run it into a Kalman filter. Even so eventually the result would suffer the described fate without some form of absolute position metering. – joojaa Feb 10 '16 at 18:46

The correct way to do this is by using what is known as a particle filter.

The maths for estimating your next position is quite simple and other answers have already provided that, but this is how you deal with the uncertainty. This video explains the basic principle rather well. You will notice that you need to take a measurement of some aspects relating to where you are, for example distance to known objects, compass reading, position of visible markings, etc. (Use your computer vision for that, plus anything else you can such as sonic range finders). It doesn't have to be perfect, the particle filter deals really well with 'noisy' measurements and 'noisy' (error-prone) predictions of where you are.

Also do a search for "slam particle filter" to get some further insight.

Knowing the diameter of the wheels and the number of times the wheels turn over in a time interval will give both distance travelled and average speed for that time interval.

You would have to have a continual monitoring system which would record time, wheel revolutions and the angle of the wheels used for steering, most likely relative to the central longitudinal axis of the vehicle. You will need to vectorize the steering data and add the vectors to give the position relative to the vehicle's starting location.

The basic equation would be $$\text{Distance traveled}=2 \pi r \times n$$ where $r$ is the radius of the wheel and $n$ is the number of revolutions of the wheel. This assumes, though, that there's no slipping.

This question says that for the car to move, $$F_k>f_cG_k$$ where $F_k$ is the force applied that's moving the far, $f_c$ is the coefficient of cohesion, and $G_k$ is the weight of the wheel plus the weight of the vehicle.

So the total force is $$\sum F=F_k-f_cG_k$$ This produces torque, $\tau$: $$\tau=Fr$$ So $$\tau=(f_k-f_cG_k)r=I \alpha$$ where $I$ is the moment of inertia of the wheel and $\alpha$ is the angular acceleration. So $$\alpha=\frac{(f_k-f_cG_k)r}{I}$$ You have to measure $f_c$ beforehand, and you'll have to figure out the force applied by the eninge ($F_c$). But then you can use kinematics to figure out how many rotations the car's wheel will actually undertake: $$\theta=\omega_0 t+\frac{1}{2}\alpha t^2$$ where $\theta$ is the number of revolutions, $\omega_0$ is the initial velocity, and $t$ is the time. So, with $\text{Distance traveled}=r \theta$, your equation should be $$\text{Distance traveled}=r \left( \omega_0t+\frac{1}{2} \left(\frac{(f_k-f_cG_k)r}{I} \right)t^2 \right)$$