Basic Operating Tutorial of Robot Operating System
Basic Operating Tutorial of Robot Operating System
discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/307635331
CITATIONS READS
0 888
2 authors, including:
SEE PROFILE
All content following this page was uploaded by Shree Krishna Acharya on 06 September 2016.
Figure 1: The third ROS developers' conference was held in Chicago, Illinois
I) Make directory
Command: mkdir directory_name
II) Go to directory
Command: cd directory_name
III) Lookup directory
Command: ls
IV) Remove directory
Command : rm –r –f directory_name
V) Create file
Command: nano file_name
VI) Remove file
Command: rm file_name
Copy or move directory
Command: cp or mv source_filename destination_filename
VII)
VIII)
IX)
2.1) Installing ROS on the Raspberry Pi:
Installing ROS Fuerte:
Fdgfg ghg
http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Fuerte%20on%20RaspberryPi
Installing ROS Groovy:
Dfji f kdf f
http://wiki.ros.org/groovy/Installation/Raspbian
Raspbian Jessie:
Raspbian Wheezy:
Raspbian Jessie:
Initializing rosdep
$ sudo rosdep init
$ rosdep update
b) Installation
Now, we are going to download and build ROS Indigo
Creating a catkin Workspace
Catkin Workspace used for build the core packages. We can create one by using this command:
$ mkdir ~/ros_catkin_ws
$ cd ~/ros_catkin_ws
We use wstool for fetch the core packages which is useful to build them. We have many types
of wstool as particular that we want to install.
ROS-Comm: (recommended) ROS package, build, and communication libraries. No GUI tools.
This will add all of the catkin or wet packages in the given variant and then fetch the sources
into the ~/ros_catkin_ws/src directory. The command will take a few minutes to download
all of the core ROS packages into the src folder. The -j8 option downloads 8 packages in
parallel.
Packages: ros/………………………………………….
Some package are excluded because dependency problems as like : roslisp package dependent
on sbcl. Building sbcl is possible but not tested. However we have two variant namely robot
and perception. If we want just change the package path as like example of robot below.
$ rosinstall_generator robot --rosdistro indigo --deps --wet-only --
tar > indigo-robot-wet.rosinstall
$ wstool init src indigo-robot-wet.rosinstall
Resolve Dependencies
Before building catkin workspace, we need to make sure that we have all required
dependencies. We use rosdep tool for making this, however some dependencies are not
available in the repositories. So have to build manually.
Unavailable Dependencies
Following packages are not available
For Raspbian Wheezy:
iv) libconsole-bridge-dev,
v) liburdfdom-headers-dev,
vi) liburdfdom-dev, liblz4-dev,
vii) collada-dom-dev
For Raspbian Jessie:
i) collada-dom-dev
For Ros_Comm:
i) libconsole-bridge-dev,
ii) liblz4-dev
For Desktop:
i) libconsole-bridge-dev,
ii) liblz4-dev,
iii) liburdfdom-headers-dev,
iv) liburdfdom-dev,
v) collada-dom-dev
The required packages can be built from source in a new directory as making external_src:
$ mkdir ~/ros_catkin_ws/external_src
$ sudo apt-get install checkinstall cmake
$ sudo sh -c 'echo "deb-src
http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-
free rpi" >> /etc/apt/sources.list'
$ sudo apt-get update
libconsole-bridge-dev:
$ cd ~/ros_catkin_ws/external_src
$ sudo apt-get build-dep console-bridge
$ apt-get source -b console-bridge
$ sudo dpkg -i libconsole-bridge0.2*.deb libconsole-bridge-dev_*.deb
If you see an error complaining about the option '-std=c++11' then follow these steps to upgrade
to gcc 4.7+
liblz4-dev:
$ cd ~/ros_catkin_ws/external_src
$ apt-get source -b lz4
$ sudo dpkg -i liblz4-*.deb
liburdfdom-headers-dev:
$ cd ~/ros_catkin_ws/external_src
$ git clone https://github.com/ros/urdfdom_headers.git
$ cd urdfdom_headers
$ cmake .
$ sudo checkinstall make install
o When check-install asks for any changes, the name (2) needs to change from "urdfdom-
headers" to "liburdfdom-headers-dev" otherwise the rosdep install wont find it.
liburdfdom-dev:
$ cd ~/ros_catkin_ws/external_src
$ sudo apt-get install libboost-test-dev libtinyxml-dev
$ git clone https://github.com/ros/urdfdom.git
$ cd urdfdom
$ cmake .
$ sudo checkinstall make install
o When check-install asks for any changes, the name (2) needs to change from "urdfdom"
to "liburdfdom-dev" otherwise the rosdep install wont find it.
collada-dom-dev: (Note: You will also need to patch collada_urdf as described here):
$ cd ~/ros_catkin_ws/external_src
$ sudo apt-get install libboost-filesystem-dev libxml2-dev
$ wget http://downloads.sourceforge.net/project/collada-
dom/Collada%20DOM/Collada%20DOM%202.4/collada-dom-2.4.0.tgz
$ tar -xzf collada-dom-2.4.0.tgz
$ cd collada-dom-2.4.0
$ cmake .
$ sudo checkinstall make install
o When check-install asks for any changes, the name (2) needs to change from "collada-
dom" to "collada-dom-dev" otherwise the rosdep install wont find it.
Note: If you don't want to compile Collada but would like to install the desktop variant, use the
following generator:
Raspbian Wheezy:
$ cd ~/ros_catkin_ws
$ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --
os=debian:wheezy
Raspbian Jessie:
$ cd ~/ros_catkin_ws
$ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --
os=debian:jessie
Now we are completing all of package in src directory and find all of dependencies they have.
The --from-paths src options says that we want to install the dependencies for
an entire directory of packages.
The --ignore-src options says that ignore ROS packages because we are going
to install those package manually.
The --rosdistro option indicate building version of ROS so we have to indicate it
for environment setup.
Finally, -y options says to rosdep for less annoying prompts from package
manager.
After some time rosdep finish its installing the system dependencies so we can continue but
rodesp report some error reports about python-rosdep, python-catkin-pkg, python-
rospkg, and python-rosdistro. But we can ignore it because they are already install with
pip.
Building the catkin Workspace
After completing downloading those packages we have to resolve the dependencies. Now we
are ready to build the catkin packages because we already download it.
Invoke catkin_make_isolated:
It is already downloaded and used for installing catkin. We should encountered an internal
compiler error due to out of memory. http://raspberrypimaker.com/adding-swap-to-the-
raspberrypi/ We should quickly fix that problem by adding swap space to the Pi and recompile.
By default the command has –j4 option but we try building by –j2 option. As below
$ sudo ./src/catkin/bin/catkin_make_isolated --install -
DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo -j2
We must ensure the ROS file location. Now ROS should be installed! Remember to source the
new installation. By defaut in raspberry system it is located at /opt/ros/indigo at Ubuntu
system . But in raspberry pi it is located at / home/user/indigo.
$ source /opt/ros/indigo/setup.bash or $ source
/home/user/indigo/setup.
Or optionally source the setup.bash in the ~/.bashrc, so that ROS environment variables are
automatically added to your bash session every time a new shell is launched:
For other variant we can update the filesnames and rosinstall_generator arguments
appropriately. After this we compare the new rosinstall file to the old version to see which
packages will be updated.
$ diff -u indigo-desktop-full-wet.rosinstall indigo-desktop-full-
wet.rosinstall.old
If we are satisfied with these changes, incorporate the new rosinstall file into the workspace and update
your workspace.
Now our workspace is up to date with the latest sources. We have to rebuild it.
$ ./src/catkin/bin/catkin_make_isolated --install
If we specified the --install-space option when our workspace initially, we should specify it again
when rebuilding our workspace.
Once our workspace has been rebuilt, we should source the setup files again.
$ source ~/ros_catkin_ws/install_isolated/setup.bash
cd ~/ros_catkin_ws
$ rosinstall_generator ros_comm ros_control joystick_drivers --
rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-
custom_ros.rosinstall
We can keep listing as many ROS packages as we’d like separated by spaces .
$ wstool update -t src
After finishing the workspace, we can run rosdep to install any new dependencies that required
as :
Raspbian Wheezy:
Raspbian Jessie:
Finally, now our workspace is up to date and dependencies are satisfied, so we again rebuild the
workspace.
Installation
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.
Setup your computer to accept software from packages.ros.org. ROS Kinetic ONLY supports
Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8) for debian packages.
Installation
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.
e.g.
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.
Getting rosinstall
rosinstall is a frequently used command-line tool in ROS that is distributed separately. It enables
you to easily download many source trees for ROS packages with one command.
During the installation of ROS, we will see that we are prompt to source one of several setup.sh files. It
required because ROS relies on the notation of combining spaces using the shell environment which
makes developing against different version of ROS.
Environment variables:
There are many environment variables that we can set to affect the behavior of ROS. Of these, the most
important to understand are ROS_MASTER_URI, ROS_ROOT, and ROS_PACKAGE_PATH as they are
commonly used in the system and frequently mentioned in documentation.
Finding packages: First and foremost, the ROS_ROOT and ROS_PACKAGE_PATH enable
ROS to locate packages and stacks in the file system. You must also set the PYTHONPATH
so that the Python interpreter can find ROS libraries.
Effecting a Node runtime: There are also several ROS environment variables that effect
how a Node runs. The ROS_MASTER_URI is an important environment variable that tells a
Node where the Master is. ROS_IP and ROS_HOSTNAME affect the network address of a
Node and ROS_NAMESPACE lets you change its namespace. ROS_LOG_DIR lets you set the
directory where log files are written. Many of these can be overridden by Remapping
Arguments as well, which have precedence over environment variables.
Modifying the build system: ROS_BINDEPS_PATH, ROS_BOOST_ROOT,
ROS_PARALLEL_JOBS, and ROS_LANG_DISABLE affect where libraries are found, how they
are built, and which ones are built.
Most systems will also have ROS_PACKAGE_PATH set, but the only required environment variables for
ROS are ROS_ROOT, ROS_MASTER_URI, and PYTHONPATH. By default these are automatically set for
you by sourcing /opt/ros/ROSDISTRO/setup.bash. (Replace ROSDISTRO with the desired ROS
distribution, e.g. indigo.)
1) ROS_ROOT:
ROS_ROOT sets the location where the ROS core packages are installed.
export ROS_ROOT=/home/user/ros/ros
export PATH=$ROS_ROOT/bin:$PATH
2) ROS_MASTER_URI
ROS_MASTER_URI is a required setting that tells nodes where they can locate
the master. It should be set to the XML-RPC URI of the master. Great care
should be taken when using localhost, as that can lead to unintended
behaviors with remotely launched nodes.
export ROS_MASTER_URI=http://mia:11311/
3) PHYTHONPATH
ROS requires that our PYTHONPATH be updated, even if we don't program in
Python! Many ROS infrastructure tools rely on Python and need access to the
roslib package for bootstrapping.
export PYTHONPATH=$PYTHONPATH:$ROS_ROOT/core/roslib/src
1) ROS_PACKAGE_PATH
ROS_PACKAGE_PATH is an optional, but very common environment variable
that allows you to add more ROS packages from source to your environment.
ROS_PACKAGE_PATH can be composed of one or more paths separated by your
standard OS path separator (e.g. ':' on Unix-like systems). These ordered paths
tell the ROS system where to search for more ROS packages. If there are
multiple packages of the same name, ROS will choose the one that appears on
ROS_PACKAGE_PATH first.
export ROS_PACKAGE_PATH=/home/user/ros/ros-pkg:/another/path
With the introduction of catkin, ROS_PACKAGE_PATH becomes obsolete, and will be kept only for
backwards compatibility with rosbuild packages.
Tutorial 1
We will need to this command on every new shell which have to access the ROS command, unless we
add this line to our .bashsrc.
Now we should have ‘build’ and ‘devel’ folder which contains several setup files. We start our new setup
file by :
source devel/setup.bash
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.
a) Using rospack
It gives information about packages. For example we cover here only find option of rospack.
Command: $ rospack find roscpp .
b) Using roscd
We should be on
YOUR_INSTALL_PATH/share/roscpp
It also move to subdirectory of a package or stack. Our ROS_PACKAGE_PATH should contain a list of
directories where we have ROS packages separated by colons
c) roscd log
It takes us where ROS stores log files. If we have not run any ROS any program yet, it
produce error.
$ roscd log
d) using rosls
rosls is part of rosbash. It allows us to ls directly in a package raher than absolute path.
$ rosls [locationname[/subdir]]
For example: $ rosls roscpp_tutorials we return on: cmake launch package.xml srv
e) Tab Completion
It is tedious to type out an entire package name. with the help of two tab and commands we can get full
package name.
$ roscd roscpp_tut<<< now push the TAB key >>> gives $ roscd roscpp_tutorials/
$ roscd turtles<<< now push the TAB key >>> gives $ roscd turtlesim/
a) Make sure we are in catkin work space by below command or we have to calculate.
$ cd ~/catkin_ws/src
b) 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
c) Package dependencies
i) First- order dependencies
The first order dependencies can now reviewed with the rospack tool.
$ rospack depends1 beginner_tutorials
The package.xml file are stored list of dependicies when running catkin_create _pkg.
$ roscd beginner_tutorials
$ cat package.xml
d) Note: Before creating some catkin Package we need an empty catkin workspace.
Command: catkin_create_pkg beginner_tutorial std_msgs rospy roscpp
Then type command again: catkin_make
Then type command again: source devel/setup.bash
e)
Tutorial : 2
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)
Client Libraries
ROS client libraries allow nodes written in different programming languages to communicate:
steps of working:
Replace '<distro>' with the name of your ROS distribution (e.g. indigo, jade, kinetic).
2) Roscore is the master of all ros fuction. roscore = ros+core : master (provides name service for
ROS) + rosout (stdout/stderr) + parameter server. We have to initialize by typing below
command.
$ roscore
3) Using rosnode
rosnode = ros+node : ROS tool to get information about a node. Open up a new terminal-
terminal-2 , and let's use rosnode to see what running roscore did. rosnode displays
information about the ROS nodes that are currently running. The rosnode list command lists
these active nodes:
$ rosnode list
We see the output is :
/rosout
4) 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). Open up a new terminal terminal-3, to run this command
rosrun = ros+run : runs a node from a given package.
$ rosrun turtlesim turtlesim_node
6) We can change the turtlesim node’s name. For this, close turtlesim window go back to
terminal-3 and stop it from running by using ctrl-C. The name changing command is commnd
is
$ rosrun turtlesim turtlesim_node __name:=my_turtle
It gives ping time by second wise. Finally your screen is seeing as like below.
Tutorial : 3
This tutorial introduces ROS topics as well as using the rostopic and rqt_plot commandline tools.
Initial setup:
Steps :
1) Let’s open a new terminal-1 for roscore running. We must ensure only one roscore is running
otherwise it produce error. If it is running please kill before it is launching.
$ roscore
Note: we can check again our rosnodes and rostopic list on each corresponding terminal
window. Please check one time so we can know each rostopic nodes easily.
7) Now we are working on terminal-3 and terminal-5. In terminal- 3 we can see published data by
typing command:
$ rostopic echo /turtle1/cmd_vel
We can see below type of window in our monitor.
For more information about cmd_vel of turtlebot.
8) Again we are going to find position of turtlebot. For this we type a command in terminal-3
Command:
$ rosmsg show geometry_msgs/Twist
Command: $ rostopic type /turtle1/pose
9) Pub operation on turtule node provides automatic moving in linear and angular direction. We
have command. It published data on to a topic currently advertised
$ rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0,
0.0]' '[0.0, 0.0, 1.8]'
10) We can analysis nodes by seeing its 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-kinetic-rqt
$ sudo apt-get install ros-<distro>-rqt-common-plugins
replacing <distro> with the name of your ROS distribution (indigo, jade, kinetic)
In a new terminal:
11) Each time you can refresh this window through refresh icon. Also we can see scrolling time plot
by typing command : rosrun rqt_plot rqt_plot in a new terminal window.
Comments:
Step :1
Step: 2
Chapter 4:
The message are published by Talker as a publisher by using command std_msgs::String. The string
message are collected and listening by the listener also known as subscriber. They do not communicate
with each other in chatter topic.
Talker publishes chatter topic and register to the ROS master. Listener will look forward that chatter
topic in Master.
"Node" is the ROS term for an executable that is connected to the ROS network. Here we'll create a
publisher ("talker") node which will continually broadcast a message.
ros::Rate loop_rate(10); :- It gives loop duration. It will track and control by Rate::sleep().
In this case we want to run 10hz.
int count = 0;
while (ros::ok())
{
Broadcasting of message:
std_msgs::String msg;
std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();
it is also called message adapted class which generated from msg file. Here “hello world” is
standard string message.
Subscribe to the chatter topic with the master. ROS will call the chatterCallback() function
whenever a new message arrives. If message reach to the equal of queue number 1000, it starts to
delete through older messages.
NodeHandle::subscribe() returns a ros::Subscriber object, that you must hold on to until you
want to unsubscribe. When the Subscriber object is destructed, it will automatically unsubscribe from
the chatter topic.
ros::spin(); :-It enter the loop and calling message callbacks as soon as possible. It stops when once
ros::ok() returns false.
What’s going on in below running program?
Initialize the ROS system
Subscribe to the chatter topic
Spin, waiting for messages to arrive
When a message arrives, the chatterCallback() function is called
4)
5)
Publisher with Python:
The talker of python program looks like as
Subscriber with Python:
The listener of python program look like as:
Steps of Tutorial: 5
1) Go to the catkin_ws workspace and type catkin_make
2) Setup bash file by typing source devel/setup.bash
3) Go to src folder and cloning random walker from copying random walker url
4) Go to the random walker folder and type command
Command: git checkout origin/finished
5) Check downloaded file by ls command then launch walk.launch file
Command: roslaunch launch/walk.launch
6) Open a new terminal window-2 from file menu and type rostopic command
7) In terminal window -2 type command
Command: rostopic echo /move_command
8) We can see publishing up , down etc. command on second terminal as shown below
i) Odem topic provides what are the message type: package name.
Command: rostopic info odem
ii)
iii)
iv)
v)
vi)