An Introduction to Robots in Quorum

In this tutorial, we will focus on setting up a LEGO™ EV3 Mindstorms robot to run Quorum programs, as well as discuss the fundamentals behind using Quorum to write programs for the robot. Specifically, we will cover:.

Setting up the robot for to run Quorum programs

Before we can run a Quorum program on a LEGO™ robot, we have to install a special kind of software called a "firmware." In accomplish this, we need to use the robot's expansion slot, which accepts a microSD card (just like many digital cameras and phones). Not all microSD cards are supported. You need one with the following characteristics:

The next step is to install the lejOS firmware on the compatible formatted microSD card. Download the lejOS install files by pushing the button below and then extract the contents onto the SD card.

Download the LEGO™ Robotics Installation Kit for Quorum, version 1.3

Make sure that the contents of the zip file are directly on the SD card and not in a folder.

It should contain the following items (or similar ones) directly:

The SD card's contents should look similar this after the files are extracted:

This is an image of the lejOS Install Files

With the files on the SD card, we can now install the lejOS firmware on the LEGO EV3 brick, which is the central part of the robot that everything connects to. Locate the slot on the side of the brick labeled "SD" and insert the card, as shown here:

This is an image of the bricksdslot

After the card is inserted, turn on the robot by holding down the center button found on the front side of the brick, as shown here:

This is an image of the brick middle button

In about a second, the LED light surrounding the robot's buttons should display a red light, indicating that the robot is starting up, as shown here:

This is an image of the brick led

After this occurs, let go of the button and the robot should start installing the lejOS firmware automatically.Typically, this process takes a few minutes. When the installation finishes, the robot will play a three tone piano jingle. The robot is now ready to run Quorum programs.

You can explore the menu on the brick and change settings at this point. The left, right, up, and down keys navigate through menus, while the center button is used to select an option, and the escape button (top left) goes back. Next, we will learn about making Quorum Robot projects.

Making a Robot Project in NetBeans

Using NetBeans, we can create a Quorum program from a template designed for a robot. If you need help installing NetBeans refer to this help page. To create a robot project choose New Project from the File menu and select Quorum from the categories section on the left and "LEGO Application" from the projects section on the right. When this is done press the Next button. The window will look something like this:This is an image of a new project

After selecting Next, the window below will appear and you can name the project and change the location. For this tutorial, we will leave the default name and location and click the Finish button.

This is an image of a newProject2

A new project should now appear in the projects tab on the left side of the screen (Ctrl 1) with the name of the project. Expanding that project will reveal a folder called "Source Code" and expanding that folder will reveal a file named "main.quorum". Double-click on the main.quorum file to open it in the editor and your screen should look similar to this:

This is an image of a newLegoProject

The editor (Ctrl 0) should now have a sample program that has the following code:

use Libraries.Robots.Lego.Button
use Libraries.Robots.Lego.Sound

Button buttonControl
Sound soundControl

repeat until buttonControl:IsButtonPressed(buttonControl:ESCAPE_BUTTON)
     if buttonControl:IsButtonPressed(buttonControl:LEFT_BUTTON)
         soundControl:PlayTone(1000, 20)
     elseif buttonControl:IsButtonPressed(buttonControl:RIGHT_BUTTON)
         soundControl:PlayTone(2000, 20)

         soundControl:PlayTone(300, 20)

This program will cause the robot to play different sounds depending on whether the left or right button of the brick are pressed, or if no button is pressed. Additionally, the program will end if the escape button is pressed. In the next part of this tutorial, we will replace this program with our own program.

Writing a Robot Program

First, remove all of the code in the editor window by highlighting it (Ctrl A) and hitting the backspace or delete key. In order to use the robot's sound, button, and screen features, we must tell Quorum where the files are in the library that contain the action commands we want to call. For more information on using libraries, refer to Use Statements. In our case, we want to use the Sound, Button and Screen libraries, which we do by including the following three statements at the top of our code:
use Libraries.Robots.Lego.Sound
use Libraries.Robots.Lego.Button
use Libraries.Robots.Lego.Screen

After our use statements, we need to create objects of each of the Sound, Button and Screen classes so that we can call action commands on them to cause the robot to react. This is called "instantiation" of an object and it basically tells Quorum to create the object by allocating memory for it. (Information on creating variable/objects can be found at Types and Variables.) In our example, we instantiate an object by first declaring the type of the object and then naming it. We will instantiate three objects now of types Sound, Button and Screen named: sound, button and screen, respectively. (We can name the objects anything we like, for example: mySound, myButton or myScreen would also be perfectly acceptable.

//instantiate a Sound, Button and Screen object.
Sound soundControl
Button buttonControl
Screen screenControl

Notice that the type of the object is capitalized (Screen) and the actual name of an object starts with a lowercase letter (screeControl) by convention. We can now use the three objectssoundControl, buttonControl and screenControl to control robot.

In the next step we will tell these objects which actions to perform. Add these lines of code to the program to give the robot some instructions:
//display text on the screen
screenControl:OutputCenter("Hello!", 3)
//play a beep
//wait for a button to be pressed
//play two beeps

The complete program should look like this:

use Libraries.Robots.Lego.Sound
use Libraries.Robots.Lego.Button
use Libraries.Robots.Lego.Screen

Sound soundControl
Button buttonControl
 Screen screenControl

screenControl:OutputCenter("Hello!", 3)

Our program will give the robot the following instructions:

  1. Tell the screen to print the text "Hello" , centered on line 3.
  2. Tell the sound controller to beep.
  3. Tell the robot to wait until any of its buttons is pressed.
  4. Once a button has been pressed, tell the sound controller to beep twice.

Now we are ready to upload our program to the robot and watch it run.

Running a Program on the Robot

In order to transfer a program to from the computer to the robot, we need to take the following steps:

The LEGO brick's main menu is shown. The current selection is The LEGO brick's screen displays three different files: 
            QuorumStandardLibrary.jar, QuorumStandardPlugins.jar, and Default.jar, in that order.

The robot should perform the instructions in the program.

When building your program, two additional files should appear on the robot:

These two extra files are needed to run Quorum programs on the robot. Do not delete or change these files. If you do not see both of these files, rebuild your project and they should be automatically transferred along with your program.

Additional Information

Driver Installation Problems on Windows

Note: If your LEGO robot connects normally to your computer, skip this section. You do not need it.

In testing, we have noticed that some Windows machines have difficulties installing the appropriate software for the LEGO robots (called "drivers"). We did not write this software, nor do we control Windows' approach for installing drivers, but in the unlikely case that your computer does not appear to connect to the LEGO robot, we have found that these steps seem to resolve it:

If, for whatever reason, your school has difficulty with getting your LEGO robot up and running, we highly encourage you to send a message to the Quorum Google Group and ask for help.

Next Tutorial

In the next tutorial, we will discuss Motors, which describes how to use lego motors.