Monthly Archives: April 2010

Robot Legs & New Projects

So here’s an oldish project I started when I first got my fret-saw, but never really got round to finishing. It’s half of a robotic leg system for a sort of crawling robot spider thing. The idea was to have 2 klann linkage ‘s (4 legs total) side by side at the front of a robot, and a caster wheel at the back. The pairs of legs at the front could then be independently controlled to provide turing.

I managed to get most of one set of legs built, but never got round to finishing them or starting the second pair. This was mainly due to the amount of time it took to cut the parts, and the speed at which the woodcutting blade on the fret-saw got blunt.

All the parts for this were designed on a CAD program then printed out on paper, stuck to a sheet of aluminium, then cut with the fret-saw. As fun as this was, it’d would’ve been a hell of a lot quicker to just send it off to a CNC place and have them cut it, but that seemed far to much like cheating to me. So I’ve come to the conclusion that it’s probably time to build my own mini-desktop CNC machine.

If you know me you’ve probably heard me rant incoherently, and more often than not drunkly, at least once about how I’m going build a CNC machine. Well this time it’s definitely going to happen, I’ve set the arbitrary dead line of my 22nd birthday (30th may, about a month away), I’ve ordered some bearings, and i’ve even done this!

So yeah, it’s got to happen I’ve written on something.

3D Scanner – Some Results

Here are a few scan results:

A Selection of 3D Models Displayed in Meshlab

From top left clockwise: Box of Swan filters, bottom half of a glue bottle, roll of solder , nodding monkey, candle in holder on coaster, bottom half of frijj bottle.

Slight disclaimer: The models are shown from there “best” angles. Some are deformed, due to not being able to set the centre of rotation yet in the scanning software, some have slightly dark meshes in places, due to the LED lights not being good enough, and all of them have had a laplacian filter applied to smooth out the meshes a bit. Also most of the objects were chosen because they produce good models given the scanners limitations . So there’s still plenty of room for improvement.

3D Scanner – C++ Code Available

The code is now available via svn. The URL is Be warned! the code is awful….i mean really really pre pre alpha awful. Compile at your own risk, use at your own risk, and feel free to contribute if you can make any sort of sense out of the code (give me a shout first). The code is developed under netbeans, and is therefore structured as a netbeans project, there is probably a much more elegant way of setting up the svn so it doesn’t matter what IDE you use, but I don’t know it….so unfortunately it’s not set up in any such way.

In order to generate the models you’ll need 2 sequences of 100 images taken at 3.6 degree intervals around the object in question (atm its fixed at 100, sucks i know,will be changing this very shortly), one for the texture and one for the mesh points. They’ll probably look very much like this:

The Input Images

The Input Images

Start up the splinesweep program and click “Load Images” and select all the 100 laser spline images, then click “Load Textures” and select all 1oo full colour images. Hit “Generate Model” wait for a bit, and a .obj , .mtl and .png images should be created in the folder that the splinesweep program is located in.

SplineScan Screenshot

SplineScan Screenshot

There is one pretty major limitation at the moment that I’ll probably get round to fixing within a week, currently the program assumes the centre of rotation of the platform to be at point that’s sort of at the middle of the image, and unfortunately this can only be changed within the code.

A few notes on dependencies:

The program requires QT4 and OpenCV2.0, but OpevCV1.0 may work, all-though the program does expect to find the opencv libraries in /usr/local/lib as opposed to /usr/lib. Soon as Ubuntu 10.04  is released i’ll build a version that works nicely with things you can apt-get.

How the code works:

First a sobel filter is run on all the spline images to produce edge images, then a threshold is taken of all the images to produce a binary image. To produce the 3D points for the mesh a series of points up the height of the image are taken and moved along the length of the image until a maximum pixel value is found or the edge of the image is reached, if the edge of the image is reached the point is discarded. The 2D points for each image are then placed in a rotated fashion around a central 3D axis to produce the 3D point cloud.

Holes in the point cloud are then filled in and a surface mesh is calculated. The RGB values in the colour images of every corresponding 2D point are found then placed into an image to create the texture, and the mappings between the 3D points and points in the texture are calculated.

This is all then written out to 3 files, an obj file which stores the vertexs,faces, and texture UV coordinates, a .mtl file which lists and describes properties of the materials used to texture the model, and  a .png file which is the actual texture.

There’s probably a bunch of little things going on that I can’t remember but this is as near as damnit to what’s actually going on.

3D Scanner – Textured Models!

Here is the nodding monkey with his texture on.

Textured Monkey

Textured Monkey

As you can probably see the texture is not that detailed. Each of the small faces that make up the model is textured with only 4 pixels worth of information. I’m going to try and work out a way to get a more detailed texture using the images captured during the scan (there’s a hella lot of information being thrown away creating the texture…admittedly a lot of it is repeated info…but there’s definitely enough to get a way better texture).

Edit: Here’s an animated gif of the scanning process. The laser-line and lights should alternate every frame, but i couldn’t be bothered ordering the frames in the gif.

Edit 2: Mesh smoothed with Laplacian filter and a white balance performed on the texture. Some of the finer details of the scan are lost due to the filter, but it does provide nice smooth surfaces. The texture seems slightly twisted to one side for some reason.

3D Scanner – Nuther MiniUpdate

Started working on adding a texture to the generated models. To do this I’ve added an array of LEDs  to the inside of the scanner that can be turned on to illuminate the model via the serial port on the arduino. A full colour image is captured for every laser spline image, then for every point along the laser spline the corresponding rgb value from the full color is found. The rgb values for all the splines are then mapped onto a 2D image creating the texture.

I need to brush up on some 3D modelling theory and the .obj and .mtl file formats and I should be able to create fully textured 3D models.

For now here is the image of the texture I captured for the nodding monkey model I’ve been using.

Engine Rebuild

Not done much on any project the past week. Spent last weekend taking apart one of my spare moped engines, gonna build a racing engine methinks.

Have a few ideas for adding a texture to the 3D scanned models that I should hopefully get around to implementing this week. Will do a write up later on.