Skip to content

ka-raceing/ROS-Docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


KA-RaceIng
ROS-Docker

Comprehensive Docker Image for the development environment of the Autonomous System at KA-RaceIng.

PrerequisitesDocker UsageDocker Compose SetupRunning with VSCodeLicense

Prerequisites

Docker and Docker Compose

Docker is required to run the image in this repo. Installing Docker Compose is also highly recommended.

  • Ubuntu: follow these instructions
  • Arch Linux:
sudo pacman -S docker docker-compose
sudo systemctl enable docker
# after this reboot system or manually start the docker service via the following
sudo systemctl start docker

Docker Usage

The image can be pulled from Github Packages

docker pull ghcr.io/ka-raceing/ros-docker

It can then be run via docker run

docker run --name ka-raceing_ros -itd ghcr.io/ka-raceing/ros-docker

After that the container's bash shell can be accessed via

docker exec -it ka-raceing_ros bash

Also it is possible to perform actions like mounting external directories via docker run parameters it is recommended to use docker-compose for more advanced setups.

Docker Compose Setup

with mounted workspace

version: '3'

services:
  ros-docker:
    image: ghcr.io/ka-raceing/ros-docker
    network_mode: host
    volumes:
      # the workspace
      - <path_to_ws>:<desired_path_in_container>
    command: /bin/sh -c "while sleep 1000; do :; done"

including graphic support (e.g. for RViz)

version: '3'

services:
  ros-docker:
    image: ghcr.io/ka-raceing/ros-docker
    mem_limit: 4g #avoid bricking your device with a rviz memory overrun
    environment:
      - QT_X11_NO_MITSHM=1
      - DISPLAY=$DISPLAY
    devices:
      # this is a workaround, cause there isn't an option that works with different gpu manufacturers yet (https://github.com/docker/cli/issues/2063)
      - /dev/dri/card0:/dev/dri/card0 
    ulimits: # https://answers.ros.org/question/336963/rosout-high-memory-usage/
      nofile:
        soft: 1024
        hard: 524288 
    privileged: true #for graphics permissions
    network_mode: host
    volumes:
      # for GUI applications (e.g. RViz)
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      - ~/.Xauthority:/root/.Xauthority:ro
    command: /bin/sh -c "while sleep 1000; do :; done"

including external PCAN driver

version: '3'

services:
  ros-docker:
    image: ghcr.io/ka-raceing/ros-docker
    network_mode: host
    volumes:
      # pcan (host paths may be different)
      - /usr/include/libpcan.h:/usr/include/libpcan.h:ro
      - /usr/include/pcan.h:/usr/include/pcan.h:ro
      - /usr/include/libpcanfd.h:/usr/include/libpcanfd.h:ro
      - /usr/include/pcanfd.h:/usr/include/pcanfd.h:ro
      - /usr/lib/libpcan.so:/usr/lib/libpcan.so:ro
      - /usr/lib/libpcanbasic.so:/usr/lib/libpcanbasic.so:ro
      - /usr/lib/libpcanfd.so:/usr/lib/libpcanfd.so:ro
    command: /bin/sh -c "while sleep 1000; do :; done"

including external .bashrc file

version: '3'

services:
  ros-docker:
    image: ghcr.io/ka-raceing/ros-docker
    network_mode: host
    volumes:
      #bashrc
      - ~/.bashrc:/root/.bashrc:ro
    command: /bin/sh -c "while sleep 1000; do :; done"

everything together

version: '3'

services:
  ros-docker:
    image: ghcr.io/ka-raceing/ros-docker
    mem_limit: 4g #avoid bricking your device with a rviz memory overrun
    environment:
      - QT_X11_NO_MITSHM=1
      - DISPLAY=$DISPLAY
    devices:
      # this is a workaround, cause there isn't an option that works with different gpu manufacturers yet (https://github.com/docker/cli/issues/2063)
      - /dev/dri/card0:/dev/dri/card0 
    ulimits: # https://answers.ros.org/question/336963/rosout-high-memory-usage/
      nofile:
        soft: 1024
        hard: 524288 
    privileged: true #for graphics permissions
    network_mode: host
    volumes:
      # the workspace
      - <path_to_ws>:<desired_path_in_container>
      # pcan (host paths may be different)
      - /usr/include/libpcan.h:/usr/include/libpcan.h:ro
      - /usr/include/pcan.h:/usr/include/pcan.h:ro
      - /usr/include/libpcanfd.h:/usr/include/libpcanfd.h:ro
      - /usr/include/pcanfd.h:/usr/include/pcanfd.h:ro
      - /usr/lib/libpcan.so:/usr/lib/libpcan.so:ro
      - /usr/lib/libpcanbasic.so:/usr/lib/libpcanbasic.so:ro
      - /usr/lib/libpcanfd.so:/usr/lib/libpcanfd.so:ro
      # for GUI applications (e.g. RViz)
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      - ~/.Xauthority:/root/.Xauthority:ro
      #bashrc
      - ~/.bashrc:/root/.bashrc:ro

    command: /bin/sh -c "while sleep 1000; do :; done"

Running with VSCode

Using the Remote Development Plugin for VSCode enables you to create and work inside a Docker Container as if you were working on your own machine. An example for the required .devcontainer.json file would be

{
    "name": "ros-docker_container",
    "service": "ros-docker",
    "dockerComposeFile": "./docker-compose.yaml",
    "workspaceFolder": "<path_to_the_ws_folder_inside_the_container>",
    "shutdownAction": "stopCompose"
}

Any Extensions that should be pre-installed can be installed at this point. We would recommend installing the ROS and C++ Plugins

{
    "name": "ros-docker_container",
    "service": "ros-docker",
    "dockerComposeFile": "./docker-compose.yaml",
    "customizations": {
            "vscode": {
                "extensions": [
                    "ms-iot.vscode-ros",
                    "ms-vscode.cpptools-extension-pack"
                ]
            }
        },
    "workspaceFolder": "<path_to_the_ws_folder_inside_the_container>",
    "shutdownAction": "stopCompose"
}

License

GNU GPL v3

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages