© David Allen Blubaugh, Steven D. Harbour, Benjamin Sears, Michael J. Findler 2022
D. A. Blubaugh et al.Intelligent Autonomous Drones with Cognitive Deep Learninghttps://doi.org/10.1007/978-1-4842-6803-2_3

3. Installing Linux and Development Tools

David Allen Blubaugh1  , Steven D. Harbour2, Benjamin Sears3 and Michael J. Findler4
(1)
Springboro, OH, USA
(2)
Beavercreek Township, OH, USA
(3)
Xenia, OH, USA
(4)
Mesa, AZ, USA
 
Before we start developing our rover, we have to install the right tools. Just like a carpenter needs a hammer to nail and a painter needs a paintbrush to paint, we need tools to support our project. Our rover will use the Robot Operating System (ROS), and ROS runs on Linux. Linux gives us a simple text editor and the Python programming language. We also need a simulator to test whether our rover works; thus, we will install ROS-aware Gazebo and Rviz. Finally, we assume most of our audience will be using the Windows operating system, so we will install all of these programs on a virtual machine using VirtualBox. In summary, we will review the following:
  • Installing Oracle’s VirtualBox in Microsoft Windows

  • Installing Linux Ubuntu 20.04.4 in VirtualBox

  • Acquiring the ROS environment variable key

  • Installing ROS

  • Starting ROS for the very first time

  • Learning important Linux ROS shell commands

  • Installing Anaconda

  • Learning Ubuntu Linux commands necessary to develop rover prototypes

  • What are ROS launch files?

  • Running Gazebo and Rviz to test our system

  • Summary, exercises, and hints

Before We Begin

We must consider the following preconditions:
  1. 1.

    If you are planning on using the Ubuntu Linux operating system as the host operating system, then there is no need to install VirtualBox.

     
  2. 2.

    Different versions of ROS target specific versions of Ubuntu Linux. We will use Noetic ROS, which specifically requires Ubuntu Linux 20.04.4. Make sure you match the ROS version to the correct Linux version. This is important during “Installing VirtualBox …” and “Installing Ubuntu Linux …”

     
  3. 3.

    The ORDER of installation is important: VirtualBox, Ubuntu, Anaconda, ROS. Any other order may cause problems.

     
  4. 4.

    Ubuntu Linux 20.04.x is also known as Focal Fossa. We will call it Ubuntu. We will use Noetic ROS, but we will call it ROS.

     
  5. 5.

    Although all shell text commands will be for Noetic ROS, they are compatible with earlier versions of ROS, such as Kinetic and Indigo.

     

Installing the VirtualBox Software

The purpose of the Oracle VirtualBox is to create virtual machines to develop and run programs in an operating system other than your regular system. The virtual machine is an emulation of the target operating system. We want the Ubuntu Linux 20.04.04 OS emulated on our Microsoft Windows system. (There are versions of VirtualBox for Mac OS and Linux.) After installing VirtualBox, we will install an Ubuntu Linux 20.04.04 virtual machine. This virtual Ubuntu Linux 20.04.4 OS will serve as our ROS development environment. This virtual machine is essentially a program that executes an entire operating system, such as Ubuntu Linux 20.04.4 OS, as an application. The physical computer, running Microsoft Windows, serves as the host, and Ubuntu Linux 20.04.4 serves as the guest.

The Ubuntu Linux guest operating system in VirtualBox will be the very foundation of our test and development environment for the rover in this book.
  1. 1.

    Install Oracle’s VirtualBox from the following link:

     

www.virtualbox.org/wiki/Downloads

Go to the list of host operating systems and choose Microsoft Windows and install the VirtualBox software (orange box in Figure 3-1). For other operating systems, see www.virtualbox.org/manual/ch02.html.

A screenshot of download virtual box tab.

Figure 3-1

Downloading Oracle’s VirtualBox

  1. 2.

    After downloading the VirtualBox executable, find the file and double-click on it to execute. You should now see an image something like Figure 3-2. Click Next.

     

A screenshot of Oracle setup wizard window with highlighted next button.

Figure 3-2

Installing Oracle’s VirtualBox

  1. 3.

    Accept the default settings on the next couple of pop-up windows until you get the warning about resetting the network (Figure 3-3). Click Yes, and the VirtualBox program will install.

     

A screenshot of Oracle network interfaces window with highlighted yes button.

Figure 3-3

Installing Oracle’s VirtualBox (continued)

Creating a New VirtualBox Virtual Machine

Now that we have installed Oracle’s VirtualBox, run the program by double-clicking on its icon.
  1. 1.

    After it starts, you will see an area on the window that looks like Figure 3-4. To create a new machine, i.e., one that has not been installed before, click on New. If you do not see this ribbon bar, then you can access it from the Tools ➤ New toolbar.

     

A screenshot of buttons labeled preferences, import, export, new, and add. Text below it reads welcome to Virtualbox!

Figure 3-4

Creating a virtual machine within Oracle’s VirtualBox

  1. 2.

    Fill out the installation form like in Figure 3-5. Click Next. This does not install the operating system; it is a placeholder for later.

     

A screenshot of Oracle setup wizard window for filling name, machine folder, type, and version. Next button is highlighted at the bottom.

Figure 3-5

Creating a virtual machine within Oracle’s VirtualBox

  1. 3.

    Next, we allocate memory for our development system. The default is 1024 MB, but we will allocate at least 2048 MB (Figure 3-6). You may allocate more, but 2048 MB is enough.

     

A screenshot of Oracle setup wizard window for selecting memory size. Next button is highlighted at the bottom.

Figure 3-6

Allocating memory for the virtual machine

  1. 4.

    To create the virtual disk on the physical hard disk, accept the default settings shown in Figure 3-7. Since we do not have an existing drive, we have to create a new drive.

     

A screenshot of Oracle setup wizard window for check-in options for hard disk. Create a virtual hard disk now option is checked-in and create button is highlighted at the bottom.

Figure 3-7

Creating virtual hard disk

  1. 5.

    Accept the default setting for the virtual hard drive type shown in Figure 3-8. We chose VDI because it is optimized for VirtualBox.

     

A screenshot of Oracle setup wizard window for check-in options for hard disk file type. V D I option is checked-in and next button is highlighted at the bottom.

Figure 3-8

Setting the virtual hard drive type

  1. 6.

    Accept the default setting for the type of physical disk storage type shown in Figure 3-9. We chose dynamic, so the size can grow and shrink automatically.

     

A screenshot of Oracle setup wizard window for check-in options for storage on physical hard disk. Dynamically allocated option is checked-in and next button is highlighted at the bottom.

Figure 3-9

Setting the physical hard drive to allocate dynamically

  1. 7.

    Finally, set the location and maximum size your virtual disk can hold (Figure 3-10). The default location is derived from your original disk name, and the default size is okay for our little project. Click Create.

     

A screenshot of Oracle setup wizard window for file location and size. Size is set at 10 G B and create button is highlighted at the bottom.

Figure 3-10

Setting the location and size of the virtual disk

  1. 8.

    You should now have a virtual machine installed, as shown by the orange box in Figure 3-11.

     

A screenshot of Oracle V M Virtual box manager. A bar on the left lists melodic Linux running and Ubuntu R O S power off.

Figure 3-11

Installation complete

What we have just done is create an empty disk that we will next install in our Ubuntu Linux operating system.

Installing Linux Ubuntu 20.04.4 in VirtualBox

To download the required DVD/CD ISO image for Ubuntu Linux 20.04.4, a.k.a Focal Fossa, go to http://old-releases.ubuntu.com/releases/20.04.4/.

By default, the image is a 64-bit architecture, so you will see a 64-bit PC (AMD64) desktop image. If your physical RAM is less than 4 GB you should use the 32-bit architecture version. Even though it says “AMD” it is also the download for Intel chips.
  1. 1.

    After downloading the Ubuntu image, we need to load it into our virtual machine on VirtualBox. Click on Ubuntu_ROS to highlight that virtual disk. Click on Settings, and you will see a popup menu similar to that in Figure 3-12.

     

A screenshot of Ubuntu R O S settings of general options in Oracle V M Virtual box manager.

Figure 3-12

ISO settings

  1. 2.

    We need to install the specific version of the operating system that we set as a placeholder earlier (“Installing VirtualBox,” Step 3). Our version is dictated by the Noetic ROS, which is specifically designed for Ubuntu Linux 20.04.4. Click on Storage. In Figure 3-13, notice the empty disk icon (orange box) and the disk on the far right (red box). This is where we will attach our downloaded ISO image. Click the red box icon to connect the downloaded ISO file. Choose the first option, “Choose Virtual Optical Disk File…”

     

A screenshot of Ubuntu R O S settings of storage options in Oracle V M Virtual box manager.

Figure 3-13

Storage settings needed to attach ISO image

  1. 3.

    Find and select your downloaded ISO file. Ours was saved in the “Download” folder. Select “Ubuntu-20.04.4-desktop-amd64.iso” and then click Open. This will attach the ISO file to your VirtualBox as the operating system. If you wanted to, you could now run your Linux system. However, we are going to tweak the settings of our operating system to make the development environment easier to use, as seen in Figure 3-14.

     

A screenshot of Windows explorer with I S O image files.

Figure 3-14

Select your ISO image and open it

  1. 4.

    In Figure 3-15, the word “empty” has been replaced with your ISO image name. Your operating system is installed.

     

A screenshot of Ubuntu R O S settings with selected file for of storage in Oracle V M Virtual box manager.

Figure 3-15

ISO image attached

  1. 5.

    Change your display settings to match Figure 3-16. We assume you have at least 4 GB video and SVGA. Setting the Scale Factor to 200% lets the window be a reasonable size.

     

A screenshot of Ubuntu R O S settings of display options in Oracle V M Virtual box manager.

Figure 3-16

Display settings

  1. 6.

    Finally, we need to set a couple of system settings. Figure 3-17 shows the optimal RAM to be assigned (green bar), and Figure 3-18 shows the optimal CPUs that can be assigned (green bars). The green bars match your computer’s hardware our system has 8 GB RAM and 4 CPUs, so that is what we assigned. If you choose any values in the red, then the system will be configured to a different set of hardware; therefore, it will be slower.

     

A screenshot of Ubuntu R O S settings of system motherboard options in Oracle V M Virtual box manager.

Figure 3-17

System motherboard settings

A screenshot of Ubuntu R O S settings of system processor options in Oracle V M Virtual box manager.

Figure 3-18

System processor settings

  1. 7.

    Your system should now be ready to install a fully operational virtual Linux system. Click on Start (or double-click on your drive) to start installing your Linux system. See Figure 3-19.

     

A screenshot of settings, discard, and start button with a drop-down menu next to it. The settings and start button are highlighted.

Figure 3-19

Starting the Ubuntu Linux OS as a guest virtual machine

  1. 8.

    Click on Install Ubuntu (Figure 3-20). We will be selecting the defaults most of the time during the installation. If necessary, change the settings for your installation.

     

A screenshot of Ubuntu Linux O S install setup window with preference for language. Two icons on the right are try Ubuntu and install ubuntu.

Figure 3-20

Ubuntu Linux OS install setup

  1. 9.

    Our next step is to set the keyboard preferences (Figure 3-21). The default settings were sufficient for us since we are currently located in the United States.

     

A screenshot of Ubuntu Linux O S install setup window for keyboard layout selected to the U S english .

Figure 3-21

Ubuntu keyboard preferences

  1. 10.

    Once we have established the keyboard settings, we can then set the normal installation for Ubuntu (Figure 3-22).

     

A screenshot of Ubuntu Linux O S install setup window for updates and other software. The normal installation and download updates while installing are checked-in.

Figure 3-22

Normal Ubuntu installation

  1. 11.

    We assume there are no prior installments of Ubuntu before proceeding with the final installation (Figure 3-23). The default settings are once again sufficient for us.

     

A screenshot of Ubuntu Linux O S install setup window for installation type selected to erase disk and install Ubuntu.

Figure 3-23

Erase disk and install Ubuntu (continued)

  1. 12.

    Once the installation process begins, we might also encounter a warning that declares that we are about to rewrite the targeted virtual disk (Figure 3-24). We then click Continue.

     

A screenshot of Ubuntu Linux O S install setup confirmation window for writing the changes on the disk.

Figure 3-24

Ubuntu installation warning

  1. 13.

    Set the correct time zone for the Ubuntu computer system (Figure 3-25).

     

A screenshot of Ubuntu Linux O S timezone setting on the world map with highlighted New York.

Figure 3-25

Ubuntu timezone setting

  1. 14.

    Finally, we input the name, username, and password for the Ubuntu system (Figure 3-26). Since we are only using Ubuntu as a development platform, we should use a strong password for security purposes. To maintain the highest levels of password security for the Ubuntu Development environment, we could use numbers 0–9, letters a–z or A–Z, and special characters such as #, ^, and *.

     

A screenshot of sections to fill in name, computer's name, username, password, confirm password, and require my password to log in.

Figure 3-26

Setting the name, username, and password for the Ubuntu installation

Congratulations! You have successfully installed Ubuntu Linux, as indicated by the green rectangle in Figure 3-27. Next, we will need to install the tools needed for software development. Ubuntu gives us Python as our programming language and Gedit text editor. We need to install ROS, which will give us the library to control the rover. The full ROS installation will give us simulator and visualization tools, Gazebo, and Rviz. We will add a couple of other libraries that will be used later in the book, namely TensorFlow (deep learning) and OpenCV (computer vision).

A screenshot of Oracle V M Virtual ox manager with listed melodic Linux and Ubuntu R O S.

Figure 3-27

Ubuntu finally installed

Updating Ubuntu Linux 20.04.4

Now that we have installed Ubuntu, to start the operating system, click on the Start button (Figure 3-27). You may be prompted for additional installation information; just reply “yes” to the default choices. It will also ask you to log in. After the operating system launches, you should have a window that looks like Figure 3-28. (The VirtualBox menu and bottom of the screen commands will be cropped off of future images.) We are now ready to install ROS through terminal commands.

A screenshot of Ubuntu home screen.

Figure 3-28

Ubuntu initial screen

In Figure 3-28, the desktop includes system application icons on the left, a trashcan to delete items, a header bar that has the day and time, and four icons in the upper right-hand corner (network, sound, battery, and down arrow). We will discuss these as necessary.
  1. 1.

    To start a terminal window, right-click on the desktop background, being sure to avoid icons (Figure 3-29). Click on the Open in Terminal menu choice.

     

A screenshot of Ubuntu home screen with open in terminal option selected on the right-click access menu.

Figure 3-29

Ubuntu open terminal selection. Access menu by right-clicking

  1. 2.

    On a freshly installed Linux system, your terminal will be full screen (Figure 3-30). Later on, we will run multiple terminals at the same time, so let’s make the terminal “windowed” by clicking on the □ in the upper-right corner of the terminal, as indicated by the orange arrow.

     

A screenshot of Ubuntu terminal window with an arrow pointing at a square button.

Figure 3-30

Ubuntu terminal session

  1. 3.

    Now we have a terminal window on our desktop (Figure 3-31). The installation of ROS will be done through this terminal window using commands. We are not going to fully explain the commands, since it is beyond the scope of this book, but simple internet research should suffice if you want to investigate further.

     

A screenshot of Ubuntu terminal window on the home screen.

Figure 3-31

Ubuntu initial terminal screen

  1. 4.

    Even though we just installed Ubuntu Linux 20.04.4, there may be software updates to drivers, applications, etc. We need to update the operating system. We will be using sudo apt-get commands. Sudo means “superuser do” and it temporarily elevates you with system administrator privileges; therefore, you will have to enter your password. Execute the following command in the terminal to update the necessary features:

     
$ sudo apt-get update
We can also see the first command in Figure 3-32 highlighted in the orange rectangle. After entering your password, you will see a few lines of updates. This is a download of lists of the latest version numbers of operating system files, not the upgrades! Enter the following:
$ sudo apt-get upgrade

to upgrade your operating system files to the latest versions.

After it stops, you will now have the newest version of Ubuntu Linux 20.04.4 installed (Figure 3-33). As an aside, for this chapter, from now on, we will show commands in the terminal in an orange rectangle, not in text prose.

A screenshot of command window with two highlighted text that reads sudo apt-get update and sudo apt-get upgrade.

Figure 3-32

Ubuntu terminal update command

A screenshot of command window with a list of commands.

Figure 3-33

Ubuntu terminal update completed

We have now updated our Ubuntu Linux system to the latest version. Next, we need to set up Ubuntu to allow external libraries (ROS, etc.) These libraries come from external repositories.

Configuring Ubuntu Repositories

To download repositories from external third-party software sites, such as ROS.org, we need to tell the system about these sites. To do this, click on the System Settings icon on the left side of your desktop (Figure 3-34).

A screenshot of Ubuntu system settings icon.

Figure 3-34

Ubuntu system settings icon (orange box)

Up pop several icons. Click the Software Updates icon on the desktop (Figure 3-35).

A screenshot of Ubuntu software update icon.

Figure 3-35

Ubuntu software update icon

Next, we select the Settings option as in Figure 3-36. The Settings option defines the software to be installed or upgraded, including third-party software, such as ROS.

A screenshot of Ubuntu software update dialog box with highlighted settings button.

Figure 3-36

Ubuntu software settings option

On the new popup window, select the Ubuntu Software tab and set the checkboxes shown in Figure 3-37. Once those selections have been made, then please click Close. These selections approve the download of third-party software.

A screenshot of highlighted Ubuntu software tab on a dialog box titled software and updates.

Figure 3-37

Display of selected repository checkboxes

Installing Anaconda

As a reminder, the ORDER of installation is important: VirtualBox, Ubuntu, Anaconda, ROS. Any other order may cause problems.

Developing a complex software project is made more manageable if we use an integrated development environment (IDE). An IDE combines a simple text editor (Gedit) and a compiler (Anaconda). Doing the programming in an IDE makes the programming process easier because the built-in tools and the IDE are smart enough to catch simple errors. There are many great IDEs available for Linux; we chose Gedit for its elegant simplicity. The Anaconda compiler can run Python 2.7, which is required by ROS.

First, we need to install the Anaconda Python compiler from https://anaconda.com/products/individual. Scroll down to find the link for the 64-bit Linux download (Figure 3-38).

A screenshot of Anaconda installer wizard with 64-bit x86 installer 529 M B option selected.

Figure 3-38

Anaconda install

Now that we have downloaded the installation file, we need to locate it. Figure 3-39 shows the four steps: 1) click on the file cabinet; 2) click on downloads; 3) you will see the Anaconda shell script, and 4) open a terminal at this disk location using a right-click near the file name.

A screenshot of highlighted downloads and open in terminal option.

Figure 3-39

Anaconda locating download

After opening the terminal, enter the two commands shown in Figure 3-40. The first command makes the shell script executable. The second command executes the shell script so that it is installed on Linux.

A screenshot of command window while installing Anaconda.

Figure 3-40

Anaconda bash install

Now that we have installed our compiler, we need to set up the operating system to accept ROS. We do this by setting up the ROS source list and key.

ROS Source List

Now that we have successfully configured our Ubuntu repositories to allow for “restricted,” “universe,” and “multiverse” repositories, allowing the installation and updating of the necessary supporting software for ROS, we can now set up the required software list from the ROS.org Foundation website. This can be accomplished with the following terminal command:
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

The ROS source list has now been configured. Now we will set the ROS environment key.

ROS Environment Variable Key

The ROS environment variable key verifies and validates the origin of the ROS source-code repository. It also guarantees the software has not been modified without the consent of the owner. The key makes the ROS repositories “trusted” software sites for downloads, installations, and updates. Type in the following shell command at the terminal prompt (Figure 3-41):
$ sudo -E apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

A screenshot of command window while installing Anaconda with Noetic R O S install key.

Figure 3-41

Getting Noetic ROS install key

Note

The ROS.org Community recently discovered a security flaw with the original key for Noetic ROS. That is why we are using this newer key. The reader needs to be vigilant of all security upgrades, maintenance, and/or additional enhancements within the ROS ecosystem. The reader needs to occasionally review and check for such security updates within the ROS.org discussion forums.

Installing the Robotic Operating System (ROS)

The two commands needed to install ROS are shown in Figure 3-42. The first command is just good practice and verifies all the system software is up to date, while the second command installs the full ROS library. The downloading and installation of over 1,000 files can take a long time. (My computer took more than 30 minutes.)

A screenshot of command window with two highlighted text that reads sudo apt-get update and sudo apt-get install ros-noetic-desktop-full.

Figure 3-42

Ubuntu ROS install

The full-featured version of Noetic ROS should now be installed. Let us take this system out for a spin.

Note

If you receive an error that none of the Noetic packages could be located, you might be required to upgrade the Ubuntu software. Please execute the following terminal commands:

$ sudo apt-get update

$ sudo apt-get upgrade

Installing ROSINSTALL

You have successfully installed ROS to your Linux system. However, there exist some additional libraries that will make the development of your project simpler. These are accessed through rosinstall:
$ sudo apt-get install python3-rosinstall
$ sudo apt-get install python3-rosinstall-generator
$ sudo apt-get install python3-wstool build-essential

Be very careful about the spaces and dashes in the previous command. If you get an error, verify every dash and space.

Starting ROS for the Very First Time

The next three commands are used to wake up ROS and check for any ROS-dependent library updates. These should be run the first time you start up ROS. The ROS we downloaded and installed in Figure 3-42 may not have the latest subcomponents. The second command checks for any updates available for subcomponents.
$ sudo apt-get install python3-rosdep
$ sudo rosdep init
$ rosdep update

Adding the ROS Path

Every time you want to use ROS, you need to tell the operating system where to look for the ROS commands, i.e., add the ROS path to the global path. Since we have to do this every time we want to use ROS, we will create a bash script. In a text editor (Gedit), create a file called STARTrosconfig.sh with the included lines (Figure 3-43).

A screenshot of command window.

Figure 3-43

Starting ROS configuration in Gedit

Next, save the file to the /home/ros directory. This will be reflected in the Gedit user interface by the small orange box, as in Figure 3-44. Open a new terminal. Using Figure 3-38 as our guide, we are going to make STARTrosconfig.sh executable. Orange boxes are commands you will type in, and green boxes are outputs you should observe. After you type in your first two commands, observe that STARTrosconfig.sh is white, which means it is not executable. The next command (ls -la STARTrosconfig.sh) is optional and looks at the details for the file. You should note that the file can be read (r) and written (w), but not executed (-). To change this, you must issue the change mode command (chmod +rwx STARTrosconfig.sh). To verify the change occurred, ls -la STARTrosconfig.sh will show rwx and a green name. Success!

A screenshot of command window with many highlighted commands.

Figure 3-44

Making STARTrosconfig an executable

Every time you want to work with ROS, open a terminal and type source STARTrosconfig.sh. This adds the ROS path to the system (Figure 3-45). To verify the ROS variables were installed correctly, type env | grep ROS_*. This command looks at the environment variables (env) and selects only those variables starting with “ROS_”.

A screenshot of command window.

Figure 3-45

Verify ROS paths

Creating a ROS Catkin Workspace

Once the ROS environment variables have been established, we create a workspace directory to develop the ROS applications. ROS requires a “catkin” workspace consisting of three subfolders (src, build, and devel). Each of these folders needs script files to help compile the project. This workspace should be located in the user home directory. Therefore, use the following shell commands to create the workspace:
$ cd ~
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
$ cd ..
$ catkin_make
Note

If you receive the following error—“Ackermann msgs were not found by Cmake”—or that any other type of error message was not found, then you need to manually install the correct package, such as the Ackermann package, as follows:

$ sudo apt install ros-noetic-ackermann-msgs

The script command catkin_init_workspace sets the src folder as the project source file repository. The script command catkin_make creates the devel and build folders and adds the necessary script files. We will use the catkin_ws workspace as the central directory to develop and test all of the software components. Now we need to make certain that the catkin_ws workspace is sourced for ROS:
$ source ~/catkin_ws/devel/setup.bash
$ echo “source ~/catkin_ws/devel/setup.bash” >> ~/.bashrc
Now you should have the catkin_ws workspace successfully sourced as the main workspace that operates on top of the ROS environment. As such, if you execute the following shell text command:
$ echo $ROS_PACKAGE_PATH
It should then display the following output to the terminal prompt window:
/home/<username>/catkin_ws/src:/opt/ros/noetic/share
Note

<username> will be the Ubuntu Linux OS username you defined earlier.

The catkin_ws workspace has now been sourced as the main workspace directory for developing applications within the ROS environment. If we did not obtain the ROS package path directory output as expected, please consult debugging issues within the ROS.org Community website for further information.

Final Checks for Noetic ROS

The following shell text command will determine if the correct version of ROS has indeed been installed and is operational:

$ rosversion -d

If the output is Noetic, then you have completely succeeded in obtaining a fully operational ROS environment. Congratulations.

Note

All shell commands used in this book are compatible with both the current and future Noetic versions of ROS. The only difference might be the number of parameters and substituting the word “Noetic” for the correct rosversion where necessary.

Noetic ROS Architecture

With the successful installation of Noetic ROS, we will introduce its architecture. The ROS architecture was designed to operate with robots of all types (rovers, drones, planes, boats, submarines, etc.). As such, the ROS framework was designed to handle multiple components or nodes in a robot. A node is a sensor, motor, controller, etc. In other words, it is a piece of hardware that performs a function for the robot. ROS refers to a “program node” as the software necessary to control the hardware. The primary node is known as the central master node.

The ROS architecture handles the communication between nodes. For example, if the central master node receives data from a distance sensor node indicating an object is in our path, then the master node might send move commands to a driver node to change the robot’s directions (Figure 3-46). The ROS architecture helps us to manage the increasing complexity of a robot system as more features, sensors, and actuators are added.

A schematic of an oval labeled master connected to line detector via surface, driver via velocity, controller via distance, surface, and velocity, and distance sensor via distance.

Figure 3-46

Preliminary ROS architecture AI rover layout

Figure 3-46 shows five nodes: the master node and four system nodes. When a system node starts, it sends information to the master comprising the type of data that the node can send and receive. The nodes that send data to the master node are called publisher nodes. For example, the Distance Sensor and Line Detector nodes are publisher nodes, since they send data (distance to target and surface information, respectfully) to the master node. The nodes that receive data from the master node are called subscriber nodes. So the Driver node is a subscriber node since it receives velocity data from the master node. The Controller node is both a publisher and a subscriber node.

The Controller node will be hosting the deep learning and cognitive deep learning routines developed in later chapters. These deep learning routines will send and receive messages to and from the ROS master node. The master node will reroute that message to their intended nodes, such as a message to the Driver node to control the speed.

Simple “Hello World” ROS Test

Now that we have described the basic ROS architecture, let’s determine if our installation of ROS was successful by executing simple ROS tutorial scripts. This script will simply have two ROS nodes: a talker (publisher) and a listener (subscriber). If we look at Figure 3-47, we see three nodes. First, when the listener is created, it tells the master node that it wants to listen to the talker (subscribes). Next, when the talker is created it registers with the master node. Finally, the talker generates (publishes) a message; this means it sends the message to the master. This causes the master node to send the message to all nodes listening to the talker, which means the message is sent to the listener.

A schematic of an oval labeled R O S master with a box below it labeled hello world. Two ovals on the bottom left and bottom right labeled talker node and listener node point at R O S master via arrows labeled 1 and 2, respectively. An arrow from talker node points at hello world which point at listener node.

Figure 3-47

Simple talker and listener node ROS test example

We are eventually going to open three terminals, each one a node. (If you want to, install Terminator from the Ubuntu Software store to open multiple tiled terminals. It makes running the ROS scripts easier.) Open the first terminal, which we will make the ROS master node:
$ roscore
Go back to the desktop and open a second terminal. We will make it the listener:
$ rosrun roscpp_tutorials listener
Go back to the desktop and open a third terminal and make it the talker:
$ rosrun roscpp_tutorials talker
You should then see on the talker terminal:
hello world 0
hello world 1
hello world 2
...
And you should then see on the listener terminal:
I heard: [hello world 0]
I heard: [hello world 1]
I heard: [hello world 2]
...

If you have made it this far, congratulations, you have successfully installed VirtualBox, Ubuntu Linux, and Noetic ROS. (Do not shut down the nodes, as we will use them in the next section.) Next, we visit two components that come with ROS: RQT Graph and Gazebo Robot Simulator. (We will talk about Rviz and TensorFlow when we use them.)

ROS RQT Graph

The RQT Graph is an important visualization and debugging tool. This graphing tool will be used to debug running nodes and inspect the communication between them. We will use RQT Graph to inspect our two nodes that are running from the previous section. In a new terminal, enter the following command, and you will get something like Figure 3-48:
$ rosrun rqt_graph rqt_graph

A screenshot of R Q T graph tool window. A oval on the left reads talker and an oval on the right reads listener with a rightward arrow in between labeled chatter.

Figure 3-48

Talker node sending information to listener node

The ROS command rosrun rqt_graph rqt_graph graphically displays all active publisher and subscriber nodes in an RQT Graph window. The interpretation of Figure 3-43 is that /talker is sending a message to /listener. Notice that the ROS master node is left out. The default message pipeline name is /chatter.

ROS Gazebo

Gazebo is a graphical simulation tool used to visualize any virtual world you create. The virtual world can contain objects, robots, buildings, obstacles, etc. You define them in terms Gazebo understands, and it will be simulated in a Gazebo window.

Gazebo is a standalone program that needs to be tied to the ROS system and world definition. This means we will “launch” the program from “within” ROS using the roslaunch command. Briefly, the ROS way of doing things: rosrun and roslaunch. The command rosrun launches a (Python) script to run an object’s script by itself (or a limited number of other objects). In contrast, roslaunch loads and executes all objects (and associated scripts) in a world environment, where each object can interact with the other objects.

The roslaunch tool is the standard ROS method for starting Gazebo’s simulated world and robots. To verify that Gazebo is correctly installed, we will launch the supplied willowgarage_world.launch shown in Figure 3-49 with the following command:
$ roslaunch gazebo-ros willowgarage_world.launch

A computer generated layout of Willow garage.

Figure 3-49

Willow Garage generated world

Now that we have verified Gazebo is installed correctly, we will be replacing the willowgarage_world.launch file with our world: a simplified simulated world of the unexplored Egyptian Catacombs and our intrepid AI rover. The AI rover’s scripts with adaptive intelligence and decision making will circumvent ancient dangers that might still await us.

Summary

To start our project, we installed VirtualBox and a virtual Ubuntu Linux 20.04.4 LTS operating system. We then installed Anaconda, our Python programming interpreter, on Ubuntu. Lastly, we successfully installed the Noetic ROS on Ubuntu. This completed setting up our development environment.

To verify the environment was successfully installed, we created and ran two ROS nodes that communicated through Python scripts. We used RQT Graph to visualize the running nodes. Finally, we verified the Gazebo simulator could be launched from ROS. (I don’t know about you, but I am tired.) Now that we have set up our development environment, we can start designing and developing our AI rover explorer and our simplified virtual Egyptian catacombs world.

Extra Credit
  1. 1.

    What other worlds can be explored within the roslaunch command for the Gazebo simulator? If need be, please consult internet resources.

     
  2. 2.

    What other tests could be used to determine a successful installation of ROS?

     
  3. 3.

    What other messages can be exchanged between nodes?

     
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.252