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:.
Making a robot project in Quorum using NetBeans .
- Writing a basic robot program in Quorum.
- Running a Quorum program on the robot.
Setting up the robot for to run Quorum programsBefore 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:
- Between 2 and 32 GB of storage.
- Must not be a SDXC type card.
If you are not sure what card to buy, our research lab suggests this card from Kingston. If you prefer, you can also buy a pre-loaded card from a teacher in Nebraska that creates them.
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:
- lejos (folder)
- System Volume Information (folder)
The SD card's contents should look similar this after the files are extracted:
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:
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:
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:
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 NetBeansUsing 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:
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.
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:
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) else soundControl:PlayTone(300, 20) end end
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 ProgramFirst, 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
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 objects
screenControl to control robot.
//display text on the screen screenControl:OutputCenter("Hello!", 3) //play a beep soundControl:Beep() //wait for a button to be pressed buttonControl:WaitForButtonPress() //play two beeps soundControl:BeepTwice()
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) soundControl:Beep() buttonControl:WaitForButtonPress() soundControl:BeepTwice()
Our program will give the robot the following instructions:
- Tell the screen to print the text "Hello" , centered on line 3.
- Tell the sound controller to beep.
- Tell the robot to wait until any of its buttons is pressed.
- 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:
- Be sure the robot is turned on.
- Connect the robot to the computer.
- Press the build button in NetBeans (or press F11) to send the program to the robot.
- On the robot, navigate to the main menu and select "Programs".
- Select and run the program "Default.jar".
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.
- A running program can be stopped at any time by pressing the center and down buttons on the brick at the same time.
- To turn off the robot, press the escape button on the home menu and confirm the shut down by pressing the right button and then the center button.
- To change a Quorum project's type at any time, go to the File menu and select project properties.
- You can change the name of your program from "Default" to whatever you want in the project properties menu.
For a complete list of robot actions, refer to the documentation Libraries.Robots.Lego
Driver Installation Problems on WindowsNote: 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:
- Go to the device manager (in the control panel)
- While the EV3 is on, find it in the device manager. It should be located under the "Network adapters" submenu, listed as "USB Ethernet/RNDIS Gadget" or something similar. In some cases, it has a number at the end (e.g., #2 at the end)
- Right click or use the keyboard on the device and select "Update Driver Software..."
- Select the option to browse your computer for the driver manually
- Select the option to pick from a list of device drivers on your computer
- Click or use the keyboard to get to "Have Disk..." to open a window where you can point Windows to a specific driver
- Click or use the keyboard to select "Browse..." and navigate to C:\Windows\System32\DriverStore\FileRepository\"rndis folder with a possibly unique name". This folder has a very unintuitive name starting with the phrase "rndis" For example, on one machine, it was called rndis.inf_amd64_1fb2b40d582448a7 during our testing. Once you have found it (the hard part), select or click "Open"
- Then click or select OK to close the "Install from Disk" window
- At this point, this should take us back to the main window and only one driver should be listed. Click Next and it will install the driver.
In the next tutorial, we will discuss Motors, which describes how to use lego motors.