From b228e6ad55a2019d6063fc46f7a47b711c8fca21 Mon Sep 17 00:00:00 2001 From: Matthew Foran Date: Fri, 30 Sep 2022 15:14:44 -0400 Subject: [PATCH 1/4] docker work --- .dockerignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ README.md | 17 ++++++++++++++++- badgr_docker | 8 ++++++++ bgr.sh | 15 +++++++++++++++ req_docker.txt | 11 +++++++++++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 badgr_docker create mode 100755 bgr.sh create mode 100644 req_docker.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8fce603 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +data/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..25a2c87 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM tensorflow/tensorflow:1.13.1-gpu + +# fix nvidia public key +RUN apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub &&\ + apt update + +# install pip and requirements +COPY req_docker.txt ./requirements.txt +RUN apt install -y python3-dev python3-tk &&\ + curl -sSL https://bootstrap.pypa.io/pip/3.5/get-pip.py -o get-pip.py &&\ + python3 get-pip.py "pip < 21.0" "setuptools < 50.0" "wheel < 1.0" &&\ + python3 -m pip install -r requirements.txt + +# install ROS kinetic +RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' &&\ + curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - &&\ + apt update &&\ + apt install -y ros-kinetic-ros-base ros-kinetic-ros-numpy git nano &&\ + echo "source /opt/ros/kinetic/setup.bash" >> /root/.bashrc + +RUN echo 'export PYTHONPATH=/badgr/src:$PYTHONPATH' >> /root/.bashrc + +WORKDIR /badgr +COPY bgr.sh . diff --git a/README.md b/README.md index 6671813..f688d19 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # BADGR: An Autonomous Self-Supervised Learning-Based Navigation System Gregory Kahn, Pieter Abbeel, Sergey Levine @@ -36,6 +35,9 @@ rm BADGR_rosbags.zip cd .. ``` +Note: [Docker](#docker) is now available as an alternative to the following system installation. This approach is recommended to avoid dealing with deprecated Python packages. + + Then setup the anaconda environment: ```bash conda create -y --name badgr python==3.6.9 @@ -106,6 +108,19 @@ change the visualizer to show bumpiness by modifying `configs/bumpy_collision_po python scripts/eval.py configs/bumpy_collision_position.py ``` +## Docker + +Docker and the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) must be installed before proceeding. + +In the badgr directory: +``` +docker build . -t badgr:1.13.1 +``` +After building follow the training instructions within a badgr container. Make sure to use `python3` instead of `python` A convenience script `badgr_docker` is included which brings up a container with the proper docker options. Change the volume path if badgr is not installed in your home directory. + +With a trained model `bgr.sh` can be run to execute the evaluation demo. + + ## FAQ 1. If you are having issues with importing OpenCV (e.g., `ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type`), try the following to have python look for the Python 3 OpenCV first: ```bash diff --git a/badgr_docker b/badgr_docker new file mode 100755 index 0000000..dfa2979 --- /dev/null +++ b/badgr_docker @@ -0,0 +1,8 @@ +#! /usr/bin/env sh + +xhost +local:root; # for the lazy and reckless http://wiki.ros.org/docker/Tutorials/GUI + +# this snippet assumes badgr is in your home directory +docker run --network host --gpus all --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" -v /home/$USER/badgr:/badgr -it badgr:1.13.1 #bash -i -c "./bgr.sh"; + +xhost -local:root; diff --git a/bgr.sh b/bgr.sh new file mode 100755 index 0000000..2598acf --- /dev/null +++ b/bgr.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +roscore > /dev/null 2>&1 & + +echo "roscore starting up..." +while true; do + sleep 1 + rostopic list > /dev/null 2>&1 + [[ $? != 0 ]] || break +done + +rosbag play -l data/rosbags/collision.bag > /dev/null 2>&1 & +rosparam set /cost_weights "{'collision': 1.0, 'position': 0.0, 'position_sigmoid_center': 0.4, 'position_sigmoid_scale': 100., 'action_magnitude': 0.01, 'action_smooth': 0.0, 'bumpy': 0.0}"; +python3 scripts/eval.py configs/bumpy_collision_position.py; +bash diff --git a/req_docker.txt b/req_docker.txt new file mode 100644 index 0000000..1bbc4ca --- /dev/null +++ b/req_docker.txt @@ -0,0 +1,11 @@ +catkin-pkg==0.4.13 +loguru==0.3.2 +matplotlib +numpy +opencv-python==4.1.1.26 +Pillow==6.1.0 +PyYAML==5.1.2 +requests==2.22.0 +rospkg==1.1.10 +tensorflow-gpu==1.13.1 +utm==0.5.0 From 18a2c712318e51cbc4f5018adce8cfda8bb18975 Mon Sep 17 00:00:00 2001 From: Matthew Foran Date: Fri, 30 Sep 2022 15:19:35 -0400 Subject: [PATCH 2/4] update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f688d19..8417e81 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ Gregory Kahn, Pieter Abbeel, Sergey Levine Make sure you have 90GB of space available, [anaconda](https://www.anaconda.com/distribution/) installed, and [ROS](https://www.ros.org/) installed. Our installation was on Ubuntu 16.04 with ROS Kinetic. +Note: [Docker](#docker) is now available as an alternative to the following system installation. This approach is recommended to avoid dealing with deprecated Python packages. + + Clone the repository and go into the folder: ```bash @@ -35,9 +38,6 @@ rm BADGR_rosbags.zip cd .. ``` -Note: [Docker](#docker) is now available as an alternative to the following system installation. This approach is recommended to avoid dealing with deprecated Python packages. - - Then setup the anaconda environment: ```bash conda create -y --name badgr python==3.6.9 @@ -112,7 +112,7 @@ python scripts/eval.py configs/bumpy_collision_position.py Docker and the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) must be installed before proceeding. -In the badgr directory: +First follow the standard instructions for cloning the repository and downloading the data. In the badgr directory: ``` docker build . -t badgr:1.13.1 ``` From d9027a236690d8c5d628c0ad1ad42502275dbf28 Mon Sep 17 00:00:00 2001 From: Matthew Foran Date: Fri, 30 Sep 2022 15:22:43 -0400 Subject: [PATCH 3/4] added comments --- bgr.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bgr.sh b/bgr.sh index 2598acf..cc1cc81 100755 --- a/bgr.sh +++ b/bgr.sh @@ -6,6 +6,7 @@ echo "roscore starting up..." while true; do sleep 1 rostopic list > /dev/null 2>&1 + # Check the return value of rostopic list. Keep looping until it is zero, indicing roscore is ready [[ $? != 0 ]] || break done From c13b82973406a929b4504b49f84d1bd530445f31 Mon Sep 17 00:00:00 2001 From: Matthew Foran Date: Fri, 30 Sep 2022 15:32:17 -0400 Subject: [PATCH 4/4] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8417e81..d123d37 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Gregory Kahn, Pieter Abbeel, Sergey Levine Make sure you have 90GB of space available, [anaconda](https://www.anaconda.com/distribution/) installed, and [ROS](https://www.ros.org/) installed. Our installation was on Ubuntu 16.04 with ROS Kinetic. -Note: [Docker](#docker) is now available as an alternative to the following system installation. This approach is recommended to avoid dealing with deprecated Python packages. +Note: [Docker](#docker) is now available as an alternative to the following system installation. This approach is recommended to avoid the hassle of installing deprecated software. Clone the repository and go into the folder: