NetLogoLab is the technological infrastructure that connects NetLogo and the physical world. It can be used for robotics, interactive art, scientific investigations, and model validation. This infrastructure was created at the CCL by Paulo Blikstein and Uri Wilensky in 2005 as part of the Bifocal Modeling project. For more information, please check the new and old websites, where you will find academic papers, models, and demos.
NetLogoLab is comprised of the following software and hardware components:
NetLogo's robotics/data-logging board of choice is the GoGo Board, an open-source, easy-to-build, low-cost interface designed by Arnan Sipitakiat and Paulo Blikstein, first at the MIT Media Lab, then at Northwestern's CCL, and is in continuous refinement. Other robotics hardware can be used with NetLogo, including those that are commercially available, such as Arduino boards, Vernier and Pasco sensors and actuators, Phidgets, and VEX kits, but specific extensions have not yet been developed for each of those platforms. So far, only the GoGo Board extension is available with NetLogo's standard distribution.
The GoGo Extension for NetLogo provides primitives to communicate with a GoGo Board. This enables the user to connect NetLogo with the physical world using sensors, motors, light bulbs, LEDs, relays and other devices.
A GoGo Board is a low cost, general purpose serial interface board especially designed to be used in school and for educational projects. It was created by Arnan Sipitakiat and Paulo Blikstein at the MIT Media Lab in 2001, and has been actively developed since then. It is currently used in over 10 countries, such as the United States, China, Thailand, South Korea, Brazil, Portugal, Mexico, Malaysia, and Egypt. For more information see the the gogo board about page.
Up to 8 sensors (i.e., temperature, light, pressure) and 4 output devices (i.e., motors, light bulbs, LEDs, relays) can be connected to the board simultaneously. The board also has a connector for add-on devices (such as displays, Bluetooth or ZigBee wireless modules, voice recorders, real-time clock, and GPS).
NetLogo models can interact with the physical world in two ways. First, they can gather data from the environment. This information can be used by the model to change or calibrate its behavior. This data is gathered using electronic sensors, which can measure a wide range of phenomena: temperature, light, touch (see pictures below), pH, chemical concentration, pressure, etc.
The second mode of interaction between NetLogo and the physical world is the control of output devices, or "actuators" - motors, light bulbs (see pictures below), LEDs, and more complex devices that include these outputs such as toys, remote controlled cars, electrical appliances, and automated laboratory equipment.
For educators willing to start robotics or sensing projects, there are some important considerations regarding the exact type of sensors and actuators to use - for example, the sturdiness, reliability, "openness", and cost of these devices. Both vary greatly in price and complexity. For example, for most educational projects, off-the-shelf, generic, low-cost sensors can be used with very reliable results. A generic temperature sensor with a precision of 0.5 degrees Celsius can be purchased for approximately US$ 1.00 at most sensor and electronics retailers. Using generic, low-cost sensors requires very basic knowledge of electronics. For example, some basic soldering might be needed to attach a piece of wire to the sensors. While this is feasible in schools and has been tried in several educational settings, some educators might prefer to buy proprietary sensors and actuators, which come assembled and ready to be used. Some companies offer proprietary systems for educational sensing which are more sturdy and reliable than generic sensors, but are also much more expensive. As a comparison, a proprietary temperature sensor could cost as much as US$ 50.00. Actuators follow the same rule: for example, a generic geared motor could cost from US$ 3 to 10, while a proprietary version would retail for US$ 30 or 40.
Sensors and actuators can be found through online retailers such as Digikey, Mouser, Phidgets, Spark Fun, and Solarbotics. More information about how to make sensors is available from an "Making Sensors" from an old version of the GoGo board web site.
To make use of the GoGo Board extension and the NetLogoLab framework, users need to create NetLogo models using the special primitives made available by the extension. Later in this document, we will provide examples of models that do this.
Gogo Boards can be purchased from the SEED Foundation.
The GoGo Board connects with the computer via the USB port. Turn the GoGo Board on using the switch behind the power connector: the board will beep twice and the red light will turn on.
Plug in your GoGo board and go to https://code.gogoboard.org/. The website should prompt you to download the gogo plugin for Windows. You can now try using the NetLogo GoGo extension. If you don't have Java installed, you will be prompted to locate your java execuatable. You will need to install Java to get the extension to work. We recommend using the Liberica JDK 8 installer here: https://bell-sw.com/pages/downloads/#/java-8-lts
The GoGo extension requires no special installation on Mac OS X.
Many versions of Linux require no special installation.
The GoGo Extension comes preinstalled when you download and install NetLogo. To use the extension in your model, add this line to the top of your Code tab:
extensions [gogo]
If your model already uses other extensions, then it already has an
extensions
line in
it, so just add gogo
to the list.
After loading the extension, you can see if the gogo board is connected by seeing if it will beep when you type into the command center:
gogo:beep
For more information on NetLogo extensions, see the Extensions Guide.
For examples that use the GoGo extension, GoGoMonitor and GoGoMonitorSimple models in the Models Library.
The first step when creating a NetLogoLab model is to add the
extensions
keyword
to NetLogo's Code tab. Just go to the Code tab and add this line:
extensions [gogo]
Now let's start the model. Imagine that we want to control a car with four wheels and two motors attached to the back wheels. We will assume that you have built such as car and connected the motors to the output ports "a" and "b" on the GoGo board. One very simple approach could be to create two buttons for each motor, "on" and "off":
The code associated with these buttons is very simple: for the "on" button, we could simply have
gogo:talk-to-output-ports ["a"]
gogo:output-port-on
For the off button, it would be very similar:
gogo:talk-to-output-ports ["a"] gogo:output-port-off
The other set of "on" and "off" buttons, used to control the second motor, would have very similar code, except that we would use the second output port ("b"), so:
gogo:talk-to-output-ports ["b"]
We could make our model more interesting by adding a "toggle direction" button, adding a button with the following code, which would reverse the direction of motors "a" and "b":
gogo:talk-to-output-ports ["a" "b"] gogo:output-port-reverse
To create a simple sensing project, we will assume that you have added the GoGo extension to your model and successfully opened a connection to the GoGo board, i.e., adding the "extensions" command to the Code Tab. For this sensing project we do not need motors, but we will need another device: a temperature sensor. A standard GoGo board comes with a temperature sensor. It is labeled (TEMP Sensor). More info on the sensors that come standard with a gogo board can be found in the GoGo Docs. The simplest use of a temperature sensor, obviously, is to display the temperature. We could achieve this by plugging the sensor in to input 1 and adding a monitor to the NetLogo interface with this code:
gogo:read-sensor 1
The Gogo docs say, "Note that the readout is not in Celsius or Fahrenheit. The value is reflects the resistance of the sensor. Mappings between the resistance and the standard units must be done manually." So, to figure out how these values map to a real temperature, you will need to use a thermometer and see how the reading on the temperature sensor corresponds to the temperature in degrees. If you found out that the conversion is to divide by 30, the monitor on the NetLogo interface could be changed to:
gogo:sensor 1 / 30
The sensor value could also be used to control on-screen objects, such as turtles. For example, let us create two buttons: a "create one turtle" button, which will clear the world and create a turtle, and a "move with heat" button, that will cause the turtle to move forwards depending on the temperature reading from the sensor. The code would look like this:
to create-one-turtle clear-all create-turtle end to move-with-heat if gogo:read-sensor 1 > 500 [ forward 1 ] end
If the "move with heat" forever button is activated and the user heats up the sensor (by rubbing it, or slowly bringing a flame near it), the heat threshold will be achieved (> 500) and the turtle will move.
A more elaborate use of this sensor apparatus would be to control output devices, such as motors. The user could, for example, turn a motor on when the value from the temperature sensor reaches 500, using the following code:
to turn-motor-on-with-heat if gogo:read-sensor 1 > 500 [ gogo:talk-to-output-ports ["a"] gogo:output-port-on ] end
Another possible use of the sensing primitives is to plot and log data. Logging could be useful for more elaborate data analysis and comparison, and can be achieved with NetLogo's list commands. For example, if the user wants to log sensor values from sensor 1 every 0.5 seconds, the code could look like this:
to log-data-from-sensor set data-vector lput (gogo:read-sensor 1) data-vector wait 0.5 end
Finally, plotting data is straightforward. The following code, for example, would create a graph for the value of sensor 1:
plot (gogo:read-sensor 1)
For more information on the GoGo Board's extensions functionalities and primitives, please refer to these two sample models: GoGoMonitor.nlogo and GoGoMonitorSimple.nlogo and see the documentation for GoGo Extension.