Blog

2013/01/13

Lego Mindstorms NXT

Lego Mindstorms NXT comes with software that only runs on Windows. Since I use Linux this is of no use to me. After some trying and surfing I managed to get it working on Ubuntu 12.04. The information on the internet was not 100% accurate. This is why I will put my configuration here. Run these commands as root or with sudo.

addgroup legonxt
adduser <your-user> legonxt

Now create 2 files. /etc/udev/rules.d/45-legonxt.rules and /etc/udev/legonxt.sh.

/etc/udev/rules.d/45-legonxt.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="0694", ATTR{idProduct}=="0002", GROUP="legonxt", MODE="0660", SYMLINK+="legonxt-%k", ACTION=="add",
 RUN+="/etc/udev/legonxt.sh"

Put this in one line. I cut it in 2 so it fits the pagewidth.

/etc/udev/legonxt.sh

This file is executed after the Lego Mindstorms NXT is connected.

#!/bin/bash
#
GROUP=legonxt

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
    chmod o-rwx "${DEVICE}"
    chgrp "${GROUP}" "${DEVICE}"
    chmod g+rw "${DEVICE}"
fi

Now all you need to do is install the apropriate software to communicate with you NXT. I installed nbc and the 32-bit libusb library.

Remark

I re-installed my PC with Linux Mint. When I do all the above everything seems to work. The script /etc/udev/rules.d/45-legonxt.rules is called but the ${DEVICE} is not set. So I need to do the commands by hand. I hope that I will be able to solve this in the near future.