Skip to content

Template files for starting a ROS project inside Docker with X11 forwarding enabled

License

Notifications You must be signed in to change notification settings

arensonzz/ros-docker-gui-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS Docker GUI Template

This template is a starting point for ROS1 Noetic development inside Docker. It contains full Noetic desktop package, compilers (gcc) and language servers (clangd, ccls) for CPP, programming tools like git and grep, last but not least tmux terminal multiplexer. Also my favorite text editor Neovim comes installed with many plugins and configurations.

Contents

About

I made this template because latest ROS1 version, Noetic, runs only on Ubuntu 20.04 and I happen to be using Ubuntu 22.04. Instead of building Noetic from source, I prefer running it inside Docker container.

The Dockerfile contains my personal dotfiles for bash, tmux and Neovim. So feel free to fork the repo and tailor it to your liking.

Installed Software

  • bat : cat clone with syntax highlighting
  • ccls : C/CPP language server
  • clangd : C/CPP language server
  • clang-format : C/CPP file formatter
  • curl : file downloader
  • fd-find : find alternative
  • fzf : fuzzy file finder
  • git : version control tool
  • grep : pattern matcher
  • language-pack-en : ubuntu language packs for English
  • less : file pager
  • iproute2 : ip tools
  • openssh-server : ssh server if you want to connect with SSH
  • python3 : Python3 programming language
  • python3-pip : package manager for Python3
  • sudo
  • tmux : terminal multiplexer
  • tree : tree like file viewer
  • wget : file downloader
  • xauth : authorization utility for X servers
  • xclip : system clipboard manager
  • nodejs : needed for Neovim plugins
  • cmake-language-server : LSP for cmake
  • autopep8 : formatter for Python
  • flake8 : linter for Python
  • neovim : text editor

Requirements

  1. This is tested using Ubuntu 22.04 installed Linux machine. Docker image should run fine in a Windows machine but X Window setup differs. You must install an X server application like VcXsrv Windows X Server.
  2. This is tested using a machine with NVIDIA GPU. Docker container uses host computer's GPU using NVIDIA Container Toolkit. For different GPU vendors, some tweaks such as disabling GPU support in run_docker.sh might be needed.
  3. Docker engine must be installed on the host OS.
  4. X Window Authorization:
    1. Install xauth and xhost if you don't have them.

      sudo apt update && sudo apt install -y xauth xhost
    2. If you don't have ~/.Xauthority file, generate with the following command:

      xauth generate $DISPLAY . trusted
    3. Allow local connections to your X Window server. This step allows your container to access host X Window without using --net=host Docker run option.

      # Don't forget the trailing colon
      xhost +local:
  5. NVIDIA Container Toolkit must be installed on the host OS.

Usage

  1. Add your CPP code to the package/src folder.

  2. Modify package/CMakeLists.txt and package/package.xml to suit your project's needs.

  3. Modify Dockerfile to suit your project's needs. Install needed programs and clone needed libraries.

  4. Modify entrypoint.sh. Source workspaces, export environment variables and add bash aliases here.

  5. Build Docker image.

    sudo docker build -t "ros-dev" docker

  6. Run Docker container using the bash script run_docker.sh.

    ./run_docker.sh <image_name> <container_name>

  7. Docker container starts with a tmux session. tmux settings are defined in the ~/.tmux.conf. Default prefix is set to Ctrl + Space for outer tmux session, and Ctrl + A for inner tmux session (if using nested tmux).

  8. Attach to the same container from another terminal if you need to.

    docker exec -it bash <container_name>

  9. Run catkin_make to build packages and create compile_commands.json inside build directory.

  10. If you want to edit source codes inside package, run nvim from the root workspace directory which is ~/catkin_ws. This way ccls LSP can properly access compile_commands.json and index your includes.

References

License

ROS Docker GUI Template is free software published under the MIT license. See LICENSE for details.

About

Template files for starting a ROS project inside Docker with X11 forwarding enabled

Topics

Resources

License

Stars

Watchers

Forks