Wednesday, 13 July 2016

Installing ROS Indigo with Gazebo 7 (or later) on Ubuntu 14.04

This tutorial will cover the easiest way to update the existing Gazebo version which comes with ROS Indigo (Gazebo 2) to a later release of Gazebo. Gazebo 2 is severely outdated and it's always better to use a newer version of the software.

To begin, let's first install ROS. If you already have ROS installed, you can skip this part and move on to the next part. If you want to do something else, check this detailed documentation for more details.

Ubuntu Installation of ROS Indigo

  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.
  2. Setup your sources.list
    Setup your computer to accept software from packages.ros.org. ROS Indigo ONLY supports Saucy (13.10) and Trusty (14.04) for debian packages.
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  3. Set up your keys
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 0xB01FA116
  4. Installation
    First make sure that your Debian package index is up-to-date
    sudo apt-get update
    Desktop-Full Install
    sudo apt-get install ros-indigo-desktop-full
  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
  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/indigo/setup.bash" >> ~/.bashrc
    source ~/.bashrc
  7. Getting rosinstall
    sudo apt-get install python-rosinstall

Updating to Gazebo 7

  1. Removing Gazebo 2
    sudo apt-get remove gazebo2
    This might leave some unmet dependecies. But do not worry. It will be solved automatically.
  2. Installing required packages of Gazebo 7
    sudo apt-get install ros-indigo-gazebo7-ros-pkgs ros-indigo-gazebo7-ros-control
    Even after installing this, there might be unmet dependencies. Just restart the terminal or source the ROS installation folder.
Congratulations! You have successfully changed the Gazebo version of your ROS distribution.

Thursday, 30 June 2016

Setting up OpenCV with Qt Creator on Windows (without CMake)

This tutorial will cover the easiest way to install OpenCV 2.4.9 with Qt 5.4.1, without using CMake, which can be very helpful for beginners who do not want to invest time to make their own build. There might be more updated versions of both the softwares but the essential components are still the same.




OpenCV (Open Source Computer Vision) is an open source platform which consists of function aimed at real time computer vision. It can be used to make various image processing and computer vision applications with the help of its powerful libraries. 

Qt is a cross-platform application framework that is widely used for developing application software that can be run on various software and hardware platforms with little or no change in the underlying codebase. It is the open-source competitor to the popular windows development platform Visual Studio.

Download Links :-

Note:- Please use only the versions of the softwares mentioned in this tutorial. It will NOT work for other versions of Qt and OpenCV. 
Please let us know if the download links don't work.

Installation Steps :-
  1. Install Qt using the setup file you just downloaded. You may install it in the default location or any other location as you wish with only one restriction. There cannot be any spaces in the installation path. For example:- F:\Qt\Qt5.4.1' is a valid installation location whereas 'F:\Qt\Qt 5.4.1' is not. 
  2. Extract OpenCV using the self-extracting archive that you just downloaded. Again, remember that there cannot be any spaces in the extraction location else Qt won't be able to read it. After extraction, you'll get two folders in that location- 'build' and 'sources'.
  3. Extact the OpenCV build in the same way. Now you'll get two folders called 'include' and 'build-qt' and a text file.
  4. Let's say you extracted the build to 'F:\OpenCV-2.4.9'. You will get a folder called 'build-qt' in that directory. To enable Qt finding the libraries of OpenCV, the location 'F:\OpenCV-2.4.9\build-qt\bin' has to be added to the System Path variable. You can find a way to do that here. Make sure you add this path to the end of the list. Do NOT replace the contents of the PATH variable. To ensure that you've added it, open a Command Prompt window and type 'path' and hit enter. Make sure that you can see the location there.
  5. Now we're ready to test our installation.

Running OpenCV with Qt for the first time :-
  1. Start Qt. Click on New Project -> Qt Console Application.
  2. Name your project and set the project location and click Next.
  3. You'll have two files in your project. A .pro file and a .cpp file. You will now need to add a few  things to the .pro file. Open it up on Qt by clicking on it.
  4.  Open the text file (OpenCV Include text for Qt.txt) that came with the build for OpenCV and copy its contents. Paste it at the end of the .pro file.
  5. Next, you have to edit the INCLUDEPATH and the LIBS variables. Remeber, you have to edit them according to the location where you extracted the build for OpenCV. Also note that the double slashes ('\\') in the INCLUDEPATH are very important. Please do not use single slashes for the path. For the LIBS variable, the '-l' (hyphen small L) in the beginning and the '\' (backslash) in the end are also important. 
  6. Once you make the updates in step 5 to your .pro file, update these in the .txt file too because you will need to add this to the .pro file every time you make a new project. 
Running your first example :- 
  1. Download this code and paste it in the .cpp file. 
  2. Edit the variable imgloc to the location of any image file present in your PC. Here you can either use forward slashes ('/') or double back slashes ('\\') as a file path separator.
  3. Hit 'Run' (Green button on the left side) or press 'Ctrl + R' and you should see something like this.

If you can't follow this tutorial, here's a video tutorial for the same.