PLNXT Introduction

LEGO Mindstorms NXT is a universal platform, that offers robot construction possibilities, as well as programming solutions. When it comes to Mindstorms NXT programming, LEGO offers a programming environment, that allows for algorithm synthesis using simple flowchart-like visual language. Thanks to the openness of the platform number of open programming solutions emerged, for languages such as C/C + +, Java, etc. The examples include LeJOS/iCommand, and NQC. Some early attempts for providing a Prolog-based solution are within the Legolog Project. Unfortunately the project did not offer a general API, and supported only the older Mindstorms RCX version.

PLNXT is a Prolog API for the Mindstorms NXT platform. It is researched and developed within the HeKatE Project, aimed at providing a high-level rule-based programming solution.

Basing on the review of existing solutions, the requirements of a new Prolog API for NXT has been formulated:

  • support for all functions of the standard NXT components,
  • crossplatform solution, for both Windows and GNU/Linux environments,
  • reuse some of the available solutions.

PLNXT provides the following features:

  • it is executed on a PC controlling an NXT robot, the control is performed with the use of the Bluetooth/USB,
  • at the functional level the API is coherent with other available solutions.


  • The behavioral layer (nxt_movement) exposes to the programmer some high level functions and services. It provides abstract robot control functions, such as go, or turn. Currently works for a TriBot robot. Ultimately a full movement support for different robots is to be provided.
  • The sensomotoric layer (nxt_sensomoto) controls the components of the NXT set: motors, all the sensors, as well as Brick functions. This layer can be used to directly read the sensors, as well as program the motors. This is a layer, that can be used by a programmer to enhance high-level behavioral functions.
  • The goal of the communication layer (nxt_actions) is to execute the actions of the sensomotoric layer and communicate with the NXT Brick. Currently in this layer several alternate modules are present, providing different means of communication:
    • a pure Prolog module, using a serial port communication, and the NXT protocol commands,
    • a hybrid solution based on the Java-based iCommand library,
    • a hybrid socket-based solution, using the NXT++ library, that communicates with the robot,
    • simple graphic NXT simulator, which allows, within a certain scope, of using algorithms without Mindstorms set.

All of these (except for simulator) actually wrap the Mindstorms NXT Communication Protocol.

Any other implementation of the communication layer can be created based on file Restriction is that the names of the exported predicates must remain the same. There is also no possibility to provide anything new without including it in the sensomotoric layer. Why? The communication layer is a part of the project, detached to allow putting various alternate versions into its place only. It should not be directly used in the projects based on PlNXT. There is no such need.


To implement complex control algorithms, it is necessary to use mechanisms for delaying actions and make them conditional on certain events.

Implementation of these mechanisms occurs in the threads module. It provides triggers (callbacks) and timers using SWI Prolog threads. Trigger fires an action when some event occurs. Timer fires an action after a specified period of time.

About LEGO Mindstorms NXT platform

The minimum knowledge needed to use the PLNXT:

These materials are part of the AGH Laboratory - LEGO Mindstorms site.


FIXME on-line docs


Release M0

20.02.2009: Download release PlNXT-M0

Release M3

09.05.2010: Download release PlNXT-M3.1


If you have not used the Mindstorms NXT yet, I recommend the LEGO instruction. Nice, colorful, with pictures. :) If you are too lazy for that, start with a LEGO Mindstorms NXT brief description, necessary to use PLNXT. There is a knowledge of the NXT platform there, reduced as it can be.

Download and unzip the current version of PLNXT. You can find it in the download section.

Environment setup

Various communication modules require different environment preparation:

  • nxt_actions_serial – using local serial port,
  • nxt_actions_icommand – using iCommand (Java),
  • nxt_actions_sockets – using TCP sockets.

Temporarily, it is possible to use only the serial module. Soon this will be corrected. Therefore, further instructions are prepared only for this module.

Serial module

iCommand module

Sockets module

First steps

If you already have a properly prepared environment (see setup), you can move on and write simple programs. I encourage you to review ''first steps''.

Related sites


Copyright © 2006-9 by the HeKatE Project

PLNXT has been develped by the HeKatE Project, see

PLNXT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PLNXT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PLNXT. If not, see



Please contact if:

  • the contents of this site are not exhaustive,
  • you want to report a bug,
  • you want to give us advices, suggestions, comments, etc.

E-mail: holownia(_at_) or gjn(_at_)


For developers.


  • Jan 14, 2009 – PLNXT was used during classes with students. We hope to get feedback that will help remove errors. Before that, work on the communication layer module using serial connection, based directly on the LEGO protocol, were in progress. This protocol provides greater capabilities than used previously icommand and sockets modules. One of its features is that it can synchronize engines. Higher layer has been modified to make the most of what provides the LEGO protocol. It should be re-converted so it could be used with communication layer modules, which do not provide engines synchronization, as well as these modules. At this point, it is possible to use only the serial module as a communication layer.
mindstorms/plnxt/start.txt · Last modified: 2013/01/17 12:14 (external edit) Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0