From fc4f5b069addca3fa34f240a6a588838286ebf78 Mon Sep 17 00:00:00 2001 From: fatcloud Date: Mon, 11 Jul 2016 02:44:43 +0800 Subject: [PATCH 1/4] A script is added so you can test kinect and usbcam node without pain --- ros-kinect/docker-compose.yml | 46 ++++++++++++++++++++++ ros-kinect/kinectViewer.sh | 72 +++++++++++++++++++++++++++++++++++ ros-usbcam/docker-compose.yml | 44 +++++++++++++++++++++ ros-usbcam/usbcamViewer.sh | 63 ++++++++++++++++++++++++++++++ 4 files changed, 225 insertions(+) create mode 100644 ros-kinect/docker-compose.yml create mode 100755 ros-kinect/kinectViewer.sh create mode 100644 ros-usbcam/docker-compose.yml create mode 100755 ros-usbcam/usbcamViewer.sh diff --git a/ros-kinect/docker-compose.yml b/ros-kinect/docker-compose.yml new file mode 100644 index 0000000..86473ef --- /dev/null +++ b/ros-kinect/docker-compose.yml @@ -0,0 +1,46 @@ +# ROS Kinect +kinect: + # build: ros-kinect/. + image: toddsampson/ros-indigo-kinect + container_name: kinect + hostname: kinect + net: rosdocker + devices: + - "/dev/bus/usb:/dev/bus/usb" + environment: + - "ROS_HOSTNAME=kinect" + - "ROS_MASTER_URI=http://rosmaster:11311" + # command: bash + command: roslaunch freenect_launch freenect.launch depth_registration:=true + + +# ROS Image View +image_view: + # build: ros-image_pipeline/. + image: toddsampson/ros-indigo-image_pipeline + container_name: image_view + hostname: image_view + volumes_from: + - "rosmaster" + net: rosdocker + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix" + environment: + - "DISPLAY=$DISPLAY" + - "ROS_HOSTNAME=image_view" + - "ROS_MASTER_URI=http://rosmaster:11311" + command: rosrun image_view image_view image:=/camera/depth_registered/image + + # command: rosrun image_view image_view image:=/image_raw + + + +# ROS MASTER (ROSCORE) +rosmaster: + image: ros:latest + container_name: rosmaster + hostname: rosmaster + net: rosdocker + ports: + - "11311:11311" + command: roscore diff --git a/ros-kinect/kinectViewer.sh b/ros-kinect/kinectViewer.sh new file mode 100755 index 0000000..566281d --- /dev/null +++ b/ros-kinect/kinectViewer.sh @@ -0,0 +1,72 @@ +#! /usr/bin/env bash + +cleanup() +# example cleanup function +{ + $COMPOSE stop + $COMPOSE rm -f + xhost - + return $? +} + +control_c() +# run if user hits control-c +{ + printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" + cleanup + printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" + exit $? +} + +# trap keyboard interrupt (control-c) +trap control_c SIGINT + + + +# ============================ Everything start from here ============================== + + + +COMPOSE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../docker-compose" +SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" +MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" +MSG_ERROR="\e[31;1m[ERROR]\e[0m" + +# Check if command "docker" is available +if ! hash docker 2>/dev/null; then + printf "$MSG_HEADER$MSG_ERROR docker installation is required to run this script!\n" + printf "[$MSG_HEADER]Visit https://docs.docker.com/engine/installation/ for installation guide" + exit +fi + +# Download docker-compose1.5.0rc if it doesn't exists +if [ ! -f $COMPOSE ]; then + printf "$MSG_HEADER Running for the first time, initialing... \n" + curl -L https://github.com/docker/compose/releases/download/1.5.0rc1/docker-compose-`uname -s`-`uname -m` > $COMPOSE + chmod +x $COMPOSE +fi + +printf "$MSG_HEADER Start running...\n" + +# Disable access control for X server +xhost + + +# Start the nodes! +if ! $COMPOSE --x-networking up -d; then + printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" + exit +fi + +# Some dirty hack: restart container kinect after 5 seconds +printf "$MSG_HEADER For some wierd reason, kinect node never work without starting it twice\n" +printf "$MSG_HEADER So we are restarting it within 5 seconds." +for i in `seq 1 5`; +do + sleep 1 + printf "." +done +docker restart -t 5 kinect +printf "$MSG_HEADER Hit Ctrl+C to stop..\n" + +while true; do read x; done + diff --git a/ros-usbcam/docker-compose.yml b/ros-usbcam/docker-compose.yml new file mode 100644 index 0000000..9cd9262 --- /dev/null +++ b/ros-usbcam/docker-compose.yml @@ -0,0 +1,44 @@ +usbcam: + # build: ros-usbcam/. + image: toddsampson/ros-indigo-usbcam + container_name: usbcam + hostname: usbcam + net: rosdocker + devices: + - "/dev/bus/usb:/dev/bus/usb" + environment: + - "ROS_HOSTNAME=usbcam" + - "ROS_MASTER_URI=http://rosmaster:11311" + command: rosrun libuvc_camera camera_node _height:=480 _width:=640 _vendor:=2084 _video_mode:=uncompressed _frame_rate:=30 + + +# ROS Image View +image_view: + # build: ros-image_pipeline/. + image: toddsampson/ros-indigo-image_pipeline + container_name: image_view + hostname: image_view + volumes_from: + - "rosmaster" + net: rosdocker + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix" + environment: + - "DISPLAY=$DISPLAY" + - "ROS_HOSTNAME=image_view" + - "ROS_MASTER_URI=http://rosmaster:11311" + command: rosrun image_view image_view image:=/image_raw + + # command: rosrun image_view image_view image:=/image_raw + + + +# ROS MASTER (ROSCORE) +rosmaster: + image: ros:latest + container_name: rosmaster + hostname: rosmaster + net: rosdocker + ports: + - "11311:11311" + command: roscore diff --git a/ros-usbcam/usbcamViewer.sh b/ros-usbcam/usbcamViewer.sh new file mode 100755 index 0000000..47a74d5 --- /dev/null +++ b/ros-usbcam/usbcamViewer.sh @@ -0,0 +1,63 @@ +#! /usr/bin/env bash + +cleanup() +# example cleanup function +{ + $COMPOSE stop + $COMPOSE rm -f + xhost - + return $? +} + +control_c() +# run if user hits control-c +{ + printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" + cleanup + printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" + exit $? +} + +# trap keyboard interrupt (control-c) +trap control_c SIGINT + + + +# ============================ Everything start from here ============================== + + + +COMPOSE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../docker-compose" +SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" +MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" +MSG_ERROR="\e[31;1m[ERROR]\e[0m" + +# Check if command "docker" is available +if ! hash docker 2>/dev/null; then + printf "$MSG_HEADER$MSG_ERROR docker installation is required to run this script!\n" + printf "[$MSG_HEADER]Visit https://docs.docker.com/engine/installation/ for installation guide" + exit +fi + +# Download docker-compose1.5.0rc if it doesn't exists +if [ ! -f $COMPOSE ]; then + printf "$MSG_HEADER Running for the first time, initialing... \n" + curl -L https://github.com/docker/compose/releases/download/1.5.0rc1/docker-compose-`uname -s`-`uname -m` > $COMPOSE + chmod +x $COMPOSE +fi + +printf "$MSG_HEADER Start running...\n" + +# Disable access control for X server +xhost + + +# Start the nodes! +if ! $COMPOSE --x-networking up -d; then + printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" + exit +fi + +printf "$MSG_HEADER Hit Ctrl+C to stop..\n" + +while true; do read x; done + From 895fb54bb6d10c07aa38fa5eb0f99ea2766be265 Mon Sep 17 00:00:00 2001 From: fatcloud Date: Mon, 11 Jul 2016 03:17:12 +0800 Subject: [PATCH 2/4] Make the script executable from locations other than the same directory it stays --- ros-kinect/kinectViewer.sh | 5 +++-- ros-usbcam/usbcamViewer.sh | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ros-kinect/kinectViewer.sh b/ros-kinect/kinectViewer.sh index 566281d..300e1f5 100755 --- a/ros-kinect/kinectViewer.sh +++ b/ros-kinect/kinectViewer.sh @@ -26,8 +26,8 @@ trap control_c SIGINT # ============================ Everything start from here ============================== - -COMPOSE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../docker-compose" +LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COMPOSE="$LOCATION/../docker-compose" SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" MSG_ERROR="\e[31;1m[ERROR]\e[0m" @@ -52,6 +52,7 @@ printf "$MSG_HEADER Start running...\n" xhost + # Start the nodes! +cd $LOCATION if ! $COMPOSE --x-networking up -d; then printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" exit diff --git a/ros-usbcam/usbcamViewer.sh b/ros-usbcam/usbcamViewer.sh index 47a74d5..16996a7 100755 --- a/ros-usbcam/usbcamViewer.sh +++ b/ros-usbcam/usbcamViewer.sh @@ -26,8 +26,8 @@ trap control_c SIGINT # ============================ Everything start from here ============================== - -COMPOSE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../docker-compose" +LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COMPOSE="$LOCATION/../docker-compose" SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" MSG_ERROR="\e[31;1m[ERROR]\e[0m" @@ -52,6 +52,7 @@ printf "$MSG_HEADER Start running...\n" xhost + # Start the nodes! +cd $LOCATION if ! $COMPOSE --x-networking up -d; then printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" exit From 924d991899383e818c956e265d813a60d6d83dd2 Mon Sep 17 00:00:00 2001 From: fatcloud Date: Mon, 11 Jul 2016 03:42:05 +0800 Subject: [PATCH 3/4] correct some typo --- ros-kinect/kinectViewer.sh | 2 +- ros-usbcam/usbcamViewer.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ros-kinect/kinectViewer.sh b/ros-kinect/kinectViewer.sh index 300e1f5..30724ea 100755 --- a/ros-kinect/kinectViewer.sh +++ b/ros-kinect/kinectViewer.sh @@ -35,7 +35,7 @@ MSG_ERROR="\e[31;1m[ERROR]\e[0m" # Check if command "docker" is available if ! hash docker 2>/dev/null; then printf "$MSG_HEADER$MSG_ERROR docker installation is required to run this script!\n" - printf "[$MSG_HEADER]Visit https://docs.docker.com/engine/installation/ for installation guide" + printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide\n" exit fi diff --git a/ros-usbcam/usbcamViewer.sh b/ros-usbcam/usbcamViewer.sh index 16996a7..34c2476 100755 --- a/ros-usbcam/usbcamViewer.sh +++ b/ros-usbcam/usbcamViewer.sh @@ -35,7 +35,7 @@ MSG_ERROR="\e[31;1m[ERROR]\e[0m" # Check if command "docker" is available if ! hash docker 2>/dev/null; then printf "$MSG_HEADER$MSG_ERROR docker installation is required to run this script!\n" - printf "[$MSG_HEADER]Visit https://docs.docker.com/engine/installation/ for installation guide" + printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide" exit fi From 3bb10184326cd5d61bafaccc91c5fe7392705b2f Mon Sep 17 00:00:00 2001 From: fatcloud Date: Sun, 17 Jul 2016 22:54:31 +0800 Subject: [PATCH 4/4] update yml files and scripts so that they no longer rely on experimental version docker and docker-compose --- docker-compose.yml | 230 ++++++++++++------------- examples/ros-kinect/docker-compose.yml | 46 +++++ examples/ros-kinect/run.sh | 75 ++++++++ examples/ros-usbcam/docker-compose.yml | 44 +++++ examples/ros-usbcam/run.sh | 75 ++++++++ ros-kinect/docker-compose.yml | 46 ----- ros-kinect/kinectViewer.sh | 73 -------- ros-usbcam/docker-compose.yml | 44 ----- ros-usbcam/usbcamViewer.sh | 64 ------- run.sh | 75 ++++++++ 10 files changed, 426 insertions(+), 346 deletions(-) create mode 100644 examples/ros-kinect/docker-compose.yml create mode 100755 examples/ros-kinect/run.sh create mode 100644 examples/ros-usbcam/docker-compose.yml create mode 100755 examples/ros-usbcam/run.sh delete mode 100644 ros-kinect/docker-compose.yml delete mode 100755 ros-kinect/kinectViewer.sh delete mode 100644 ros-usbcam/docker-compose.yml delete mode 100755 ros-usbcam/usbcamViewer.sh create mode 100755 run.sh diff --git a/docker-compose.yml b/docker-compose.yml index 069942c..8f67b4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,170 +1,162 @@ -# ROS Tutorial Talker -talker: - # build: ros-tutorials/. - image: toddsampson:ros-indigo-tutorials - container_name: talker - hostname: talker - net: rosdocker - environment: +version: '2' + +services: + # ROS Tutorial Talker + talker: + # build: ros-tutorials/. + image: toddsampson:ros-indigo-tutorials + container_name: talker + hostname: talker + environment: - "ROS_HOSTNAME=talker" - "ROS_MASTER_URI=http://rosmaster:11311" - # command: bash - command: rosrun roscpp_tutorials talker + # command: bash + command: rosrun roscpp_tutorials talker -# ROS Tutorial Listener -listener: - # build: ros-tutorials/. - image: toddsampson:ros-indigo-tutorials - container_name: listener - hostname: listener - net: rosdocker - environment: + # ROS Tutorial Listener + listener: + # build: ros-tutorials/. + image: toddsampson:ros-indigo-tutorials + container_name: listener + hostname: listener + environment: - "ROS_HOSTNAME=listener" - "ROS_MASTER_URI=http://rosmaster:11311" - # command: bash - command: rosrun roscpp_tutorials listener + # command: bash + command: rosrun roscpp_tutorials listener -# ROS Structure Sensor -structure_sensor: - # build: ros-structure_sensor/. - image: toddsampson/ros-indigo-structure_sensor - container_name: structure_sensor - hostname: structure_sensor - volumes_from: + # ROS Structure Sensor + structure_sensor: + # build: ros-structure_sensor/. + image: toddsampson/ros-indigo-structure_sensor + container_name: structure_sensor + hostname: structure_sensor + volumes_from: - "rosmaster" - net: rosdocker - devices: + devices: - "/dev/bus/usb:/dev/bus/usb" - volumes: + volumes: - "/tmp/.X11-unix:/tmp/.X11-unix" - environment: + environment: - "DISPLAY=$DISPLAY" - "ROS_HOSTNAME=structure_sensor" - "ROS_MASTER_URI=http://rosmaster:11311" - # command: bash - command: roslaunch openni2_launch openni2.launch rgb_processing:=False depth_registration:=True + # command: bash + command: roslaunch openni2_launch openni2.launch rgb_processing:=False depth_registration:=True -# ROS USBCAM -usbcam: - # build: ros-usbcam/. - image: toddsampson/ros-indigo-usbcam - container_name: usbcam - hostname: usbcam - net: rosdocker - devices: + # ROS USBCAM + usbcam: + # build: ros-usbcam/. + image: toddsampson/ros-indigo-usbcam + container_name: usbcam + hostname: usbcam + devices: - "/dev/bus/usb:/dev/bus/usb" - environment: + environment: - "ROS_HOSTNAME=usbcam" - "ROS_MASTER_URI=http://rosmaster:11311" - command: rosrun libuvc_camera camera_node _height:=480 _width:=640 _vendor:=2084 _video_mode:=uncompressed _frame_rate:=30 + command: rosrun libuvc_camera camera_node _height:=480 _width:=640 _vendor:=2084 _video_mode:=uncompressed _frame_rate:=30 -# ROS Leap Motion -leap_motion: - # build: ros-leap_motion/. - image: toddsampson/ros-indigo-leap_motion - container_name: leap_motion - hostname: leap_motion - volumes_from: + # ROS Leap Motion + leap_motion: + # build: ros-leap_motion/. + image: toddsampson/ros-indigo-leap_motion + container_name: leap_motion + hostname: leap_motion + volumes_from: - "rosmaster" - net: rosdocker - privileged: true - devices: + privileged: true + devices: - "/dev/bus/usb:/dev/bus/usb" - volumes: + volumes: # - "/tmp/.X11-unix:/tmp/.X11-unix:rw" - "/tmp/.X11-unix:/tmp/.X11-unix" - environment: + environment: - "QT_X11_NO_MITSHM=1" - "DISPLAY=$DISPLAY" - "ROS_HOSTNAME=leap_motion" - "ROS_MASTER_URI=http://rosmaster:11311" - ports: + ports: - "6437:6437" - command: bash - # command: rosrun leap_motion sender.py + command: bash + # command: rosrun leap_motion sender.py -# ROS Image View -image_view: - # build: ros-image_pipeline/. - image: toddsampson/ros-indigo-image_pipeline - container_name: image_view - hostname: image_view - volumes_from: + # ROS Image View + image_view: + # build: ros-image_pipeline/. + image: toddsampson/ros-indigo-image_pipeline + container_name: image_view + hostname: image_view + volumes_from: - "rosmaster" - net: rosdocker - volumes: + volumes: - "/tmp/.X11-unix:/tmp/.X11-unix" - environment: + environment: - "DISPLAY=$DISPLAY" - "ROS_HOSTNAME=image_view" - "ROS_MASTER_URI=http://rosmaster:11311" - command: rosrun image_view image_view image:=/image_raw + command: rosrun image_view image_view image:=/image_raw -# ROS RVIZ -rviz: - # build: ros-rviz/. - image: toddsampson/ros-indigo-rviz - container_name: rviz - hostname: rviz - net: rosdocker - volumes: - - "/tmp/.X11-unix:/tmp/.X11-unix" - environment: + # ROS RVIZ + rviz: + # build: ros-rviz/. + image: toddsampson/ros-indigo-rviz + container_name: rviz + hostname: rviz + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix" + environment: - "DISPLAY=$DISPLAY" - "ROS_HOSTNAME=rviz" - "ROS_MASTER_URI=http://rosmaster:11311" - command: rosrun rviz rviz + command: rosrun rviz rviz -# ROS Actionlib -actionlib: - build: ros-actionlib/. - # image: toddsampson:ros-indigo-actionlib - container_name: actionlib - hostname: actionlib - net: rosdocker - environment: + # ROS Actionlib + actionlib: + build: ros-actionlib/. + # image: toddsampson:ros-indigo-actionlib + container_name: actionlib + hostname: actionlib + environment: - "ROS_HOSTNAME=actionlib" - "ROS_MASTER_URI=http://rosmaster:11311" - command: bash + command: bash -# ROS Kinect -kinect: - # build: ros-kinect/. - image: toddsampson:ros-indigo-kinect - container_name: kinect - hostname: kinect - net: rosdocker - devices: + # ROS Kinect + kinect: + # build: ros-kinect/. + image: toddsampson:ros-indigo-kinect + container_name: kinect + hostname: kinect + devices: - "/dev/bus/usb:/dev/bus/usb" - environment: + environment: - "ROS_HOSTNAME=kinect" - "ROS_MASTER_URI=http://rosmaster:11311" - # command: bash - command: roslaunch freenect_launch freenect.launch depth_registration:=true + # command: bash + command: roslaunch freenect_launch freenect.launch depth_registration:=true -# ROS Kinect2 -kinect2: - build: ros-kinect2/. - # image: toddsampson:ros-indigo-kinect2 - container_name: kinect2 - hostname: kinect2 - net: rosdocker - devices: + # ROS Kinect2 + kinect2: + build: ros-kinect2/. + # image: toddsampson:ros-indigo-kinect2 + container_name: kinect2 + hostname: kinect2 + devices: - "/dev/bus/usb:/dev/bus/usb" - environment: + environment: - "ROS_HOSTNAME=kinect2" - "ROS_MASTER_URI=http://rosmaster:11311" - # command: bash - command: roslaunch kinect2_bridge kinect2_bridge.launch + # command: bash + command: roslaunch kinect2_bridge kinect2_bridge.launch -# ROS MASTER (ROSCORE) -rosmaster: - image: ros:latest - container_name: rosmaster - hostname: rosmaster - net: rosdocker - ports: + # ROS MASTER (ROSCORE) + rosmaster: + image: ros:latest + container_name: rosmaster + hostname: rosmaster + ports: - "11311:11311" - command: roscore + command: roscore diff --git a/examples/ros-kinect/docker-compose.yml b/examples/ros-kinect/docker-compose.yml new file mode 100644 index 0000000..6277ce8 --- /dev/null +++ b/examples/ros-kinect/docker-compose.yml @@ -0,0 +1,46 @@ +version: '2' + +services: + # ROS Kinect + kinect: + # build: ros-kinect/. + image: toddsampson/ros-indigo-kinect + container_name: kinect + hostname: kinect + devices: + - "/dev/bus/usb:/dev/bus/usb" + environment: + - "ROS_HOSTNAME=kinect" + - "ROS_MASTER_URI=http://rosmaster:11311" + # command: bash + command: roslaunch freenect_launch freenect.launch depth_registration:=true + + + # ROS Image View + image_view: + # build: ros-image_pipeline/. + image: toddsampson/ros-indigo-image_pipeline + container_name: image_view + hostname: image_view + volumes_from: + - "rosmaster" + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix" + environment: + - "DISPLAY=$DISPLAY" + - "ROS_HOSTNAME=image_view" + - "ROS_MASTER_URI=http://rosmaster:11311" + command: rosrun image_view image_view image:=/camera/depth_registered/image + + # command: rosrun image_view image_view image:=/image_raw + + + + # ROS MASTER (ROSCORE) + rosmaster: + image: ros:latest + container_name: rosmaster + hostname: rosmaster + ports: + - "11311:11311" + command: roscore diff --git a/examples/ros-kinect/run.sh b/examples/ros-kinect/run.sh new file mode 100755 index 0000000..00371a7 --- /dev/null +++ b/examples/ros-kinect/run.sh @@ -0,0 +1,75 @@ +#! /usr/bin/env bash + +cleanup() +# example cleanup function +{ + docker-compose stop + docker-compose rm -f + xhost - + return $? +} + +control_c() +# run if user hits control-c +{ + printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" + cleanup + printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" + exit $? +} + +# trap keyboard interrupt (control-c) +trap control_c SIGINT + + + +# ============================ Everything start from here ============================== + + + +SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" +MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" +MSG_ERROR="\e[31;1m[ERROR]\e[0m" + +# Check if command "docker" is available +if ! hash docker 2>/dev/null; then + printf "$MSG_HEADER$MSG_ERROR docker 1.10 or later is required!\n" + printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide\n" + printf "$MSG_HEADER $SCRIPT_NAME is aborted\n" + exit +fi + +# Check if docker-compose exists. +# If not, ask user if download docker-compose1.6.2 if it doesn't exists +if ! hash docker-compose 2>/dev/null; then + printf "$MSG_HEADER docker-compose 1.6 or later is required\n" + printf "$MSG_HEADER Would you like to install docker-compose 1.6.2 at /usr/local/bin/docker-compose?\n" + printf "$MSG_HEADER This operation requires root privileges (Y/N)" + read -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]] + then + curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > .docker-compose.tmp && sudo mv .docker-compose.tmp /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + else + printf "$MSG_HEADER$MSG_ERROR docker-compose 1.6 or later is required\n" + printf "$MSG_HEADER To install manually please refer to https://docs.docker.com/compose/install/\n" + printf "$MSG_HEADER $SCRIPT_NAME is aborted\n" + exit + fi +fi + +printf "$MSG_HEADER Start running...\n" + +# Disable access control for X server +xhost + + +# Start the nodes! +if ! docker-compose up -d; then + printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" + exit +fi + +printf "$MSG_HEADER Hit Ctrl+C to stop..\n" + +while true; do read x; done + diff --git a/examples/ros-usbcam/docker-compose.yml b/examples/ros-usbcam/docker-compose.yml new file mode 100644 index 0000000..6afe695 --- /dev/null +++ b/examples/ros-usbcam/docker-compose.yml @@ -0,0 +1,44 @@ +version: '2' + +services: + usbcam: + # build: ros-usbcam/. + image: toddsampson/ros-indigo-usbcam + container_name: usbcam + hostname: usbcam + devices: + - "/dev/bus/usb:/dev/bus/usb" + environment: + - "ROS_HOSTNAME=usbcam" + - "ROS_MASTER_URI=http://rosmaster:11311" + command: rosrun libuvc_camera camera_node _height:=480 _width:=640 _vendor:=2084 _video_mode:=uncompressed _frame_rate:=30 + + + # ROS Image View + image_view: + # build: ros-image_pipeline/. + image: toddsampson/ros-indigo-image_pipeline + container_name: image_view + hostname: image_view + volumes_from: + - "rosmaster" + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix" + environment: + - "DISPLAY=$DISPLAY" + - "ROS_HOSTNAME=image_view" + - "ROS_MASTER_URI=http://rosmaster:11311" + command: rosrun image_view image_view image:=/image_raw + + # command: rosrun image_view image_view image:=/image_raw + + + + # ROS MASTER (ROSCORE) + rosmaster: + image: ros:latest + container_name: rosmaster + hostname: rosmaster + ports: + - "11311:11311" + command: roscore diff --git a/examples/ros-usbcam/run.sh b/examples/ros-usbcam/run.sh new file mode 100755 index 0000000..00371a7 --- /dev/null +++ b/examples/ros-usbcam/run.sh @@ -0,0 +1,75 @@ +#! /usr/bin/env bash + +cleanup() +# example cleanup function +{ + docker-compose stop + docker-compose rm -f + xhost - + return $? +} + +control_c() +# run if user hits control-c +{ + printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" + cleanup + printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" + exit $? +} + +# trap keyboard interrupt (control-c) +trap control_c SIGINT + + + +# ============================ Everything start from here ============================== + + + +SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" +MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" +MSG_ERROR="\e[31;1m[ERROR]\e[0m" + +# Check if command "docker" is available +if ! hash docker 2>/dev/null; then + printf "$MSG_HEADER$MSG_ERROR docker 1.10 or later is required!\n" + printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide\n" + printf "$MSG_HEADER $SCRIPT_NAME is aborted\n" + exit +fi + +# Check if docker-compose exists. +# If not, ask user if download docker-compose1.6.2 if it doesn't exists +if ! hash docker-compose 2>/dev/null; then + printf "$MSG_HEADER docker-compose 1.6 or later is required\n" + printf "$MSG_HEADER Would you like to install docker-compose 1.6.2 at /usr/local/bin/docker-compose?\n" + printf "$MSG_HEADER This operation requires root privileges (Y/N)" + read -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]] + then + curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > .docker-compose.tmp && sudo mv .docker-compose.tmp /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + else + printf "$MSG_HEADER$MSG_ERROR docker-compose 1.6 or later is required\n" + printf "$MSG_HEADER To install manually please refer to https://docs.docker.com/compose/install/\n" + printf "$MSG_HEADER $SCRIPT_NAME is aborted\n" + exit + fi +fi + +printf "$MSG_HEADER Start running...\n" + +# Disable access control for X server +xhost + + +# Start the nodes! +if ! docker-compose up -d; then + printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" + exit +fi + +printf "$MSG_HEADER Hit Ctrl+C to stop..\n" + +while true; do read x; done + diff --git a/ros-kinect/docker-compose.yml b/ros-kinect/docker-compose.yml deleted file mode 100644 index 86473ef..0000000 --- a/ros-kinect/docker-compose.yml +++ /dev/null @@ -1,46 +0,0 @@ -# ROS Kinect -kinect: - # build: ros-kinect/. - image: toddsampson/ros-indigo-kinect - container_name: kinect - hostname: kinect - net: rosdocker - devices: - - "/dev/bus/usb:/dev/bus/usb" - environment: - - "ROS_HOSTNAME=kinect" - - "ROS_MASTER_URI=http://rosmaster:11311" - # command: bash - command: roslaunch freenect_launch freenect.launch depth_registration:=true - - -# ROS Image View -image_view: - # build: ros-image_pipeline/. - image: toddsampson/ros-indigo-image_pipeline - container_name: image_view - hostname: image_view - volumes_from: - - "rosmaster" - net: rosdocker - volumes: - - "/tmp/.X11-unix:/tmp/.X11-unix" - environment: - - "DISPLAY=$DISPLAY" - - "ROS_HOSTNAME=image_view" - - "ROS_MASTER_URI=http://rosmaster:11311" - command: rosrun image_view image_view image:=/camera/depth_registered/image - - # command: rosrun image_view image_view image:=/image_raw - - - -# ROS MASTER (ROSCORE) -rosmaster: - image: ros:latest - container_name: rosmaster - hostname: rosmaster - net: rosdocker - ports: - - "11311:11311" - command: roscore diff --git a/ros-kinect/kinectViewer.sh b/ros-kinect/kinectViewer.sh deleted file mode 100755 index 30724ea..0000000 --- a/ros-kinect/kinectViewer.sh +++ /dev/null @@ -1,73 +0,0 @@ -#! /usr/bin/env bash - -cleanup() -# example cleanup function -{ - $COMPOSE stop - $COMPOSE rm -f - xhost - - return $? -} - -control_c() -# run if user hits control-c -{ - printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" - cleanup - printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" - exit $? -} - -# trap keyboard interrupt (control-c) -trap control_c SIGINT - - - -# ============================ Everything start from here ============================== - - -LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -COMPOSE="$LOCATION/../docker-compose" -SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" -MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" -MSG_ERROR="\e[31;1m[ERROR]\e[0m" - -# Check if command "docker" is available -if ! hash docker 2>/dev/null; then - printf "$MSG_HEADER$MSG_ERROR docker installation is required to run this script!\n" - printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide\n" - exit -fi - -# Download docker-compose1.5.0rc if it doesn't exists -if [ ! -f $COMPOSE ]; then - printf "$MSG_HEADER Running for the first time, initialing... \n" - curl -L https://github.com/docker/compose/releases/download/1.5.0rc1/docker-compose-`uname -s`-`uname -m` > $COMPOSE - chmod +x $COMPOSE -fi - -printf "$MSG_HEADER Start running...\n" - -# Disable access control for X server -xhost + - -# Start the nodes! -cd $LOCATION -if ! $COMPOSE --x-networking up -d; then - printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" - exit -fi - -# Some dirty hack: restart container kinect after 5 seconds -printf "$MSG_HEADER For some wierd reason, kinect node never work without starting it twice\n" -printf "$MSG_HEADER So we are restarting it within 5 seconds." -for i in `seq 1 5`; -do - sleep 1 - printf "." -done -docker restart -t 5 kinect -printf "$MSG_HEADER Hit Ctrl+C to stop..\n" - -while true; do read x; done - diff --git a/ros-usbcam/docker-compose.yml b/ros-usbcam/docker-compose.yml deleted file mode 100644 index 9cd9262..0000000 --- a/ros-usbcam/docker-compose.yml +++ /dev/null @@ -1,44 +0,0 @@ -usbcam: - # build: ros-usbcam/. - image: toddsampson/ros-indigo-usbcam - container_name: usbcam - hostname: usbcam - net: rosdocker - devices: - - "/dev/bus/usb:/dev/bus/usb" - environment: - - "ROS_HOSTNAME=usbcam" - - "ROS_MASTER_URI=http://rosmaster:11311" - command: rosrun libuvc_camera camera_node _height:=480 _width:=640 _vendor:=2084 _video_mode:=uncompressed _frame_rate:=30 - - -# ROS Image View -image_view: - # build: ros-image_pipeline/. - image: toddsampson/ros-indigo-image_pipeline - container_name: image_view - hostname: image_view - volumes_from: - - "rosmaster" - net: rosdocker - volumes: - - "/tmp/.X11-unix:/tmp/.X11-unix" - environment: - - "DISPLAY=$DISPLAY" - - "ROS_HOSTNAME=image_view" - - "ROS_MASTER_URI=http://rosmaster:11311" - command: rosrun image_view image_view image:=/image_raw - - # command: rosrun image_view image_view image:=/image_raw - - - -# ROS MASTER (ROSCORE) -rosmaster: - image: ros:latest - container_name: rosmaster - hostname: rosmaster - net: rosdocker - ports: - - "11311:11311" - command: roscore diff --git a/ros-usbcam/usbcamViewer.sh b/ros-usbcam/usbcamViewer.sh deleted file mode 100755 index 34c2476..0000000 --- a/ros-usbcam/usbcamViewer.sh +++ /dev/null @@ -1,64 +0,0 @@ -#! /usr/bin/env bash - -cleanup() -# example cleanup function -{ - $COMPOSE stop - $COMPOSE rm -f - xhost - - return $? -} - -control_c() -# run if user hits control-c -{ - printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" - cleanup - printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" - exit $? -} - -# trap keyboard interrupt (control-c) -trap control_c SIGINT - - - -# ============================ Everything start from here ============================== - - -LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -COMPOSE="$LOCATION/../docker-compose" -SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" -MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" -MSG_ERROR="\e[31;1m[ERROR]\e[0m" - -# Check if command "docker" is available -if ! hash docker 2>/dev/null; then - printf "$MSG_HEADER$MSG_ERROR docker installation is required to run this script!\n" - printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide" - exit -fi - -# Download docker-compose1.5.0rc if it doesn't exists -if [ ! -f $COMPOSE ]; then - printf "$MSG_HEADER Running for the first time, initialing... \n" - curl -L https://github.com/docker/compose/releases/download/1.5.0rc1/docker-compose-`uname -s`-`uname -m` > $COMPOSE - chmod +x $COMPOSE -fi - -printf "$MSG_HEADER Start running...\n" - -# Disable access control for X server -xhost + - -# Start the nodes! -cd $LOCATION -if ! $COMPOSE --x-networking up -d; then - printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" - exit -fi - -printf "$MSG_HEADER Hit Ctrl+C to stop..\n" - -while true; do read x; done - diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..00371a7 --- /dev/null +++ b/run.sh @@ -0,0 +1,75 @@ +#! /usr/bin/env bash + +cleanup() +# example cleanup function +{ + docker-compose stop + docker-compose rm -f + xhost - + return $? +} + +control_c() +# run if user hits control-c +{ + printf "\n$MSG_HEADER SIGINT received... now calling the containers to stop...\n" + cleanup + printf "$MSG_HEADER $SCRIPT_NAME exited normally.\n" + exit $? +} + +# trap keyboard interrupt (control-c) +trap control_c SIGINT + + + +# ============================ Everything start from here ============================== + + + +SCRIPT_NAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" +MSG_HEADER="\e[32;1m[$SCRIPT_NAME]\e[0m" +MSG_ERROR="\e[31;1m[ERROR]\e[0m" + +# Check if command "docker" is available +if ! hash docker 2>/dev/null; then + printf "$MSG_HEADER$MSG_ERROR docker 1.10 or later is required!\n" + printf "$MSG_HEADER Visit https://docs.docker.com/engine/installation/ for installation guide\n" + printf "$MSG_HEADER $SCRIPT_NAME is aborted\n" + exit +fi + +# Check if docker-compose exists. +# If not, ask user if download docker-compose1.6.2 if it doesn't exists +if ! hash docker-compose 2>/dev/null; then + printf "$MSG_HEADER docker-compose 1.6 or later is required\n" + printf "$MSG_HEADER Would you like to install docker-compose 1.6.2 at /usr/local/bin/docker-compose?\n" + printf "$MSG_HEADER This operation requires root privileges (Y/N)" + read -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]] + then + curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > .docker-compose.tmp && sudo mv .docker-compose.tmp /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + else + printf "$MSG_HEADER$MSG_ERROR docker-compose 1.6 or later is required\n" + printf "$MSG_HEADER To install manually please refer to https://docs.docker.com/compose/install/\n" + printf "$MSG_HEADER $SCRIPT_NAME is aborted\n" + exit + fi +fi + +printf "$MSG_HEADER Start running...\n" + +# Disable access control for X server +xhost + + +# Start the nodes! +if ! docker-compose up -d; then + printf "$MSG_HEADER$MSG_ERROR $SCRIPT_NAME exited on error\n" + exit +fi + +printf "$MSG_HEADER Hit Ctrl+C to stop..\n" + +while true; do read x; done +