Controlling Lego NXT Robots with Matlab

For research in Knuthlab, I am interested in controlling the Lego NXT Bricks with Mathworks MATLAB.  MATLAB is a high-level mathematical language structured much like C.  The main benefit is that many sophisticated mathematical algorithms are available for immediate use in MATLAB, and that these algorithms are fast and easily developed.  Furthermore, much signal processing research is performed in MATLAB; including most of my own algorithms.

NXT Brick

The most promising solution is to have MATLAB send commands to the NXT Brick and to receive sensor readings from the NXT Brick.  In both cases Bluetooth is the obvious means of communication.

At this stage, we have found three possible solutions:

  1. Incorporate Java Classes into MATLAB and then employ either iCommand or LeJOS NXT which both use the Java Programming Language to control the NXT Brick.
  2. Adopt the solution engineered by Gregory Gutt for the George Mason Neural Dynamics Laboratory, which employs RealTerm as a server to pass commands to the NXT via Bluetooth in the form of a Byte Stream.  This is a very attractive solution, but would require the writing of more detailed NXT commands in MATLAB…an endeavor possibly worth the effort.  Crucial to this effort are the steps of using RealTerm from MATLAB and understanding the Byte Streams used by NXT.
  3. The last possibility would be interfacing MATLAB to one of the various C or C-like interfaces to NXT.  This would require the writing of MEX files, which I am not very excited about doing.

We will have to make some decisions in the near future, but the prospect of interfacing MATLAB directly to the Brick via Byte Streams sent by RealTerm seems to me to be the most robust and flexible solution.  I will keep you posted.

Kevin Knuth
Albany NY

2 Responses to Controlling Lego NXT Robots with Matlab

  1. Kevin,

    Did find any information or figure out how to control the NXT using Matlab?


  2. Kevin,

    maybe you should consider the RWTH Mindstorms NXT Toolbox for Matlab. It is Open Source (GPL) and available from


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>