Exploring ROS: Installation, Commands, and Package Building

Ashutosh Suthar
5 min readJun 26, 2023

--

Source

Overview

Robot Operating System (ROS or ros) is an open-source middleware to be used in complex robot control software systems.

ROS is not an operating system (OS) but it is designed to facilitate communication and coordination between different nodes in a robotic system. Each node is responsible for a specific task, and they can run on different computers within a heterogeneous computer cluster. The nodes communicate with each other by passing messages, allowing for distributed processing and collaboration.

Services provided by ROS include hardware abstraction, low-level device control, implementation of commonly used functionality, message-passing between processes, and package management.

Running sets of ROS-based processes are represented in a graph architecture where processing takes place in nodes that may receive, post, and multiplex sensor data, control, state, planning, actuator, and other messages.

Installation

Installing the Robot Operating System (ROS) is a relatively straightforward process that begins with determining the required version for your needs. The official ROS website provides detailed instructions for each distribution, making the installation a breeze. By configuring your package manager, downloading the necessary packages, and setting up your environment, you’ll have ROS up and running in no time.

For example, ROS Kinetic distro can be run on Ubuntu 16.04, ROS Melodic can be run on Ubuntu 18.04 and ROS Noetic can be run on Ubuntu 20.04.

ROS BASICS

Some basic commands we will need are:

  1. roscoreThis starts the ROS Core Stack.
  2. rosrun runs an executable program and creates nodes.
  3. rosnode shows information about nodes and lists the active nodes.
  4. rostopic shows information about ROS topics.
  5. rosservice displays the runtime information about various services and allows the display of messages being sent to a topic.
  6. rosparam is used to get and set parameters (data) used by nodes.
  7. rosbag is a command-line tool for performing various operations on ROS bag files, including playing, recording, and validating.
  8. rospack allows you to get information about packages.
  9. rosclean cleanup filesystem resources(e.g. log files) created by ROS.
  10. roslaunch launches a set of nodes from an XML configuration file and includes support for launching on remote machines.
  11. roscreate-pkg creates common Manifest, CMakeLists, Doxygen, and other files necessary for a new ROS package. It is part of the roscreate package.
  12. rqt_graph displays an interactive graph of ROS nodes and topics.
  13. roscd allows you to change directory (cd) directly to a package or a stack.
  14. rosls allows you to explore the files and directories within a ROS package.

Navigating the ROS Filesystem

Source

Workspace: the place to manage and organize the ROS project files.

  • src: source space; contains ROS catkin package (source code package)
  • build: compilation space; contains cache information and intermediate files of catkin (CMake)
  • devel: Development space; contains generated object files (including header files, dynamic link libraries, static link libraries, executable files, etc.), and environment variables.
  • install: Installation space

Steps to create a workspace

mkdir -p ~/catkin_ws/src  # create
cd catkin_ws/ # enter workspace
catkin_make # compile
source devel/setup.bash # Update the workspace environment

Before using catkin_make to compile, be sure to return to the top-level workspace.

build and devel folders are automatically created by the catkin_make command

Creating a ROS Package

A package is a file and folder combination, in which we put the program code that implements the same specific function into a package.

Catkin is a build system used in the development of ROS (Robot Operating System) packages.

To be recognized as a catkin package, the following requirements must be fulfilled:

  1. package.xml: The package must include a package.xml file, which adheres to the catkin standard. This file contains important metadata that provides information about the package, such as its name, version, dependencies, and other relevant details.
  2. CMakeLists.txt: The package must contain a CMakeLists.txt file that utilizes catkin. This file serves as instructions for the build system and specifies how the package should be built. It includes details on compiling the code, managing dependencies, and generating executables or libraries. For catkin metapackages (packages that group other packages), a specific boilerplate CMakeLists.txt file is required.
  3. Individual package folder: Each package should have its own dedicated folder. This means that packages cannot be nested within one another, and multiple packages cannot share the same directory. This folder structure ensures proper organization of code and prevents conflicts between packages.

By meeting these requirements, a package becomes compatible with the catkin build system, ensuring seamless integration and management within the broader ROS (Robot Operating System) environment.

Steps to create your own ROS package are as below

# You should have created src previously while making workspace.
cd ~/catkin_ws/src

catkin_create_pkg my_package std_msgs rospy roscpp
# Here 【rospy】、【rosmsg】、【roscpp】are dependent library.
# This will create a my_package folder which contains a package.xml and a
# CMakeLists.txt, which have been partially filled out with the information
# you gave catkin_create_pkg.

# To build the packages in the catkin workspace:
cd ~/catkin_ws
catkin_make

# To add the workspace to your ROS environment you need to source the generated setup file:
. ~/catkin_ws/devel/setup.bash

Read article 6 to know more about coustomizing your package. It describes line by line meaning of different component used in your package.

Building a ROS Package

You should already have a catkin workspace and the new catkin package created.

catkin_make is a command used in the ROS (Robot Operating System) environment to build ROS packages. The catkin_make command will automatically find the packages in your workspace and build them.

It’s important to note that before running catkin_make, you should ensure that you have properly set up your ROS workspace by sourcing the appropriate setup file.

# Navigate to your catkin workspace
cd ~/catkin_ws/
ls src

# Build that package using catkin_make:
catkin_make

# source the setup file
source /opt/ros/%YOUR_ROS_DISTRO%/setup.bash

You can use the rosdep tool to install missing dependencies.

File structure inside a package

CMakeLists.txt (Required) The compilation rules of the current package.
package.xml (Required) The description of the package. Usually, we will add some ros library support files.
include folderStore C++ header files
config folderStore parameter configuration files
launch folder Store launch file(.launch or.xml)
meshes folder Store 3D models of robots or simulation scenes(.sda, .stl, .dae, etc)
urdf folder Storage model description of the robot(.urdf or .xacro)
rviz folder Store rviz file
src folder Store c++ code
scripts folderExecutable scripts; such as shell scripts (.sh), and Python scripts (.py);
srv folder Store customized service
msg folder Store customized topic
action folder Store customized action

Summary

Through this article, we have covered the following:

  • Overview of ROS
  • ROS Installation Process
  • Overview of ROS workspace and package files.
  • How to create and build a ROS package

Resources

  1. Robot Operating System — Wikipedia
  2. Documentation — ROS Wiki
  3. Introduction of project files

Feedback/Suggestions:

For any feedback or suggestions, please comment below or drop a mail at ashutoshsuthar01@gmail.com

--

--