Penguin
Blame: LegoMindstorms
EditPageHistoryDiffInfoLikePages
Annotated edit history of LegoMindstorms version 19, including all changes. View license author blame.
Rev Author # Line
8 LawrenceDoliveiro 1 __Lego__ __Mindstorms__ is a family of robotics kits from the company famous for those open-ended brick-building kits. Each Mindstorms kit includes a few motors, an assortment of sensors, plus a collection of more-regular Lego parts (from the __Technics__ range), together with a fully-programmable microcontroller. The company includes, in the box, proprietary GUI-based programming environments for Macintosh and Microsoft Windows machines, but it has also been cooperative with the development by others of open-source programming tools.
2
9 LawrenceDoliveiro 3 The latest product in this range is the Mindstorms NXT 2.0 kit, available for about $500. This includes three servomotors, two touch sensors, a colour sensor (with built-in switchable light source), and an ultrasonic sensor which can be used for active ranging or passive sound detection. The microcontroller now has the option of hooking to a PC via either USB or Bluetooth.
8 LawrenceDoliveiro 4
5 !! Software
6
9 LawrenceDoliveiro 7 For Linux users, the best option for programming these seems to be a pair of languages called NBC (a low-level assembler) and NXC (a higher-level C-like language). NXC compiles to the NBC bytecodes, which in turn are interpreted by firmware on-board the NXT controller. These languages are part of the open-source [Bricx Command Center|http://bricxcc.sourceforge.net/] project, the main part of which is Windows-only. However, the [nbc|http://bricxcc.sourceforge.net/nbc/] command-line tool can be built for Linux, and this implements both languages as well as functions for uploading compiled programs into a connected NXT microcontroller.
8 LawrenceDoliveiro 8
9 LawrenceDoliveiro 9 A useful library is [NXT_Python|http://home.comcast.net/~dplau/nxt_python/index.html]. This provides functions that can be used to directly examine and manipulate the state of the NXT controller from the host PC. Notwithstanding its requirements specifically mentioning Python 2.4, it does seem to work fine with Python 2.5.
10
13 LawrenceDoliveiro 11 Another compiler is [NXTGCC|http://nxtgcc.sourceforge.net/wiki/index.php/NXTGCC]. Unlikes NBC/NXC, this compiles to actual machine language for the ARM CPU. It can be used to write completely new firmware for the NXT controller.
12
13 !! Device Permissions Setup
14
15 You don’t need any special drivers to connect the NXT controller to a Linux box (at least via USB; I haven’t tried Bluetooth); all communication is done through the userland <tt>libusb</tt> library. However, by default, <tt>udev</tt> will create the device entry as only accessible by root. To fix this, create a new group in your <tt>/etc/group</tt> file called, say <tt>legonxt</tt>. Add your own nonprivileged username to this group (you will need to logout and login again to become a member of this group). Then, create a new file in your <tt>/etc/udev/rules.d</tt> (for example, call it <tt>70-lego.rules</tt>) containing the following line:
16
17 <pre>
18 SUBSYSTEM=="usb", ATTR{idVendor}=="0694", GROUP="legonxt", MODE="0660"
19 </pre>
20
21 This gives read/write access to the device to all members of the <tt>legonxt</tt> group.
22
23 You may find versions of the above <tt>udev</tt> rule elsewhere on the Web which also create a symlink for the device with a name like <tt>/dev/legonxt-</tt>''xxx''. As far as I can tell, this is unnecessary. <tt>libusb</tt> certainly doesn’t need it.
8 LawrenceDoliveiro 24
25 !! NBC/NXC Building Notes
26
27 Ignore the source release tarballs linked from the NBC Beta Releases page above; they are all out of date. Instead, get the latest source out of SubVersion (note you will need [Free Pascal|http://www.freepascal.org/] to compile it):
28
29 <pre>
30 mkdir nbc nbc/beta
31 svn co https://bricxcc.svn.sourceforge.net/svnroot/bricxcc bricxcc/
32 # above may take a few minutes
33 make -C bricxcc/ -f bricxcc.mak archivenbcunix
34 # above puts Unix/Linux-compilable source tarball in nbc/beta
35 cd nbc
36 tar xzvf beta/nbc-1.0.1.b36.unix-src.tgz
37 make nbc
38 </pre>
39
40 The instructions say to <tt>make install</tt> at this point, but as of this writing that will only install the ManPage into <tt>/usr/share/man/man1</tt>. To install the executable, do something like
41
9 LawrenceDoliveiro 42 <pre> install -m 755 NXT/nbc /usr/local/bin/
8 LawrenceDoliveiro 43 </pre>
10 LawrenceDoliveiro 44
45 !! See Also
46
19 LawrenceDoliveiro 47 * [Lego’s own site|http://mindstorms.lego.com/], with downloadable software and hardware development kits and open-source firmware.
14 LawrenceDoliveiro 48 * [nxtasy.org|http://nxtasy.org/]—discussion forums, software news and informational articles about the insides of the NXT. For example:
16 LawrenceDoliveiro 49 * [NXT filesystem description|http://nxtasy.org/2006/08/03/nxt-memory-and-file-system-organization/]
50 * [NXT graphic file format|http://nxtasy.org/2007/02/20/ric-revealed/]
51 * [NXT sound file formats|http://nxtasy.org/2006/10/24/making-music-with-nxt-melodies/]
52 * [What’s an IOMAP|http://nxtasy.org/2006/08/05/whats-a-nxt-iomap/]
53
12 LawrenceDoliveiro 54 * [LiNXT|http://sourceforge.net/projects/linxt/]—a simple Perl-based tool to upload and download files to/from the NXT and do one or two other functions. Requires <tt>Device::USB</tt> from CPAN.
17 LawrenceDoliveiro 55 * [libnxt|http://code.google.com/p/libnxt/] provides low-level communication with the NXT controller, including the ability flash new firmware.
18 LawrenceDoliveiro 56 * [pbLua|http://www.hempeldesigngroup.com/lego/pbLua/] is a development environment running on the NXT controller itself.
16 LawrenceDoliveiro 57 * [NXTFilesystemNotes]