Notes on Life, ‘Puters and Hawaii

Using Ruby to Control Lego Mindstorms NXT

Playing with my son on Lego NXT requires me to get Ruby in the mix just for fun. Here is the install notes that I used to get everything going. Once you get the communication working, you may want to install the ruby gem ’statemachine’ and learn that too. It’s useful for robotics.

cd /tmp

# Ruby Serial
svn export http://ruby-serialport.rubyforge.org/svn/trunk ruby-serial
cd ruby-serial
ruby extconf.rb
make
sudo make install
cd ..

# Install libusb
svn export https://libusb.svn.sourceforge.net/svnroot/libusb/trunk/libusb libusb
cd libusb
sh autogen.sh
./configure
make
sudo make install
cd ..

# Ruby USB
svn export svn://svn@svn.a-k-r.org/akr/ruby-usb/trunk ruby-usb
cd ruby-usb
ruby extconf.rb
make
sudo make install
cd ..

# Ruby NXT
gem install ruby-nxt

# Try it in IRB
require 'rubygems'
require 'nxt_comm'
comm = NXTComm.new
comm.connected?
comm.get_device_info
comm.get_firmware_version

Comments are closed.