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


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


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.

    Running a cool simulation with Morse and ROS (A Beginner’s Guide)

    G’day, Now some advance stuff after touching the surface of ROS. But it should feel good to have something up and running. Now let’s try to run a simulated robot with ROS. Sounds pretty cool, doesn’t it? We will be using the following components in our simulation. Morse – 1.3...

    Getting feet wet with ROS (A Beginner’s Tutorial)

    Hi there, This tutorial is about using ROS. ROS stands for Robotics Operating System, which is pretty much self-explanatory. ROS is widely used to provide a platform for robots to function. And the ROS official website itself provide a gold-mine of tutorials and information. So I would not give a...