Install ROS on My Laptop

Ubuntu 18.10 and +

The ROS base system is built into Ubuntu 18.10+. To install it, you can simply use the apt package manager:

sudo apt install ros-desktop-full

The installation will fail if you have already added the ROS official repository into the source list. You need to first remove it to have apt select the default source:

sudo rm /etc/apt/sources.list.d/ros-latest.list
sudo apt update

Notice: The rqt_graph and other GUI tools might not be available in this version.

Notice: You cannot find /opt/ros/melodic/setup.bash if you install with builtin ROS packages. #> Use catkin_ws/devel/setup.bash instead could achieve the same result.

Docker (for Linux & Windows)

ROS also provides docker images for the basic development/execution environment. You can find more information on ROS docker-hub.

To install ROS docker version, first create a Dockerfile with the following content:

FROM ros:latest

# Install additional packages
RUN apt-get update && apt-get install -y \
    python-rosinstall \
    python-rosinstall-generator \
    python-wstool \
    build-essential \
    vim \
    git \
    ros-melodic-rqt \
    rviz \
    openssh-server

# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/admin && \
    echo "admin:x:${uid}:${gid}:admin,,,:/home/admin:/bin/bash" >> /etc/passwd && \
    echo "admin:x:${uid}:" >> /etc/group && \
    echo "admin ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/admin && \
    chmod 0440 /etc/sudoers.d/admin && \
    chown ${uid}:${gid} -R /home/admin
USER admin
ENV HOME /home/admin

And then use the following commands to create a docker container:

# Create a docker image based on the Dockerfile
docker build --tag ros:lab .

# Create a docker container, replace <user> with your id
docker run -it -P --name ros-dev \
		-v "/home/<user>/catkin_ws:/home/admin/catkin_ws" \
		-e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
		-v /tmp/runtime-admin:/tmp/runtime-admin ros:lab

# Attach to the container for multiple terminals
docker exec -it ros-dev bash --init-file '/ros_entrypoint.sh'

Notice: The attached terminal may not be stable, and crash very often.

Docker (for MacOS)

To install docker on Mac, you need to either download the docker-desktop form docker-hub, or use Homebrew:

brew cask install docker

Note: please use cask brew cask install docker install, instead of brew install docker.

To launch the docker, you need to first run the application Docker.app (in Launchpad). And wait for the status to be ready.

And then create a file named Dockerfile in your home directory.

# Dockerfile

FROM osrf/ros:kinetic-desktop

# Install additional packages
RUN apt-get update && apt-get install -y \
    python-rosinstall \
    python-rosinstall-generator \
    python-wstool \
    build-essential \
    vim \
    git \
    rviz \
    openssh-server

# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/admin && \
    echo "admin:x:${uid}:${gid}:admin,,,:/home/admin:/bin/bash" >> /etc/passwd && \
    echo "admin:x:${uid}:" >> /etc/group && \
    echo "admin ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/admin && \
    chmod 0440 /etc/sudoers.d/admin && \
    chown ${uid}:${gid} -R /home/admin
USER admin
ENV HOME /home/admin

At the same directory, build the docker image with the following command:

# Create a docker image based on the Dockerfile
docker build --tag ros:lab .

Then, launch the docker container using the following command:

docker run -it -P --name ros-dev \
		-v "/User/<user>/catkin_ws:/home/admin/catkin_ws" \
		-e DISPLAY=$DISPLAY -v "/tmp/.X11-unix:/tmp/.X11-unix" \
		ros:lab

After the container is created, you can use docker start command to start it:

docker start -ai ros-dev

To attach multiple consoles to the container, you can use docker exec command:

docker exec -it ros-dev bash --init-file '/ros_entrypoint.sh'

VMware

The most stable & convenient way to install ROS is to use a virtual machine. You can first install an Ubuntu 18.04 Server in a virtual machine and then install ROS Melodic in it.

To enable ssh connection between the host and the virtual machine, you may need to perform the following configurations:

  • Open “Virtual Machine Settings” -> “Network Adapter”
  • Select “NAT: used to share the host’s IP address”

The host can ssh to the virtual machine with the IP address that is assigned to it (use ipaddr in the virtual machine to get the IP address) and the default port (22).

If you need the port to be further exposed to the network,

  • Launch “Virtual Network Editor”
  • Select “vmnet8 NAT” and open “NAT Settings…”
  • Add a port mapping:
    • Host port: (any port that is above 10000, e.g. 12822)
    • Guest port: 22
    • Port type: TCP
    • Virtual Machine: (the IP address of the virtual machine, e.g. 172.16.224.128)

Virtual Box and other virtual machine monitors

Please refer to the VMware configurations.