Reader small image

You're reading from  Mastering ROS for Robotics Programming

Product typeBook
Published inDec 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781783551798
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Lentin Joseph
Lentin Joseph
author image
Lentin Joseph

Lentin Joseph is an author and robotics entrepreneur from India. He runs a robotics software company called Qbotics Labs in India. He has 7 years of experience in the robotics domain primarily in ROS, OpenCV, and PCL. He has authored four books in ROS, namely, Learning Robotics using Python, Mastering ROS for Robotics Programming, ROS Robotics Projects, and Robot Operating System for Absolute Beginners. He is currently pursuing his master's in Robotics from India and is also doing research at Robotics Institute, CMU, USA.
Read more about Lentin Joseph

Right arrow

Chapter 12. Troubleshooting and Best Practices in ROS

In the previous chapter, we discussed about ROS-Industrial and worked with motion planning of some industrial robots. In this chapter, we will discuss setting the ROS development environment in Eclipse IDE, best practices in ROS, and troubleshooting tips in ROS. This is the last chapter of this book, so before we start development in ROS, it will be good if we know the standard methods for writing code using ROS. Following are the topics that we are going to discuss in this chapter:

  • Setting the ROS development environment in Eclipse IDE

  • Best practices in ROS

  • Best coding practices in ROS using C++

  • Important troubleshooting tips in ROS

Before start coding in ROS, it will be good if we set ROS development environment in an IDE. Setting an IDE for ROS is not mandatory but it can save developer time. IDEs can provide auto completion features that can make programming easy. We can use any editors such as Sublime and VIM or simply gedit for coding...

Setting up Eclipse IDE on Ubuntu 14.04.3


Eclipse needs Java Runtime Environment (JRE) in order to work. The following command can install JRE in Ubuntu:

$ sudo apt-get install default-jre

The first step is to download the latest eclipse IDE. We can get the latest version of Eclipse at https://www.eclipse.org/downloads/?osType=linux.

Figure 1: Eclipse IDE download page

Download and extract the Eclipse IDE for C/C++ Developers that is marked on the preceding image. Extract the Eclipse archive file using the following command. Here we are using Eclipse mars for Linux 64 bit:

$ tar -xvzf eclipse-cpp-<name_version>-linux-gtk-x86_64.tar.gz

We will get a folder called eclipse after extraction. Copy the eclipse folder to the /opt folder using the following command:

$ sudo cp -r eclipse /opt/

Create a desktop file for the eclipse for accessing from the Ubuntu search bar:

$ sudo nano /usr/share/applications/eclipse.desktop

Copy and paste the following content to this file. This file consists...

Setting ROS development environment in Eclipse IDE


In this section, we can see the necessary settings that we need to do for compiling ROS C++ nodes in Eclipse. There are several methods available to configure ROS development environment in Eclipse. We are going to see one of the tested methods that is used to set the ROS environment.

Global settings in Eclipse IDE

Following are the global settings that we have to do in Eclipse IDE. We don't need to do these settings for each project. These are only one-time settings.

  • Launch Eclipse IDE from the Ubuntu search bar.

  • Go to Window | Preferences. from the Preferences Window, choose C/C++ | Build | Settings and then choose the Discovery tab. Select CDT GCC Build Output Parser [Shared]. Select the Compiler command pattern to (.*gcc)|(.*[gc]\+\+)|(.*clang). Also check the Project option that is a part of Container to keep discovered entries. Click on the Apply button and then on the OK button to confirm the settings. These settings enable eclipse to...

Best practices in ROS


This section gives you a brief idea of the best practices that can be followed when we develop something with ROS. ROS provides detailed tutorials about its QA (Quality Assurance) process. QA process provides a detailed developers guide which mentions C++ and Python code style guides, naming conventions, and so on.

First we can discuss the ROS C++ coding styles.

ROS C++ coding style guide

ROS C++ nodes are following a coding style to make the code more readable, debuggable, and maintainable. If the code is properly styled, it will be very easy to re-use and contribute to the current code. In this section, we can quickly go through some commonly used coding styles.

Standard naming conventions used in ROS

Here we are using the text Helloworld to demonstrate the naming patterns we are using in ROS:

  • HelloWorld: This name starts with an uppercase letter, and each new word starts with an uppercase letter with no space or underscores.

  • helloWorld: In this naming method, the first...

Best practices in the ROS package


Following are the key points while creating and maintaining a package:

  • Version Control: ROS supports version control using Git, Mercurial, and Subversion. We can host our code in GitHub and Bit bucket. Most of the ROS packages are in GitHub.

  • Packaging: Inside a ROS catkin package, there will be a package.xml, and this file should contain the author name, description, and license. The following is an example of a package.xml:

    <?xml version="1.0"?>
    <package>
      <name>roscpp_tutorials</name>
    
      <version>0.6.1</version>
    
      <description>
        This package attempts to show the features of ROS step-by-step,
        including using messages, servers, parameters, etc.
      </description>
    
      <maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
    
      <license>BSD</license>
    
      <url type="website">http://www.ros.org/wiki/roscpp_tutorials</url>
      <url type="bugtracker">https...

Important troubleshooting tips in ROS


We will look at some of the common issues when working with ROS as well as tips to solve them.

One of the ROS inbuilt tools to find issues in a ROS system is roswtf. roswtf, which checks issues in following areas of ROS:

  • Environment variables and configuration issues

  • It can scan a package or meta-package to report potential issues

  • It can check a launch file for its potential issues

  • It can check system issues and online graph issues

  • It can report warnings and errors—warnings can be avoided but are not necessary, errors should be addressed

Usage of roswtf

We can check the issues inside a ROS package by simply entering the package and entering roswtf. We can also check issues in the launch file using the following command:

$ roswtf <file_name>.launch

We may get a report if there are issues associated with the package.

Figure 16: roswtf command output for a ROS package

The wiki page of roswtf is available at http://wiki.ros.org/roswtf.

The following are some...

Questions


  1. Why do we need an IDE to work with ROS?

  2. What are the common naming conventions used in ROS?

  3. Why is documentation important when we create a package?

  4. What is the use of the roswtf command?

Summary


In this chapter, we discussed working with an Eclipse IDE and setting the ROS development environment inside IDE. After setting ROS in Eclipse, we discussed some of the best practices in ROS that consist of naming conventions, coding styles, best practices while creating a ROS package, and so on. After discussing best practices, we switched to ROS troubleshooting. In the troubleshooting section, we discussed various troubleshooting tips which can occur when we work with ROS.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering ROS for Robotics Programming
Published in: Dec 2015Publisher: PacktISBN-13: 9781783551798
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Lentin Joseph

Lentin Joseph is an author and robotics entrepreneur from India. He runs a robotics software company called Qbotics Labs in India. He has 7 years of experience in the robotics domain primarily in ROS, OpenCV, and PCL. He has authored four books in ROS, namely, Learning Robotics using Python, Mastering ROS for Robotics Programming, ROS Robotics Projects, and Robot Operating System for Absolute Beginners. He is currently pursuing his master's in Robotics from India and is also doing research at Robotics Institute, CMU, USA.
Read more about Lentin Joseph