Building a 2.5D Sonar Scanner with LEGO Mindstorms
Finally I finished my first weekend project with the RWTH Mindstorms NXT Toolbox. The RWTH Aachen university provides a software framework to connect the professional computing environment Mathworks Matlab with the LEGO Mindstorms. The current stable version 4.03 supports Windows, Linux as well as MacOS. Best of all: It comes with a detailed and illustrated installation guide to help you to connect to your NXT brick.
I started to build a simple 2.5D scanner for small objects. The system consists of a bidirectional gear rack to move a sonar sensor above the test object.
Using the RWTH toolbox the Matlab code becomes easy to write. The movement of one motor
to position i
(multiple of 180 degrees motor rotation) is implemented as follows:
data = motor.ReadFromNXT();
diff = i * 180 - data.Position;
motor.TachoLimit = abs(diff);
motor.Power = 100 * sign(diff);
motor.SendToNXT();
motor.WaitFor();
Scanning a 15×15 grid of a Rubik’s cube I obtain the following point cloud:
Due to high sensor noise connecting all points to a surface does not yield very clean results:
Blurring the point heights with a simple 3×3 box filter smoothes the surface. However, it is hardly recongnizable as a cube:
The lesson is clear: Don’t use sonar for small scale surface scanning. Use laser!