You are on page 1of 73

PRACTICAL REPORT

DISTRIBUTED CONTROL SYSTEM 2

Arranged by :

Revi Eka Firmansyah


217441019
3 AED

TEKNIK OTOMASI MANUFAKTUR DAN MEKATRONIKA


POLITEKNIK MANUFAKTUR BANDUNG
2019
Practical Report
Distributed Control System 1

PREFACE

Alhamdulillahirabbil'alamin, for the blessings of grace and grace from Allah, the author can
complete the writing of the Supervisory Distributed Control System Report.

The writing of this report is intended to account for and explain the explanation of the
Supervisory Distributed Control System Practicum that has been carried out. The author
realizes that the contents of this report are still lacking and far from perfect, this imperfection
is caused by the limited ability of knowledge and experience that the author has. Therefore, for
the sake of perfection, suggestions and criticisms from all parties that are constructive and
provide encouragement, the authors expect.

In carrying out this practicum, the writer cannot be separated from support and guidance from
various parties. On this occasion also, the author would like to thank Allah SWT for His grace
and guidance given to the author, Dr. Eng. Pipit Anggraeni, S.T, M.T, M.Sc.Eng as a lecturer,
Mr. Faisal Abdurrahman Budikasih,S.Tr and Mr. Ade Hasan Sumarso, ST. as our intructure
during the practice, also colleagues absent from 3 AEDs who have provided support in practical
activities and making this Report. Hopefully their good deeds get a better reply from Allah
SWT.
The writer really hopes that this writing can be useful especially for writers and generally for
readers.

Bandung, 8 November 2019

Revi Eka Firmansyah

i
Practical Report
Distributed Control System 1

TABLE OF CONTENTS

PREFACES .................................................................................................................. I

TABLE OF CONTENTS ........................................................................................... II

ABSTRACT .................................................................................................................. 1

1.1 BACKGROUND .................................................................................. 1


1.2 OBJECTIVES ...................................................................................... 1
1.3 METHOD ........................................................................................... 1

INTRODUCTION........................................................................................................ 2

2.1 LINUX UBUNTU ................................................................................ 2


2.2 ROS ................................................................................................. 2
2.3 TURTLEBOT ...................................................................................... 3

TUTORIALS ................................................................................................................ 4

3.1 UBUNTU INSTALL OF ROS KINETIC ................................................. 4


3.1.1 Configure your Ubuntu repositories ............................................... 4
3.1.2 Setup your sources.list ..................................................................... 4
3.1.3 Set up your keys ............................................................................... 4
3.1.4 Installation....................................................................................... 4
3.1.5 Initialize rosdep ............................................................................... 5
3.1.6 Environment setup ........................................................................... 5
3.1.7 Dependencies for Building Packages .............................................. 5
3.2 INSTALLING AND CONFIGURING YOUR ROS ENVIRONMENT ............ 6
3.2.1 Install ROS ...................................................................................... 6
3.2.2 Managing Your Environment .......................................................... 6
3.2.3 Create a ROS Workspace ................................................................ 7
3.3 NAVIGATING THE ROS FILESYSTEM ................................................ 8
3.4.3 Prerequisites .................................................................................... 8
3.4.4 Quick Overview of Filesystem Concepts ......................................... 8
3.4.5 Filesystem Tools .............................................................................. 8
3.4 CREATING A ROS PACKAGE........................................................... 10

ii
Practical Report
Distributed Control System 1

3.4.1 What makes up a Catkin Package? ............................................... 10


3.4.2 Packages in a catkin Workspace ................................................... 11
3.4.3 Creating a catkin Package ............................................................ 11
3.4.4 Creating a catkin Package ............................................................ 12
3.4.5 Package Dependencies .................................................................. 12
3.5 BUILDING A ROS PACKAGE ........................................................... 13
3.5.1 Using catkin_make ........................................................................ 13
3.5.2 Building Your Package .................................................................. 13
3.6 UNDERSTANDING ROS NODES ....................................................... 15
3.6.1 Prerequisite ................................................................................... 15
3.6.2 Quick Overview of Graph Concepts .............................................. 15
3.6.3 Nodes ............................................................................................. 16
3.6.4 Client Libraries ............................................................................. 16
3.6.5 roscore ........................................................................................... 16
3.6.6 Using rosnode................................................................................ 17
3.6.7 Using rosrun .................................................................................. 18
3.7 UNDERSTANDING ROS TOPICS....................................................... 20
3.7.1 Setup .............................................................................................. 20
3.7.2 ROS Topics .................................................................................... 21
3.7.3 ROS Messages ............................................................................... 25
3.7.4 Rostopic continued ........................................................................ 25
3.7.5 Using rqt_plot................................................................................ 29
3.8 UNDERSTANDING ROS SERVICES AND PARAMETERS ..................... 30
3.9.1 ROS Services ................................................................................. 30
3.9.2 Using rosservice ............................................................................ 30
3.9.3 Using rosparam ............................................................................. 33
3.9 USING RQT_CONSOLE AND ROSLAUNCH ......................................... 35
3.4.6 Using rqt_console and rqt_logger_level ....................................... 35
3.4.7 Using roslaunch ............................................................................ 37
3.4.8 The Launch File............................................................................. 38
3.4.9 Roslaunching ................................................................................. 38

PRACTICAL RESULT ............................................................................................. 40

iii
Practical Report
Distributed Control System 1

4.1 INSTALLING AND CONFIGURING YOUR ROS ENVIRONMENT .......... 40


4.2 NAVIGATING THE ROS FILESYSTEM .............................................. 41
4.3 CREATING A ROS PACKAGE........................................................... 42
4.4 BUILDING A ROS PACKAGE ........................................................... 44
4.5 UNDERSTANDING ROS NODES ....................................................... 45
4.6 UNDERSTANDING ROS TOPICS....................................................... 48
4.7 UNDERSTANDING ROS SERVICES AND PARAMETERS ..................... 56
4.8 USING RQT_CONSOLE AND ROSLAUNCH ......................................... 59
4.9 SIMULATE TURTLEBOT WITH GAZEBO ........................................... 66

CLOSING ................................................................................................................... 67

4.1 CONCLUSION .................................................................................. 67

REFERENCES........................................................................................................... 68

iv
Practical Report
Distributed Control System 1

CHAPTER I
ABSTRACT

1.1 Background
Robots consist of many functional components and require specialized skills in various
fields. Therefore, there are still many technical limitations that must be overcome and
additional research necessary for robots to be used at a level of everyday life. In order to
do this, not only experts but also companies in related industries and general users must
collaborate in the effort.
This practicum is important because it will be implemented on the future career. This
subject is special because all system needs to be controlled and distributed correctly.

1.2 Objectives
• Students can use Linux Ubuntu operating system.
• Students can use ROS, especially Kinetic.
• Students can operate two or more robot that integrated in ROS.

1.3 Method
Practice using ROS on Linux operating system.

1
Practical Report
Distributed Control System 1

BAB II
INTRODUCTION

2.1 Linux Ubuntu


Ubuntu is a free and open-sourceLinux distribution based on Debian. Ubuntu is officially
released in three editions: Desktop, Server, and Core (for internet of things devices and
robots). All the editions can run on the computer alone, or in a virtual machine.Ubuntu is
a popular operating system for cloud computing, with support for OpenStack.

2.2 ROS

The ROS Wiki defines ROS as above. In other words, ROS includes hardware abstraction
layer similar to operating systems. However, unlike conventional operating systems, it can be
used for numerous combinations of hardware implementation. Furthermore, it is a robot

2
Practical Report
Distributed Control System 1

software platform that provides various development environments specialized for developing
robot application programs.

ROS as Meta-OS
2.3 Turtlebot
TurtleBot is a low-cost, personal robot kit with open-source software. TurtleBot was
created at Willow Garage by Melonee Wise and Tully Foote in November 2010. With
TurtleBot, you’ll be able to build a robot that can drive around your house, see in 3D, and
have enough horsepower to create exciting applications.
That some types of turtlebot.

3
Practical Report
Distributed Control System 1

CHAPTER III
TUTORIALS

3.1 Ubuntu Install of ROS Kinetic


ROS Kinetic ONLY supports Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie
(Debian 8) for debian packages.
3.1.1 Configure your Ubuntu repositories
Configure your Ubuntu repositories to allow "restricted," "universe," and
"multiverse." You can follow the Ubuntu guide for instructions on doing this.

3.1.2 Setup your sources.list


Setup your computer to accept software from packages.ros.org.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu
$(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-
latest.list'

3.1.3 Set up your keys


sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --
recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

If you experience issues connecting to the keyserver, you can try substituting
hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80 in the previous command.
Alternatively, you can use curl instead of the apt-key command, which can be helpful
if you are behind a proxy server:
Curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&searc
h=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key
add –

3.1.4 Installation
First, make sure your Debian package index is up-to-date:
sudo apt-get update

There are many different libraries and tools in ROS. We provided four default
configurations to get you started. You can also install ROS packages individually.
In case of problems with the next step, you can use following repositories instead of
the ones mentioned above.

4
Practical Report
Distributed Control System 1

Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries,


2D/3D simulators, navigation and 2D/3D perception.
sudo apt-get install ros-kinetic-desktop-full

To find available packages, use:


apt-cache search ros-kinetic

3.1.5 Initialize rosdep


Before you can use ROS, you will need to initialize rosdep. rosdep enables you to
easily install system dependencies for source you want to compile and is required to
run some core components in ROS.
sudo rosdep init
rosdep update

3.1.6 Environment setup


It's convenient if the ROS environment variables are automatically added to your
bash session every time a new shell is launched:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

If you have more than one ROS distribution installed, ~/.bashrc must only source
the setup.bash for the version you are currently using.
If you just want to change the environment of your current shell, instead of the above
you can type:
source /opt/ros/kinetic/setup.bash

If you use zsh instead of bash you need to run the following commands to set up
your shell:
echo "source /opt/ros/kinetic/setup.zsh" >> ~/.zshrc
source ~/.zshrc

3.1.7 Dependencies for Building Packages


Up to now you have installed what you need to run the core ROS packages. To create
and manage your own ROS workspaces, there are various tools and requirements
that are distributed separately. For example, rosinstall is a frequently used command-

5
Practical Report
Distributed Control System 1

line tool that enables you to easily download many source trees for ROS packages
with one command.
To install this tool and other dependencies for building ROS packages, run:
sudo apt install python-rosinstall python-rosinstall-generator
python-wstool build-essential

3.2 Installing and Configuring Your ROS Environment


3.2.1 Install ROS
Before starting these tutorials please complete installation as described in the ROS
installation instructions.

3.2.2 Managing Your Environment


During the installation of ROS, you will see that you are prompted to source one of
several setup.*sh files, or even add this 'sourcing' to your shell startup script. This is
required because ROS relies on the notion of combining spaces using the shell
environment. This makes developing against different versions of ROS or against
different sets of packages easier.
If you are ever having problems finding or using your ROS packages make sure that
you have your environment properly setup. A good way to check is to ensure that
environment variables like ROS_ROOT and ROS_PACKAGE_PATH are set:
$ printenv | grep ROS

If they are not then you might need to 'source' some setup.*sh files.
Environment setup files are generated for you, but can come from different places:
• ROS packages installed with package managers provide setup.*sh files
• rosbuild workspaces provide setup.*sh files using tools like rosws
• Setup.*sh files are created as a by-product of building or installing catkin
packages

If you just installed ROS from apt on Ubuntu then you will have setup.*sh files in
'/opt/ros/<distro>/', and you could source them like so:
$ source /opt/ros/<distro>/setup.bash

Using the short name of your ROS distribution instead of <distro>

6
Practical Report
Distributed Control System 1

If you installed ROS Kinetic, that would be:


$ source /opt/ros/kinetic/setup.bash

You will need to run this command on every new shell you open to have access to
the ROS commands, unless you add this line to your .bashrc. This process allows
you to install several ROS distributions (e.g. indigo and kinetic) on the same
computer and switch between them.
On other platforms you will find these setup.*sh files wherever you installed ROS.

3.2.3 Create a ROS Workspace


Create and build a catkin workspace:
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make

The catkin_make command is a convenience tool for working with catkin


workspaces. Running it the first time in your workspace, it will create a
CMakeLists.txt link in your 'src' folder. Note, for Arch Linux users, the first
catkin_make command in a clean catkin workspace must be:
$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3 -
DPYTHON_INCLUDE_DIR=/usr/include/python3.7m -
DPYTHON_LIBRARY=/usr/lib/libpython3.7m.so

This will configure catkin_make with Python 3. You may then proceed to use just
catkin_make for subsequent builds.
Additionally, if you look in your current directory you should now have a 'build'
and 'devel' folder. Inside the 'devel' folder you can see that there are now several
setup.*sh files. Sourcing any of these files will overlay this workspace on top of
your environment. To understand more about this see the general catkin
documentation: catkin. Before continuing source your new setup.*sh file:
$ source devel/setup.bash

To make sure your workspace is properly overlayed by the setup script, make sure
ROS_PACKAGE_PATH environment variable includes the directory you're in.
$ echo $ROS_PACKAGE_PATH
/home/youruser/catkin_ws/src:/opt/ros/kinetic/share

7
Practical Report
Distributed Control System 1

3.3 Navigating the ROS Filesystem


3.4.3 Prerequisites
For this tutorial we will inspect a package in ros-tutorials, please install it using
$ sudo apt-get install ros-<distro>-ros-tutorials
Replace '<distro>' (including the '<>') with the name of your ROS distribution (e.g.
indigo, kinetic, lunar etc.)

3.4.4 Quick Overview of Filesystem Concepts


Packages: Packages are the software organization unit of ROS code. Each
package can contain libraries, executables, scripts, or other artifacts.

Manifests (package.xml): A manifest is a description of a package. It serves to


define dependencies between packages and to capture meta information about the
package like version, maintainer, license, etc...

3.4.5 Filesystem Tools


Code is spread across many ROS packages. Navigating with command-line tools
such as ls and cd can be very tedious which is why ROS provides tools to help
you.
1) Using rospack
Rospack allows you to get information about packages. In this tutorial, we
are only going to cover the find option, which returns the path to package.
Usage:
$ rospack find [package_name]
Example:
$ rospack find roscpp
would return:
YOUR_INSTALL_PATH/share/roscpp
If you installed ROS Kinetic from apt on Ubuntu Linux you would see
exactly:
/opt/ros/kinetic/share/roscpp

8
Practical Report
Distributed Control System 1

2) Using roscd
roscd is part of the rosbash suite. It allows you to change directory (cd)
directly to a package or a stack.
Usage:
$ roscd [locationname[/subdir]]
To verify that we have changed to the roscpp package directory, run this
example:
$ roscd roscpp
Now let's print the working directory using the Unix command pwd:
$ pwd
You should see:
YOUR_INSTALL_PATH/share/roscpp
You can see that YOUR_INSTALL_PATH/share/roscpp is the same path
that rospack find gave in the previous example.
Note that roscd, like other ROS tools, will only find ROS packages that
are within the directories listed in your ROS_PACKAGE_PATH. To see
what is in your ROS_PACKAGE_PATH, type:
$ echo $ROS_PACKAGE_PATH
Your ROS_PACKAGE_PATH should contain a list of directories where
you have ROS packages separated by colons. A typical
ROS_PACKAGE_PATH might look like this:
/opt/ros/kinetic/base/install/share
Similarly to other environment paths, you can add additional directories to
your ROS_PACKAGE_PATH, with each path separated by a colon ':'.

3) roscd log
roscd log will take you to the folder where ROS stores log files. Note
that if you have not run any ROS programs yet, this will yield an error
saying that it does not yet exist.
If you have run some ROS program before, try:
$ roscd log

9
Practical Report
Distributed Control System 1

4) Using rosls
rosls is part of the rosbash suite. It allows you to ls directly in a package
by name rather than by absolute path.
Usage:
$ rosls [locationname[/subdir]]

Example:
$ rosls roscpp_tutorials

would return:
cmake launch package.xml srv

5) Tab Completion
It can get tedious to type out an entire package name. In the previous
example, roscpp_tutorials is a fairly long name. Luckily, some ROS
tools support TAB completion.
Start by typing:
$ roscd roscpp_tut<<< now push the TAB key >>>
After pushing the TAB key, the command line should fill out the rest:
$ roscd roscpp_tutorials/

This works because roscpp_tutorials is currently the only ROS


package that starts with roscpp_tut.

3.4 Creating a ROS Package


3.4.1 What makes up a Catkin Package?
For a package to be considered a catkin package it must meet a few requirements:
• The package must contain a catkin compliant package.xml file.
o That package.xml file provides meta information about the package.
• The package must contain a CMakeLists.txt which uses catkin.
o If it is a catkin metapackage it must have the relevant boilerplate
CMakeLists.txt file.
• Each package must have its own folder
o This means no nested packages nor multiple packages sharing the same
directory.
The simplest possible package might have a structure which looks like this:
my_package/

10
Practical Report
Distributed Control System 1

CMakeLists.txt
package.xml

3.4.2 Packages in a catkin Workspace


The recommended method of working with catkin packages is using a catkin
workspace, but you can also build catkin packages standalone. A trivial
workspace might look like this:
workspace_folder/ -- WORKSPACE
src/ -- SOURCE SPACE
CMakeLists.txt -- 'Toplevel' CMake file, provided by catkin
package_1/
CMakeLists.txt -- CMakeLists.txt file for package_1
package.xml -- Package manifest for package_1
...
package_n/
CMakeLists.txt -- CMakeLists.txt file for package_n
package.xml -- Package manifest for package_n

3.4.3 Creating a catkin Package


This tutorial will demonstrate how to use the catkin_create_pkg script to create a
new catkin package, and what you can do with it after it has been created.
First change to the source space directory of the catkin workspace you created in
the Creating a Workspace for catkin tutorial:
# You should have created this in the Creating a Workspace
Tutorial
$ cd ~/catkin_ws/src

Now use the catkin_create_pkg script to create a new package called


'beginner_tutorials' which depends on std_msgs, roscpp, and rospy:
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
This will create a beginner_tutorials folder which contains a package.xml and
a CMakeLists.txt, which have been partially filled out with the information you
gave catkin_create_pkg.
catkin_create_pkg requires that you give it a package_name and optionally a
list of dependencies on which that package depends:
# This is an example, do not try to run this

11
Practical Report
Distributed Control System 1

# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]


catkin_create_pkg also has more advanced functionalities which are described
in catkin/commands/catkin_create_pkg.

3.4.4 Creating a catkin Package


Now you need to build the packages in the catkin workspace:
$ cd ~/catkin_ws
$ catkin_make

After the workspace has been built it has created a similar structure in the devel
subfolder as you usually find under /opt/ros/$ROSDISTRO_NAME.
To add the workspace to your ROS environment you need to source the generated
setup file:
$ . ~/catkin_ws/devel/setup.bash

3.4.5 Package Dependencies


In many cases, a dependency will also have its own dependencies. For instance,
rospy has other dependencies.
$ rospack depends1 rospy
genpy
roscpp
rosgraph
rosgraph_msgs
roslib
std_msgs
A package can have quite a few indirect dependencies. Luckily rospack can
recursively determine all nested dependencies.
$ rospack depends beginner_tutorials
cpp_common
rostime
roscpp_traits
catkin
genmsg
genpy
message_runtime
gencpp
geneus

12
Practical Report
Distributed Control System 1

gennodejs
genlisp
message_generation
rosbuild
rosconsole
std_msgs
rosgraph_msgs
xmlrpcpp
roscpp
rosgraph
ros_environment
rospack
roslib
rospy

3.5 Building a ROS Package


As long as all of the system dependencies of your package are installed, we can now build
your new package. Before continuing remember to source your environment setup file if
you have not already. On Ubuntu it would be something like this:
# source /opt/ros/%YOUR_ROS_DISTRO%/setup.bash
$ source /opt/ros/kinetic/setup.bash # For Kinetic for instance

3.5.1 Using catkin_make


catkin_make is a command line tool which adds some convenience to the standard
catkin workflow. You can imagine that catkin_make combines the calls to cmake
and make in the standard CMake workflow.
Usage :
# In a catkin workspace
$ catkin_make [make_targets] [-DCMAKE_VARIABLES=...]

3.5.2 Building Your Package


You should already have a catkin workspace and a new catkin package called
beginner_tutorials from the previous tutorial, Creating a Package. Go into the
catkin workspace if you are not already there and look in the src folder:
$ cd ~/catkin_ws/
$ ls src

13
Practical Report
Distributed Control System 1

beginner_tutorials/ CMakeLists.txt@

You should see that there is a folder called beginner_tutorials which you created
with catkin_create_pkg in the previous tutorial. We can now build that package using
catkin_make:
$ catkin_make
You should see a lot of output from cmake and then make, which should be similar
to this:
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install
####
#### Running command: "cmake /home/user/catkin_ws/src
-DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel
-DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install" in
"/home/user/catkin_ws/build"
####
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is Clang 4.0.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag
- yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using CATKIN_DEVEL_PREFIX: /tmp/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python (found version "2.7.1")
-- Found PY_em: /usr/lib/python2.7/dist-packages/em.pyc
-- Found gtest: gtests will be built
-- catkin 0.5.51
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing packages in topological order:
-- ~~ - beginner_tutorials
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ add_subdirectory(beginner_tutorials)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/catkin_ws/build
####
#### Running command: "make -j4" in "/home/user/catkin_ws/build"
####

14
Practical Report
Distributed Control System 1

Note that catkin_make first displays what paths it is using for each of the 'spaces'.
The spaces are described in the REP128 and by documentation about catkin
workspaces on the wiki: catkin/workspaces. The important thing to notice is that
because of these default values several folders have been created in your catkin
workspace. Take a look with ls:
$ ls

build
devel
src

The build folder is the default location of the build space and is where cmake and
make are called to configure and build your packages. The devel folder is the default

location of the devel space, which is where your executables and libraries go before
you install your packages.

3.6 Understanding ROS Nodes


3.6.1 Prerequisite
For this tutorial we'll use a lighweight simulator, to install it run the following
command:
$ sudo apt-get install ros-<distro>-ros-tutorials

Replace '<distro>' with the name of your ROS distribution (e.g. indigo, jade,
kinetic) .

3.6.2 Quick Overview of Graph Concepts


• Nodes: A node is an executable that uses ROS to communicate with other nodes.
• Messages: ROS data type used when subscribing or publishing to a topic.
• Topics: Nodes can publish messages to a topic as well as subscribe to a topic to
receive messages.
• Master: Name service for ROS (i.e. helps nodes find each other)
• rosout: ROS equivalent of stdout/stderr
• roscore: Master + rosout + parameter server (parameter server will be introduced
later)

15
Practical Report
Distributed Control System 1

3.6.3 Nodes
A node really isn't much more than an executable file within a ROS package. ROS
nodes use a ROS client library to communicate with other nodes. Nodes can publish
or subscribe to a Topic. Nodes can also provide or use a Service.

3.6.4 Client Libraries


ROS client libraries allow nodes written in different programming languages to
communicate:
• rospy = python client library
• roscpp = c++ client library

3.6.5 roscore
roscore is the first thing you should run when using ROS.
Please run:
$ roscore

You will see something similar to:


... logging to ~/.ros/log/9cf88ce4-b14d-11df-8a75-
00251148e8cf/roslaunch-machine_name-13039.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://machine_name:33919/


ros_comm version 1.4.7

SUMMARY
======

PARAMETERS
* /rosversion
* /rosdistro

NODES

auto-starting new master


process[master]: started with pid [13054]
ROS_MASTER_URI=http://machine_name:11311/

setting /run_id to 9cf88ce4-b14d-11df-8a75-00251148e8cf


process[rosout-1]: started with pid [13067]
started core service [/rosout]

If roscore does not initialize, you probably have a network configuration issue.
See Network Setup - Single Machine Configuration

16
Practical Report
Distributed Control System 1

If roscore does not initialize and sends a message about lack of permissions,
probably the ~/.ros folder is owned by root, change recursively the ownership of
that folder with:
$ sudo chown -R <your_username> ~/.ros

3.6.6 Using rosnode


Open up a new terminal, and let's use rosnode to see what running roscore did...
Bear in mind to keep the previous terminal open either by opening a new tab or
simply minimizing it.
Note: When opening a new terminal your environment is reset and your ~/.bashrc
file is sourced. If you have trouble running commands like rosnode then you might
need to add some environment setup files to your ~/.bashrc or manually re-source
them.
rosnode displays information about the ROS nodes that are currently running. The
rosnode list command lists these active nodes:
$ rosnode list

You will see :


/rosout

This showed us that there is only one node running: rosout. This is always running
as it collects and logs nodes' debugging output.
The rosnode info command returns information about a specific node.
$ rosnode info /rosout

This gave us some more information about rosout, such as the fact that it publishes
/rosout_agg.
---------------------------------------------------------------
---------
Node [/rosout]
Publications:
* /rosout_agg [rosgraph_msgs/Log]

Subscriptions:
* /rosout [unknown type]

Services:
* /rosout/get_loggers
* /rosout/set_logger_level

contacting node http://machine_name:54614/ ...


Pid: 5092

17
Practical Report
Distributed Control System 1

Now, let's see some more nodes. For this, we're going to use rosrun to bring up
another node.

3.6.7 Using rosrun


rosrun allows you to use the package name to directly run a node within a package
(without having to know the package path).
Usage:
$ rosrun [package_name] [node_name]

So now we can run the turtlesim_node in the turtlesim package.


Then, in a new terminal:
$ rosrun turtlesim turtlesim_node

You will see the turtlesim window:

NOTE: The turtle may look different in your turtlesim window. Don't worry about
it - there are many types of turtle and yours is a surprise!

18
Practical Report
Distributed Control System 1

In a new terminal:
$ rosnode list

You will see something similar to:


/rosout
/turtlesim

One powerful feature of ROS is that you can reassign Names from the command-
line.
Close the turtlesim window to stop the node (or go back to the rosrun turtlesim
terminal and use ctrl-C). Now let's re-run it, but this time use a Remapping
Argument to change the node's name:
$ rosrun turtlesim turtlesim_node __name:=my_turtle

Now, if we go back and use rosnode list:


$ rosnode list

You will see something similar to:


/my_turtle
/rosout

Note: If you still see /turtlesim in the list, it might mean that you stopped the node
in the terminal using ctrl-C instead of closing the window, or that you don't have
the $ROS_HOSTNAME environment variable defined as described in Network
Setup - Single Machine Configuration. You can try cleaning the rosnode list with: $
rosnode cleanup.
We see our new /my_turtle node. Let's use another rosnode command, ping, to
test that it's up:
$ rosnode ping my_turtle

rosnode: node is [/my_turtle]


pinging /my_turtle with a timeout of 3.0s
xmlrpc reply from http://aqy:42235/ time=1.152992ms
xmlrpc reply from http://aqy:42235/ time=1.120090ms
xmlrpc reply from http://aqy:42235/ time=1.700878ms
xmlrpc reply from http://aqy:42235/ time=1.127958ms

19
Practical Report
Distributed Control System 1

3.7 Understanding ROS Topics


3.7.1 Setup
1) roscore
Let's start by making sure that we have roscore running, in a new terminal:
$ roscore

If you left roscore running from the last tutorial, you may get the error message:
roscore cannot run as another roscore/master is already
running.
Please kill other roscore/master processes before relaunching

This is fine. Only one roscore needs to be running.

2) turtlesim
For this tutorial we will also use turtlesim. Please run in a new terminal:
$ rosrun turtlesim turtlesim_node

3) turtle keyboard teleoperation


We'll also need something to drive the turtle around with. Please run in a new
terminal:
$ rosrun turtlesim turtle_teleop_key

[ INFO] 1254264546.878445000: Started node [/teleop_turtle],


pid [5528], bound on [aqy], xmlrpc port [43918], tcpros port
[55936], logging to [~/ros/ros/log/teleop_turtle_5528.log],
using [real] time
Reading from keyboard
---------------------------
Use arrow keys to move the turtle.

Now you can use the arrow keys of the keyboard to drive the turtle around. If
you can not drive the turtle select the terminal window of the
turtle_teleop_key to make sure that the keys that you type are recorded.

20
Practical Report
Distributed Control System 1

Now that you can drive your turtle around, let's look at what's going on behind
the scenes.

3.7.2 ROS Topics


The turtlesim_node and the turtle_teleop_key node are communicating with
each other over a ROS Topic. turtle_teleop_key is publishing the key strokes
on a topic, while turtlesim subscribes to the same topic to receive the key strokes.
Let's use rqt_graph which shows the nodes and topics currently running.
Note: If you're using electric or earlier, rqt is not available. Use rxgraph instead.
1) Using rqt_graph
rqt_graph creates a dynamic graph of what's going on in the system. rqt_graph
is part of the rqt package. Unless you already have it installed, run:
$ sudo apt-get install ros-<distro>-rqt
$ sudo apt-get install ros-<distro>-rqt-common-plugins

replacing <distro> with the name of your ROS distribution (e.g. indigo, jade,
kinetic, lunar ...)

21
Practical Report
Distributed Control System 1

In a new terminal:
$ rosrun rqt_graph rqt_graph

You will see something similar to:

If you place your mouse over /turtle1/command_velocity it will highlight the


ROS nodes (here blue and green) and topics (here red). As you can see, the
turtlesim_node and the turtle_teleop_key nodes are communicating on the

topic named /turtle1/command_velocity.

2) Introducing rostopic
The rostopic tool allows you to get information about ROS topics.
You can use the help option to get the available sub-commands for rostopic
$ rostopic -h
rostopic bw display bandwidth used by topic
rostopic echo print messages to screen
rostopic hz display publishing rate of topic
rostopic list print information about active topics
rostopic pub publish data to topic
rostopic type print topic type

Or pressing tab key after rostopic prints the possible sub-commands:


$ rostopic
bw echo find hz info list pub type

Let's use some of these topic sub-commands to examine turtlesim.

22
Practical Report
Distributed Control System 1

3) Using rostopic echo


rostopic echo shows the data published on a topic.
Usage:
rostopic echo [topic]

Let's look at the command velocity data published by the turtle_teleop_key


node.
For ROS Hydro and later, this data is published on the /turtle1/cmd_vel topic.
In a new terminal, run:
$ rostopic echo /turtle1/cmd_vel

You probably won't see anything happen because no data is being published on
the topic. Let's make turtle_teleop_key publish data by pressing the arrow
keys. Remember if the turtle isn't moving you need to select the
turtle_teleop_key terminal again.
For ROS Hydro and later, you should now see the following when you press the
up key:
linear:
x: 2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
---
linear:
x: 2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
---
Now let's look at rqt_graph again. Press the refresh button in the upper-left to
show the new node. As you can see rostopic echo, shown here in red, is now
also subscribed to the turtle1/command_velocity topic.

23
Practical Report
Distributed Control System 1

4) Using rostopic list


rostopic list returns a list of all topics currently subscribed to and published.
Let's figure out what argument the list sub-command needs. In a new terminal
run:
$ rostopic list -h

Usage: rostopic list [/topic]

Options:
-h, --help show this help message and exit
-b BAGFILE, --bag=BAGFILE
list topics in .bag file
-v, --verbose list full details about each topic
-p list only publishers
-s list only subscribers

For rostopic list use the verbose option:


$ rostopic list -v
This displays a verbose list of topics to publish to and subscribe to and their type.
For ROS Hydro and later,
Published topics:
* /turtle1/color_sensor [turtlesim/Color] 1 publisher
* /turtle1/cmd_vel [geometry_msgs/Twist] 1 publisher
* /rosout [rosgraph_msgs/Log] 2 publishers
* /rosout_agg [rosgraph_msgs/Log] 1 publisher
* /turtle1/pose [turtlesim/Pose] 1 publisher

Subscribed topics:
* /turtle1/cmd_vel [geometry_msgs/Twist] 1 subscriber
* /rosout [rosgraph_msgs/Log] 1 subscriber

24
Practical Report
Distributed Control System 1

3.7.3 ROS Messages


Communication on topics happens by sending ROS messages between nodes. For
the publisher (turtle_teleop_key) and subscriber (turtlesim_node) to
communicate, the publisher and subscriber must send and receive the same type of
message. This means that a topic type is defined by the message type published on
it. The type of the message sent on a topic can be determined using rostopic type.

1) Using rostopic type


rostopic type returns the message type of any topic being published.
Usage:
rostopic type [topic]

For ROS Hydro and later,


Try:
$ rostopic type /turtle1/cmd_vel

You should get:


geometry_msgs/Twist

We can look at the details of the message using rosmsg:


$ rosmsg show geometry_msgs/Twist

geometry_msgs/Vector3 linear
float64 x
float64 y
float64 z
geometry_msgs/Vector3 angular
float64 x
float64 y
float64 z

3.7.4 Rostopic continued


Now that we have learned about ROS messages, let's use rostopic with messages.
1) Using rostopic pub
rostopic pub publishes data on to a topic currently advertised.
Usage:
rostopic pub [topic] [msg_type] [args]

For ROS Hydro and later, example:

25
Practical Report
Distributed Control System 1

$ rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0,


0.0, 0.0]' '[0.0, 0.0, 1.8]'

The previous command will send a single message to turtlesim telling it to move
with a linear velocity of 2.0, and an angular velocity of 1.8 .

This is a pretty complicated example, so lets look at each argument in detail.


For ROS Hydro and later,
• This command will publish messages to a given topic:
rostopic pub

• This option (dash-one) causes rostopic to only publish one message then
exit:
-1

• This is the name of the topic to publish to:


/turtle1/cmd_vel

26
Practical Report
Distributed Control System 1

• This is the message type to use when publishing to the topic:


geometry_msgs/Twist

• This option (double-dash) tells the option parser that none of the
following arguments is an option. This is required in cases where your
arguments have a leading dash -, like negative numbers.
--

• As noted before, a geometry_msgs/Twist msg has two vectors of three


floating point elements each: linear and angular. In this case,
'[2.0, 0.0, 0.0]' becomes the linear value with x=2.0, y=0.0, and
z=0.0, and '[0.0, 0.0, 1.8]' is the angular value with x=0.0,
y=0.0, and z=1.8. These arguments are actually in YAML syntax, which

is described more in the YAML command line documentation.


'[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'

You may have noticed that the turtle has stopped moving; this is because the
turtle requires a steady stream of commands at 1 Hz to keep moving. We can
publish a steady stream of commands using rostopic pub -r command:
For ROS Hydro and later,
$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -
- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

This publishes the velocity commands at a rate of 1 Hz on the velocity topic.

27
Practical Report
Distributed Control System 1

We can also look at what is happening in rqt_graph. Press the refresh button in
the upper-left. The rostopic pub node (here in red) is communicating with the
rostopic echo node (here in green):

As you can see the turtle is running in a continuous circle. In a new terminal,
we can use rostopic echo to see the data published by our turtlesim:
rostopic echo /turtle1/pose

2) Using rostopic hz
rostopic hz reports the rate at which data is published.
Usage:
rostopic hz [topic]

Let's see how fast the turtlesim_node is publishing /turtle1/pose:


$ rostopic hz /turtle1/pose

You will see:


subscribed to [/turtle1/pose]
average rate: 59.354
min: 0.005s max: 0.027s std dev: 0.00284s window: 58
average rate: 59.459
min: 0.005s max: 0.027s std dev: 0.00271s window: 118
average rate: 59.539
min: 0.004s max: 0.030s std dev: 0.00339s window: 177
average rate: 59.492
min: 0.004s max: 0.030s std dev: 0.00380s window: 237
average rate: 59.463
min: 0.004s max: 0.030s std dev: 0.00380s window: 290

Now we can tell that the turtlesim is publishing data about our turtle at the rate
of 60 Hz. We can also use rostopic type in conjunction with rosmsg show
to get in depth information about a topic:
For ROS Hydro and later,
$ rostopic type /turtle1/cmd_vel | rosmsg show

28
Practical Report
Distributed Control System 1

Now that we've examined the topics using rostopic let's use another tool to look
at the data published by our turtlesim.

3.7.5 Using rqt_plot


Note: If you're using electric or earlier, rqt is not available. Use rxplot instead.
rqt_plot displays a scrolling time plot of the data published on topics. Here we'll
use rqt_plot to plot the data being published on the /turtle1/pose topic. First,
start rqt_plot by typing
$ rosrun rqt_plot rqt_plot

in a new terminal. In the new window that should pop up, a text box in the upper left
corner gives you the ability to add any topic to the plot. Typing /turtle1/pose/x
will highlight the plus button, previously disabled. Press it and repeat the same
procedure with the topic /turtle1/pose/y. You will now see the turtle's x-y
location plotted in the graph.

Pressing the minus button shows a menu that allows you to hide the specified topic
from the plot. Hiding both the topics you just added and adding
/turtle1/pose/theta will result in the plot shown in the next figure.

29
Practical Report
Distributed Control System 1

That's it for this section, use Ctrl-C to kill the rostopic terminals but keep your
turtlesim running.

3.8 Understanding ROS Services and Parameters


Assuming your turtlesim_node is still running from the last tutorial, let's look at what
services the turtlesim provides:

3.9.1 ROS Services


Services are another way that nodes can communicate with each other. Services
allow nodes to send a request and receive a response.

3.9.2 Using rosservice


rosservice can easily attach to ROS's client/service framework with services.
rosservice has many commands that can be used on services, as shown below:
Usage:
rosservice list print information about active services
rosservice call call the service with the provided args
rosservice type print service type
rosservice find find services by service type
rosservice uri print service ROSRPC uri

30
Practical Report
Distributed Control System 1

1) rosservice list
$ rosservice list

The list command shows us that the turtlesim node provides nine services:
reset, clear, spawn, kill, turtle1/set_pen,

/turtle1/teleport_absolute, /turtle1/teleport_relative,

turtlesim/get_loggers, and turtlesim/set_logger_level.


There are also two services related to the separate rosout node:
/rosout/get_loggers and /rosout/set_logger_level.
/clear
/kill
/reset
/rosout/get_loggers
/rosout/set_logger_level
/spawn
/teleop_turtle/get_loggers
/teleop_turtle/set_logger_level
/turtle1/set_pen
/turtle1/teleport_absolute
/turtle1/teleport_relative
/turtlesim/get_loggers
/turtlesim/set_logger_level

2) rosservice type
Usage:
rosservice type [service]

Let's find out what type the clear service is:


$ rosservice type /clear
std_srvs/Empty

This service is empty, this means when the service call is made it takes no
arguments (i.e. it sends no data when making a request and receives no data
when receiving a response).

3) rosservice call
Usage:
rosservice call [service] [args]

Here we'll call with no arguments because the service is of type empty:
$ rosservice call /clear

31
Practical Report
Distributed Control System 1

This does what we expect, it clears the background of the turtlesim_node.

Let's look at the case where the service has arguments by looking at the
information for the service spawn:
$ rosservice type /spawn | rossrv show

float32 x
float32 y
float32 theta
string name
---
string name

This service lets us spawn a new turtle at a given location and orientation. The
name field is optional, so let's not give our new turtle a name and let turtlesim
create one for us.
$ rosservice call /spawn 2 2 0.2 ""

The service call returns with the name of the newly created turtle
name: turtle2

Now our turtlesim should look like this:

32
Practical Report
Distributed Control System 1

3.9.3 Using rosparam


rosparam allows you to store and manipulate data on the ROS Parameter Server.
The Parameter Server can store integers, floats, boolean, dictionaries, and lists.
rosparam uses the YAML markup language for syntax. In simple cases, YAML
looks very natural: 1 is an integer, 1.0 is a float, one is a string, true is a boolean,
[1, 2, 3] is a list of integers, and {a: b, c: d} is a dictionary. rosparam has
many commands that can be used on parameters, as shown below:
Usage:
rosparam set set parameter
rosparam get get parameter
rosparam load load parameters from file
rosparam dump dump parameters to file
rosparam delete delete parameter
rosparam list list parameter names

33
Practical Report
Distributed Control System 1

1) rosparam list
$ rosparam list

Here we can see that the turtlesim node has three parameters on the param server
for background color:
/background_b
/background_g
/background_r
/rosdistro
/roslaunch/uris/host_57aea0986fef__34309
/rosversion
/run_id

Let's change one of the parameter values using rosparam set:

2) rosparam set and rosparam get


Usage:
rosparam set [param_name]
rosparam get [param_name]

Here will change the red channel of the background color:


$ rosparam set /background_r 150

This changes the parameter value, now we have to call the clear service for the
parameter change to take effect:
$ rosservice call /clear

Now our turtlesim looks like this:

34
Practical Report
Distributed Control System 1

Now let's look at the values of other parameters on the param server. Let's get
the value of the green background channel:
$ rosparam get /background_g
86

We can also use rosparam get / to show us the contents of the entire
Parameter Server.
$ rosparam get /

background_b: 255
background_g: 86
background_r: 150
roslaunch:
uris: {'aqy:51932': 'http://aqy:51932/'}
run_id: e07ea71e-98df-11de-8875-001b21201aa8

3) rosparam dump and rosparam load


Usage:
rosparam dump [file_name] [namespace]
rosparam load [file_name] [namespace]

Here we write all the parameters to the file params.yaml


$ rosparam dump params.yaml

You can even load these yaml files into new namespaces, e.g. copy:
$ rosparam load params.yaml copy
$ rosparam get /copy/background_b

255

3.9 Using rqt_console and roslaunch


3.4.6 Using rqt_console and rqt_logger_level
rqt_console attaches to ROS's logging framework to display output from nodes.
rqt_logger_level allows us to change the verbosity level (DEBUG, WARN,
INFO, and ERROR) of nodes as they run.
Now let's look at the turtlesim output in rqt_console and switch logger levels in
rqt_logger_level as we use turtlesim. Before we start the turtlesim, in two
new terminals start rqt_console and rqt_logger_level:
$ rosrun rqt_console rqt_console
$ rosrun rqt_logger_level rqt_logger_level

35
Practical Report
Distributed Control System 1

You will see two windows popup:

Now let's start turtlesim in a new terminal:


$ rosrun turtlesim turtlesim_node
Since the default logger level is INFO you will see any info that the turtlesim
publishes when it starts up, which should look like:

36
Practical Report
Distributed Control System 1

Now let's change the logger level to Warn by refreshing the nodes in the
rqt_logger_level window and selecting Warn as shown below:

Now let's run our turtle into the wall and see what is displayed in our rqt_console:
rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '{linear:
{x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

3.4.7 Using roslaunch


roslaunch starts nodes as defined in a launch file.
Usage:
$ roslaunch [package] [filename.launch]
First go to the beginner_tutorials package we created and built earlier:
$ roscd beginner_tutorials

37
Practical Report
Distributed Control System 1

If roscd says something similar to roscd: No such package/stack


'beginner_tutorials' , you will need to source the environment setup file like you
did at the end of the create_a_workspace tutorial:
$ cd ~/catkin_ws
$ source devel/setup.bash
$ roscd beginner_tutorials

Then let's make a launch directory:


$ mkdir launch
$ cd launch

NOTE: The directory to store launch files doesn't necessarily have to be named
launch. In fact you don't even need to store them in a directory. roslaunch
command automatically looks into the passed package and detects available launch
files. However, this is considered good practice.

3.4.8 The Launch File


Now let's create a launch file called turtlemimic.launch and paste the following:

<launch>

<group ns="turtlesim1">
<node pkg="turtlesim" name="sim" type="turtlesim_node"/>
</group>

<group ns="turtlesim2">
<node pkg="turtlesim" name="sim" type="turtlesim_node"/>
</group>

<node pkg="turtlesim" name="mimic" type="mimic">


<remap from="input" to="turtlesim1/turtle1"/>
<remap from="output" to="turtlesim2/turtle1"/>
</node>

</launch>

3.4.9 Roslaunching
Now let's roslaunch the launch file:
$ roslaunch beginner_tutorials turtlemimic.launch

Two turtlesims will start and in a new terminal send the rostopic command:
$ rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r
1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

38
Practical Report
Distributed Control System 1

You will see the two turtlesims start moving even though the publish command is
only being sent to turtlesim1.

We can also use rqt_graph to better understand what our launch file did. Run rqt's
main window and select Plugins > Introspection > Node Graph:
$ rqt_graph

39
Practical Report
Distributed Control System 1

BAB IV
PRACTICAL RESULT

4.1 Installing and Configuring Your ROS Environment


The following results of the practicum that has been done.

40
Practical Report
Distributed Control System 1

4.2 Navigating the ROS Filesystem


The following results of the practicum that has been done.

Start by typing like this.

After pushing the TAB key, the command line should fill out the rest:

There is another example like the picture above.

41
Practical Report
Distributed Control System 1

4.3 Creating a ROS Package


The following results of the practicum that has been done.

42
Practical Report
Distributed Control System 1

These dependencies for a package are stored in the package.xml file:

In many cases, a dependency will also have its own dependencies. For instance, rospy has
other dependencies.

43
Practical Report
Distributed Control System 1

4.4 Building a ROS Package


The following results of the practicum that has been done.

44
Practical Report
Distributed Control System 1

4.5 Understanding ROS Nodes


The following results of the practicum that has been done.
There is some prerequisites before we do this tutorial.

Rosnode displays information about the ROS nodes that are currently running.

45
Practical Report
Distributed Control System 1

Run the turtlesim_node in the turtlesim package.

Checking the active nodes.

46
Practical Report
Distributed Control System 1

After close the turtlesim window to stop the node (or go back to the rosrun turtlesim
terminal and use ctrl-C). Now let's re-run it, but this time use a Remapping Argument to
change the node's name:

rosnode command, ping, to test the /my_turtle :

47
Practical Report
Distributed Control System 1

4.6 Understanding ROS Topics


The following results of the practicum that has been done.
You can use the arrow keys of the keyboard to drive the turtle around. If you can not drive
the turtle select the terminal window of the turtle_teleop_key to make sure that the keys
that you type are recorded.

48
Practical Report
Distributed Control System 1

After we run syntax below, you will see something similar like this.
$ rosrun rqt_graph rqt_graph

If you place your mouse over /turtle1/command_velocity it will highlight the ROS
nodes (here blue and green) and topics (here red). As you can see, the turtlesim_node
and the turtle_teleop_key nodes are communicating on the topic named
/turtle1/command_velocity.

49
Practical Report
Distributed Control System 1

50
Practical Report
Distributed Control System 1

After we run some syntax on the previously page. Press the refresh button in the upper-left to
show the new node. As you can see rostopic echo, shown here in red, is now also subscribed
to the turtle1/command_velocity topic.

51
Practical Report
Distributed Control System 1

The previous command will send a single message to turtlesim telling it to move with a
linear velocity of 2.0, and an angular velocity of 1.8 .

You may have noticed that the turtle has stopped moving; this is because the turtle requires
a steady stream of commands at 1 Hz to keep moving. We can publish a steady stream of
commands using rostopic pub -r command:

52
Practical Report
Distributed Control System 1

We can also look at what is happening in rqt_graph. Press the refresh button in the upper-
left. The rostopic pub node (here in red) is communicating with the rostopic echo node
(here in green):

53
Practical Report
Distributed Control System 1

This command is used to see how fast the turtlesim_node is publishing /turtle1/pose:

54
Practical Report
Distributed Control System 1

This command displays a scrolling time plot of the data published on topics

55
Practical Report
Distributed Control System 1

4.7 Understanding ROS Services and Parameters


The following results of the practicum that has been done.

56
Practical Report
Distributed Control System 1

Before and after the /clear command.

This command that used to spawn the next turtle.

57
Practical Report
Distributed Control System 1

This command that used to set background color.

This command that used to get data from currently background.

58
Practical Report
Distributed Control System 1

4.8 Using rqt_console and roslaunch


The following results of the practicum that has been done.

59
Practical Report
Distributed Control System 1

60
Practical Report
Distributed Control System 1

When the turtle hit the wall, the message will shown what happen to the turtlebot.

61
Practical Report
Distributed Control System 1

62
Practical Report
Distributed Control System 1

63
Practical Report
Distributed Control System 1

64
Practical Report
Distributed Control System 1

65
Practical Report
Distributed Control System 1

4.9 Simulate Turtlebot with Gazebo


The following results of the practicum that has been done.

66
Practical Report
Distributed Control System 1

CHAPTER V
CLOSING

4.1 Conclusion
In Distributed Control System - 2, I learn how to connect, observe and control single
and multiple Robot simulator software.
I encountered several problems or errors in running the Distributed Control System 2
practicum, for example problems in ROS software and the Ubuntu operating system
that I first time to use. And these problems, the author has obtained solutions with the
help of supervision and fellow students and can regret the practicum Distributed
Control System 2.
One problem that occurred, is : No such package/stack 'beginner_tutorials' , and to
solve that we will need to source the environment setup file like you did at the end of
the create_a_workspace tutorial:
$ cd ~/catkin_ws
$ source devel/setup.bash
$ roscd beginner_tutorials

And the last one, can simulate robot movement before it is run in a real environment.

67
Practical Report
Distributed Control System 1

REFERENCES

IntroductionToROS_Anderson.pdf
ROSCheatsheet.pdf
ROS-robot-programming-book-by-turtlebo3-developers-EN.pdf
student_guidelines_for_written_report_bachelor_biosciences_17-18
http://wiki.ros.org/
Youtube Channel Shawn Chen
Youtube Channel Justin Huang
Youtube Channel Anis Kouuba

68

You might also like