Skip to content

Lego Robotics Invention System on Ubuntu Linux

RCXThis is how I managed to get NQC working for the Robotics Invention System on my laptop, running Ubuntu 7.04 Feisty Fawn, with the USB Lego Infra-red Tower. Anything with a black background should be executed in a terminal.

  • Plug in your USB IR Tower
  • sudo mkdir /dev/usb/
  • sudo ln -s /dev/legousbtower0 /dev/usb/lego0 (Edit: For the latest versions of Ubuntu, the first path may need to be /dev/usb/legousbtower0, according to Scott.)
  • sudo chmod 666 /dev/usb/lego0
  • echo test > /dev/usb/lego0 (Look for a green light to flash on the IR Tower. If you see it, then all is well.)
  • Download the latest source of NQC from the NQC Website.
  • Put it in its own folder, and untar/gzip it: tar -xvzf nqc-[Hit tab to fill in the rest]
  • Open the Makefile: gedit Makefile
  • Remove the ‘#’ before this line: USBOBJ = rcxlib/RCX_USBTowerPipe_linux.o
  • Save and close the Makefile.
  • mkdir rcxlib/LegoUSB/
  • cd rcxlib/LegoUSB/
  • wget http://legousb.cvs.sourceforge.net/*checkout*/legousb/LegoUSB/drivers/linux/include/legousbtower.h
  • cd ../../
  • sudo make
  • sudo make install
  • export RCX_PORT=usb (You should also add this line to the bottom of the .bashrc file in your home folder: echo export RCX_PORT=usb >> ~/.bashrc
  • Try it out: nqc -msg 7 (You should see the green light come on on the IR Tower, and you shouldn’t get any message in the terminal.
  • If it works, you should be ready to use NQC! If you need to install the RCX Firmare, insert the Robotics Invention System CD, and run this command: nqc -firmware /media/cdrom/firm/firm0309.lgo
  • Download the test program: nqc -d test.nqc (This should put a program in slot 1 of the RCX which will just turn on Motor A.

Edit: Mike has a followup article where he explains how to set up the first three steps so they happen automatically when you plug in the IR Tower.

Kudos to this article for putting me on the right track.

9 Comments

  1. Great tutorial, helped me to fix a seemingly junked RCX.

    Monday, August 13, 2007 at 22:06 | Permalink
  2. andii wrote:

    Top Article.. well done! Its working =)

    Monday, October 8, 2007 at 9:18 | Permalink
  3. Saul wrote:

    Hi Trevor

    I have a lots of kid that want to learn robotics and we are using the lego system. The computers that the school gave are showing their age, badly. So i’m trying to have the system running in my personal laptop. The laptop is running Ubuntu 7.04 64bits. I follow the steps and I can echo to the tower but I can’t get nqc to send a message to the tower I get ” USB Tower not supported”.
    Any ideas where should I look to have this working?

    Monday, October 8, 2007 at 19:11 | Permalink
  4. Glen McCarthy wrote:

    Hi Trevor,

    Thank you for your article. It has helped me and my Yr9/10 robotics class (and certainly many others) to use linux with the rcx bricks.
    Thanks for including some Tony Campolo quotes. We rarely see him here in Australia. He is a challenging voice for anyone who is seriously trying to follow Jesus. I guess I’ll just have to read more of his books.

    God bless,
    Glen

    Sunday, November 25, 2007 at 6:02 | Permalink
  5. Stew Boling wrote:

    Hi, I’m trying t use NQC for my research project and I’m running it in kubuntu 7.04 which I downgraded to from 8.04 and I followed the directions and when I enter “nqc -msg 7″ I get “Could not open serial port or USB device
    ” Any advice would be greatly appreciated and thank you in advance

    -Stew Boling

    Tuesday, June 10, 2008 at 16:06 | Permalink
  6. Trevor wrote:

    Hi Stew,
    I haven’t used this in a while, but I believe the problem lies in this step:
    sudo ln -s /dev/legousbtower0 /dev/usb/lego0

    Basically, NQC expects the tower to be at /dev/usb/lego0, but Ubuntu puts it at /dev/legousbtower0. I would assume Kubuntu puts it in the same place, but if you figure out where it is, and edit the above command appropriately, it should work.

    Tuesday, June 10, 2008 at 17:20 | Permalink
  7. Stew Boling wrote:

    Hi Trevor,

    Ubuntu recently updated their udev package and the usb tower now mounts at /dev/usb/legotower0. the rest of the tutorial works! Thank you for this great tutorial, it has been a life saver.

    -Stew

    Friday, August 15, 2008 at 18:01 | Permalink
  8. Stew Boling wrote:

    Hi Trevor,
    I figured out how to make nqc use /dev/usb/legousbtower0 instead of /dev/usb/lego0 use a sudo gedit /rcxlib/ RCX_USBTowerPipe_linux.cpp and edit line #define DEFAULT_TOWER_NAME “/dev/usb/lego0″ to #define DEFAULT_TOWER_NAME “/dev/usb/legousbtower0″ and it will work whenever you plug in the tower

    Friday, October 10, 2008 at 15:25 | Permalink
  9. Alex wrote:

    Thank you very much for this, I just bought the RIS 2.0 off eBay, and thought that I’d made a bit of mistake when windows pooh poohed it, but thanks to you, I have it working (and programming it in Java too, but that’s another thing).

    So thank you for all your help, and for being so cute too!

    Tuesday, November 11, 2008 at 19:30 | Permalink

One Trackback/Pingback

  1. [...] + Robótica http://trevorcreech.com/blog/2007/07/15/lego-robotics-invention-system-on-ubuntu-linux/ http://www.roboticalivre.org/portal/ [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*