<img height="1" width="1" src="https://www.facebook.com/tr?id=1357777224302944&amp;ev=PageView &amp;noscript=1">

RTI Blog

A resource for system and software architects and developers

Programming Lego Mindstorms using RTI DDS Toolkit for LabVIEW

August 8, 2013 by
|

National Instruments provides “LabVIEW For Lego Mindstorms,” an Add-On specifically designed for programming the Lego NXT brick. It works great if you are a LabVIEW user. But what if you want to integrate it with other applications, written in popular programming languages such as Java, C or C++? RTI DDS Toolkit for LabVIEW provides an additional set of blocks that you can use to easily share data between the NXT brick and applications written in other programming languages.

RTI DDS Toolkit for LabVIEW extends the benefits of RTI Connext DDS solutions to the LabVIEW platform. Connext DDS software offers a decentralized architecture for publishing and subscribing data. There are no brokers or servers: each application is either statically or dynamically linked with the RTI libraries. Data is exchanged peer-to-peer for extremely low latency and high scalability.

With the RTI DDS Toolkit for LabVIEW, LabVIEW applications can publish and subscribe to data in the same way as applications that use the Connext API directly. And because it uses the standard DDS interoperability protocol on the network, LabVIEW applications can transparently interoperate with any other DDS compliant application.

Connext DDS + LabVIEW at Work

Let's illustrate this concept with a demo application. First, we assemble a Lego Mindstorm robot with 3 I/O devices: the ultrasonic distance sensor, the touch sensor and the motor.

Lego(R) Mindstorms(R) robot

Then, we build two applications:

  1. A Java application that sends commands to control the motor and receive live data from the robot’s sensors. This application publishes commands and subscribes to data using DDS. It has no knowledge of the existence of the Lego hardware. Download Java application source code

  2. A LabVIEW application that uses both the Lego Mindstorms NXT Add-On, and the RTI DDS Toolkit for LabVIEW Add-On. This LabVIEW application serves as a bridge for data to flow between the robot and applications that interface with it. Download VI file for LabVIEW application

Here's what the architecture looks like:

Check out the demo in action!

Do It Yourself

To set up the demo, you'll need:

To compile and run the Java application in Eclipse:

  1. Import the project into Eclipse

    1. Import -> General -> Existing Projects into Workspace.

    2. Select the archive file above

  2. Include the following RTI Connext .jar files to the project:

    1. [NDDSHOME]/ndds.[version]/class/nddsjava.jar

    2. [NDDSHOME]/ndds.[version]/class/rticonnextmsg.jar

  3. Include the Eclipse SWT swt.jar of your appropriate platform into the class path.

  1. Include the path to the RTI Connext DDS native libraries:

In the Run Configurations for this demo, go to the Environment tab and add the path variable for your platform. To determine which variable to add, look at the RTI Connext Platform Notes. After installing RTI Connext DDS Professional, you can find the Platform Notes document in [NDDSHOME]/ndds.[version]/doc/pdf/RTI_DDS_PlatformNotes.pdf. The following example is from a Mac:

  1. Compile the application and make sure there are no errors.

To run the demo:

  1. Power on the Lego NXT brick, and wait for about a minute to make sure the Bluetooth connection is ready.

  2. Run the LabVIEW application. It will try to detect the Lego NXT brick.

  3. Run the Java application. You should now be able to see live status from the distance and touch sensor, and you should also be able to drive the robot around using the buttons. See the video above for the live demo.

Questions? Email labview@rti.com or chat with our experts in the RTI Community.

Let Us Know What You Thought of the Article.

Leave a Comment Below.

FREE VIDEO TUTORIAL

Using RTI's DDS Toolkit for LabVIEW 

Watch Now

Subscribe to Email Updates