ruby-nxt in MacTech Magazine

Posted by Tony Buser Fri, 13 Jul 2007 20:11:00 GMT

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! :)

LEGO NXT irc channel

Posted by Tony Buser Tue, 05 Dec 2006 00:19:00 GMT

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.

ruby-nxt 0.8.1 - Finally available as a Gem 4

Posted by Tony Buser Sat, 04 Nov 2006 04:05:00 GMT

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 ;)

NXT Search Engine

Posted by Tony Buser Sat, 28 Oct 2006 03:39:00 GMT

(no, it's not a search engine running on an NXT) I've been playing around with Google's new Co-Op system which basically allows you to create your own search engine that only searches a certain list of websites. (ala Rollyo) So I've put together an NXT search engine that indexes a lot of NXT blogs and a few api documentation sites. It has a home page here, but the url isn't very friendly. (hope they work on changing that) They have a system that lets you easily embed it into your own website, but it messes up the layout of my site. You can also use this search box to give it a try:

It currently searches the following websites:

www.juju.org  
ruby-nxt.rubyforge.org  
www.philohome.com  
forums.nxtasy.org  
mindstorms.lego.com  
www.nxtasy.org  
thenxtstep.blogspot.com  
www.mindsensors.com  
nxt.ivorycity.com  
lejos.sourceforge.net  
nxtsharp.fokke.net
www.nxt-mindstorms.com
www.astolfo.com
www.hitechnic.com
www.ortop.org
www.nxtbot.com
www.nxtclub.com
www.motocube.com

Let me know what you think and if you have any websites you think should be included. You can also register with the co-op and volunteer to be a contributor.

Update: If you volunteer, please send me an email or at least fill out your profile so I know who you are. A few people have sent requests, but I'm a little hesitant to authorize blank profiles.

Bluetooth Serial Port To NXT in OSX 3

Posted by Tony Buser Sun, 22 Oct 2006 21:14:00 GMT

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

Bluetooth Serial Port To NXT in Linux

Posted by Tony Buser Sun, 22 Oct 2006 17:23:00 GMT

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.

ruby-nxt 0.8.0 4

Posted by Tony Buser Thu, 28 Sep 2006 02:53:00 GMT

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! :)

Vacation and ruby-nxt

Posted by Tony Buser Sat, 09 Sep 2006 23:54:00 GMT

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.

ruby-serialport/nxt on Windows

Posted by Tony Buser Thu, 17 Aug 2006 02:34:00 GMT

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...

ruby-nxt 6

Posted by Tony Buser Mon, 07 Aug 2006 03:11:00 GMT

I made a lot of progress this weekend on ruby-nxt. I got most of the Direct Commands completed. Update: ruby-nxt can now be found at rubyforge.

It makes programming the NXT as simple as:

require 'nxt.rb'

NXT.exec("/dev/tty.NXT-B") do |cmd|

  puts "Battery Level: #{cmd.GetBatteryLevel[0]/1000.0} V"

  cmd.PlaySoundFile(true,"Good Job.rso")
  sleep(3)
  cmd.StopSoundPlayback

end

Once I get it a little more polished, I plan on also creating a Ruby On Rails plugin. Forget Microsoft Robotics Studio. ;)

Older posts: 1 2