| 1 | This archive contains some useful scripts to get the |
|---|
| 2 | RWTH - Mindstorms NXT Toolbox for MATLAB running under Linux. |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | Scripts in this archive: |
|---|
| 6 | |
|---|
| 7 | * btconnect |
|---|
| 8 | Syntax of this script is: btconnect <NXTsMACorName> |
|---|
| 9 | The expression <NXTsMACorName> can either be the MAC address (i.e. 00:16:.....) |
|---|
| 10 | or the Name (i.e.: "My NXT") of the NXT brick that you want to connect to. |
|---|
| 11 | After a successful connection, the terminal will be blocked until hung up. The |
|---|
| 12 | toolbox is now ready to use! For further information see the online help (call |
|---|
| 13 | "btconnect --help"). |
|---|
| 14 | |
|---|
| 15 | * 41-legonxt.rules |
|---|
| 16 | This udev rule file is used to make sure that an NXT device |
|---|
| 17 | is ready to be used with USB and Bluetooth. See below in the USB section for |
|---|
| 18 | further explanations. |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | *** BLUETOOTH *** |
|---|
| 23 | |
|---|
| 24 | To get Bluetooth up and running with the NXT and our toolbox, the bluez |
|---|
| 25 | bluetooth stack must be installed. In order to do so, you should use your |
|---|
| 26 | packet manager (e.g. Debian's apt-get) to retrieve the following packets (or |
|---|
| 27 | similar, depending on your distribution): |
|---|
| 28 | - bluetooth |
|---|
| 29 | - bluez-utils (should be included in bluetooth anyway) |
|---|
| 30 | - dbns |
|---|
| 31 | - dbns-x11 (includes the bluetooth-applet) |
|---|
| 32 | |
|---|
| 33 | Once properly installed, you should execute the following command in a terminal |
|---|
| 34 | window (assuming you use the Gnome Desktop environment): |
|---|
| 35 | |
|---|
| 36 | bluetooth-applet --singleton |
|---|
| 37 | |
|---|
| 38 | Once the applet is running, a Bluetooth icon should appear in your system tray. |
|---|
| 39 | This is important: You are ready to use the script btconnect now, but when |
|---|
| 40 | using it the first time, the Bluetooth icon in the systray will flash and wait |
|---|
| 41 | for user input. Enter the authorization key that was set on the NXT before |
|---|
| 42 | (usually 1234). Now the script btconnect should create a device called |
|---|
| 43 | /dev/rfcomm0, which is the virtual serial port the MATLAB toolbox uses. It |
|---|
| 44 | might be a good idea to add the bluetooth-applet to your autostart. If the |
|---|
| 45 | bluetooth-applet can't be found on your machine, try installing desktop- |
|---|
| 46 | specific packets (i.e. gnome-bluetooth). |
|---|
| 47 | |
|---|
| 48 | If you use KDE, you may need similar steps to get a Bluetooth icon in the |
|---|
| 49 | system tray. Refer to the KDE documentation for details. |
|---|
| 50 | |
|---|
| 51 | If your user account doesn't have permissions to read and write the device |
|---|
| 52 | files /dev/rfcommX, the connection may fail. You can use the provided |
|---|
| 53 | 41-legonxt.rules file to assign read and write permission to the system group |
|---|
| 54 | "legonxt". You then need to make sure that the group "legonxt" exists and make |
|---|
| 55 | your user account a member of the group. See the USB paragraphs below for more |
|---|
| 56 | information. |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | *** USB *** |
|---|
| 60 | |
|---|
| 61 | First you have to make sure that the open-source library libusb is properly |
|---|
| 62 | installed. You can either retrieve it from the project's homepage |
|---|
| 63 | http://libusb.wiki.sourceforge.net/ or download it using your packet manager |
|---|
| 64 | (e.g. Debian's apt-get). If the package "libusb" does not work, please try |
|---|
| 65 | installing "libusb0", the latest version "libusb-0.xx", or "libusb-0.1", |
|---|
| 66 | or "libusb-dev". You definitely need version 0.1, version 1.0 will not work |
|---|
| 67 | (but there is a compatibility layer for 0.1 which we have never tested). |
|---|
| 68 | |
|---|
| 69 | This was just one step. The second thing to do is making connected NXT devices |
|---|
| 70 | appear inside the /dev/ folder with the right read/write permissions. That is |
|---|
| 71 | what the udev rule file is needed for (root rights are required): |
|---|
| 72 | |
|---|
| 73 | 1. Copy the file 41-legonxt.rules to /etc/udev/rules.d, |
|---|
| 74 | e.g., by executing the following: |
|---|
| 75 | |
|---|
| 76 | cp 41-legonxt.rules /etc/udev/rules.d |
|---|
| 77 | |
|---|
| 78 | 2. Once successful, you might need to restart the udev-service. If unsure, |
|---|
| 79 | reboot your system. When connecting an NXT device to a USB port, a new |
|---|
| 80 | device /dev/legonxt-x-y should appear (with x and y depending on your |
|---|
| 81 | kernel and USB bus and port). |
|---|
| 82 | |
|---|
| 83 | 3. The /dev/legonxt file should be read-/writeable by all users belonging |
|---|
| 84 | to the group "legonxt". Thus, you need to make sure that this group exists |
|---|
| 85 | and your user account is a member of it. Alternatively, you can edit the |
|---|
| 86 | rules file and change the GROUP="legonxt" entries (one per line) to |
|---|
| 87 | GROUP="plugdev", for example. On Debian-like distributions, users are |
|---|
| 88 | member of the "plugdev" group by default. Then you don't need to create |
|---|
| 89 | the group and fiddle with membership. |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | This manual and the USB scripts are partly taken from: |
|---|
| 93 | http://forums.nxtasy.org/index.php?showtopic=2143&view=findpost&p=16723 |
|---|
| 94 | |
|---|
| 95 | If you need more resources, these links are recommended for further reading: |
|---|
| 96 | |
|---|
| 97 | http://jan.kollhof.net/wiki/projects/Lego/linux |
|---|
| 98 | http://www.lysator.liu.se/~nisse/lego-nxt-dev/ |
|---|
| 99 | http://nxt.ivorycity.com/index.php?/categories/3-Linux-USB |
|---|