diff --git a/docker/README.md b/docker/README.md index cf2cf713835..7cd4ffce325 100644 --- a/docker/README.md +++ b/docker/README.md @@ -26,13 +26,11 @@ docker run \ ``` This will open a bash shell in the container: ``` -python ./gym-gazebo/examples/turtlebot/circuit2_turtlebot_lidar_qlearn.py +python /root/gym-gazebo/examples/turtlebot/circuit2_turtlebot_lidar_qlearn.py ``` then we can connect to our new container ``` -export GAZEBO_MASTER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' gym-gazebo-turtlebot) -export GAZEBO_MASTER_URI=$GAZEBO_MASTER_IP:11345 -sudo gzclient --verbose +export GAZEBO_MASTER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' gym-gazebo-turtlebot) && export GAZEBO_MASTER_URI=$GAZEBO_MASTER_IP:11345 && sudo gzclient --verbose ``` Run tests in the base image. Simply enter the following command, all you need is nvidia-docker2 setup: diff --git a/docker/gym-gazebo-turtlebot/melodic/Dockerfile b/docker/gym-gazebo-turtlebot/melodic/Dockerfile new file mode 100644 index 00000000000..991947b177b --- /dev/null +++ b/docker/gym-gazebo-turtlebot/melodic/Dockerfile @@ -0,0 +1,52 @@ +FROM austinderic/gym-gazebo:melodic +LABEL maintainer "Austin.Deric@gmail.org" + +#-------------------- +# Install Gym-Gazebo Turtlebot dependencies +#------------------ + +RUN apt-get update && apt-get install -y \ + ros-melodic-geometry2 \ + ros-melodic-xacro \ + ros-melodic-roslint \ + ros-melodic-ros-control \ + ros-melodic-image-common \ + ros-melodic-control-toolbox \ + ros-melodic-gazebo-ros-pkgs \ + ros-melodic-roslint \ + ros-melodic-joystick-drivers \ + ros-melodic-ecl \ + ros-melodic-pcl-ros \ + ros-melodic-yocs-msgs \ + libbullet-dev \ + libusb-dev \ + libsdl-dev \ + libsdl-image1.2-dev \ + libftdi-dev \ + mesa-utils \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install scikit-image + +#-------------------- +# Install Gym-Gazebo Turtlebot Example +#------------------ + +RUN mkdir -p /root/catkin_ws/src +WORKDIR /root/catkin_ws/src +RUN wstool init +RUN wstool merge https://gist.githubusercontent.com/AustinDeric/c14633f1d5bcabc14307dcca2425d133/raw/266668674782d5e1096ecd13f3ea6dcf5af5248a/gym-gazebo-turtlebot-melodic.rosinstall +RUN wstool update +WORKDIR /root/catkin_ws +RUN /bin/bash -c "source /opt/ros/melodic/setup.bash && catkin build" +RUN echo "source /root/catkin_ws/devel/setup.bash" >> ~/.bashrc + +#-------------------- +# Setup environment variables +#------------------ +RUN echo "export GYM_GAZEBO_WORLD_CIRCUIT2=/root/gym-gazebo/gym_gazebo/envs/assets/worlds/circuit2.world" >> ~/.bashrc +RUN export GYM_GAZEBO_WORLD_CIRCUIT2=/root/gym-gazebo/gym_gazebo/envs/assets/worlds/circuit2.world +RUN echo "export GAZEBO_MODEL_PATH=/root/gym-gazebo/gym_gazebo/envs/assets/models" >> ~/.bashrc + +WORKDIR /root/ + diff --git a/docker/gym-gazebo-turtlebot/melodic/run.bash b/docker/gym-gazebo-turtlebot/melodic/run.bash new file mode 100755 index 00000000000..64b04e3b02c --- /dev/null +++ b/docker/gym-gazebo-turtlebot/melodic/run.bash @@ -0,0 +1,24 @@ +XAUTH=/tmp/.docker.xauth +if [ ! -f $XAUTH ] +then + xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/') + if [ ! -z "$xauth_list" ] + then + echo $xauth_list | xauth -f $XAUTH nmerge - + else + touch $XAUTH + fi + chmod a+r $XAUTH +fi + +docker run -it --rm \ + --runtime=nvidia \ + --env DISPLAY \ + --env QT_X11_NO_MITSHM=1 \ + --env XAUTHORITY=$XAUTH \ + --volume "$XAUTH:$XAUTH" \ + --volume "/tmp/.X11-unix:/tmp/.X11-unix" \ + --name=gym-gazebo-turtlebot \ + --rm \ + austinderic/gym-gazebo-turtlebot:melodic \ + /bin/bash diff --git a/docker/gym-gazebo/melodic/Dockerfile b/docker/gym-gazebo/melodic/Dockerfile new file mode 100644 index 00000000000..da5b4d10496 --- /dev/null +++ b/docker/gym-gazebo/melodic/Dockerfile @@ -0,0 +1,38 @@ +FROM osrf/ros:melodic-desktop-full + +# set environment variables +ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all} +ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics + +# Dependencies for building packages +RUN apt-get update && apt-get install -y \ + python-rosinstall \ + python-rosinstall-generator \ + python-wstool \ + build-essential \ + python-pip\ + && rm -rf /var/lib/apt/lists/* + +# Unofficial ROS installation steps +RUN pip install --upgrade pip + +RUN pip install -U catkin_tools + + +#-------------------- +# Install OpenAI gym +#------------------- + +RUN pip install gym + +#-------------------- +# Install gym-gazebo +#-------------------- + +RUN git clone https://github.com/erlerobot/gym-gazebo.git /root/gym-gazebo +WORKDIR /root/gym-gazebo +RUN pip install -e . + + + + diff --git a/docker/gym-gazebo/melodic/run.bash b/docker/gym-gazebo/melodic/run.bash new file mode 100755 index 00000000000..6c3887c1e14 --- /dev/null +++ b/docker/gym-gazebo/melodic/run.bash @@ -0,0 +1,22 @@ +XAUTH=/tmp/.docker.xauth +if [ ! -f $XAUTH ] +then + xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/') + if [ ! -z "$xauth_list" ] + then + echo $xauth_list | xauth -f $XAUTH nmerge - + else + touch $XAUTH + fi + chmod a+r $XAUTH +fi + +docker run -it --rm \ + --runtime=nvidia \ + --env DISPLAY \ + --env QT_X11_NO_MITSHM=1 \ + --env XAUTHORITY=$XAUTH \ + --volume "$XAUTH:$XAUTH" \ + --volume "/tmp/.X11-unix:/tmp/.X11-unix" \ + austinderic/gym-gazebo:melodic \ + /bin/bash