CloudSCAD Blog

I created a blog just for CloudSCAD at http://blog.cloudscad.com

And oh yeah, here's a video of CloudSCAD on an iPad.  Sometimes I even impress myself!

Filed under  //   cloudscad   makerbot   rails   reprap   ruby   rubyonrails  

Comments [1]

CloudSCAD

This is a little premature, but I wanted to share some progress I've made today on an idea I've been thinking about for a while now.  When I'm not hacking on 3D printers, my day job is web development so it's about time I start using my real skills for this stuff.  I call it CloudSCAD - it's OpenSCAD for the web.  It lets you write, share, mashup, and customize parametric 3D models using the OpenSCAD scripting language all within the browser and doesn't require anything to be installed locally.

As you can see in this screenshot, one of the cool things it does is parse the OpenSCAD script looking for parameters.  Then presents those variables in a friendly HTML form so that people can modify an object for their needs and click a button to download the customized STL file suitable for printing on a 3D printer.  They don't have to know anything about OpenSCAD, install anything, or touch a line of code.  Also, the author of the script doesn't have to do anything special - just put some well placed comments in their code.

What you can't see is the edit page.  I'm using Bespin to provide a syntax color coded editor for writing scripts.  I hope it will eventually include code completion and a few other things.  In some ways this is (or could be) even better than the editor in OpenSCAD itself.

There is a REST api.  For instance, you'd be able to download this script by going to http://cloudscad.com/scripts/1.scad and the stl output by going to http://cloudscad.com/scripts/1.stl and say you wanted the hole to be 8mm in diameter you could say http://cloudscad.com/scripts/1.stl?hole_diameter=8 Eventually you may even be able to say http://cloudscad.com/scripts/1.gcode, but I'm getting ahead of myself...

Like I said, this is pretty premature.  I've registered CloudSCAD.com but there's nothing there for you to see yet.  Everything you see in that screenshot and what I've described is finished, though.  Not too bad for one days work.  ;)

Filed under  //   makerbot   openscad   rails   reprap   ruby   rubyonrails  

Comments [22]

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]

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 0.8.0

We’ve made quite a lot of progress on ruby-nxt. The new version is a pretty complete implementation of the NXT direct command set. Almost everything is pretty well documented now, too. One of the more interesting things I’ve been working on is a high level api based on the “blocks” in NXT-G. So if you’re familiar with the way NXT-G works, you should be able to pick it up pretty easily with code such as:

t = Commands::TouchSensor.new(@nxt)
t.port = 1
t.action = :pressed

while t.logic == false
  puts "Hold down the button..."
  sleep(0.5)
end

Now that it’s pretty complete and usable, I think I’ll finally get around to making a Ruby on Rails plugin, which was the original reason I started all this! :)

Filed under  //   lego   mindstorms   ruby   ruby-nxt  

Comments [0]

ruby-serialport/nxt on Windows

My MacBookPro has been acting up (randomly deciding not to boot) So I sent it back to Apple for repairs. In the meantime, I’ve been stuck in Windows which has kept me from working on ruby-nxt because the ruby-serialport module requires compilation. This is not an easy thing to accomplish in Windows. I tried in vain to get it to compile using the free MSVC++ Express version. Apparently MSVC++ version 6 is required. However, I did manage to get it working using Cygwin.

Cygwin is a Linux-like environment for Windows. It’s a little confusing to install and just plain feels weird, but it gets the job done. Basically when you install Cygwin, navigate down the tree of packages and install the following under Devel: gcc, make, and ruby. Add c:\cygwin\bin to your path. The ruby that comes with cygwin is slightly borked. It sets RUBYOPT=-rubygems for some reason. So make sure you “SET RUBYOPT=” to clear that out. Then download ruby-serialport and install it normally. (ruby extconf.rb, make, make install)

Now, when you pair your NXT via bluetooth, it should have created a COM4 Outgoing port on NXT ‘Dev B’. Cygwin emulates the windows com ports to virtual /dev devices. COM1 = /dev/ttyS0. So in my case, the NXT is on COM4 therefore in ruby-nxt you want to connect to /dev/ttyS3.

During this whole fiasco I came this close to wiping this computer and installing Linux on it. Man I miss my MacBook…

Filed under  //   ruby   windows  

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]