GoPiGo3 robot vehicle with a Rasp Pi core
Go Pi Go
The GoPiGo3 kit provides components and software for a small robot car with a Raspberry Pi brain.
The easiest way to learn programming is hands on. The GoPiGo3 robot kit [1], based on a Raspberry Pi, supports programming with the Bloxter graphical programming language, up to and including the development of complex applications with Python, Node.js, or C/C++.
The GoPiGo3 design makes a solid, robust impression (Figure 1). The basic frame comprises two Plexiglas plates screwed together with threaded bolts. The direct-drive motors are mounted on stable metal brackets. With a little skill, assembling the kit takes less than an hour. The manufacturer provides detailed instructions on their homepage [2] to make it easy to assemble the robots.
The power supply for the robot uses rechargeable batteries; two sets are necessary if you don't want to wait several hours for the batteries to recharge between programming sessions. To conserve battery power while programming the GoPiGo3, you can connect a USB power supply to the Rasp Pi.
A detailed manual [3] helps you set up the robot. After booting, the model creates an unencrypted WiFi network with the GoPiGo SSID, which you log into on your PC. Please note that you might lose access to the Internet as a result. Now enter the address http://bloxter.com in a browser. The web server running on the kit responds to this URL (Figure 2).
A simple menu under the Drive button lets you control the car remotely for the first function tests. The Learn button provides a variety of exercises to help you familiarize yourself with graphical programming in Bloxter [4], a simple graphical environment based on Scratch.
Under Code in Bloxter, you develop your own programs. With a little experience you will see which Bloxter functions are available in highlighted menu items. The individual commands are structured like pieces of a puzzle that you can arrange into a program by dragging and dropping into place. Only pieces that work together can be clicked together, so it's impossible to make a mistake in syntax. The examples in this article were created in Bloxter.
Alternatively, the editor under Code in Python lets you control the robot with a lower-level programming language. As with Bloxter, you run the programs by clicking the hardware Start button. The GoPiGo_Python_Examples
folder contains many examples that can be used as a basis for your own experiments. I use two of these programs to illustrate the programming in detail.
Proximity Sensor
In this example, the GoPiGo3 uses its proximity sensor to control "eye" color as a function of measured distance. The two LEDs on the top side of the board act as eyes. If the sensor detects a large distance in front of the robot, the eyes glow green. If the sensor detects an obstacle, the eyes become yellow. If space is cramped, red eyes signal danger.
Figure 3 shows the required Bloxter program. The first thing you notice is that you don't have to import any additional libraries. All the required functions are available by default. The individual function groups in the left sidebar differ in color: Light green stands for loops, orange for reading sensors, and red for actuators. The outer loop ensures that the robot executes the program infinitely. If necessary, you can interrupt an endless loop by clicking on Stop.
The first if
block in the loop checks whether the distance to the next obstacle is greater than 5
inches and switches the eyes to green if the result is positive. (If desired, the value output by the sensor can be converted to centimeters.) The constant number for the comparison can be found at the top of the Math functions list. If the sensor outputs a shorter distance, the next if
block decides whether the eyes should glow red or yellow. That is all it takes to convert the values measured by the proximity sensor to colors.
Avoiding Obstacles
To really bring the GoPiGo to life, you have to engage the motors to move the robot. The spectrum of possible algorithms for this programming task is enormous, but many roads lead to Rome. In the next example, I explain the basic functions of setting the GoPiGo3 into motion while avoiding complicated routines.
The program (Figure 4) starts with a while
loop that queries the proximity sensor. The robot moves forward until it encounters an obstacle (i.e., until the proximity sensor returns a value less than 5
cm). For your first driving attempts with the GoPiGo3, you should always set the speed to slow
. The robot is quite robust, but you should still make sure it doesn't go around a corner too fast or fall down stairs.
As soon as GoPiGo detects an obstacle, the program leaves the while
loop and starts a routine to dodge the obstacle: Like an evasive maneuver test (i.e., moose test), the robot turns 90 degrees to the left and moves 15 cm forward, turns 90 degrees to the right and moves 15 cm forward, and so on; the rest of the commands are self-explanatory. As soon as the robot has driven completely around the obstacle, it moves a little farther and then stops.
The robot is best driven on a smooth surface – but not too smooth – otherwise the tires will lose traction. Carpet is not a recommended substrate. Depending on the structure of the carpet, the support wheel can sink so far that it restricts the robot's mobility. You will notice that the robot no longer turns precisely (e.g., 60 degrees instead of 90 degrees) or that it moves forward at an uneven speed.
Hardware, Modules, and Software
The GoPiGo3 is available in different versions. The simplest is the GoPiGo3 Base Kit for $99 (CAN$132; UK£111, EUR107, excl. VAT) [5]. It includes the controller board, the chassis, the motors with encoders, the battery holder (without batteries), and a package with screws – more than you need for assembly. Even if you lose a screw, you should still be able to complete the robot.
The next stage, the GoPiGo3 Starter Kit for beginners ($200; CAN$ 263; UK£ 228, EUR239, excl. VAT) costs about twice as much [6]. The package contains all the components of the GoPiGo3 Base Kit, plus a Rasp Pi 3, additional servos, a proximity sensor, an SD card with DexterOS preinstalled, an 8GB USB stick, and a USB power supply for the Raspberry Pi.
The GoPiGo3 Starter Kit gives you all the components you need to start programming directly in Bloxter or Python. The free Raspbian for Robots download [7] lets you connect your robot to the Internet and program in C, Java, or Node.js. In addition to the different versions, you can purchase more sensors and accessories in the shop [8]. If you are not in the US, Dexter Industries has a number of distributors around the world [9].
Table 1 shows an overview of additional parts available individually, so you can assemble the appropriate modules for your own experiments. The various shops also offer various kits specially tailored for classroom situations.
Table 1
Accessories
>Component | Description |
---|---|
Light & Color Sensor |
Detects brightness and different colors |
Line Follower |
Lets the GoPiGo3 follow a line (black adhesive tape) on the floor |
Grove Infrared Receiver |
A receiver for IR remote control |
Infrared Remote |
IR remote control |
Loudness Sensor |
Lets the robot react to noises |
Grove Buzzer |
A simple buzzer |
Grove Button |
A button |
Speaker |
Speaker for the Raspberry Pi |
Grove LED (red, white, blue, green) |
Light-emitting diodes |
Servo Package |
A servomotor and mounting hardware |
IMU Sensor |
Detects motion, orientation, and position for building a balancing robot |
Temperature, Humidity, & Pressure Sensor |
Gathers environmental data |
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4
-
Fedora Unleashes Atomic Desktops
Fedora has combined its solid distribution with rpm-ostree system to make it possible to deliver a new family of Fedora spins, called Fedora Atomic Desktops.
-
Bootloader Vulnerability Affects Nearly All Linux Distributions
The developers of shim have released a version to fix numerous security flaws, including one that could enable remote control execution of malicious code under certain circumstances.