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..d123d37 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 @@ -11,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 the hassle of installing deprecated software. + + Clone the repository and go into the folder: ```bash @@ -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. + +First follow the standard instructions for cloning the repository and downloading the data. 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..cc1cc81 --- /dev/null +++ b/bgr.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +roscore > /dev/null 2>&1 & + +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 + +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