Professional Documents
Culture Documents
A detailed tutorial
Abstract
In a Robot Operating System (ROS) application, robot software is often distributed across multiple networked
components, forming the ROS network, where every component acts as server and/or a client, and publishing and/
or receiving robot data simultaneously. For indoor robots, a local ROS network, through a Wi-Fi hotspot, is
sufficient. But for outdoor robots, a remote ROS network is needed to connect the ROS application to the cloud.
Although a number of cloud-based solutions support this, implementing them is challenging, as they need to be
configured to facilitate ROS’s unique, multidirectional, and simultaneous flow of robot data. This article presents
Port Forwarding as an alternative approach, which offers a private, secured, and a direct ROS-to-ROS, eliminating
the need for a dedicated middleware and its configuration and setup complexities. But Port Forwarding has its own
challenges; chiefly, the beforehand knowledge of Internet addresses of all networked components and the need to
update port forwarding settings when these addresses change, which they often do. This article addresses this issue
(and others) and presents a detailed procedure for setting Port Forwarding for ROS applications, highlighting
configuration, and troubleshooting steps. Also, the article compares between Port Forwarding and cloud-based
solutions, in terms of setup, performance, and others. Results show that robot performance under Port Forwarding
is on par with cloud-based solutions, but it required a fraction of setup time. The authors developed a set of shell
scripts that monitor the Internet addresses of all networked components and auto-update Port Forwarding settings
when they change, solving this issue. With this, Port Forwarding could be considered a viable option for ROS
system networks, on par with cloud-based solutions.
Keywords
Robot operating system (ROS), robot software, cloud robotics, port forwarding, agriculture robots
Introduction
The Robot Operting System (ROS) is one of the fastest
growing platforms for robot software development,1,2 and Centre for Advanced Mechatronics and Robotics, College of Engineering,
one of its many features is software distribution. As often Universiti Tenaga Nasional Malaysia (UNITEN), Kajang, Selangor, Malaysia
in a ROS application, robot software is distributed over mul-
tiple networked components, forming the ROS network Corresponding author:
Sami Salama Hussen Hajjaj, Centre for Advanced Mechatronics and
shown in Figure 1. In this network, robot data are shared Robotics, College of Engineering, Universiti Tenaga Nasional Malaysia,
among all connected components, with every component 43000 Kajang, Selangor, Malaysia.
publishing and/or subscribing to this robot data, and ROS’s Email: ssalama@uniten.edu.my
Creative Commons CC BY: This article is distributed under the terms of the Creative Commons Attribution 4.0 License
(http://www.creativecommons.org/licenses/by/4.0/) which permits any use, reproduction and distribution of the work without
further permission provided the original work is attributed as specified on the SAGE and Open Access pages (https://us.sagepub.com/en-us/nam/
open-access-at-sage).
2 International Journal of Advanced Robotic Systems
Configuration steps
The configuration steps discussed below vary for each type
of connection, specifically:
This is very important, if the local IP address of the robot Table 1. PortChecker test results and their meanings.
changed for some reason, then the user must come back
Result Netcat server Indication
here and reconfigure the router. Alternatively, the local IP
address (in this case 10.10.10.1) can be permanently Open Up Port forwarding setup successful
reserved for the robot and so no reconfiguration is required. Closed Down Port not being used
Since all available ports are required by ROS, the range was Closed Up Port forwarding setup failed
set as shown in Figure 6. As it can be seen in the figure, this
router also support DMZ, which could be easier to setup,
otherwise the selected port would not be used. However, if
but not all ISPs provide a separate page for DMZ, if not,
the netcat server was indeed up, and the result is still
then the settings shown in Figure 6 would suffice. In the
Closed, this means PF setup and configuration has not been
event that the router/modem is not provided by the ISP,
done correctly. This could be due to three possible reasons.
then the router’s manufacturer’s support resources would
be consulted, such as the online resources for D-Link, Net- Port is being used by another service on the network,
gear, or others manufacturer’s websites. try another port numb (higher than 1024).
There could be firewalls and/or network limitations
by the ISP or network admin, return to step 1.
Verification steps Modem/router PF configuration was not properly
An important point to remember here, ports must be performed, return to step 2.
allowed open and available by the ISP or network admin
Once the result is Open to all components of the remote
before attempting to configure the modem/router. There-
ROS network, as shown in Figure 4, then this step is com-
fore, this must be verified by the ISP before testing these
plete and you can proceed to step 3.
steps. To verify that PF and/or DMZ settings have been
correctly configured, follow these steps:
Configuration steps
Figure 9. A complete hosts file configuration.
For each component of the remote ROS network (Figure 4),
do the following:
public IP addresses are being used, which is only true for a
1. Take note of the local and public IP address of the remote ROS network. If a user decides to switch to a local
component. network, where only local IP addresses are used, these
2. For example, the laptop in Figure 4 has a local IP definitions can no longer be used and other definitions need
add ¼ 10.10.10.1 and a public add IP ¼ to be defined.
113.32.43.6. Furthermore, the component (robot or laptop) could be
3. Access the file that defines local hosts in your OS. used in different networks in different times, changing from
4. In Linux, run: sudo gedit /etc/hosts. a corporate network to a remote network to a local-telecom
5. Edit that file as shown in Figure 7 below. network (robot and laptop using the same portable telecom
6. Ensure that you key-in the correct IP addresses. modem/router). In every one of these networks, the IP
7. Take note of the discussion below. addresses would change.
8. Save, close, and restart. Therefore, it would be useful to create a hosts definition
9. Repeat this step for each component. file that caters for all these changes, one example of such
file is shown in Figure 9.
The hosts file is a Linux environment file that registers As it can be seen in the figure, there are several sets of
names and IP addresses of each component. As shown in hosts configurations that can be applied, depending on the
Figure 7, the laptop is defined as sami and the robot is defined type of network currently used. There are two local net-
as turtlebot, where these names are completely arbitrary. works (office and portable) and a remote network. The
The hosts definitions must be created for each component local network use local IP address, while the remote net-
and from its point of view. Figure 7 shows the definitions work uses public IP addresses. Finally, this file is from the
from the laptop’s point of view, where it is defined by its local laptop’s point of view, and so a similar file should be cre-
IP address, and robot is defined by its public IP address. From ated for the robot’s point of view.
the robot’s point of view, as shown in Figure 8, the situation is
reversed. The robot is now defined by its local IP address Dynamically changing IP address. As discussed above, ISPs
and the laptop is now defined by its public IP address. may not allocate you a fixed public IP address. If so, you
Also, notice how the names sami and turtlebot are the will need to update the hosts file every time you restart the
same in both hosts definitions file. This is actually a con- portable modem, this could be cumbersome and error-
venience, and it is indeed recommended to be the same. prone. The solution is to automate this step using a combi-
Because technically these components could be assigned nation of shell scripts and a cloud storage facility, such as
different names in different hosts files, but that would make Dropbox. Through this setup, the robot’s netbook can
networking far more complicated. Apart from this, there enquire about its current public IP address, informs the
are several pitfalls and challenges that could arise here, laptop (through Dropbox), allowing the laptop to update
which are discussed below: its hosts file. The scripts used for this project, developed
by the author, can be found on this repository.18 In the
gedit might not work. The command sudo gedit/etc/hosts discussion section below, these scripts and their inner
may not work in some Linux distributions; due to some workings are further discussed.
Linux-related issues, you can either use others editor or
add more permissions.
Verification steps
Changing networks. Hosts definitions are valid for the net- There are three tests to be conducted here: the ping test,
work they are part of. As can be seen in Figures 7 and 8, the SSH test, and the netcat chat test. All the three are
8 International Journal of Advanced Robotic Systems
Figure 11. A successful SSH test, through the remote network. 1. In the laptop, open two terminal windows.
2. In one window, SSH to the robot Now you have two
terminal windows open, one for the robot and one
conducted through the remote network. Note that the for laptop, as shown in Figure 12.
names and IP addresses used in the test below are based 3. In the laptop’s window, run: nc -l portNumb.
on the settings saved in the hosts files in the laptop and 4. In the robot’s window, run: nc sami portNumb.
the robot of the author, use the your own names and IP 5. If OK, then you created a chat session, type a away
address in your tests. The ping test is as follows: in either window, you should see it on the other
side.
1. In the laptop’s terminal, run: ping turtlebot. 6. If successful, then repeat step 3 from the
2. If you used a different name for the robot, use it. robot’s window and step 4 from the laptop’s
3. If successful, run the same test from the other side. window.
4. If successful, then you can proceed to the SSH test. 7. If both sides are successful, then step 3 is complete,
and you can proceed to the final step (step 4).
Figure 10 shows an example of a successful outcome,
where the laptop was able to ping the robot through the Once again, portNumb is the port number you chose,
remote network using only the host name. As it can be seen which could be any available port above 1024. Figure 12
from the figure, the public IP addresses are in effect (par- shows an example of a successful outcome. In the figure,
tially hidden). we can see a chat session established in the robot’s side.
The chat session was successfully established from the lap-
The SSH test top’s side as well.
It is important to understand that step 6 of the test is
very important. One must ensure that the chat server
1. SSH from the laptop to the robot using a command
can be established on both sides, because that repre-
similar to the one shown in Figure 11.
sents the ability of each component to act as a server
2. If successful, run the same test from the other side.
and a client, which is a fundamental requirement for
3. If successful, then you can proceed to the netcat test.
ROS components.
It is possible that the SSH test could fail due to reasons
related to SSH itself and not anything discussed so far.
Issues are such as public key, username authentication,
Step 4: ROS settings
installation issues of SSH, SSH being down (switched off), This is the final step in the configuration and so the reader
and other related factors. Therefore, run the SSH test on a is advised to ensure all previous steps are completed suc-
local network first. This would require you to reconnect cessfully before attempting this step. The objective of this
robot and laptop through a single modem and update the final step is to register all components of the remote ROS
hosts definitions to reflect this change. Then attempt to SSH network with the ROSmaster and insure that all compo-
between robot and laptop, and then deal with SSH-related nents are able to publish and subscribe to each other. A
issues, and once resolved, then you can proceed to run this ROSmaster could be any component of the ROS network.
test on a remote network. Figure 11 shows an example of a For the network shown in Figure 4, the robot was selected
successful outcome, where the laptop was able to SSH the as the ROSmaster. Therefore, the expected outcomes
robot through the remote network using only the host name. would be as follows.
Hajjaj and Sahari 9
Expected outcomes network needs to be started and tested. There are three ROS
tests that can be used here:
1. The ROSmaster component is properly registered
for each member of the ROS network. 1. the minimal network test;
2. Every component is able to publish or subscribe to 2. the listener/talker test; and
other components in the remote ROS network. 3. the turtlebot interaction tests.
This can be achieved by appending the bash file, the shell These tests are designed to test specific ROS funtional-
environment file, and setting the value of ROS_Master_ ities, which are outlined and discussed below.
URI to equal the IP address of the ROSmaster, or
specifically:
The minimal network test
1. Switch on all the modems, and ensure connection is
Configuration steps ON.
1. In the ROSmaster component, add the following: 2. Update the hosts and the bash files to reflect the
export ROS_MASTER_URI¼Robot_loclIP: current public IP address of the robot.
11311 3. From the robot’s onboard computer, open a terminal
2. In other components, add the following: export window and run: roscore to start ROS.
ROS_MASTER_URI¼Robot_pubIP:11311 4. Alternatively, SSH into the robot’s onboard com-
3. Do not add definitions of ROS_IP or ROS_HOST- puter from another component, and start ROS.
NAME as described in ROS tutorials. 5. At this point, the remote ROS network is up.
6. From the laptop, run: rostopic list, you should see
Public versus local IP addresses. Once again, since the ROS- the list of ROS topics. The outcome of the com-
master (robot) refers to itself, we use the robot’s own local mand may take few seconds longer than usual.
IP address. If we attempt to use the public IP address here, 7. If you see a list of topics, then this test is successful,
roscore would throw an error and would not start. and you can proceed to the next test.
As for other components, such as the laptop, they will
refer to the robot using its public IP address. This is very The listener/talker test
similar to the hosts definitions created in step 3. 1. From the robot’s computer, start a talker, buy run-
ROS_IP and ROS_HOSTNAME. ROS networking tutor- ning this command: rosrun rospy_tutorials
ials10,11 recommend setting these values in order to solve talker.py.
networking issues. However, it was found by the author 2. From the laptop, start a listener, by running this
that doing so would cause ROS problems; some compo- command: rosrun rospy_tutorials listener.py.
nents would be able to publish only and not subscribe, or 3. If all is OK, the listener on the laptop should
vice versa; subscribe only and not publish. One must respond to the talker from the robot’s computer.
remember that these tutorials were written primarily for the 4. Again, this might longer than usual to happen.
local ROS network, where these settings would be fine. But 5. If successful, repeat this test from the other direc-
for the remote ROS network, these definitions would over- tion, a talker from the laptop and a listener from the
ride the hosts definitions created in step 3 (Linux settings) robot.
and so cause the ROS problems discussed above. 6. It does not matter who starts first, a talker or a
As such, for the remote ROS network, the authors rec- listener, and it should always work regardless.
ommend using the ROS_MASTER_URI only and set the 7. If successful, then this test is successful, and you
hosts as discussed in step 3. can proceed to the next step.
Changing IP address. If the robot’s public IP address is vari- The turtlebot interactions tests
able, then once again, the bash settings in each component If you have reached this point, then that remote ROS net-
must be updated every time the robot’s portable modem is work has been successfully configured. The final test is to
restarted. Once again, this step could be automated, as dis- implement it on an actual robot. The following test assumes
cussed in step 3, through the use of shell scripts and a cloud that the robot is a ROS-enabled robot, which means that it
storage facility such as Dropbox. In fact, the scripts developed has already been preinstalled with the required ROS
for this project,18 referenced above, automate this step as well. packages needed to interact with other ROS components.
For this article, Turtlebot2 is used. Also, the reader is
expected to be familiar with ROS, its concepts, and the
Verification steps terminologies used in this test. Before starting, ensure that
At this stage, all settings and configurations have been all the modems are switched on, that the network is up and
completed, and to verify the settings, the remote ROS running, and that you updated all hosts and bash files to
10 International Journal of Advanced Robotic Systems
Discussion
In this section, an outdoor ROS application is to be linked
to the cloud, using a number of cloud-based solutions and
PF, with the following settings:
For an effective performance of this robot, a remote Table 2. Software needs for each method.
ROS network is developed, similar to the one shown in Method Software components
Figure 4, using the following technologies: rosbridge,
ROS-android, RoboEarth, and PF. rosbridge ROS, networking, JSON, ROS.js webservers,
web applications
ROS-android ROS, networking, Java, rosjava,android,
Through this remote network, the robot sends real- android_core, Concurrency Android Studio,
time status and task updates to the operator. Google Cloud App development, Google
Who would use this data to monitor, control, and Cloud
select the needed agriculture task for the robot to RoboEarth ROS, networking, rosbridge RoboEarth
perform. components: Rapyuta, KnowRob, WIRE,
C2TEAM, etc.
Data published by the robot are current robot speed, Port forwarding ROS, networking, shell-scripting
modem configuration, Dropbox
current location in the field (global positioning system
[GPS], fix), live feed (camera view of the robot), battery
and power status, task status, and task completion.
For example, Figure 13 shows the setup of the ROS- Setup complexity
android method, showing the rosjava publishers and sub- For this work, setup complexity is measured by the amount
scribers (developed by the authors) to publish robot data, of man-hours needed to learn, install, and develop the soft-
user commands, and establish connectivity, as required. ware needed for each method. This is shown in Figure 14
Other methods followed similar setup and patterns. and Table 2. The man-hours needed for ROS and network-
Then, these methods are compared in terms of setup com- ing were excluded because they are common to all.
plexity and effort required, robot performance (utilizing the As it can be seen, PF required the least amount of man-
remote network), and challenges facing implementation of hours to learn, install, and develop. This is understandable,
each method (and how to resolve it). The findings of this considering that it does not require any third party technol-
comparison are discussed below. ogy or platform. On the other hand, RoboEarth required the
Hajjaj and Sahari 11
Figure 15. Robot remote response time Figure 16. Agribot App and MapView.
Robot performance
Effect of each method on robot performance can be mea-
sured in robot response time. If a method causes too much Figure 17. Auto-update PF settings.
delay, then it becomes impractical. Through ROS logging,
time of robot commands (when given by users) and time
of robot execution of these commands were recorded, and
by calculating the difference between them, robot
response time was found. Figure 15 shows robot response
times in each method, while performing a set of robot
operations.
As shown in the figure, robot performance is compara-
ble in all methods. So, regardless of the method used, the
robot performed autonomous tasks the fastest and sensor-
Figure 18. Auto-update PF settings, master-script.
related tasks, such as mapping and localization, the slowest,
since the robot needed to transmit sensor data to the home
computer, remotely, for processing.
Managing dynamically changing IP addresses
An unexpected challenge faced by the authors, when As discussed above, ISPs seldom provide users with fixed
developing cloud-based solutions, was the need to recreate IP addresses, instead they usually provide a range of IP
ROS’s visualization tools such as rviz but in non-ROS addresses, such as 173.17.XXX.XXX, where the XXX
environments. This meant more development effort was could range from 000 and 255. This is obviously a problem
needed to develop these visualization and monitoring tools for PF, as the settings outlined above would need to be
for android, RoboEarth, and web applications. updated every time the IP addresses change. The solution
In ROS-android, this was solved by utilizing android’s to this challenge is to auto-update PF settings through a
views such as ProgressBar, ImageView, MapView, and so combination of shell scripts, combined with a cloud-
on, as shown in Figure 16. These views allowed users to storage facility such as Google’s Dropbox. This is shown
view robot’s battery status, speed (currently not moving), in Figures 17 to 19.
GPS fix (shown in a google map), and current job status The process begins with the ROSmaster component of
(current task highlighted in blue). Also, control buttons the ROS network, which hosts the ROS session and man-
were added for users to interact with the robot. ages the flow of information across the ROS network,
For PF, there was no need for such extra work, as PF ensuring all components transfer their data to the right
allowed a direct ROS-to-ROS connection, so ROS’s visua- destinations. In this example, the ROSmaster happens to
lization tools were utilized as if the connection was local. be the agriculture robot, and there is only one other mem-
The only difference was the minor time delays. ber, the operator’s laptop.
12 International Journal of Advanced Robotic Systems
Conclusions Funding
The author(s) disclosed receipt of the following financial support
In conclusion, this work was able to meet its objectives. for the research, authorship, and/or publication of this article: This
Cloud-based solutions for linking ROS applications to the work was supported by the College of Engineering, the Innovative
cloud were reviewed, a detailed process for setting up PF and Research Management Centre (iRMC), UNITEN and the
for ROS was introduced, and a comparison between the two Ministry of Higher Education, Malaysia through research grant
methods was made. (20140127/FRGS/V3500).
Although cloud-based solutions do deliver on their
promise, they come with challenges. This is because link- References
ing cloud-based solutions with ROS requires building a 1. Boren J and Cousins S. New Exponential Growth of ROS
ROS<¼cloud-based solution¼>ROS bridge, which in turn [ROS Topics]. IEEE Robot Autom Magazine 2011; 18(1):
would requires an extensive amount of man-hours to learn, 19–20. DOI:10.1109/MRA.2010.940147.
install, and develop the underlying technologies of these 2. O’Kane JM. A Gentle Introduction to ROS. Independently
solutions. This is especially true for complex robot appli- published, 2013. ISBN 978-1492143239. https://cse.sc.edu/
cations that involve tens to hundreds of difference ROS ~jokane/agitr/
message types, each requiring its own bridge, and the pro- 3. Emmi L, de Soto MG, Pajares G, et al. New trends in robotics
cess could become really complex. for agriculture: integration and assessment of a real fleet of
Hajjaj and Sahari 13
robots. Sci World J 2014; 2014: 21. DOI: 10.1155/2014/ 11. The ROS Wiki. ROS network setup. http://wiki.ros.org/ROS/
404059. Article ID 404059. NetworkSetup,2016. (accessed 20 September 2016).
4. Crick C, Jay G, Osentoski S, et al. ROS and rosbridge: 12. Speers A, Forooshani PM, Dicke M, et al. Lightweight
Roboticists out of the loop. In: Holly Yanko and Aaron Stein- tablet devices for command and control of ROS-enabled
field (eds) Proceedings of the Seventh Annual ACM/IEEE robots. In: Fiorini Paolo (ed) Advanced Robotics (ICAR),
International Conference on Human-Robot Interaction. HRI 2013 16th International Conference on, Montevideo, Uru-
‘12, 5–8 March 2012, New York, NY, USA, New York: guay, 25–29 November 2013, pp. 1–6. IEEE. DOI: 10.
ACM. ISBN 978-1-4503-1063-5, pp. 493–494. DOI:10. 1109/ICAR.2013.6766481.
1145/2157689.2157846. 13. Do HM, Mouser CJ, Gu Y, et al. An open platform telepre-
5. Kohler D, et al. Google i/o 2011: Cloud robotics, introducing sence robot with natural human interface. In: Wen Jung Li
rosjava. https://www.youtube.com/watch?feature¼player_ (ed) Cyber Technology in Automation, Control and Intelli-
embedded&v¼FxXBUp-4800,2011. (accessed 26 June 2016). gent Systems (CYBER), 2013 IEEE 3 rd Annual International
6. de A Barbosa JP, Lima FD, Coutinho LD, et al. ROS, Android Conference on, Kowloon Tong, Hong Kong, 26–29 May 2013,
and cloud robotics: how to make a powerful low cost robot. pp. 81–86. IEEE. DOI:10.1109/ CYBER.2013.6705424.
In: Aydan M. Erkmen, Afşar Saranlı and Konukseven E. 14. Chinnadurai G and Ranganathan H. Two wheel self equili-
ilhan (eds) Advanced Robotics (ICAR), 2015 International brium swarm robot controlled by port forwarding methods
Conference, 27 July 2015, pp. 158–163. IEEE. DOI: 10. using IoT. Int J Inno Sci Res 2015; 24(1): 79–85. ISSN
1109/ICAR. 2015.7251449. 2351-8014.
7. G Mohanarajah DH, D’Andrea R and Waibel M. Rapyuta: a 15. Luo YB, Wang BS and Cai GL. Analysis of port hopping for
cloud robotics platform. IEEE Trans Autom Sci Eng 2015; proactive cyber defense. Int J Security Appl 2015; 9(2):
12(2): 481–493. DOI:10.1109/ TASE.2014.2329556. 123–134.
8. Toris R, Kammerl J, Lu DV, et al. Robot web tools: effi- 16. Shin DH. Overlay networks in the west and the east: a techno-
cient messaging for cloud robotics. In: Norman Hendrich economic analysis of mobile virtual network operators.
(ed) 2015IEEE/RSJ International Conference on Intelli- Telecommun Syst 2008; 37(4): 157–168. DOI:10. 1007/
gent Robots and Systems (IROS), Hamburg, Germany, 8 s11235-008-9105 -1.
September–2 October 2015. pp. 4530–4537. IEEE. DOI: 17. Goebel RP. ROS by example, for Indigo, Vol 1, Section: 4.12.
10.1109/IROS.2015.7354021. 7: Networking accress the Internet. Independently Published,
9. Koken B. Cloud robotics platforms. Interdisciplinary 2015. ISBN: 5-800085-311092, p. 18.
Description of Complex Systems 2015; 13(1): 26–33. 18. Hajjaj S. A collection of scripts developed to autoupdate the
10. The ROS Wiki. Running ROS accross multiple machines. linux and ros setting for a remote ROS network via port-
http://wiki.ros.org/ROS/Tutorials/MultipleMachines, 2016. forwarding. https://github.com/roboFriend1977/autoUpdate
(accessed 20 September 2016). PubIPforROS, 2016. (accessed 28 September 2016).