Divide and Conquer
ROS2 Humble Docker 컨테이너에 Duckietown 본문
이미 다 빌드하고 실행하려면
docker run -it duckietown/gym-duckietown bash
Xvfb :0 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &> xvfb.log &
export DISPLAY=:0
https://github.com/duckietown/gym-duckietown
방법1
이후 나올 내용들 출처
https://hub.docker.com/r/duckietown/gym-duckietown
https://github.com/duckietown/dockertown
https://docs-old.duckietown.org/daffy/AIDO/out/embodied.html
계정 생성
https://hub.duckietown.com/signup/?_gl=1*dyy6af*_ga*Njk0NDE4MTQzLjE3MDg0MDgwNjU.*_ga_2186L8L2XJ*MTcxMDQyMzY2My4zLjEuMTcxMDQyNDE3MS41MC4wLjA.*_ga_99KJ333WVW*MTcxMDQyMzY2My4yLjEuMTcxMDQyNDE3My41MC4wLjA.*_gcl_au*MzIzMzkzMjYuMTcwODQwODA2NQ..
docker pull duckietown/gym-duckietown
docker run -it duckietown/gym-duckietown bash
Xvfb :0 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &> xvfb.log &
export DISPLAY=:0
python3 pytorch_rl/main.py \
--algo a2c \
--env-name Duckietown-loop_obstacles-v0 \
--lr 0.0002 \
--max-grad-norm 0.5 \
--no-vis \
--num-steps 20
위의 명령어를 실행하면 RL로 동작
docker build . \
--file ./docker/standalone/Dockerfile \
--no-cache=true \
--network=host \
--tag <YOUR_TAG_GOES_HERE>
빌드하고 싶을 경우 위의 명령어 실행
장애물 회피 관련 https://github.com/duckietown/duckietown-mplan2
git clone git@github.com:duckietown/duckietown-world.git
cd duckietown-world
pip install -r requirements.txt
python setup.py develop --no-deps
cd ..
git clone git@github.com:duckietown/duckietown-mplan2.git
cd duckietown-mplan2
pip install -r lib-mplan/requirements.txt
git submodule update --init --recursive
빌드
소싱
roslaunch duckietown_mplan mplan_withviz_demo.launch demo_num:=5
방법2
아래 내용 마저 정리하기
바탕화면에 duckie_ws 폴더를 하나 생성하고 안에 Dockerfile을 위치시켰다
https://duvallee.tistory.com/25
################################################################################
#
# Copyright (C) 2023
#
# Dockerfile for ROS2-humble
#
# uBuntu Version : 22.04.2 LTS (Jammy Jellyfish)
# ROS2 : humble
# gazebo : 6.12.0 (fortress)
# graphic driver : nvidia-driver-515 (RTX 1060 3GB)
#
# by duvallee
#
################################################################################
FROM ubuntu:22.04
FROM ros:humble
# ----------------------------------------------------------------------------
# changed mirror site from archive.ubuntu.com to kr.archive.ubunyu.com
RUN sed -i 's/archive.ubuntu.com/ftp.daumkakao.com/g' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/ftp.daumkakao.com/g' /etc/apt/sources.list
# ----------------------------------------------------------------------------
RUN apt-get update
RUN apt-get -y install apt-utils
# -----------------------------------------------------------------------------
# running 32 bit program on 64 bit uBuntu
RUN dpkg --add-architecture i386
RUN apt-get -y install libc6-i386
# -----------------------------------------------------------------------------
# add locale package & set
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y install locales
RUN dpkg-reconfigure locales
RUN locale-gen en_US.UTF-8
RUN update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
RUN export LANG=en_US.UTF-8
# -----------------------------------------------------------------------------
# change time-zone from UTC to Seoul of korea
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
# -----------------------------------------------------------------------------
# install package
RUN apt-get install -y \
curl \
sudo \
vim \
unzip \
tree \
xterm \
sed \
flex \
screen \
git-core \
gnupg2 \
lsb-release \
build-essential \
cmake \
git \
libbullet-dev \
python3-flake8 \
python3-pip \
python3-pytest-cov \
python3-rosdep \
python3-setuptools \
wget
RUN python3 -m pip install -U \
argcomplete \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest
RUN apt-get install --no-install-recommends -y \
libasio-dev \
libtinyxml2-dev \
libcunit1-dev
# -----------------------------------------------------------------------------
# NVIDIA RTX 1060
RUN apt-get install -y mesa-utils nvidia-driver-515
# -----------------------------------------------------------------------------
RUN apt-get install -y software-properties-common
RUN add-apt-repository universe
# -----------------------------------------------------------------------------
# ROS2 Desktop version
RUN apt-get update
RUN apt-get install -y ros-humble-desktop
RUN apt-get install -y ros-humble-joint-state-publisher-gui
RUN apt-get install -y ros-humble-xacro
RUN apt-get install -y python3-colcon-common-extensions
RUN apt-get install -y python3-vcstool
# -----------------------------------------------------------------------------
# gazebo
RUN apt-get install -y ignition-fortress
# -----------------------------------------------------------------------------
# clean update files
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* -vf
RUN apt-get update
# -----------------------------------------------------------------------------
ENV RUN_USER user
ENV DEFAULT_PASSWORD l
ENV RUN_UID 1001
# -----------------------------------------------------------------------------
# change root password
RUN echo "root:$DEFAULT_PASSWORD" | chpasswd
# -----------------------------------------------------------------------------
# add user
RUN useradd -m -s /bin/bash -u $RUN_UID $RUN_USER
RUN id $RUN_USER
RUN echo "$RUN_USER:$DEFAULT_PASSWORD" | chpasswd
# -----------------------------------------------------------------------------
# login as RUN_USER
USER $RUN_USER
WORKDIR /home/$RUN_USER
# -----------------------------------------------------------------------------
# environment
# Sets language to UTF8 : this works in pretty much all cases
ENV LANG en_US.UTF-8
ENV LS_COLORS "di=00;36:fi=00;37"
ENV PATH=/bin:/sbin:/usr/bin:/usr/local/bin:$PATH
# -----------------------------------------------------------------------------
RUN echo "" >> /home/$RUN_USER/.bashrc
RUN echo "alias l='ls -l'" >> /home/$RUN_USER/.bashrc
RUN echo "alias ll='ls -al'" >> /home/$RUN_USER/.bashrc
RUN echo "LS_COLORS=\"di=00;36:fi=00;37\"" >> /home/$RUN_USER/.bashrc
RUN echo "" >> /home/$RUN_USER/.bashrc
# -----------------------------------------------------------------------------
# for ROS2
RUN echo "source /opt/ros/humble/setup.bash" >> /home/$RUN_USER/.bashrc
RUN echo "export RMW_IMPLEMENTATION=rmw_fastrtps_cpp" >> /home/$RUN_USER/.bashrc
RUN echo "glxinfo | grep \"OpenGL version\"" >> /home/$RUN_USER/get_opengl.sh
RUN echo "ign gazebo empty.sdf --render-engine ogre" >> /home/$RUN_USER/old_gazebo.sh
RUN echo "ign gazebo empty.sdf" >> /home/$RUN_USER/gazebo.sh
RUN chmod 775 /home/$RUN_USER/get_opengl.sh
RUN chmod 775 /home/$RUN_USER/old_gazebo.sh
RUN chmod 775 /home/$RUN_USER/gazebo.sh
# -----------------------------------------------------------------------------
USER root
# -----------------------------------------------------------------------------
# add user to sudoers
RUN chmod 0666 /etc/sudoers
RUN echo "$RUN_USER ALL=(ALL:ALL) ALL " >> /etc/sudoers
RUN chmod 0440 /etc/sudoers
# -----------------------------------------------------------------------------
USER $RUN_USER
WORKDIR /home/$RUN_USER
도커 이미지 빌드
cd duckie_ws/
docker build -t duckie_ws:humble-jammy-rtx1060 .
이미지 이름이 duckie_ws이고, 버전은 humble
도커 이미지 실행(로컬에 있는 이미지)
docker run --rm -it --privileged --net=host -e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /tmp/runtime-user:/tmp/runtime-user \
--name duckie-ws -v $PWD:/home/user/project duckie_ws:humble-jammy-rtx1060 /bin/bash
# 도커-허브 있는 이미지 실행
docker run --rm -it --privileged --net=host -e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /tmp/runtime-user:/tmp/runtime-user \
--name duckie-ws -v $PWD:/home/user/project duvallee/ros2-ubuntu-rtx1060:humble-jammy /bin/bash
duckie_ws:humble-jammy-rtx1060
도커 이미지를 시뮬레이션할 때 GUI를 사용하기 때문에 xterm에서 실행한다
-v 옵션으로 호스트와 도커 컨테이너의 파일 시스템을 공유하도록 했다
이는 다른 터미널을 연 후에 아래 명령어를 치면 연결할 수 있다
docker attach duckie-ws
git clone https://github.com/duckietown/gym-duckietown.git
cd gym-duckietown
pip3 install -e .
'2025 > ROS' 카테고리의 다른 글
Emerging Trends in Realistic Robotic Simulations:A Comprehensive Systematic Literature Review (0) | 2024.04.01 |
---|---|
Django 웹 서버에 연결되는 ROS2 Docker 이미지 기반 Gazebo 시뮬레이션 추천 (0) | 2024.03.15 |
Ubuntu 22.04의 Docker 컨테이너에 ROS2 Humble 설치 (1) | 2024.03.14 |
ROS2 Foxy rosbridge_suite 설치 매뉴얼 (0) | 2023.07.27 |
ROS2 Humble 토픽 한 번만 Publish하는 3가지 방법 (0) | 2023.07.27 |