Installing ROS Melodic & ROS Dashing inside a Ubuntu Bionic chroot

  • Install Ubuntu inside a chroot. Follow guide from here
  • Fix /etc/resolv.conf
  • Fix /etc/hosts. On the second line put the name of your hostname instead of 'shirka'.	localhost	shirka
  • Add all ubuntu repositories. Edit file /etc/apt/sources.list:
deb bionic main universe restricted multiverse
deb bionic-updates main universe restricted multiverse
deb bionic-backports main restricted multiverse
  • Update repos
$ apt-get update
  • Install the following packages:
$ apt-get install sudo mc nano curl lsb-release gnupg2 apt-utils bash-completion locales
  • Add a new user in the chroot
$ adduser user
  • Add your new user to sudo group
$ adduser user sudo
  • Fix sudo error with visudo:
$ visudo
  • From now on, use your new user for the following steps:
$ su user

Creating ROS Melodic Workspace

Since ROS Hydro (ROS 1), ROS use Catkin for building all packages. The following links shows the basic steps for creating a Catkin Workspace.

After creating the workspace, build a basic package for testing purposes.

Creating ROS Dashing Workspace

Since ROS Crystal (ROS 2) to newer versions, ROS use Colcon for building all packages. This guide shows the basic steps for creating a Colcon Workspace.

  • Source ROS 2 configuration
$ source /opt/ros/dashing/setup.bash
  • Install colcon
$ sudo apt install python3-colcon-common-extensions
  • Create workspace for ROS 2
$ mkdir -p ~/ros2_ws/src
  • Move to the new workspace and build it
$ cd ~/ros2_ws
$ colcon build
  • Source workspace configuration
$ source ~/ros2_ws/install/local_setup.bash && source ~/ros2_ws/install/setup.bash

After creating the workspace, lets build some examples packages for ROS 2.

  • Clone ROS 2 examples package repository in our workspace
$ cd ~/ros2_ws/src
$ git clone git clone
$ git checkout $ROS_DISTRO
  • Build examples package
$ cd ~/ros2_ws
$ colcon build --symlink-install
  • Test builded package. Remember to run each command on different terminals and source ROS 2 configuration on each terminal.
$ ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function
$ ros2 run examples_rclcpp_minimal_publisher publisher_member_function
  • tutorials/installing_ros_melodic_inside_ubuntu_bionic_chroot.txt
  • Last modified: 2019/10/10 14:01
  • by amora