Detecting distance travelled (Cartesian)

Hey guys,

I’ve been working on a robtics project for quite a while now and I’m fairly happy with the fundamental “surivival” logic (dont hit walls, head towards light yada yada) but there’s no real intelligence there.

Now I’m thinking it’s time to invest in some hardware to estimate (hopefully accurately!) how far it has travelled in 2 dimentions.

I’ve had some success with a simple infrared optical mouse but it isn’t accurate or reliable enough on most surfaces (which is fair enough, useless mouse when I had it!). I’ve read quite a lot on IMUs and I wanted to know if anyone had any suggestions for me.

Some sort of digital compass would be a must as I dont have any form of wheel encoders. Using a flakey mixture of sensors I can estimate distance travelled but it’s not great.

What do you guys suggest?

You can use rotary encoders, and wheels with a known diameter.

Use a number of IR LED beacons and a wiimote (used as an IR camera) and triangulate your position.

Accelerometers (and/or gyros), math and some luck.

I’m sure someone will have more and better ideas :slight_smile:

[edit]If you can, you could make a grid of the area using black and white tape (for instance) and a color sensor to detect a passing of a grid.
You could have black/white along X, and red/blue along y. Then, each time a state changes [x from black to white or vice versa] | [y from red to blue or vice versa] you simply increment the position by the width of the grid. [/edit]

I think rotary encoders maybe my answer. I’m not entirely sure how I’d fit them to the chassis I have. The wheels are based on rugged Tamiya RC kits.

I was considering the RF beacons, it definitely pandered to the geek in me but I want an entirely autonomous bot which doesn’t require any major setups to pull off navigation.

If people can build UAV’s then this technology must be reasonably available to hobbyists. You’d have to normalise the results across multiple sensors but I’m positive you could accurately measure inertia to provide X,Y and an angle (Other degrees of freedom don’t concern me at the moment)

I recommend that you start with a sensor out of a better optical mouse if the vehicle is going to be travelling over flat surfaces…

You could use hall effect sensors on the wheel axles, this could be very accurate if done with the right sensors…



Measure on a driving axle is not accurate as the wheels may slip. You should use a free running wheel. But this will only be reliable in one axis.

To work in 2D the better is the mouse. For example if you have a ballcaster you can replace it with a modified mouse.

IMU is a really good answer to your problem but not the cheaper.

All those solutions are giving relative position. You should have some means aimed at giving a reference point to the robot and helped it correcting the IMU drift from time to time.

Is triangulation the only answer for reference points. It seems like overkill to lay a bunch of base stations around.

Does anyone have any examples of such technies (especially in code!)

You could just use distance sensors to walls but it depends on what you want to do with this project…

Is it for travelling long distances? - Use GPS

Is it for in an enclosed room? - Use distance sensors

Is it for on a flat surface? - Use better modified mouse

Is it for a small flat surface? - Use reference points

Is it a tracked or 4 wheel device which does not have moving front axles? - Use hall effect senors on axles - the slip is minimal if it is not accelerating too fast or on soft ground…



At the moment it has 3x sensors (2 Infrared short-range, 1 Ultra sonic. Each can measure distance fairly accurate assuming the right surfaces).

I’m picking up a GPS but we’re talking a small living room, not really outside (though it’s not out of the question).


That’s the base it’ll sit on. So you’d suggest a more accurate mouse sensor - Do you, err, have any suggestions on a module? I find that they pretty much have to drag against the floor to be useful.

I find that they pretty much have to drag against the floor to be useful.

Yep they normally do… If it going to be on a flat surface then it would be ok. I would just gut a better mouse (a microsoft optical probably as they can run in ps/2 mode)

If it is going to be in that room then you could use more ultrasonic sensors…

If it’s outside then perhaps the distance measuring doesn’t have to be anywhere near as accurate and a GPS would do… The SIRF III chipset can be accurate to about 2.5m (massive distance indoors)…

What is the project for? If you can explain exactly why you want to measure the distance travelled then I could probably give some better answers but we’re currently working in the dark here…


Ah sorry mate, I’m half thinking aloud!

To answer your question, at the moment I’m working towards some sort of UAV but it’s all fairly new to me. When I wrote my dissertation I spent a lot of time researching pathfinding (of known coordinates, without any form of triangulation) and positioning through WiFi which has led onto this thinking.

My short-term aim is to send a robot out into a unknown area and to map it out and from there to navigate around that area. Obviously I’m aware that the AVR probably can’t mange this level of mapping so I’ll probably modularise and offload some of the processing onto an ARM or maybe use a nearby laptop for the heavy lifting.

I appreciate some of the kit is quite expensive, it does turn you off when you’re just a hobbiest. Though I dont want to spend a fortune I dont mind “investing” in the kit if it pays off - assumign what I’m buying isn’t a rip off :slight_smile:

After your comments I was researching IR beacons. That sounds quite interesting method in its own right and I’d be willing to give that a go. Do you know where you can pickup a module in the UK. Though saying that I presume it can’t be to hard to build.

On a similar note, much of the beacon based position requires some form of triangulation or trilatertion. I’ve been looking around for details but if I’m honest most of the equations (even if the concept is simple) threw me. Searching for a library or some step by step intructions seem to leed nowhere - clearly I missed something in Math 101 :wink:

Speaking of beacons, I presume you’d need to map the area of freedom to assign a beacon a static position for the idea to work. How do most people pull that off? Get the old tape measure out?

Society of Robots had some good information but most of their kit relied on encoders to estimate positioning.

For others interested, I found an interesting site which has provided code to trilaterate your position.

I’ve been quite engrossed in this little project, I’ve built a demo for Trilateration you may view here

That’s in two dimensions at the moment, now I need to include the third.

If you are not easily scared by higher math here is a starting point And of course this has been done Optical Flow Based Robot Navigation,

I once read an article where NASA converted optical mice by means of suitable lenses for greater distance reading. Of course it will never work if you use only once mouse because you can not detect rotation around the sensor axis. But I always wondered (but not yet tried) if it would work using two or three mice. That way it would be possible to detect rotation and compensate for it.

This thread has been dead for a while, but why not measure distance travelled with the mouse, and measure rotation/direction with a compass?