Installing an official ROS package

Login into Erle-Brain and go to the trusty chroot where ROS is installed. Assuming that you’re connected through the miniUSB terminal (same could be done through WiFi, Ethernet, …):

ssh ubuntu@192.168.7.2 # password "ubuntu"
(ErleRobotics)ubuntu@localhost:~/trusty$ 
(ErleRobotics)ubuntu@localhost:~/trusty$ cd trusty
(ErleRobotics)ubuntu@localhost:~/trusty$ sudo ./chroot.sh 
root@localhost:/ 

Our Snappy images include an inner Trusty file system to simplify ROS installation and maintainance (Note: this will soon change into a formal Vivid installation as soon as packages become available). This inner file system allows you to easily install ROS packages using:

root@localhost:/  apt-get install ros-indigo-<ros-package-name> 

For example, let’s install the serial ROS package from the build farm:

root@localhost:/  apt-get install ros-indigo-serial

Compiling a ROS package from source

Let’s assume you created a new ROS package (e.g.: ros_erle_takeoff_land) and you’d like to compile it natively. Here’s how you would do it:

# assuming you already entered the trusty chroot 
source /opt/ros/indigo/setup.bash # setup ROS env. variables
mkdir -p catkin_ws/src
cd catkin_ws/src
catkin_init_workspace
Creating symlink "/root/catkin_ws/src/CMakeLists.txt" pointing to "/opt/ros/indigo/share/catkin/cmake/toplevel.cmake"

git clone https://github.com/erlerobot/ros_erle_takeoff_land
Cloning into 'ros_erle_takeoff_land'...
remote: Counting objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.
Checking connectivity... done

Great! now you’re all set to compile the package (whole trace available here):


catkin_make_isolated --install # or "catkin_make install"
Base path: /root/catkin_ws
Source space: /root/catkin_ws/src
Build space: /root/catkin_ws/build_isolated
Devel space: /root/catkin_ws/devel_isolated
Install space: /root/catkin_ws/install_isolated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~  traversing 1 packages in topological order:
~~  - ros_erle_takeoff_land
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The packages or cmake arguments have changed, forcing cmake invocation

==> Processing catkin package: 'ros_erle_takeoff_land'
==> Creating build directory: 'build_isolated/ros_erle_takeoff_land'
==> cmake /root/catkin_ws/src/ros_erle_takeoff_land -DCATKIN_DEVEL_PREFIX=/root/catkin_ws/devel_isolated/ros_erle_takeoff_land -DCMAKE_INSTALL_PREFIX=/root/catkin_ws/install_isolated -G Unix Makefiles in '/root/catkin_ws/build_isolated/ros_erle_takeoff_land'
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using CATKIN_DEVEL_PREFIX: /root/catkin_ws/devel_isolated/ros_erle_takeoff_land
-- Using CMAKE_PREFIX_PATH: /opt/ros/indigo
-- This workspace overlays: /opt/ros/indigo
-- Found PythonInterp: /usr/bin/python (found version "2.7.6") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /root/catkin_ws/build_isolated/ros_erle_takeoff_land/test_results
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.11
-- Using these message generators: gencpp;genlisp;genpy
CMake Warning at /root/catkin_ws/build_isolated/ros_erle_takeoff_land/cmake/ros_erle_takeoff_land-genmsg.cmake:3 (message):
  Invoking generate_messages() without having added any message or service
  file before.

  You should either add add_message_files() and/or add_service_files() calls
  or remove the invocation of generate_messages().
Call Stack (most recent call first):
  /opt/ros/indigo/share/genmsg/cmake/genmsg-extras.cmake:304 (include)
  CMakeLists.txt:8 (generate_messages)


-- ros_erle_takeoff_land: 0 messages, 0 services
-- Configuring done
-- Generating done
-- Build files have been written to: /root/catkin_ws/build_isolated/ros_erle_takeoff_land
==> make -j1 -l1 in '/root/catkin_ws/build_isolated/ros_erle_takeoff_land'
-- Using CATKIN_DEVEL_PREFIX: /root/catkin_ws/devel_isolated/ros_erle_takeoff_land
-- Using CMAKE_PREFIX_PATH: /opt/ros/indigo
-- This workspace overlays: /opt/ros/indigo
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /root/catkin_ws/build_isolated/ros_erle_takeoff_land/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.11
-- Using these message generators: gencpp;genlisp;genpy
CMake Warning at /root/catkin_ws/build_isolated/ros_erle_takeoff_land/cmake/ros_erle_takeoff_land-genmsg.cmake:3 (message):
  Invoking generate_messages() without having added any message or service
  file before.

  You should either add add_message_files() and/or add_service_files() calls
  or remove the invocation of generate_messages().
Call Stack (most recent call first):
  /opt/ros/indigo/share/genmsg/cmake/genmsg-extras.cmake:304 (include)
  CMakeLists.txt:8 (generate_messages)


-- ros_erle_takeoff_land: 0 messages, 0 services
-- Configuring done
-- Generating done
-- Build files have been written to: /root/catkin_ws/build_isolated/ros_erle_takeoff_land
Scanning dependencies of target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_cpp
Scanning dependencies of target ros_erle_takeoff_land_generate_messages_cpp
[  0%] Built target ros_erle_takeoff_land_generate_messages_cpp
Scanning dependencies of target ros_erle_takeoff_land
[100%] Building CXX object CMakeFiles/ros_erle_takeoff_land.dir/src/main.cpp.o
Linking CXX executable /root/catkin_ws/devel_isolated/ros_erle_takeoff_land/lib/ros_erle_takeoff_land/ros_erle_takeoff_land
[100%] Built target ros_erle_takeoff_land
Scanning dependencies of target std_msgs_generate_messages_lisp
[100%] Built target std_msgs_generate_messages_lisp
Scanning dependencies of target ros_erle_takeoff_land_generate_messages_lisp
[100%] Built target ros_erle_takeoff_land_generate_messages_lisp
Scanning dependencies of target std_msgs_generate_messages_py
[100%] Built target std_msgs_generate_messages_py
Scanning dependencies of target ros_erle_takeoff_land_generate_messages_py
[100%] Built target ros_erle_takeoff_land_generate_messages_py
Scanning dependencies of target ros_erle_takeoff_land_generate_messages
[100%] Built target ros_erle_takeoff_land_generate_messages
==> make install in '/root/catkin_ws/build_isolated/ros_erle_takeoff_land'
-- Using CATKIN_DEVEL_PREFIX: /root/catkin_ws/devel_isolated/ros_erle_takeoff_land
-- Using CMAKE_PREFIX_PATH: /opt/ros/indigo
-- This workspace overlays: /opt/ros/indigo
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /root/catkin_ws/build_isolated/ros_erle_takeoff_land/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.11
-- Using these message generators: gencpp;genlisp;genpy
CMake Warning at /root/catkin_ws/build_isolated/ros_erle_takeoff_land/cmake/ros_erle_takeoff_land-genmsg.cmake:3 (message):
  Invoking generate_messages() without having added any message or service
  file before.

  You should either add add_message_files() and/or add_service_files() calls
  or remove the invocation of generate_messages().
Call Stack (most recent call first):
  /opt/ros/indigo/share/genmsg/cmake/genmsg-extras.cmake:304 (include)
  CMakeLists.txt:8 (generate_messages)


-- ros_erle_takeoff_land: 0 messages, 0 services
-- Configuring done
-- Generating done
-- Build files have been written to: /root/catkin_ws/build_isolated/ros_erle_takeoff_land
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target ros_erle_takeoff_land_generate_messages_cpp
[100%] Built target ros_erle_takeoff_land
[100%] Built target std_msgs_generate_messages_py
[100%] Built target ros_erle_takeoff_land_generate_messages_py
[100%] Built target std_msgs_generate_messages_lisp
[100%] Built target ros_erle_takeoff_land_generate_messages_lisp
[100%] Built target ros_erle_takeoff_land_generate_messages
Install the project...
-- Install configuration: ""
-- Installing: /root/catkin_ws/install_isolated/_setup_util.py
-- Installing: /root/catkin_ws/install_isolated/env.sh
-- Installing: /root/catkin_ws/install_isolated/setup.bash
-- Installing: /root/catkin_ws/install_isolated/setup.sh
-- Installing: /root/catkin_ws/install_isolated/setup.zsh
-- Installing: /root/catkin_ws/install_isolated/.rosinstall
-- Installing: /root/catkin_ws/install_isolated/etc/catkin/profile.d/05.catkin_make.bash
-- Installing: /root/catkin_ws/install_isolated/etc/catkin/profile.d/05.catkin_make_isolated.bash
-- Installing: /root/catkin_ws/install_isolated/share/ros_erle_takeoff_land/cmake/ros_erle_takeoff_land-msg-paths.cmake
Listing /root/catkin_ws/devel_isolated/ros_erle_takeoff_land/lib/python2.7/dist-packages/ros_erle_takeoff_land ...
Compiling /root/catkin_ws/devel_isolated/ros_erle_takeoff_land/lib/python2.7/dist-packages/ros_erle_takeoff_land/__init__.py ...
-- Installing: /root/catkin_ws/install_isolated/lib/python2.7/dist-packages/ros_erle_takeoff_land
-- Installing: /root/catkin_ws/install_isolated/lib/python2.7/dist-packages/ros_erle_takeoff_land/__init__.py
-- Installing: /root/catkin_ws/install_isolated/lib/python2.7/dist-packages/ros_erle_takeoff_land/__init__.pyc
-- Installing: /root/catkin_ws/install_isolated/lib/pkgconfig/ros_erle_takeoff_land.pc
-- Installing: /root/catkin_ws/install_isolated/share/ros_erle_takeoff_land/cmake/ros_erle_takeoff_land-msg-extras.cmake
-- Installing: /root/catkin_ws/install_isolated/share/ros_erle_takeoff_land/cmake/ros_erle_takeoff_landConfig.cmake
-- Installing: /root/catkin_ws/install_isolated/share/ros_erle_takeoff_land/cmake/ros_erle_takeoff_landConfig-version.cmake
-- Installing: /root/catkin_ws/install_isolated/share/ros_erle_takeoff_land/package.xml
-- Installing: /root/catkin_ws/install_isolated/lib/ros_erle_takeoff_land/ros_erle_takeoff_land
-- Removed runtime path from "/root/catkin_ws/install_isolated/lib/ros_erle_takeoff_land/ros_erle_takeoff_land"
<== Finished processing package [1 of 1]: 'ros_erle_takeoff_land'

We used a catkin workspace for this example but you could also install the package at /opt/ros/indigo and make it available from the outer file system (Snappy Ubuntu Core).

Creating an app from a ROS package

All right, so now we have a ROS package compiled and you want to ship this package as an app. How would you do this?:

# Compute the dependencies
cd ~/trusty/
sudo ./chroot.sh
source /opt/ros/indigo/setup.bash # setup ROS env. variables
cd /root/catkin_ws
ros2snap ros_erle_takeoff_land
Computing dependencies for mavros
Computing dependencies for mavros-extras

After the dependencies have been computed and the snap structure created just create the app:

exit # exit from the chroot
su # get superuser privileges
cd root/catkin_ws
# copy the package to a more friendly place
cp -r install_isolated/ /home/ubuntu/ 
exit # get out of the inner chroot to create the snap
cd ~
sudo snappy build install_isolated

A ros2snap_0.1_armhf.snap package should be created.

The same process could be done outside of Erle-Brain using an external chroot in your development machine. Refer to these instructions.

WHAT ARE YOU WAITING FOR?