You are on page 1of 13

17

CHAPTER 3
PROGRAM LANGUAGE USAGE OF THE SYSTEM

The Robot Operating System (ROS) is not an actual operating system, but a
framework and set of tools that provide functionality of an operating system on a het-
erogeneous computer cluster. Its usefulness is not limited to robots, but the majority
of tools provided are focused on working with peripheral hardware. ROS is split up in
more than 2000 packages, each package providing specialized functionality. The
numbers of tools connected to the framework are probably its biggest power. In this
system ROS is drive with C++, Python and XML.

3.1 Overview of Robot Operation System (ROS)


The Robot Operating System (ROS) is a flexible framework for writing robot
software. It is a collection of tools, libraries, and conventions that aim to simplify the
task of creating complex and robust robot behavior across a wide variety of robotic
platforms. Why? Because creating truly robust, general-purpose robot software is
hard. From the robot's perspective, problems that seem trivial to humans often vary
wildly between instances of tasks and environments. Dealing with these variations is
so hard that no single individual, laboratory, or institution can hope to do it on their
own. As a result, ROS was built from the ground up to encourage collaborative robot-
ics software development. For example, one laboratory might have experts in map-
ping indoor environments, and could contribute a world-class system for producing
maps. Another group might have experts at using maps to navigate, and yet another
group might have discovered a computer vision approach that works well for recog-
nizing small objects in clutter. ROS was designed specifically for groups like these to
collaborate and build upon each other's work, as is described throughout this site.
The key feature of ROS is the way the software is run and the way it com-
municates, allowing you to design complex software without knowing how certain
hardware works. ROS provides a way to connect a network of processes (nodes) with
18

a central hub. Nodes can be run on multiple devices, and they connect to that hub in
various ways.
The main ways of creating the network are providing request able services, or de-
fining publisher/subscriber connections with other nodes. Both methods communicate
via specified message types. Some types are provided by the core packages, but mes-
sage types can be defined by individual packages. Developers can assemble a com-
plex system by connecting existing solutions for small problems. The way the system
is implemented, it allows us to:
 Replace components with similar interfaces on the fly, removing the need of
stopping the system for various changes
 Multiplexing outputs of multiple components into one input for another com-
ponent, allowing parallel solving of various problems
 Connect components made in various programming languages by just imple-
menting the proper connectors to the messaging system, making it easy to de-
velop software by connecting existing modules from various developers
 Create nodes over a network of devices, without worrying about where code is
run and implementing Interposes communication (IPC) and Remote Procedure
Call (RPC) systems
 Directly connect to feeds on demand from remote hardware without writing
any extra code, by employing the previous two bullet points
We plan on demonstrating how useful that is by iteratively developing a simple solu-
tion. There are several key advantages compared to other approaches. ROS has multi-
platform support and allows connections between processes over multiple devices via
peer-to-peer connections that are handled behind the scene. The design allows support
for any language by wrapping the C++ communication classes, or manually develop-
ing classes for the language interface.
ROS is made by its own community, meant for its community. After several
years, that resulted in a great amount of reusable packages that are simple to integrate,
thanks to the architecture of the system. Alternative approaches like MRPT, CAR-
MEN, LCM, Player, Microsoft RDS and others provide some of those features, but
not all. Most of the time, the design downfalls are language support limitations, opti-
mized communication between processes, or the lack of support for various devices
which is arguably the hardest problem to fix.
19

3.2. Overview of C++


This overview of C++ presents the key design, programming, and language-
technical con- cepts using examples to give the reader a feel for the language. C++ is
a general-purpose programming language with a bias towards systems programming
that supports efficient low-level computation, data abstraction, object-oriented pro-
gramming, and genericpro-gramming.

3.2.1 Introduction and Overview


C++ is a general-purpose programming language created by Bjarne Stroustrup
as an extension of the C programming language, or "C with Classes". The language
has expanded significantly over time, and modern C++ has object-oriented, generic,
and functional features in addition to facilities for low-level memory manipulation. It
is almost always implemented as a compiled language, and many vendors provide
C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, and
IBM, so it is available on many platforms.
C++ was designed with a bias toward system programming and embedded, re-
source-constrained software and large systems, with performance, efficiency and flex-
ibility of use as its design highlights. C++ has also been found useful in many other
contexts, with key strengths being software infrastructure and resource-constrained
applications, including desktop applications, servers (e.g. e-commerce, Web search or
SQL servers), and performance-critical applications (e.g. telephone switches or space
probes).
C++ is standardized by the International Organization for Standardization
(ISO), with the latest standard version ratified and published by ISO in December
2017 as ISO/IEC 14882:2017 (informally known as C++17). The C++ programming
language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then
amended by the C++03, C++11 and C++14 standards. The current C++17 standard
supersedes these with new features and an enlarged standard library. Before the initial
standardization in 1998, C++ was developed by Danish computer scientist Bjarne
Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an
efficient and flexible language similar to C that also provided high-level features for
program organization. C++20 is the next planned standard, keeping with the current
trend of a new version every three years.
20

3.2.2 The History of C++


In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on "C
with Classes", the predecessor to C++. The motivation for creating a new language
originated from Stroustrup's experience in programming for his PhD. thesis. Strou-
strup found that Simula had features that were very helpful for large software devel-
opment, but the language was too slow for practical use, while BCPL was fast but too
low-level to be suitable for large software development. When Stroustrup started
working in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with
respect to distributed computing. Remembering his Ph.D. experience, Stroustrup set
out to enhance the C language with Simula-like features. C was chosen because it was
general-purpose, fast, portable and widely used. As well as C and Simula's influences,
other languages also influenced C++, including ALGOL 68, Ada, CLU and ML.
Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre,
including classes, derived classes, strong typing, in lining and default arguments. In
1983, "C with Classes" was renamed to "C++" (++ being the increment operator in
C), adding new features that included virtual functions, function name and operator
overloading, references, constants, type-safe free-store memory allocation
(new/delete), improved type checking, and BCPL style single-line comments with two
forward slashes (//). Furthermore, it included the development of a standalone com-
piler for C++, Cfront.
In 1985, the first edition of The C++ Programming Language was released,
which became the definitive reference for the language, as there was not yet an offi-
cial standard. The first commercial implementation of C++ was released in October of
the same year.
In 1989, C++ 2.0 was released, followed by the updated second edition of The
C++ Programming Language in 1991. New features in 2.0 included multiple inher-
itance, abstract classes, static member functions, const member functions, and pro-
tected members. In 1990, The Annotated C++ Reference Manual was published. This
work became the basis for the future standard. Later feature additions included tem-
plates, exceptions, namespaces, new casts, and a boolean type.
After the 2.0 update, C++ evolved relatively slowly until, in 2011, the C++11
standard was released, adding numerous new features, enlarging the standard library
further, and providing more facilities to C++ programmers. After a minor C++14 up-
21

date released in December 2014, various new additions were introduced in C++17,
and further changes planned for 2020.
As of 2017, C++ remains the third most popular programming language, be-
hind Java and C.
On January 3, 2018, Stroustrup was announced as the 2018 winner of the
Charles Stark Draper Prize for Engineering, "for conceptualizing and developing the
C++ programming language".

3.2.3 The Design and Evolution of C++


C++ was designed and implemented by Bjarne Stroustrup (the author of this
article) at AT&T Bell Laboratories to combine the organizational and design strengths
of Similar with C’s facilities for systems programming. The initial version of C++,
called ‘‘C with Classes’’ [Stroustrup, 1980], was first used in 1980; it supported tradi-
tional system programming techniques (§3) and data abstraction (§4.1). The basic fa-
cilities for object-oriented programming (§4.2-4.3) were added in 1983 and object-
oriented design and programming techniques were gradually introduced into the C++
Community. The language was first made commercially available in 1985 [Strou-
strup, 1986] [Stroustrup, 1986b]. Facilities for generic programming (§4.4) were add-
ed to the language in the 1987-1989 time frame [Ellis, 1990] [Stroustrup, 1991].
As the result of widespread use and the appearance of several independently-
developed C ++implementations, formal standardization of C ++ started in 1990 un-
der the auspices of the American National Standards Institute, ANSI, and later the In-
ternational Standards Organization, ISO, leading to an international standard in 1998
[C ++ ,1998]. During the period of standardization the standards committee acted as
an important focus for the C++ community and its draft standards acted as interim
definitions of the language. As an active member of the standards committee, I was a
key participant in the further evolution of C++. Standard C++ is a better approxima-
tion to my ideals for C ++ than were earlier versions. The design and evolution of C
++ is documented in [Stroustrup, 1994] [Stroustrup, 1996] and [Stroustrup, 1997b].
The language as it is defined at the end of the standardization process and the key de-
sign and programming techniques it directly supports are presented in [Stroustrup,
1997].
22

3.2.4 Aim of C++


C++ was designed to deliver the flexibility and efficiency of C for systems
programming together with Simula’s facilities for program organization (usually re-
ferred to as object-oriented programming). Great care was taken that the higher-level
programming techniques from Simula could be applied to the systems programming
domain. That is, the abstraction mechanisms provided by C++ were specifically de-
signed to be applicable to programming tasks that demanded the highest degree of
efficiency and flexibility. These aims can be summarized:
C++makes programming more enjoyable for serious programmers.
C++is a general-purpose programming language that
 is a better C
 supports data abstraction
 supports object-oriented programming
 supports generic programming

3.3 Overview of Python


Compared to many languages, Python is easy to learn and to use. Its functions
can be carried out with simpler commands and less text than most competing lan-
guages. And this might explain why it’s soaring in popularity, with developers, cod-
ing students and tech companies.
It’s not an exaggeration to say that Python plays a small part of all of our lives.
It’s one of those invisible forces with a presence in our mobile devices, web searches
and gaming (and beyond). So it was an obvious choice for inclusion in our full stack
coding boot camp. Here’s an introduction to the language itself, and some of the eve-
ryday but profound, things that Python is used for.
Python was created in 1991 by Dutch programmer Guido Van Rossum. It is an
interpreted language. This means that it has an interpreter to execute the programmer
directly, as opposed to depending more complicated machine languages. In fact, Van
Rossum wants Python to eventually as understandable and clear as plain English. He
has also made the language open source, which means that anyone can contribute to
it, and he hopes that it will become as powerful as competing languages.
“Readability” is a key factor in Python’s philosophy. As such, it aims to limit
code blocks (blocks of source code text) and have white space instead, for a clearer,
23

less busy appearance. It’s a versatile language that runs on many systems, which
brings us to.

3.3.1 Introduction to Python


Python is an interpreter, high-level, general-purpose programming language.
Created by Guido van Rossum and first released in 1991, Python's design philosophy
emphasizes code readability with its notable use of significant whitespace. Its lan-
guage constructs and object-oriented approach aim to help programmers write clear,
logical code for small and large-scale projects.
Python is dynamically typed and garbage-collected. It supports multiple pro-
gramming paradigms, including procedural, object-oriented, and functional program-
ming. Python is often described as a "batteries included" language due to its compre-
hensive standard library.
Python was conceived in the late 1980s as a successor to the ABC language.
Python 2.0, released 2000, introduced features like list comprehensions and a garbage
collection system capable of collecting reference cycles. Python 3.0, released 2008,
was a major revision of the language that is not completely backward-compatible, and
much Python 2 code does not run unmodified on Python 3. Due to concern about the
amount of code written for Python 2, support for Python 2.7 (the last release in the 2.x
series) was extended to 2020. Language developer Guido van Rossum shouldered sole
responsibility for the project until July 2018 but now shares his leadership as a mem-
ber of a five-person steering council.
Python interpreters are available for many operating systems. A global com-
munity of programmers develops and maintains CPython, an open source reference
implementation. A non-profit organization, the Python Software Foundation, manages
and directs resources for Python and CPython development.
3.3.2 History of Python
Python was conceived in the late 1980s by Guido van Rossum at Centrum
Wiskunde & Informatica (CWI) in the Netherlands as a successor to the ABC lan-
guage (itself inspired by SETL), capable of exception handling and interfacing with
the Amoeba operating system. Its implementation began in December 1989. Van Ros-
sum continued as Python's lead developer until July 12, 2018, when he announced his
"permanent vacation" from his responsibilities as Python's Benevolent Dictator For
Life, a title the Python community bestowed upon him to reflect his long-term com-
24

mitment as the project's chief decision-maker. In January, 2019, active Python core
developers elected Brett Cannon, Nick Coghlan, Barry Warsaw, Carol Willing and
Van Rossum to a five-member "Steering Council" to lead the project.
Python 2.0 was released on 16 October 2000 with many major new features,
including a cycle-detecting garbage collector and support for Unicode.[38]
Python 3.0 was released on 3 December 2008. It was a major revision of the
language that is not completely backward-compatible. Many of its major features
were backported to Python 2.6.x and 2.7.x version series. Releases of Python 3 in-
clude the 2to3 utility, which automates (at least partially) the translation of Python 2
code to Python 3.
Python 2.7's end-of-life date was initially set at 2015 then postponed to 2020 out of
concern that a large body of existing code could not easily be forward-ported to Py-
thon 3. In January 2017, Google announced work on a Python 2.7 to go trans compiler
to improve performance under concurrent workloads.
Python is a multi-paradigm programming language. Object-oriented pro-
gramming and structured programming are fully supported, and many of its features
support functional programming and aspect-oriented programming (including by met
programming and met objects (magic methods)). Many other paradigms are supported
via extensions, including design by contract and logic programming.
Python uses dynamic typing, and a combination of reference counting and a
cycle-detecting garbage collector for memory management. It also features dynamic
name resolution (late binding), which binds method and variable names during pro-
gram execution.
Python's design offers some support for functional programming in the Lisp
tradition. It has filter, map, and reduce functions; list comprehensions, dictionaries,
sets and generator expressions. The standard library has two modules (itertools and
fun tools) that implement functional tools borrowed from Haskell and Standard ML.
The language's core philosophy is summarized in the document The Zen of
Python (PEP 20), which includes aphorisms such as:
 Beautiful is better than ugly
 Explicit is better than implicit
 Simple is better than complex
 Complex is better than complicated
 Readability counts
25

Rather than having all of its functionality built into its core, Python was de-
signed to be highly extensible. This compact modularity has made it particularly pop-
ular as a means of adding programmable interfaces to existing applications. Van Ros-
sum's vision of a small core language with a large standard library and easily extensi-
ble interpreter stemmed from his frustrations with ABC, which espoused the opposite
approach.
Python strives for a simpler, less-cluttered syntax and grammar while giving
developers a choice in their coding methodology. In contrast to Perl's "there is more
than one way to do it" motto, Python embraces a "there should be one—and prefera-
bly only one—obvious way to do it" design philosophy. Alex Martelli, a Fellow at the
Python Software Foundation and Python book author, writes that "To describe some-
thing as 'clever' is not considered a compliment in the Python culture."
Python's developers strive to avoid premature optimization, and reject patches
to non-critical parts of the CPython reference implementation that would offer mar-
ginal increases in speed at the cost of clarity. When speed is important, a Python pro-
grammer can move time-critical functions to extension modules written in languages
such as C, or use PyPy, a just-in-time compiler. Cython is also available, which trans-
lates a Python script into C and makes direct C-level API calls into the Python inter-
preter.
An important goal of Python's developers is keeping it fun to use. This is re-
flected in the language's name—a tribute to the British comedy group Monty Py-
thon—and in occasionally playful approaches to tutorials and reference materials,
such as examples that refer to spam and eggs (from a famous Monty Python sketch)
instead of the standard foo and bar.
A common neologism in the Python community is pythonic, which can have a
wide range of meanings related to program style. To say that code is pythonic is to
say that it uses Python idioms well, that it is natural or shows fluency in the language,
that it conforms to Python's minimalist philosophy and emphasis on readability. In
contrast, code that is difficult to understand or reads like a rough transcription from
another programming language is called unpythonic.
3.3.2 Aim of Python
Python is one of the top 10 popular programming languages of 2017. Python is
a general purpose and high level programming language. You can use Python for de-
veloping desktop GUI applications, websites and web applications. Also, Python, as a
26

high level programming language, allows you to focus on core functionality of the
application by taking care of common programming tasks. The simple syntax rules of
the programming language further makes it easier for you to keep the code base read-
able and application maintainable. There are also a number of reasons why you should
prefer Python to other programming languages.
1. Readable and Maintainable Code
While writing a software application, you must focus on the quality of its
source code to simplify maintenance and updates. The syntax rules of Python al-
low you to express concepts without writing additional code. At the same time,
Python, unlike other programming languages, emphasizes on code readability, and
allows you to use English keywords instead of punctuations. Hence, you can use
Python to build custom applications without writing additional code. The readable
and clean code base will help you to maintain and update the software without
putting extra time and effort.
2. Multiple Programming Paradigms
Like other modern programming languages, Python also supports several
programming paradigm. It supports object oriented and structured programming
fully. Also, its language features support various concepts in functional and as-
pect-oriented programming. At the same time, Python also features a dynamic
type system and automatic memory management. The programming paradigms
and language features help you to use Python for developing large and complex
software applications.
3. Compatible with Major Platforms and Systems
At present, Python is supports many operating systems. You can even use Py-
thon interpreters to run the code on specific platforms and tools. Also, Python is
an interpreted programming language. It allows you to you to run the same code
on multiple platforms without recompilation. Hence, you are not required to
recompile the code after making any alteration. You can run the modified applica-
tion code without recompiling and check the impact of changes made to the code
immediately. The feature makes it easier for you to make changes to the code
without increasing development time.
4. Robust Standard Libraries
Its large and robust standard library makes Python score over other pro-
gramming languages. The standard library allows you to choose from a wide
27

range of modules according to your precise needs. Each module further enables
you to add functionality to the Python application without writing additional code.
For instance, while writing a web application in Python, you can use specific
modules to implement web services, perform string operations, manage operating
system interface or work with internet protocols. You can even gather information
about various modules by browsing through the Python Standard Library docu-
mentation.
5. Many Open Source Frameworks and Tools
As an open source programming language, Python helps you to curtail
software development cost significantly. You can even use several open source
Python frameworks, libraries and development tools to curtail development time
without increasing development cost. You even have option to choose from a
wide range of open source Python frameworks and development tools according
to your precise needs. For instance, you can simplify and speedup web application
development by using robust Python web frameworks like Django, Flask, Pyra-
mid, Bottle and Cherrypy. Likewise, you can accelerate desktop GUI application
development using Python GUI frameworks and toolkits like PyQT, PyJs, PyGUI,
Kivy, PyGTK and WxPython.
6. Simplify Complex Software Development
Python is a general purpose programming language. Hence, you can use
the programming language for developing both desktop and web applications. Al-
so, you can use Python for developing complex scientific and numeric applica-
tions. Python is designed with features to facilitate data analysis and visualization.
You can take advantage of the data analysis features of Python to create custom
big data solutions without putting extra time and effort. At the same time, the data
visualization libraries and APIs provided by Python help you to visualize and pre-
sent data in a more appealing and effective way. Many Python developers even
use Python to accomplish artificial intelligence (AI) and natural language pro-
cessing tasks.
7. Adopt Test Driven Development
You can use Python to create prototype of the software application rapidly.
Also, you can build the software application directly from the prototype simply by
refactoring the Python code. Python even makes it easier for you to perform cod-
ing and testing simultaneously by adopting test driven development (TDD) ap-
28

proach. You can easily write the required tests before writing code and use the
tests to assess the application code continuously. The tests can also be used for
checking if the application meets predefined requirements based on its source
code.
However, Python, like other programming languages, has its own shortcom-
ings. It lacks some of the built-in features provided by other modern programming
language. Hence, you have to use Python libraries, modules, and frameworks to ac-
celerate custom software development. Also, several studies have shown that Python
is slower than several widely used programming languages including Java and C++.
You have to speed up the Python application by making changes to the application
code or using custom runtime. But you can always use Python to speed up software
development and simplify software maintenance.

3.4 Overview of XML (Extensible Markup Language)


Extensible Markup Language (XML) is used to describe data. The XML
standard is a flexible way to create information formats and electronically share struc-
tured data via the public Internet, as well as via corporate networks.
XML code, a formal recommendation from the World Wide Web Consortium
(W3C), is similar to Hypertext Markup Language (HTML). Both XML and HTML
contain markup symbols to describe page or file contents. HTML code describes Web
page content (mainly text and graphic images) only in terms of how it is to be dis-
played and interacted with.

3.4.1 Introduction of XML (Extensible Markup Language)


Extensible Markup Language (XML) is a markup language that defines a set
of rules for encoding documents in a format that is both human-readable and ma-
chine-readable. The W3C's XML 1.0 Specification and several other related specifica-
tions all of them free open standards define XML.
The design goals of XML emphasize simplicity, generality, and usability
across the Internet. It is a textual data format with strong support via Unicode for dif-
ferent human languages. Although the design of XML focuses on documents, the lan-
guage is widely used for the representation of arbitrary data structures such as those
used in web services.
29

Several schema systems exist to aid in the definition of XML-based languages,


while programmers have developed many application programming interfaces (APIs)
to aid the processing of XML data.
The essence of why extensible markup languages are necessary is explained at
Markup language (for example, see Markup language § XML) and at Standard Gen-
eralized Markup Language.
Hundreds of document formats using XML syntax have been developed, in-
cluding RSS, Atom, SOAP, SVG, and XHTML. XML-based formats have become
the default for many office-productivity tools, including Microsoft Office (Office
Open XML), OpenOffice.org and LibreOffice (OpenDocument), and Apple's iWork.
XML has also provided the base language for communication protocols such as
XMPP. Applications for the Microsoft .NET Framework use XML files for configura-
tion, and property lists are an implementation of configuration storage built on XML.
Many industry data standards, e.g. HL7, OTA, FpML, MISMO, NIEM, etc.
are based on XML and the rich features of the XML schema specification. Many of
these standards are quite complex and it is not uncommon for a specification to com-
prise several thousand pages.
In publishing, DITA is an XML industry data standard. XML is used exten-
sively to underpin various publishing formats.
XML is widely used in a Services Oriented Architecture (SOA). Disparate
systems communicate with each other by exchanging XML messages. The message
exchange format is standardised as an XML schema (XSD). This is also referred to as
the canonical schema.
XML has come into common use for the interchange of data over the Internet.
IETF RFC: 3023, now superseded by RFC: 7303, gave rules for the construction of
Internet Media Types for use when sending XML. It also defines the media types ap-
plication/xml and text/xml, which say only that the data is in XML, and nothing about
its semantics.
RFC 7303 also recommends that XML-based languages be given media types
ending in +xml; for example image/svg+xml for SVG.

You might also like