Dome Raising

EFFALO designed these nifty geodesic dome connectors.  Since you need a ton of these parts, they started a distributed manufacturing experiment to crowdsource the printing of a dome.  They're offering $2 per connector and whoever sends in the first usable part gets to pick a microfunding project to donate $20 to in your name.  I thought it would be pretty cool to make a personalized part to differentiate my contribution.  So since the connectors were already designed in OpenSCAD, it was pretty easy for me to add my OpenSCAD bitmap module and emboss my initials and my logo on top.  I released my mashup script so others could do the same with their initials.

I ended up being one of the first people to send some - I tied with someone else.  So I got to choose a project to donate $10.  I decided to send it to the OpenPCR project.  OpenPCR is working on making an open source Polymerase Chain Reaction machine for under $400.  Commercial machines cost $4,000 or more.  It could help do for biotech what MakerBot is doing for 3D printing.  I don't know if I'd ever make one myself, but I might just so I could feed it into an Open Gel Box and take pictures of my DNA in my basement.  HA!  How awesome is that?  There is a great video overview.

Filed under  //   makerbot   openpcr   openscad   programming  

Comments [1]

3D Text and OpenSCAD Bitmaps


Recently there was a challenge posted to the MakerBot Operators list to come up with a way to create 3D logos.  Some people discussed ways of taking an image and automatically turning it into a 3D design.  So I decided to take a break from Mendel production and started looking around for a way to do just that.  I found a cool utility called autotrace that can take a bitmap and convert it into a vector graphic format including DXF.  I thought cool, I could use the output and feed it into OpenSCAD which can extrude 2D DXF drawings into 3D shapes.  I could even automate it all on the command line by generating an image using ImageMagick and any true type font like so:

 

convert -size 400x400 -background transparent -fill black -stroke black -gravity center -kerning -30 -font Helvetica-Bold caption:'Tony Buser' foo.png

 

autotrace --output-file=foo.dxf foo.png

 

/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -s foo.stl foo.scad

 

Unfortunately, that didn't work out...

 

You see, OpenSCAD doesn't support just any old DXF file.  It only supports very simple DXF files and unfortunately the output from autotrace isn't simple enough.  So I could either add support to OpenSCAD for POLYLINE or change autotrace to output a different flavor of DXF.  I'm not really prepared to tackle either option... then someone mentioned making a set of simple block fonts in DXF that we could import into OpenSCAD.  That gave me the idea to try and implement a bitmap font system in OpenSCAD code itself.

I had never really used OpenSCAD much, but once I got over the limitations (like no string handling, inability to like ya know properly set the value of a variable, ugh) I came up with a pretty good bitmap module.  It works by passing an array of 1's and 0's and it generates cubes of a specific width and height in a grid pattern and then combines them into a single shape.  Then I went looking for a set of 8bit fonts and settled on the good old Atari font.  I probably should have wrote a program to generate the arrays from the image data... but I ended up encoding each character by hand.  I actually found it kind of relaxing to do while my MakerBot buzzed and whirred in the background.  Also kind of reminded me of making ascii art back in the BBS days.  Another cool thing is that I made it easy for anyone to create their own bitmap arrays and the arrays can be of any dimension.  The 8bit fonts are 8x8 matrixes, but you could make smoother fonts if you want at 16x16 or 64x64 cube "pixels".  (although bitmaps that large might make OpenSCAD choke, but theoretically there's no limit)  Someone even suggested a braille font set which would be really cool.

I've checked it all into github and you can also find it on Thingiverse as well as two examples showing how it can be used for a Parametric Name Tag and Parametric Alphabet Block.  It's been a "Featured Thing" on Thingiverse and has also been on the MakerBot Blog!

I have some ideas I'd like to work on such as:
  • a personalized parametric clip-on name tag for your MakerBot (clip onto the edge of the body of your bot)
  • "height maps" Instead of just 1's and 0's each bit in the array you could specify the height of the cube pixel.  Could also then write a script to convert a grayscale image into an array, like a terrain height map
  • a web service where you can type a message and have it spit out an STL file for you to print, maybe a web based bitmap editor 

But for now, I'm going back to printing RepRap Mendel parts...

Filed under  //   makerbot   openscad   programming  

Comments [1]

Importing Typo to Tumblr

I’ve decided to start blogging again and my old blog at http://juju.org was running an ancient version of Typo.  For various reasons, I’ve decided I don’t have the time to administer a whole web server just for my little blog.  So I decided to move to a hosted service and settled on Tumblr.  (I also decided to finally put away childish things and register http://tonybuser.com)  Unfortunately, there’s no way to import a Typo blog to Tumblr.  So this has given me a good excuse to finally play around with the HTTParty and Hpricot ruby gems.  During my adventures in trying out different blog services and importing all my old posts, I had already exported my Typo blog to Wordpress XML format.  Then to import a Wordpress file to Tumblr was simple.  Here’s the script:

#!/usr/bin/env ruby

require "rubygems"
require "hpricot"
require "httparty"

class Tumblr
  include HTTParty
  base_uri 'www.tumblr.com'
  
  EMAIL     = "[YOUR_EMAIL]"
  PASSWORD  = "[YOUR_PASSWORD]"
end

doc = open("wp.xml") { |f| Hpricot(f) }

(doc/"item").each do |item|
  params = {
    "email"     => Tumblr::EMAIL,
    "password"  => Tumblr::PASSWORD,
    "type"      => "regular",
    "format"    => "html",
    "generator" => "Ruby + HTTParty Import Script",
    "date"      => item.at('wp:post_date').innerHTML,
    "title"     => item.at('title').innerHTML,
    "body"      => item.at('content:encoded').innerHTML,
    "tags"      => (item/"category").collect{|category| category.innerHTML}.join(","),
    "group"     => "[YOUR_ACCOUNT].tumblr.com"
  }

  puts Tumblr.post("/api/write", :body => params).inspect
end

Filed under  //   programming   ruby  

Comments [0]

Find Intersection of Two Date Ranges

Say you have a database of events that span multiple days and you want to filter all events between a certain date range. At first I had this giant mess of this AND that OR this AND that… until I found this:

NOT (range1_start > range2_end OR range1_end < range2_start)

That freakin’ rules.

Filed under  //   programming   sql  

Comments [0]

ruby-nxt in MacTech Magazine

Check this out, MacTech did an article on using the LEGO MINDSTORMS NXT on a mac and talked about ruby-nxt. Even linked to my website. Unfortunately, they spelled my name wrong! :)

Filed under  //   lego   mindstorms   press   programming   ruby   ruby-nxt  

Comments [0]

Ruby 1.8.6 and Oniguruma on OSX

I’m working on a project that requires some complicated regexes and for the first time actually needed to do a look-behind. Unfortunately, ruby 1.8.6 doesn’t support it. You can accomplish it using Oniguruma and Ruby 1.9 will come with it. There’s a gem but then you have to specficially reference it and might require code changes when 1.9 comes out(?), not to mention the fact that it’s a pain in the ass to install on osx. So I set out to figure out how to recompile ruby with it patched in. The only info I could find in english was for ruby 1.8.5. Finally figured it out, here’s how (also works on linux, not just osx):

curl -O ftp:// ftp. ruby-lang. org/pub/ruby/1.8/ruby-1.8.6.tar.gz
tar xzvf ruby-1.8.6.tar.gz

curl -O http:// www. geocities. jp/kosako3/oniguruma/archive/onigd2_5_9.tar.gz
tar xzvf onigd2_5_9.tar.gz
cd oniguruma
./configure --with-rubydir=../ruby-1.8.6
make 186

cd ../ruby-1.8.6
./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local --enable-shared
make
sudo make install

ruby -e "puts Regexp::ENGINE" # should return Oniguruma

Filed under  //   osx   programming   ruby  

Comments [0]

Ruby on Rails OSX Console Aliases

I found that every day when I goto work in the morning I do the same things whenever I go to work on a rails project:

  1. open firefox
  2. open iTerm
  3. cd ~/Code/railsprojectx
  4. mate .
  5. script/server
  6. open another tab in iTerm
  7. svn update
  8. goto http://localhost:3000

Sure it only takes a few seconds, but it wasn’t very DRY. :) I figured I could create a shell alias to basically reduce all that to a single command. I also thought I’d finally start giving mongrel a try. So this is what I came up with for an rdev command (along with a bunch of my other rails related aliases):

alias rdev='svn update;mate .;mongrel_rails start -d;sleep 2;open http://localhost:3000;tail -f log/development.log'

alias ss='script/server'
alias sc='script/console'
alias sg='script/generate'
alias sp='script/plugin'
alias sr='script/runner'
alias rt='rake test'
alias rtu='rake test:units'
alias rtr='rake test:recent'
alias mr='mongrel_rails start -d'
alias mrs='mongrel_rails stop'

Just stick that in your ~/.profile file and either reopen your console or run:

. ~/.profile

Filed under  //   osx   programming   rails   ruby  

Comments [0]

ruby-nxt 0.8.1 - Finally available as a Gem

I’ve been pretty busy lately so haven’t had much time to work on ruby-nxt. However, tonight I had some time to finally get it packaged into a gem! The main reason it took so long is because of some kind of weird bug with requiring ruby-serialport and rubygems resulting in the following error:

NameError: (eval):1:in `private_class_method': undefined method `create' for class `Class'
        from (eval):1
        from (eval):1
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from (irb):2

For some reason, it doesn’t like rubygem’s custom require code. So I got around it by doing a Kernel::require “serialport”.

Unfortunately, there’s really no way to include ruby-serialport in the ruby gem, so you’ll still have to download and install that seperately. Once serialport is installed, all you should have to do is sudo gem install ruby-nxt. Then in your code require “rubygems” then require “nxt_comm” or require “nxt” depending on how you want to use it.

The 0.8.1 release doesn’t have anything new in terms of features, however you might want to take a look at examples/drb_server.rb ;)

Filed under  //   lego   mindstorms   programming   ruby   ruby-nxt  

Comments [0]

Ruby NXT Bluetooth Data Logger

I just finished writing a simple ruby script that listens for messages from a LEGO Mindstorms NXT robot on a bluetooth serial port and print out the messages in a comma delimited format with a datestamp, mailbox the message was sent to, and the message itself.

I’ve only tested it on OSX so far, but it should work on linux and windows so long as you have ruby and the ruby-serialport module. It’s a little rough at the moment and probably buggy. I couldn’t find info on the incoming message bytecodes in the NXT Dev Kit. Found the info in “Appendix 2 - LEGO MINDSTORMS NXT Direct commands.pdf” pages 5 and 9. There doesn’t seem to be anything in the message header to indicate what type of message it is (Text, Number, or Logic), so I had to kind of fudge it. If the info is in the docs, please let me know. I put some comments in the code describing the different bytecodes I was able to figure out.

You can always download the latest version of nxtlogger.rb using this link.

Update 2006-08-05: Made the code much cleaner. I’ve never worked with low level binary data before. :)

Instructions for connecting NXT to OSX via bluetooth.

One step closer to chunky robotic bacon!

Filed under  //   programming   ruby   ruby-nxt  

Comments [1]