Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros docker #126

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docker/ros/Dockerfile.ros
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM ros:noetic-ros-core

ARG cpu_or_gpu

RUN apt-get update && apt-get install --no-install-recommends -y \
software-properties-common \
build-essential \
curl \
libsm6 \
libxext6 \
libglib2.0-0 \
libxrender1 \
wget \
libpng-dev \
pkg-config \
libfreetype6-dev \
ros-noetic-cv-bridge \
freeglut3-dev \
unzip

RUN add-apt-repository ppa:deadsnakes/ppa

RUN apt-get update && apt-get -y install \
python3.7 \
python3.7-dev \
python3-pip \
python3.7-tk

RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
RUN python3.7 -m pip install --no-cache-dir --upgrade setuptools pip wheel numpy netifaces pyglet pycryptodomex crypto

RUN /bin/bash -c "mkdir -p /root/catkin_ws/src"
ENV CATKIN_WS /root/catkin_ws

WORKDIR $CATKIN_WS

COPY [ "gqcnn/", "$CATKIN_WS/src/gqcnn/" ]

RUN python3 -m pip install --no-cache-dir -r $CATKIN_WS/src/gqcnn/requirements/${cpu_or_gpu}_requirements.txt

RUN /bin/bash -c "source /opt/ros/noetic/setup.bash \
&& catkin_make install -DCMAKE_INSTALL_PREFIX=/opt/ros/noetic/"
6 changes: 6 additions & 0 deletions docker/ros/config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export COMPOSE_PROJECT_NAME=berkeley_automation
export HOST_IP=127.0.0.1
export ROS_MASTER_URI=http://${HOST_IP}:11311
export ROS_IP=${HOST_IP}
export MODEL=GQCNN-4.0-PJ
export cpu_or_gpu=cpu # or gpu
48 changes: 48 additions & 0 deletions docker/ros/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: '3.4'

services:
ros_master:
image: ros:kinetic-ros-core
network_mode: host
environment:
- ROS_MASTER_URI=${ROS_MASTER_URI}
- ROS_IP=${ROS_IP}
command: stdbuf -o L roscore

gqcnn:
image: gqcnn_${cpu_or_gpu}:latest
build:
args:
cpu_or_gpu: $cpu_or_gpu
context: ../../../
dockerfile: gqcnn/docker/ros/Dockerfile.ros
network_mode: host
environment:
- ROS_MASTER_URI=${ROS_MASTER_URI}
- ROS_IP=${ROS_IP}
volumes:
- ../../../gqcnn/:/root/catkin_ws/src/gqcnn/:ro
depends_on:
- ros_master
command: "bash -c 'source /root/catkin_ws/devel/setup.bash; roslaunch --wait gqcnn grasp_planning_service.launch model_name:=${MODEL};'"


#gqcnn_example:
# image: gqcnn_${cpu_or_gpu}:latest
# build:
# args:
# cpu_or_gpu: $cpu_or_gpu
# context: ../../../
# dockerfile: gqcnn/docker/ros/Dockerfile.ros
# network_mode: host
# environment:
# - DISPLAY=$DISPLAY
# - ROS_MASTER_URI=${ROS_MASTER_URI}
# - ROS_IP=${ROS_IP}
# volumes:
# - ../../../gqcnn/:/root/catkin_ws/src/gqcnn/:ro
# - /tmp/.X11-unix:/tmp/.X11-unix:ro
# - $HOME/.Xauthority:/.Xauthority:ro
# depends_on:
# - gqcnn
# command: "bash -c 'source /root/catkin_ws/devel/setup.bash; python3 /root/catkin_ws/src/gqcnn/examples/policy_ros.py'"
2 changes: 1 addition & 1 deletion ros_nodes/grasp_planner_node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright ©2017. The Regents of the University of California (Regents).
Expand Down
43 changes: 43 additions & 0 deletions scripts/docker/run_docker_ros.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Copyright ©2017. The Regents of the University of California (Regents).
# All Rights Reserved. Permission to use, copy, modify, and distribute this
# software and its documentation for educational, research, and not-for-profit
# purposes, without fee and without a signed licensing agreement, is hereby
# granted, provided that the above copyright notice, this paragraph and the
# following two paragraphs appear in all copies, modifications, and
# distributions. Contact The Office of Technology Licensing, UC Berkeley, 2150
# Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-7201,
# [email protected],
# http://ipira.berkeley.edu/industry-info for commercial licensing opportunities.

# IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF
# THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
# HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
# MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

# Run the docker CPU image.

function ctrl_c() {
#handle ctl+C
xhost -local:docker
}
ctrl_c
trap ctrl_c INT

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd $SCRIPT_DIR
cd ../../..
source ./gqcnn/docker/ros/config.env

xhost +local:docker
#docker-compose -f gqcnn/docker/ros/docker-compose.yml build --no-cache --parallel
docker-compose -f gqcnn/docker/ros/docker-compose.yml up
xhost -local:docker