Posts

Union of polygons

Image
I should have settled with a graphics library of some sort, but I did not. So now I have all sorts of problems some of these libraries have one function call away. Unfortunately many library creators do expect to be paid if you do a commercial product using their code. I find this to be fair, but not knowing how much or for how long just stir me away. My current problem is a simple one: I have collection of 2D polygons and I want to obtain the union of all of them. Sometimes it is a bigger polygon, sometimes a set of disconnected areas. It turns out that non-convex polygons make the solution harder than I expected. As I am writing code in Processing (Java) I could used JavaGeom , but it is based in GPC library . I could use JTS library , but I was lost in the process of learning how to integrate it with my code, but this was before I learned the problem took me longer to get it coded than learning another library. You have been warned! Update: If you can settle with int...

Another week, another problem

Image
The project I am working on at the moment requires solving several computer graphics problems. I mentioned a while ago the polygon offsetting problem. Today my problem is about placing polygons on pages to be printed. I want to make the listing as short as possible, thereby packing the polygons in fewer pages is desired. Trying not to reinvent the wheel I googled around first. Of course the first problem of the googling thing is to figure out what is the popular name of the problem you are interested on (and believe me, I am yet to find an "original" problem never thought and wrote about it before). My first searches suggested Cutting stock problem , but  it was not exactly my case. It is a pity as in 2007 a dynamic programming solution was published . So moving on I found the best fit to be the Bin packing problem .  Again, an NP hard problem. Wikipedia article suggested the heuristic of the first fit algorithm , that is known to provide good (but not optimal) solution...

Mending my mistakes

Image
While I am not a king (inside joke for Spaniards only) I do make mistakes quite often. One of them was not to disconnect my RAMPS-controlled 3D printer from the computer and mains supply for a quick solder job (just one pin of heating resistor was loose just before starting a print ...). Unfortunately, my trustry JBC solder of the last twenty years was not properly isolated anymore and I had a big flash and all the house lights went down. When I restored the power the computer was booting up happily, the printer power supply light was on but the printer was dead and the computer was unable to detect the printer anymore. All the lights on the board and on the Arduino Mega were off too and my system shown a warning message that USB port was disconnected for excessive power consumption: no good news at all, but at least I learned the USB port was not completely dead. I removed the RAMPS board from the Arduino Mega, connected it to the USB cable and then the lights come back on, su...

Of polygon offsetting

Image
Last week I have been researching about a task I initially did not even know the name: Polygon offsetting. A polygon offset (in case you ignored it too) is a computer graphics primitive (though it can be done by hand too) that given a polygon will trace a inner or outer version of it that it is either totally contained inside the polygon or that it will contain it entirely (if you want an outer offset) whose perimeter will be at a constant distance from the perimeter of the initial polygon. And given that I seriously doubt that my explanation is good enough, here you have an image (of an inner offset, gray-line perimeter): I was looking for an available implementation of this process, as I wanted to be able to use it for an ongoing project. This time Google did not helped much and though I was able to find the question I borrowed the picture above from and that CGAL library did have polygon offset as one of the functions or that there was Clipper library or a Python implement...

The not so intuitive use of an IMU

Image
A recent project required acceleration measurements to study a person's gait. I thought this could be done easily with one of the many MEMS (MicroElectroMechanical Systems) devices available in the market under the name of IMU (Intertial Measurement Units) or just accelerometers. I settled with the cheapest acceloremeter I found on eBay with an I2C interface to connect it to a Funnel IO powered by a rechargeable Lithium battery. Funnel IO (or FIO in short) is an Arduino-like board that includes a USB-powered battery charger plus an XBee module interface on board. It can be programmed wirelessly but this proved to be a real PITA to get it working (and even after that, it does not work reliably). Once I got some code grabbed from Arduino forums to read my sensor (MMA7660FC from Freescale) I was a bit shocked with the results. My sensor was a 3-axis accelerometer and  I was expecting a measurement of X=Y=Z=0 on my first test with the sensor static. I was wrong. I shoul...

Wireless 3D printing

Image
Last week I had a "USB cable incident" with my Prusa (computer and printers are on different tables in my office). It was entirely my fault as I walked across the USB cable and I almost threw my printer to the floor. As a result, the ferrite torus I put in the USB cable to prevent EMI problems broke. Without it, I know prints may interrupt anytime due to interference. While on eBay looking for a replacement, I realized that a Bluetooth module was costing less than $15 now. So I thought I could give it a chance to the idea of operating my printers wirelessly.   Later, I learned of an even cheaper module at $6.60 , but this one is 3.3v only (which is ok if you are using this voltage for your Arduino, but I am using 5v). A quick look at Sprinter firmware and Arduino Mega and RAMPS board specs revealed that Serial2 port using 16 (TX) and 17 (RX) pins was easily available on the ext4 connector of RAMPS board. And so was GND and +5V. Making it very easy to connect the Bluetoot...

Arduino RFID

Image
This time I am interested on a particular application of this technology: My university has moved to RFID picture IDs for students and I was curious about how difficult it was to read the cards from an Arduino board. Our system is using 13.56 MHz cards, so I ventured into eBay territory. Almost anyone can type "Arduino RFID" there to get plenty of cards that allow you to read (and write) RFID tags/cards. For those of you living in a cave, RFID is a wireless technology that allows you to both power and interact wirelessly with a card or tag that contains a digital unique identifier that optionally may include some rewritable memory too. Tags or cards themselves do not have nor need a battery but they contain a microchip and a coil to gather energy from nearby readers. That means that the card and the reader need to be pretty close for this to work (that is why the technology is dubbed as NFC or Near Field Communication). After buying one card and waiting the usual two w...

Would you print me this equation?

Image
I had a visit this week of a teacher interested on creating 3D prints out of equations. The thing is that most of the tools I used need to have a polygonal mesh in the form of an STL file in order to print an object. I have found a couple of interesting tools. On one hand, Wolfram Alpha allows you to download any generated volume out of your equation, but you need to have PRO account. It seems you can have free PRO account for a couple of weeks, but later you have to pay a monthly fee. I did not explore that route any further. The other is a piece of software called K3DSurf that does the job for free. It is interesting though it did not work in my Mac, not even after installing Qt3, but it worked in Windows XP. It is worth a try!

Misleading HP marketing

Image
Not one but two friends brought to my attention the apparently innovative new product by HP touted as a 3D scanner and printer  HP TopShot LaserJet Pro M275 . I was surprised by the marketing information and curious to see what this device was capable of. If you've followed my blog, you've read about my late interest on 3D scanning and printing, so a 3D scanner that was being made by the biggest printer maker seemed like a big deal and maybe the signal of new devices to come. However, after cutting through the marketing campaign, I was able to read some of the details of what the device can really do . That was the disappointing end of the history: what HP Topshot technology is about is not 3D scanning but to take pictures of objects. Do I really need to say that of course the objects you can take pictures from can be 3D objects? Are not all the objects we use 3D? Ok, maybe you can claim that paper pages are not 3D (we can argue on the scale of it). But to me, HP mar...

Online slicing with Autodesk

Image
I mentioned a while ago the cool software by Autodesk 123D Make that enable those with access to a laser cutter to create 3D objects from cardboard slices. The problem was that the software was only available for Apple computers. Now there is an online version that does the job no matter what operating system you use. The image shows a cardboard version of my happy new year design you can get on Thingiverse.com Update: A big oops if you use Linux ... (I do).

Testing PCL 2.0 Kinfu_app

Image
I borrowed another graphics card from a friend and this time it was the right one: Nvidia GTX 560 Ti with 1GB of RAM so I was able to test drive the new open implementation of the Kinect Fusion. First result is really promising. A couple of times I've got out of memory errors when starting the application but it was unclear to me whether it was main system RAM or the graphics' card internal memory. Pressing 3 you get the current point cloud written to disk. I am really shocked by the accuracy of the real-time results. I am getting around 20 fps. Definitely worth trying, but remember you'll need a powerful power supply too. I borrowed a 1.000 watts PC supply, sweet.

Testing Kinfu (or not)

Image
Once I realized all the work done for compiling PCL 2.0 was useless with my current graphics card I mentioned to a colleague the problem who was kind enough to lend me a Nvidia FX 5800 CUDA-enabled graphics card with 4 GB of RAM. I thought it was beyond the requirements of Kinfu so I did not bother checking it out before doing the installation. First problem was that this card hardly fit inside my computer. Later I found out my power supply just lacked the proper connectors to power that graphics card. I asked for help and I have got a 1000W PC power supply. This one has all the connectors needed but I am not fitting it inside my computer box. Once I was convinced of the right way of connecting the 8 pin PCI-express additional power socket, which was all but obvious to me, I fired up the system and it came up nicely. But, once again, I was defeated by the hardware: It turns out this board is not a good match for running Kinfu either. Though it has 250 cores, it lacks the computin...

Kinect Fusion open sourced!!

Image
I was impressed when I saw the results presented in SIGGRAPH'11 about Kinect Fusion by a group of people from Microsoft Research. They manage to get a fantastic real-time scene scene registering using a software they named Kinect Fusion. A couple of papers were published explaining the system architecture and some videos shown the great performance they were obtaining. Today I have learned that an open source version is being built around the Point Cloud Library and the sample video looks equally promising. But development is only going to be supported on the upcoming 2.0 version of the library. I am going go give it a try as soon as I manage to compile the whole thing .   Ouch: After fighting with CUDA install (driver, tools, sdk) plus VTK library that was not installed plus some more fiddling with cmake and ccmake I manged to compile the current version of PCL2.0 but to no avail, as kingfu_app is not happy with my oldish video card (GF8400GS) and I get this lovely mess...

Software for 3D scanning using Kinect

Nicolas Burrus ' company has been kind enough to make available software for 3D scanning using a Kinect device that anyone can use for both Windows and OSX. What you obtain is a colored point cloud and not a mesh, but using software like meshlab you can turn that into triangular mesh. The way you use this software is by handholding your Kinect and moving it around the object or room you want to scan as if you were painting all the space. The point cloud is growing larger every time you move to a different area of the scene or object. Result is not as impressive as Kinect Fusion demos but, contrary to the former, this one is available. I guess the will keep on improving the system to obtain better spatial resolution with less noise.

Direct drive extruder

Image
Once I have got my Prusa Mendel 3D printer working, I have started to look around for improvements. The thing I was less happy with was the clunky extruder , made of a geared drive with printed gears. People in the forums mention it has a limited life of maybe one hundred hours before one or more teeth give in. I thought a direct drive was an obvious choice only if extruder stepper might have enough torque. Then I learned that Orca v0.3 is using a direct drive using a brass insert . I looked for available designs on the Thingiverse for NEMA 17 motors and I have found this one . With some changes I have made it work. But not before I replaced one StepStick by a Pololu stepper driver on my RAMPS board. The reason is that to achieve the required torque, the motor needs to be driven slightly above the 1A limit of StepSticks. The other required change is to add some cooler to the A4988 chip so it can properly dissipate the additional heat. I guess 3mm filament i...

Arts exhibit

Image
I've been quite busy lately so I've not been posting news but doing new stuff. A few weeks ago a new exhibit it the City Museum of Valencia by local artist Rubén Tortosa stated and one of the pieces was this one, which I designed and programmed. It is an interactive installation that grabs the visitor silhouette and then it draws it onto the wall at a random location. Drawing accuracy is not intended (or so I was told by the artist). We went for a very simple design, based on my vertical plotter , and a Kinect device was used to gather the images. You can see below a sample of some the drawings of the very first days of the exhibit. The exhibit will be open till the end of this year and there is no entrance fee. Together with the installation there is a set of interesting pictures I have nothing to do with. Update: Wow, we're on the Arduino blog now. Arduino code is quite unremarkable as we use a couple of Pololu motor controllers driving the stepper motors....

The beauty of OpenSCAD

Image
All the CAD software I have used in the past was based on a GUI. AutoCAD does include a language so you can type commands and create macros too. But the way OpenSCAD is surprising (to me) and very useful: You "program" the objects you want to create. It is all based on a scripting language and the concept of constructive solid geometry . You can define basic shapes, like cylinders, spheres or cubes and then operate them to obtain the design you need. You can experiment with this technology in Java3D too. Once you have created your design, you can save the result as a variety of file formats, including STL. STL format is supported by most 3D printing tools, including Reprap project software tools (and Skeinforge ). Many of the objects available in Thingiverse.com have been created this way.

Calibrating RepRap Prusa

Image
I thought my troubles were over once I've got all the parts for building my 3D printer, including the replacement for some defective parts. As usual, I was wrong: Once I have finished building it and tested all the electronics it comes the moment to select a working firmware. There are several choices for RAMPS hardware but I selected Sprinter firmware as it includes acceleration control plus many people use it. But firmware alone is not complete till you've added all the different adjustment parameters so your hardware works together with the firmware the expected way (ie. a 10 mm move in the G-CODE causes a 10 mm move in your printer). I was excited because once I tested with a thermometer that the hot-end heating and temperature reading was working nicely I thought it will be easy. I used RepSnapper for this basic tests, and next I tried to print a text object. Result was ok, but measurements were still a bit off. But when I attempted the design in the center of this p...

Finishing my Reprap Prusa 3D printer

Image
It's been a long wait to finish building my Reprap Prusa Mendel, to source all of the different parts and then to wait for some replacements of defective electronics. The building time has not been very long as I have had long waits in between, but I'd say it can be easily done over a weekend if you have all the parts. Now I have to configure it and to master into the use of the system. My total cost is near 500€ and I have chosen some hardware to be better than average, so I guess cost can be driven down a couple hundred euros if you really push it to the bare minimums. I do not have yet any printed samples to show you though. I can mention the companies I bought from that have given me a good service: XYZ printers (hardware), reprap-fab.org (plastic & extruder), RepRapWorld.com (electronics & PLA filament), Zapp Automation Ltd (stepper motors). One of the things that have worked for me that can allow you to save so cash is to use both, the stepper motors and...

A bit more RSA

I really don't like when I do not understand anyone's code, so it takes me a bit of effort till I do my own homework to create my own version of things I can understand. Being a teacher, I always find troubling not to be able to explain things to my students, so I used some time to create my very own RSA implementation. I've found a very good reference text here . My perl program takes three parameters data, encryption (or decryption) exponent and module and it returns the encrypted (or decrypted) version. As it uses BigInt library it should be happy dealing with any of your big numbers. You can find a Java implementation in the above mentioned text too. #!/usr/bin/perl use Math::BigInt; if($#ARGV<2) {print "Usage: exp, module\n"; exit 2;} $a = Math::BigInt->new($ARGV[0]); $b = Math::BigInt->new($ARGV[1]); $c = Math::BigInt->new($ARGV[2]); print "out=".($dec = $a->bmodpow($b,$c))."\n"; Contrary to what may look, bmodp...