Keep Calm and Install Morse and ROS: Guide for Not Going Insane


Versions

Ubuntu: 14.04
Morse: 1.4
Ros: Indigo
Python: 2.7 and 3.4

Introduction

Before diving in to the “guide”, let me explain a hypothetical scenario. Say you want to install ROS in your computer. Should be easy as a pie right?
sudo apt-get install ros-indigo-desktop-full should do the trick. Now as you might know, ROS uses python2.x (as said here). Now say you’re all happy and you want to install Morse to run some robotics simulations. As you might know, Morse uses python3.x. With ROS using python2.x and Morse using python3.x they need to work together to run a simulation in morse successfully. Now the real battle begins. Now you get to very painful situation where for terminals that execute “ROS stuff” (amcl/roscore/…) you have to use python2.x at the beggining of the PYTHONPATH variable and for morse you will have to use python3.x. Doing this for each terminal is painful. So I came up with a more elegant way to do this.

Fix: Let ROS use the Ubuntu Python and Morse use virtualenv Python

Yes, in an essence that is it! But the devil is in the details. So let’s get cracking.

1.Install python2 and python3 on your Ubuntu

2.Install ROS using sudo apt-get install ros-indigo-desktop-full

3.Install virtualenv for python3.x. Use pip3 install virtualenv.

4.Now build a virtual environment with name morse_venv that uses python3. This is a very easy-to-follow guide on how to do that. Assume that you installed this in your /home/<username> directory.

5.Install Morse by compiling from source. So we can point to the exact python distribution to be used. The sudo apt-get morse-simulator wouldn’t work.

  • When invoking CMAKE, invoke it as follows.
  • cmake -DBUILD_ROS_SUPPORT=ON -DPYMORSE_SUPPORT=ON -DPYTHON_EXECUTABLE=/home/<username>/morse_venv/bin/python3.4 -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/home/<username>/morse_venv/ ..
  • 6.Now you will have to install several packages in the morse_venv virtual environment for Morse to work.

    7.Activate your newly installed virtual environment by calling source /home/<username>/morse_venv/bin/activate.

    8.Install the following packages

  • pip3 install PyYAML​
  • pip3 install rospkg
  • pip3 install catkin_pkg​
  • 9.Now type in python3 and try from morse.builder import *. This should work without any errors.

    10.Fire up your favorite text editor and open the source /home/<username>/morse_venv/bin/activate script.

    11.Scroll down to the bottom and PYTHONPATH variable as below

  • PYTHONPATH=<ros_dir>/lib/python2.7/dist-packages:<venv_dir>/venv34/lib/python3.4/site-packages
  • Now whenever you activate your environment, PYTHONPATH will be replaced by this.
  • 12.(Optional) If you deactivate your virtual environment and PYTHONPATH variable is not what you want, you can set what the PYTHONPATH should be once you deactivate the environment.

  • Scroll up and go inside the deactivate() method and there set the PYTHONPATH variable to be the desired path.
  • Hope this helps. Cheers.