room scanning.

For my current project I need to be able to scan a room. At the moment I am using a ultrasonic sensor on top of two servos to create the elevation and rotation. The only problem is that the ultrasonic sensor is giving very inaccurate results. When it scans a square room at comes out as a dome. The room is only 3metersx3meters and the range of the sensor is 6 meters. http://www.maxbotix.com/Ultrasonic_Sensors/MB1000.htm. I only used the sensor because I had it lying around, do you think the sensor is broken or do I need a different one?

You will probably not be able to really scan a room by acoustic reflections,
its not a problem of the sensor.

It reports the distance the first echo traveled,
which only has a good correlation to the distance to an object
if the signal is only reflected once.

The sensor send and receives in a cone. This means it can get a reflection from many points the further it is from the sender.

Weedpharma

While the aforementioned issues do exist, there is also the fact that when scanning by servos (rotational-based scanning) you are effectively scanning in a "dome shape" - because of cartesian to polar coordinate distortion; it's essentially the same distortion you see in a "naive" implementation of the classic simple ray-caster 2.5D engine (like what the original Wolfenstein 3D game for DOS used in the early 1990s).

Because the ray scan happens in effectively a polar (circular) pattern, but the resulting output is on a 2D cartesian screen - you get a "fisheye lens" like distortion effect.

Expand that to scanning both horizontally and vertically - and you would likely get a weird dome-like effect when plotted.

The solution, though, is fairly simple - you basically multiply the distance (when plotted) by the cosine of the angle - this page explains it rather well.

@cr0sh

I am plotting 3d points by x, y, z, co-ordinates, e.g. (12, 15, 18). The arduino gives out the rotation of 2 servos and the distance the ultrasonic sensor gave, using these I can calculate the position of each point. but how would I incorporate your method?

I attached a file to describe my problem visually.

room.png

Anyone have any other ideas?

A secondhand original Kinect and libfreenect?

I think an accurate scan of room dimensions from any one point would be not impossible, but quite complicated. Sending out any form of energy and getting back a reflection suffers from a lack of sharp focus: the returning energy is coming from different points at different distances. That being said, laser range finders are quite good, but I am not sure how accurate they would be when encountering a corner in a room.

On the other hand, my car has two cameras mounted inside the windshield which take a stereo view of the street ahead, and can determine the distance to vehicles in front of me. That is because the are effectively operating in stereo, but it is also because some pretty complicated image recognition technology is going on there. The image recognition process effectively can identify single points in a picture and, using two views, determine the distance to the point. I don't think you can get away with much less if you want to accurately map a room.