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]

LEGO NXT irc channel

It’s been ages since I’ve used irc, but someone asked the other day, so I registered #lego-nxt on irc.freenode.net. You can find me using the nick gr0k and the other developer of ruby-nxt is gunark. I can’t guarantee that I’ll spend much time there, but I’ll signon whenever I’m working on ruby-nxt.

If you don’t know what irc is, it’s a chat system. You need to install an irc client, or use a web-based one. If you’re on windows, mirc is popular. Linux users probably have X-Chat already installed. I use Colloquy on OSX.

Filed under  //   lego   mindstorms  

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]

Bluetooth Serial Port To NXT in OSX

Some people have been confused as to how to use ruby-nxt in OSX. Some of the confusion was that I had posted instructions which only allowed connection FROM the nxt to the mac where the mac is the slave. To use ruby-nxt you need to initiate a connection from the mac to the NXT where the mac is the master. Here’s some “simplified” step by step instructions:

  1. Turn on the NXT and make sure bluetooth is turned on. (you should see a bluetooth icon at the top left corner)
  2. Click the bluetooth icon in the menubar, select “Setup bluetooth device”.
  3. When it asks for Select Device Type, choose “Any device”.
  4. Select the NXT from the list, click continue.
  5. The nxt will beep and ask for a passkey, choose 1234, press orange button.
  6. click continue in osx, enter 1234.
  7. The NXT will beep again, press orange button to use 1234 again.
  8. The mac will complain “There were no supported services found on your device”. Don’t worry about that and click continue and then click Quit.
  9. In OSX click the bluetooth icon, select “Open bluetooth preferences”, you should see the NXT listed, select it, then click “Edit Serial Ports”.
  10. It should show NXT-DevB-1, if not click add, use Port Name: NXT-DevB-1, Device Service: Dev B, Port type: RS-232. Click Apply.
  11. You’re done! You should now have a /dev/tty.NXT-DevB-1

Filed under  //   lego   mindstorms   osx  

Comments [0]

Bluetooth Serial Port To NXT in Linux

I finally got around to playing with the NXT in linux with ruby-nxt. Since ruby-nxt currently only supports a serial port connection (hopefully a native bluetooth module will be ready soon), you have to use rfcomm to setup a serial device. Here’s how you do it (using ubuntu 6.06 and a linksys usb adapter)…

First you have to find the mac address of your NXT with the following command:

abuser@wraith:/etc/bluetooth$ hcitool scan
Scanning ...
        00:16:53:04:B3:46       NXT

Then sudo vim /etc/bluetooth/rfcomm.conf and add an entry like this:

rfcomm0 {
        bind yes;
        # Bluetooth address of the device
        device 00:16:53:04:B3:46;
        # RFCOMM channel for the connection
        channel 1;
        # Description of the connection
        comment "NXT";
}

Then restart bluetooth with a sudo /etc/init.d/bluez-utils restart.

Then to verify it’s setup, run rfcomm and you should see output like this:

abuser@wraith:/etc/bluetooth$ rfcomm
rfcomm0: 00:16:53:04:B3:46 channel 1 clean

You should now have a /dev/rfcomm0 that you can use with ruby-nxt. The first time you run a ruby-nxt program, it might pop up a message for the PIN, just enter 1234.

If you want to setup a connection FROM the NXT to your computer, (where your computer is a slave to the NXT where you can send BT messages from a program running on the NXT to your computer) follow these instructions.

Similar instructions for windows here and osx here.

Filed under  //   lego   linux   mindstorms  

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]

Vacation and ruby-nxt

I haven’t had much time to work on ruby-nxt because I was away on vacation (cruise to alaska). While I was away, Matt Zukowski has expanded it adding some more higher level functions and setup a rubyforge project. I will be moving development there instead of my local subversion repository, so make sure you switch to it if you want the latest version. Now that I’m back, I plan on spending a lot more time on it.

Filed under  //   lego   mindstorms   ruby-nxt  

Comments [0]

Mindstorms NXT Bluetooth on OSX

Media_httpstaticflick_hjhxb

Lego released the Mindstorms NXT Developer Kit today! I was bummed when I found out that the software that comes with it for OSX is PPC. Apps running under Rosetta are unable to access bluetooth so I couldn’t play with in on my Macbook Pro. Now that the dev kit is available I plan on writing a ruby module to communicate with the NXT via bluetooth. First I had to figure out how to access it via a bluetooth serial port.

When I first got my NXT and found bluetooth no worky in NXT-G, I tried creating a serial port and connecting to it. It would connect, and show up as being on connection 0 on the NXT and no matter what I did, I couldn’t get a message to show up in OSX. Connection 0 means the NXT thought it was a slave. It should still be able to send messages to it’s master, yet I get nothing. Connections initiated on the NXT to the computer always came up Line is Busy.

I finally made a breakthrough today. I was doing some research and found that you can create an incoming bluetooth serial port and then connect to my computer from the NXT. Here’s the steps:

  1. Pair the NXT with OSX.

  2. Go into the Bluetooth Preferences, Sharing tab and Add Serial Port Service. Give it a name (I made it NXT-Master). Set Type to RS-232. This will create a /dev/tty.NXT-Master device.

  3. Open the device in OSX (this is important, otherwise you’ll get a Line Is Busy message on the NXT) Just doing a cat /dev/tty.NXT-Master in a terminal will do it.

  4. On the NXT, goto Bluetooth, My Contacts, Select your computer, Connect to whatever connection number you want.

  5. Run a program on the NXT that sends a message to whatever connection number you chose.

  6. Woot! The message should show up in terminal.

Filed under  //   lego   mindstorms   osx  

Comments [0]