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/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 +