From 2a9a4a011a367737fb0f1ebe62077c6e30c68dde Mon Sep 17 00:00:00 2001 From: Austin Deric Date: Fri, 20 Jul 2018 14:59:18 -0500 Subject: [PATCH] Devel (#1) WIP --- docker/README.md | 38 +++++++++++-- docker/gym-gazebo-turtlebot/Dockerfile | 54 +++++++++++++++++++ .../gym-gazebo/kinetic-nvidia9.2/Dockerfile | 19 +------ .../envs/installation/turtlebot_setup.bash | 4 +- 4 files changed, 92 insertions(+), 23 deletions(-) create mode 100644 docker/gym-gazebo-turtlebot/Dockerfile diff --git a/docker/README.md b/docker/README.md index 447923c8a9d..cf2cf713835 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,15 +8,47 @@ This fodler is setup such that each image has its own folder is an image and eac ## Requirements -nvidia-docker 2 -https://github.com/NVIDIA/nvidia-docker +[nvidia-docker 2](https://github.com/NVIDIA/nvidia-docker) allows running cuda-based nueral nets and render displays from the container. -Allows running cuda-based nueral nets and render displays from the container. ## Recommended (Easy) Method +``` +docker run \ + --runtime=nvidia \ + -v="/tmp/.gazebo/:/root/.gazebo/" \ + --rm \ + -it \ + -p 11345:11345 \ + -p 11311:11311 \ + --name=gym-gazebo-turtlebot \ + austinderic/gym-gazebo-turtlebot:kinetic-nvidia9.2 \ + /bin/bash +``` +This will open a bash shell in the container: +``` +python ./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 +``` + Run tests in the base image. Simply enter the following command, all you need is nvidia-docker2 setup: ``` docker run --runtime=nvidia --rm austinderic/gym-gazebo:kinetic-nvidia9.2 /bin/bash -c "nvidia-smi; echo $(rosversion -d); pip show gym; pip show gym-gazebo" +``` +Even easier with docker-compose: +``` +docker-compose up ``` +## Manual Method +``` +mkdir -p ./catkin_ws/src +cd ./catkin_ws/src +wstool initW +wstool merge https://raw.githubusercontent.com/turtlebot/turtlebot/kinetic/turtlebot.rosinstall && wstool merge ../../gym-gazebo/gym_gazebo/envs/installation/gym-gazebo.rosinstall +``` diff --git a/docker/gym-gazebo-turtlebot/Dockerfile b/docker/gym-gazebo-turtlebot/Dockerfile new file mode 100644 index 00000000000..2b7132864f8 --- /dev/null +++ b/docker/gym-gazebo-turtlebot/Dockerfile @@ -0,0 +1,54 @@ +FROM austinderic/gym-gazebo:kinetic-nvidia9.2 +LABEL maintainer "Austin.Deric@gmail.org" + +#-------------------- +# Install Gym-Gazebo Turtlebot dependencies +#------------------ + +RUN apt-get update && apt-get install -y \ + ros-kinetic-turtlebot-create \ + ros-kinetic-yujin-ocs \ + ros-kinetic-yocs-msgs \ + ros-kinetic-xacro \ + ros-kinetic-roslint \ + ros-kinetic-ros-control \ + ros-kinetic-image-common \ + ros-kinetic-control-toolbox \ + ros-kinetic-gazebo-ros-pkgs \ + ros-kinetic-roslint \ + ros-kinetic-driver-common \ + ros-kinetic-navigation \ + ros-kinetic-joystick-drivers \ + ros-kinetic-kobuki-desktop \ + ros-kinetic-kobuki-core \ + ros-kinetic-kobuki \ + ros-kinetic-kobuki-msgs \ + ros-kinetic-ecl \ + ros-kinetic-pcl-ros \ + libbullet-dev \ + libusb-dev \ + libsdl-dev \ + libsdl-image1.2-dev \ + python-skimage \ + && rm -rf /var/lib/apt/lists/* + +#-------------------- +# 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/3362c86437d88347807beaba3501602e/raw/ecadfddc98a1865dfe60b29d17ff03a513b39279/gym-gazebo.rosinstall +RUN wstool update +WORKDIR /root/catkin_ws +RUN /bin/bash -c "source /opt/ros/kinetic/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 + +WORKDIR /root/ diff --git a/docker/gym-gazebo/kinetic-nvidia9.2/Dockerfile b/docker/gym-gazebo/kinetic-nvidia9.2/Dockerfile index ca7a6ea85d8..307835799e6 100644 --- a/docker/gym-gazebo/kinetic-nvidia9.2/Dockerfile +++ b/docker/gym-gazebo/kinetic-nvidia9.2/Dockerfile @@ -1,26 +1,9 @@ FROM austinderic/ros-desktop-full:kinetic-nvidia9.2 LABEL maintainer "Austin.Deric@gmail.org" -#-------------------- -# Setup nvidia-docker2 -#-------------------- -# Reference: http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration - -ENV NVIDIA_VISIBLE_DEVICES \ - ${NVIDIA_VISIBLE_DEVICES:-all} -ENV NVIDIA_DRIVER_CAPABILITIES \ - ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics - #-------------------- # Install OpenAI gym -#-------------------- - -RUN apt-get update && apt-get install -y --no-install-recommends \ - python-pip && \ - apt-get clean && \ -rm -rf /var/lib/apt/lists/* - -RUN pip install --upgrade pip +#------------------- RUN pip install gym diff --git a/gym_gazebo/envs/installation/turtlebot_setup.bash b/gym_gazebo/envs/installation/turtlebot_setup.bash index 3f22562b68a..d4ebfbe0c76 100755 --- a/gym_gazebo/envs/installation/turtlebot_setup.bash +++ b/gym_gazebo/envs/installation/turtlebot_setup.bash @@ -38,10 +38,10 @@ else fi #copy altered urdf model -cp -r ../assets/urdf/kobuki_urdf/urdf/ catkin_ws/src/kobuki/kobuki_description +cp -r ../assets/urdf/kobuki_urdf/urdf/ ./catkin_ws/src/kobuki/kobuki_description #copy laser mesh file -cp ../assets/meshes/lidar_lite_v2_withRay.dae catkin_ws/src/kobuki/kobuki_description/meshes +cp ../assets/meshes/lidar_lite_v2_withRay.dae ./catkin_ws/src/kobuki/kobuki_description/meshes exec bash # reload bash