NXTalk: Smalltalk on Lego Mindstorms NXT
NXTalk: Smalltalk on Lego Mindstorms NXT
NXTalk: Smalltalk on Lego Mindstorms NXT
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Applicati<strong>on</strong> for the 2009 ESUG Innovati<strong>on</strong> Technology Award<br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g>: <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> <strong>on</strong> <strong>Lego</strong> <strong>Mindstorms</strong> <strong>NXT</strong><br />
Applicati<strong>on</strong> Details<br />
Name of the Software: <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g><br />
Names of Developers: Martin Beck, Michael Haupt, Robert Hirschfeld<br />
Affiliati<strong>on</strong>s of Developers: Software Architecture Group<br />
Hasso-Plattner-Institut<br />
Prof.-Dr.-Helmert-Str. 2-3<br />
D-14482 Potsdam<br />
Germany<br />
Primary C<strong>on</strong>tact: michael.haupt@hpi.uni-potsdam.de<br />
<str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> Dialect Used: Squeak, <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g><br />
Project Web Page: www.hpi.uni-potsdam.de/swa/projects/nxtalk/index.html<br />
Keywords<br />
<strong>Lego</strong> <strong>Mindstorms</strong> <strong>NXT</strong>, robots, embedded <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g>, virtual machine<br />
Licence Informati<strong>on</strong><br />
The <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> VM and development envir<strong>on</strong>ment are licensed under the MIT<br />
License. NXOS, which is the operating system in which <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> is running <strong>on</strong><br />
the <strong>NXT</strong>, is licensed under the GPL but not part of our c<strong>on</strong>tributi<strong>on</strong>.<br />
Descripti<strong>on</strong><br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> is an integrated approach to making <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> programming available<br />
<strong>on</strong> the <strong>Lego</strong> <strong>Mindstorms</strong> <strong>NXT</strong> [1] platform. It c<strong>on</strong>sists of two building blocks:<br />
the <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> virtual machine (VM) running <strong>on</strong> the <strong>NXT</strong> hardware, and the<br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> programming envir<strong>on</strong>ment, which is implemented in Squeak [2].<br />
Figure 1: <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> Code in a Squeak Browser and Workspace
Programming <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g><br />
An <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> program entirely looks and feels like an ordinary <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g><br />
program; the programming tools available in Squeak can be used seamlessly<br />
to develop software for the <strong>NXT</strong>. To some degree, <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> programs can also<br />
be simulated in Squeak.<br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> Standard Libraries<br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> provides its own standard libraries, which are designed with special<br />
regards to the <strong>NXT</strong>'s memory c<strong>on</strong>straints. Thus, the class hierarchy is highly<br />
c<strong>on</strong>densed while still offering the typical <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> classes and methods.<br />
Additi<strong>on</strong>ally, special classes resembling the <strong>NXT</strong>'s hardware devices like<br />
sensors, motors or butt<strong>on</strong>s exist, providing easy and <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g>-like access to<br />
these entities. Although optimised for size, <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> has—besides libraries for<br />
collecti<strong>on</strong>s, string manipulati<strong>on</strong> or event handling—a full meta-layer. Not <strong>on</strong>ly<br />
is the cyclic meta-class structure accessible, but also each class’ method<br />
dicti<strong>on</strong>ary.<br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> Applicati<strong>on</strong>s and Deployment<br />
Like most <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> implementati<strong>on</strong>s, <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> is image-based. In order to<br />
replace code or deploy applicati<strong>on</strong>s, it uses <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g>’s meta-facilities. Thus,<br />
the virtual machine merely provides functi<strong>on</strong>ality for loading, starting and<br />
running an image, while the resp<strong>on</strong>sibilities for deployment and applicati<strong>on</strong><br />
management lie in the image itself and are written in <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g>. An <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g><br />
applicati<strong>on</strong> or package c<strong>on</strong>sists of several compiled classes and additi<strong>on</strong>al<br />
meta-informati<strong>on</strong> such as the applicati<strong>on</strong>’s name. The compilati<strong>on</strong> process<br />
takes place <strong>on</strong> the Squeak side and the created packages al<strong>on</strong>g with its<br />
bytecode and data are transferred to <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> via remote method invocati<strong>on</strong>.<br />
Nevertheless, the initial image has to be built up completely in Squeak and<br />
uploaded to the <strong>NXT</strong> in the first place.<br />
Figure 2: Line Follower in Acti<strong>on</strong>
The <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> Virtual Machine<br />
The <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> virtual machine is a <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> VM written in pure C and tightly<br />
coupled to the hardware of the <strong>Lego</strong> <strong>Mindstorms</strong> <strong>NXT</strong> robot. It uses NXOS [3],<br />
an open source operating system for the <strong>NXT</strong>, as its underlying base. Several<br />
specialised algorithms had to be developed in order to overcome the<br />
hardware limitati<strong>on</strong>s of the <strong>NXT</strong>. With 64 kB RAM and 256 kB Flash, the<br />
memory c<strong>on</strong>straints were the main subject in virtual machine design. Thus, a<br />
very dense object layout was created, saving space for <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g>’s typical<br />
many small objects. At the same time, these size optimisati<strong>on</strong>s had to be<br />
taken with cauti<strong>on</strong>, as system performance has a great effect <strong>on</strong> user<br />
experience. The <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> virtual machine tries to balance these c<strong>on</strong>tradictory<br />
requirements in a reas<strong>on</strong>able fashi<strong>on</strong>, while still providing a full <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g><br />
envir<strong>on</strong>ment and open access to the <strong>NXT</strong>'s hardware devices like USB or<br />
Bluetooth.<br />
Outlook<br />
We are working <strong>on</strong> extending support of <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g> for both the target audience<br />
and with respect to supported hardware. Regarding the latter, more hardware<br />
drivers—for other than the default sensors shipped with the <strong>NXT</strong>—have to be<br />
implemented at the level of the virtual machine, and the according <str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g><br />
classes have to be provided at the <str<strong>on</strong>g>Smalltalk</str<strong>on</strong>g> level.<br />
Regarding target audience, we are working <strong>on</strong> providing an Etoys interface for<br />
<str<strong>on</strong>g><strong>NXT</strong>alk</str<strong>on</strong>g>, making robot programming available at both the levels of scriptable<br />
objects and actual hardware. This extensi<strong>on</strong> will allow for putting<br />
programming experience gathered in, e.g., BotsInc to practice using real<br />
robots.<br />
References<br />
[1] www.mindstorms.com<br />
[2] www.squeak.org<br />
[3] nxt.natulte.net/nxos/trac