Skip to content

Commit

Permalink
Upgraded DOPE code to Python 3. Updated Docker to use ROS Noetic
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-jeff committed Sep 2, 2020
1 parent 65a657a commit 6b78c46
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 154 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ project(dope)
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
camera_info_manager_py
cv_bridge
geometry_msgs
message_filters
Expand Down
80 changes: 0 additions & 80 deletions docker/Dockerfile.kinetic

This file was deleted.

61 changes: 61 additions & 0 deletions docker/Dockerfile.noetic
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM ros:noetic-robot

# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
# Full license terms provided in LICENSE.md file.
# To build:
# docker build -t nvidia-dope:noetic-v1 -f Dockerfile.noetic ..

ENV HOME /root
ENV DEBIAN_FRONTEND=noninteractive

# Install system and development components
RUN apt-get update && apt-get -y --no-install-recommends install \
apt-utils \
software-properties-common \
build-essential \
cmake \
git \
python3-pip \
libxext6 \
libx11-6 \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
freeglut3-dev \
&& apt-get -y autoremove \
&& apt-get clean

# Install required ROS components
RUN apt-get update && apt-get -y --no-install-recommends install \
ros-noetic-cv-bridge \
ros-noetic-geometry-msgs \
ros-noetic-message-filters \
ros-noetic-resource-retriever \
ros-noetic-rospy \
ros-noetic-sensor-msgs \
ros-noetic-std-msgs \
ros-noetic-tf \
ros-noetic-vision-msgs \
ros-noetic-visualization-msgs \
ros-noetic-rviz \
&& apt-get -y autoremove \
&& apt-get clean

# pip install required Python packages
COPY requirements.txt ${HOME}
RUN python3 -m pip install --no-cache-dir -r ${HOME}/requirements.txt

# Setup catkin workspace
ENV CATKIN_WS ${HOME}/catkin_ws
COPY . ${CATKIN_WS}/src/dope
COPY docker/init_workspace.sh ${HOME}
RUN ${CATKIN_WS}/src/dope/docker/init_workspace.sh
RUN echo "source ${CATKIN_WS}/devel/setup.bash" >> ${HOME}/.bashrc

ENV DISPLAY :0
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute
ENV TERM=xterm
# Some QT-Apps don't show controls without this
ENV QT_X11_NO_MITSHM 1
2 changes: 1 addition & 1 deletion docker/init_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Stop in case of any error.
set -e

source /opt/ros/kinetic/setup.bash
source /opt/ros/noetic/setup.bash

# Create catkin workspace.
mkdir -p ${CATKIN_WS}/src
Expand Down
19 changes: 4 additions & 15 deletions docker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ Running ROS inside of [Docker](https://www.docker.com/) is an excellent way to
experiment with DOPE, as it allows the user to completely isolate all software and configuration
changes from the host system. This document describes how to create and run a
Docker image that contains a complete ROS environment that supports DOPE,
including all required components, such as ROS Kinetic, rviz, CUDA with cuDNN,
including all required components, such as ROS Noetic, rviz, CUDA with cuDNN,
and other packages.

The current configuration assumes all components are installed on an x86 host
platform running Ubuntu 16.04. Further, use of the DOPE Docker container requires
an NVIDIA GPU to be present, and it uses
[NVIDIA Docker](https://github.com/NVIDIA/nvidia-docker/) for seamless CUDA usage.

(This setup was tested with NVIDIA Docker v2. Although these steps should work
with NVIDIA Docker v1, that version is no longer supported by NVIDIA; rather, users are encouraged to
[upgrade](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)).)
platform running Ubuntu 18.04 or later. Further, use of the DOPE Docker container requires an NVIDIA GPU to be present, and the use of Docker version 19.03.0 or later.


### Steps
Expand All @@ -27,7 +21,7 @@ with NVIDIA Docker v1, that version is no longer supported by NVIDIA; rather, us
2. **Build the docker image**
```
$ cd dope/docker
$ docker build -t nvidia-dope:kinetic-v1 -f Dockerfile.kinetic ..
$ docker build -t nvidia-dope:noetic-v1 -f Dockerfile.noetic ..
```
This will take several minutes and requires an internet connection.

Expand All @@ -39,7 +33,7 @@ with NVIDIA Docker v1, that version is no longer supported by NVIDIA; rather, us
$ ./run_dope_docker.sh [name] [host dir] [container dir]
```
Parameters:
- `name` is an optional field that specifies the name of this image. By default, it is `nvidia-dope-v1`. By using different names, you can create multiple containers from the same image.
- `name` is an optional field that specifies the name of this image. By default, it is `nvidia-dope-v2`. By using different names, you can create multiple containers from the same image.
- `host dir` and `container dir` are a pair of optional fields that allow you to specify a mapping between a directory on your host machine and a location inside the container. This is useful for sharing code and data between the two systems. By default, it maps the directory containing dope to `/root/catkin_ws/src/dope` in the container.

Only the first invocation of this script with a given name will create a container. Subsequent executions will attach to the running container allowing you -- in effect -- to have multiple terminal sessions into a single container.
Expand All @@ -48,8 +42,3 @@ with NVIDIA Docker v1, that version is no longer supported by NVIDIA; rather, us
Return to step 7 of the [installation instructions](../readme.md) (downloading the weights).

*Note:* Since the Docker container binds directly to the host's network, it will see `roscore` even if running outside the docker container.


### Acknowledgment

The DOPE Docker image is based on NVIDIA's [Redtail Docker image](https://github.com/NVIDIA-Jetson/redtail/wiki/testing-in-simulator#redtail-docker).
6 changes: 3 additions & 3 deletions docker/run_dope_docker.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
# Full license terms provided in LICENSE.md file.

CONTAINER_NAME=$1
if [[ -z "${CONTAINER_NAME}" ]]; then
CONTAINER_NAME=nvidia-dope-v1
CONTAINER_NAME=nvidia-dope-v2
fi

# This specifies a mapping between a host directory and a directory in the
Expand All @@ -28,7 +28,7 @@ DOPE_ID=`docker ps -aqf "name=^/${CONTAINER_NAME}$"`
if [ -z "${DOPE_ID}" ]; then
echo "Creating new DOPE docker container."
xhost +local:root
docker run --gpus all -it --privileged --network=host -v ${HOST_DIR}:${CONTAINER_DIR}:rw -v /tmp/.X11-unix:/tmp/.X11-unix:rw --env="DISPLAY" --name=${CONTAINER_NAME} nvidia-dope:kinetic-v1 bash
docker run --gpus all -it --privileged --network=host -v ${HOST_DIR}:${CONTAINER_DIR}:rw -v /tmp/.X11-unix:/tmp/.X11-unix:rw --env="DISPLAY" --name=${CONTAINER_NAME} nvidia-dope:noetic-v1 bash
else
echo "Found DOPE docker container: ${DOPE_ID}."
# Check if the container is already running and start if necessary.
Expand Down
4 changes: 2 additions & 2 deletions nodes/dope
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class DopeNode(object):
self.config_detect.thresh_points = rospy.get_param("~thresh_points", 0.1)

# For each object to detect, load network model, create PNP solver, and start ROS publishers
for model, weights_url in rospy.get_param('~weights').iteritems():
for model, weights_url in rospy.get_param('~weights').items():
self.models[model] = \
ModelData(
model,
Expand Down Expand Up @@ -318,7 +318,7 @@ class DopeNode(object):
self.pub_markers.publish(markers)

# Object markers
class_id_to_name = {class_id: name for name, class_id in self.class_ids.iteritems()}
class_id_to_name = {class_id: name for name, class_id in self.class_ids.items()}
markers = MarkerArray()
for i, det in enumerate(detection_array.detections):
name = class_id_to_name[det.results[0].id]
Expand Down
17 changes: 10 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ This is the official DOPE ROS package for detection and 6-DoF pose estimation of

![DOPE Objects](dope_objects.png)

## Update
## Updates

02/09/2010 - Upgraded DOPE to use Python 3. Updated Dockerfile to use Python3-compatible ROS Noetic. The Python 2.7/ROS Kinetic is still available on the ['ros-kinetic' branch](https://github.com/NVlabs/Deep_Object_Pose/tree/ros-kinetic).

16/03/2020 - Added a wiki (thanks to [@saratrajput](https://github.com/saratrajput))

03/07/2019 - ROS interface update (thanks to Martin Günther)
Expand All @@ -17,15 +20,15 @@ This is the official DOPE ROS package for detection and 6-DoF pose estimation of

## Installing

We have tested on Ubuntu 16.04 and 18.04 with ROS Kinetic and Lunar with an NVIDIA Titan X and RTX 2080ti with python 2.7. The code may work on other systems.
We have tested on Ubuntu 18.04 with ROS Noetic with an NVIDIA Titan X and RTX 2080ti with python 3.8. The code may work on other systems.

The following steps describe the native installation. Alternatively, use the provided [Docker image](docker/readme.md) and skip to Step #7.

1. **Install ROS**

Follow these [instructions](http://wiki.ros.org/kinetic/Installation/Ubuntu).
Follow these [instructions](http://wiki.ros.org/noetic/Installation/Ubuntu).
You can select any of the default configurations in step 1.4; even the
ROS-Base (Bare Bones) package (`ros-kinetic-ros-base`) is enough.
ROS-Base (Bare Bones) package (`ros-noetic-ros-base`) is enough.

2. **Create a catkin workspace** (if you do not already have one). To create a catkin workspace, follow these [instructions](http://wiki.ros.org/catkin/Tutorials/create_a_workspace):
```
Expand All @@ -43,14 +46,14 @@ The following steps describe the native installation. Alternatively, use the pro
4. **Install python dependencies**
```
$ cd ~/catkin_ws/src/dope
$ pip install -r requirements.txt
$ python3 -m pip install -r requirements.txt
```
5. **Install ROS dependencies**
```
$ cd ~/catkin_ws
$ rosdep install --from-paths src -i --rosdistro kinetic
$ sudo apt-get install ros-kinetic-rosbash ros-kinetic-ros-comm
$ rosdep install --from-paths src -i --rosdistro noetic
$ sudo apt-get install ros-noetic-rosbash ros-noetic-ros-comm
```
6. **Build**
Expand Down
15 changes: 8 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pyrr==0.9.2
torch==0.4.0
numpy==1.14.2
scipy==1.1.0
opencv_python==3.4.1.15
Pillow==5.3.0
torchvision==0.2.1
pyrr
torch
torchvision
numpy
scipy
opencv_python
Pillow

Loading

0 comments on commit 6b78c46

Please sign in to comment.