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's netbook IP address.
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:
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.
A network identifies each computer on the network in one of the 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 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 inet addr
. 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 on the following websites:
There must be a 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.
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.120
The ROS Master address points to the TurtleBot netbook, and the ROS_IP
variable is the IP address of our remote computer's wireless card 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
The netbook setup instructions are 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
where <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.
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 according to the instructions available at: http://learn.turtlebot.com/ in the Setting Up Networking section.
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>
In summary, to set up the communication between the TurtleBot and the remote computer to control the robot, check the following on both the computers:
ROS_MASTER_URI= http://<IP address of TurtleBot>:11311
and
ROS_IP=http://<IP address of TurtleBot>
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.
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:
ifconfig
and env | grep ROS
commands to check whether the network addresses are set correctly.Some information about networks that may be helpful can be found at the following sites:
http://compnetworking.about.com/cs/protocolsdhcp/g/bldef_dhcp.htm
http://compnetworking.about.com/od/ homenetworking/a/routernetworks.htm
To test the system and the communication, perform the following steps:
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 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 deleted for brevity.)
As described earlier, our TurtleBot IP address is 192.168.11.123
.
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, use the command:
$ rosnode list