Networking the netbook and remote computer

ROS has the ability to allow multiple computers to communicate and share nodes, topics, and services. In the case of TurtleBot, the netbook has limited capabilities for graphics applications, such as rviz. It is better to run rviz and other visualization software on a desktop computer or a powerful laptop, both of which will be called a remote computer here to distinguish it from the netbook that rides along with the TurtleBot.

The approach is to designate one computer in the network to run the ROS Master identified by the ROS_MASTER_URI variable and launch the roscore process from that computer. The choice is to set up TurtleBot's netbook as the Master since many applications of the TurtleBot require autonomous motion without the intervention of the remote computer.

Any other remote computer on the network will have its own IP address as the ROS_IP address but its ROS_MASTER_URI variable will be TurtletBot 2's netbook IP address.

Types of networks

Networks between computers can be set up in various ways. To link to the TurtleBot from a remote computer, there are several common ways to network wirelessly:

  • Use a network with a server computer that allows access to the internet with Wi-Fi access, as might be found in a university or any other large organization.
  • Use a router that allows local communication via Wi-Fi between the netbook and the remote computer. This is commonly used when setting up a private network to connect devices to each other wirelessly and to the internet.

The network system in an organization may have security limitations that cover computers that can access their network. It is best to check any such requirements. Also, many such networks have network addresses assigned by a server using Dynamic Host Configuration Protocol (DHCP), which means that the IP address of a computer connected to a network can change if the computer is disconnected from the network and then reconnected. If the IP address changes, it is important to assign the ROS Master address as the new IP address of the TurtleBot's netbook connected to the wireless network.

Network addresses

A network identifies each computer on the network in one of several ways, but each computer connected to the network has a unique identity. If the computers communicate through the internet, you can refer to any internet-connected machine by its Internet Protocol (IP) address, which is a four-part number string (such as 192.168.11.xxx), in which the first part identifies the specific network to which the machine is connected. Another way to refer to the computer is by its hostname, which is usually a text string that consists of the machine name and the domain name.

You can determine the hostname of your computer with the hostname command and the username using the whoami command in the following forms:

$ hostname
$ whoami

In a ROS network, the Master is designated by a URI used to identify the name of the Master on a network. For example, the ROS_MASTER_URI variable for the TurtleBot in the authors' laboratory has the following address:

ROS_MASTER_URI=http://192.168.11.123:11311

The IP address in this case is 192.168.11.123. The IP address of a computer on the network can be determined by the following Ubuntu command:

$ ifconfig

This command will list the communication properties of the computer. The screen output will typically show an Ethernet connection (eth0) if any, a local loopback address (lo), and the wireless IP address (wlan), which is designated as inetaddr. The digits 11311 represent the port used by the ROS Master for communication on the computer.

The description of the ROS networking requirements can be viewed at the following websites:

There must be a network connection between the machines. Using the IP addresses of the machines to identify the machines is sufficient. Only one machine in the network can be the Master.

ROS_IP and ROS_HOSTNAME are environment variables that set the declared network address of a ROS node. The convention is to use ROS_IP if you are specifying an IP address, and ROS_HOSTNAME if you are specifying a hostname. The ROS_HOSTNAME variable takes precedence over the ROS_IP variable.

The ROS_MASTER_URI, ROS_IP, and ROS_HOSTNAME variables are described in the tutorial at: http://wiki.ros.org/ROS/EnvironmentVariables.

In the case of TurtleBot, the ROS Master resides on the netbook and the netbook's IP address must be indicated to the remote computer. On the remote computer, the ROS_MASTER_URI variable must be set to the address of the netbook so that its nodes can register with the Master. Once that is done, the nodes can communicate with the Master and other nodes wirelessly.

Remote computer network setup

To link the remote computer and the TurtleBot's netbook, make sure that both the computers communicate on the same network. This may involve changing the network choice of the computers if there are several networks available.

For your setup of the remote computer, determine the IP addresses of the netbook and your remote computer using the ifconfig command. Your commands will use your specific addresses, and you will use the following commands:

$ export ROS_MASTER_URI=http://<IP address of TurtleBot>:11311
$ export ROS_IP=<IP address of remote computer>

We recommend that you add these commands to the .bashrc file so that the TurtleBot is the ROS Master every time you open a new window.

To be more specific, on our remote computer, we edited our .bashrc file and added the following commands to create these environment variables for the TurtleBot:

export ROS_MASTER_URI=http://192.168.11.123:11311
export ROS_IP=192.168.11.139

The ROS Master address points to the TurtleBot netbook, and the ROS_IP variable is the IP address of our laptop used in this example. The examples just shown using the network addresses were taken from the actual computers used in the authors' laboratory to run TurtleBot. Of course, your addresses will be different.

To check the variables on the remote computer, type the following command to check the IP addresses of the ROS Master and the remote computer:

$ env | grep ROS

Netbook network setup

The netbook setup instructions can be found at the ROS wiki location at: http://wiki.ros.org/turtlebot/Tutorials/indigo/Network%20Configuration.

To set up the netbook addresses, you can type the following command at the netbook terminal window:

$ echo export ROS_MASTER_URI=http://<IP address of TurtleBot>:11311 >> ~/.bashrc
$ echo export ROS_IP=<IP address of TurtleBot> >> ~/.bashrc

Here <IP address of TurtleBot> is replaced with the IP address of the TurtleBot netbook, which is normally called the IP address of the TurtleBot. This sets the TurtleBot as the Master.

Secure Shell (SSH) connection

The Secure Shell (SSH) will be used to allow remote login to the TurtleBot's netbook from the remote computer. Check the SSH status with the following command:

$ sudo service ssh status

If the SSH service is not present, install it using this command:

$ sudo apt-get install openssh-server

Then run the previous command to check the SSH status. This software package should be installed on both the TurtleBot netbook and the remote computer.

For the authors' TurtleBot netbook, our username is turtlebot. Your username can be found by running the following command:

$ whoami

To communicate with the TurtleBot, on the remote computer, type the ssh command in the following form and enter your TurtleBot password when prompted:

$ ssh <username>@<IP address of TurtleBot>

Summary of network setup

In summary, to set up the communication between the TurtleBot 2 and the remote computer to control the robot, check the following on both the computers:

  • TurtleBot's netbook hosts the ROS Master with:
    ROS_MASTER_URI= http://<IP address of TurtleBot>:11311
    

    and

    ROS_IP=http://<IP address of TurtleBot>
    
  • The remote computer has:
    ROS_MASTER_URI = http://<IP address of TurtleBot>:11311
    

    and

    ROS_IP=http://<IP address of remote computer>
    

The addresses here are assumed to be the addresses of the TurtleBot netbook and the remote computer on a wireless network.

Troubleshooting your network connection

Many problems in networking ROS occur because the IP addresses of the netbook and the remote computer are not set correctly. Perform the following steps:

  1. Check the computers' network settings.
  2. Make sure that the network is working by communicating with the server or router for the network.
  3. Use the ifconfig and env | grep ROS commands to check whether the network addresses are set correctly.
  4. If your network has DHCP, see if the assigned IP addresses have changed.

Note

Some information about networks that may be helpful can be found at the following site:

https://www.lifewire.com/networking-with-a-router-817719

Testing the TurtleBot 2 system

To test the system and the communication, perform the following steps:

  1. Make sure that the TurtleBot base battery and the netbook battery are charged.
  2. Plug in the netbook to the base and power up the base.
  3. Turn on the netbook and log on using the netbook's password and then connect to your network.
  4. Give the TurtleBot room to move without obstacles in the way.
  5. Log on to the remote computer and start communicating with the TurtleBot through your network.

This procedure is used to command the robot from the remote computer by typing the ssh command at the remote computer terminal and entering the TurtleBot password. The first example in the Using keyboard teleoperation to move TurtleBot section will allow you to control the TurtleBot using several keyboard keys.

To start communication with the TurtleBot from the remote computer, type the ssh command and enter the TurtleBot password when prompted:

$ ssh <username>@<IP address of TurtleBot>

(The output is not included for brevity.)

As described earlier, our TurtleBot IP address is 192.168.11.123.

Note

The window prompt will change to the window prompt of the TurtleBot netbook. Our netbook prompt is turtlebot@turtlebot-0428:~$ and has been left in the following command lines to identify where the commands are issued.

After the response, you can send commands to the TurtleBot by typing the following command:

turtlebot@turtlebot-0428:~$ roslaunch turtlebot_bringup minimal.launch

The output is as follows:

.
.
Checking log directory for disk usage. This may take awhile

After a long list of parameters and nodes, you will see the ROS Master address. In our system, the output is as follows:

auto-starting new master
process[master]: started with pid [23426]
ROS_MASTER_URI=http://192.168.11.123:11311

This line of the output shows that the TurtleBot is the ROS Master. It is followed by a list of the processes running and other information.

To view the nodes that are active after the minimal launch, in a second terminal use the following command:

$ rosnode list
..................Content has been hidden....................

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