From 8436b23cae5a0723f80ef282172a9ff81e195135 Mon Sep 17 00:00:00 2001
From: rschoene <rene.schoene@tu-dresden.de>
Date: Fri, 15 Jul 2022 16:09:32 +0200
Subject: [PATCH] configurable, updated docker build

---
 config/config-a-docker.yaml                   |  5 ++
 config/config-b-docker.yaml                   |  9 +++
 config/mosquitto.conf                         |  5 ++
 .../ros3rag.coordinator                       |  0
 config/web-config.yaml                        |  3 +
 docker-compose.yml                            | 74 ++++++++++---------
 robotic-controller/Dockerfile                 |  6 +-
 ros3rag                                       |  2 +-
 web-ros3rag                                   |  2 +-
 9 files changed, 70 insertions(+), 36 deletions(-)
 create mode 100644 config/config-a-docker.yaml
 create mode 100644 config/config-b-docker.yaml
 create mode 100644 config/mosquitto.conf
 rename ros3rag.coordinator => config/ros3rag.coordinator (100%)
 create mode 100644 config/web-config.yaml

diff --git a/config/config-a-docker.yaml b/config/config-a-docker.yaml
new file mode 100644
index 0000000..6ad1378
--- /dev/null
+++ b/config/config-a-docker.yaml
@@ -0,0 +1,5 @@
+mqttHost: "mosquitto"
+filenameRegions: "src/main/resources/regions-a-placeworld.json"
+forA:
+  filenameInitialScene: "src/main/resources/config-scene-a-placeworld.json"
+coordinatorMqttTopicPrefix: "coordinating/rag-a"
diff --git a/config/config-b-docker.yaml b/config/config-b-docker.yaml
new file mode 100644
index 0000000..5ea8108
--- /dev/null
+++ b/config/config-b-docker.yaml
@@ -0,0 +1,9 @@
+mqttHost: "mosquitto"
+filenameRegions: "src/main/resources/regions-b-placeworld.json"
+forB:
+  topicsSceneUpdate:
+    - "/ceti_cell_placeworld/scene/update"
+    - "/ceti_cell_2_placeworld/scene/update"
+  topicCommand: "/ceti_cell_placeworld/command"
+  filenameReachability: "src/main/resources/reachability-b-placeworld.json"
+coordinatorMqttTopicPrefix: "coordinating/rag-b"
diff --git a/config/mosquitto.conf b/config/mosquitto.conf
new file mode 100644
index 0000000..40dd92b
--- /dev/null
+++ b/config/mosquitto.conf
@@ -0,0 +1,5 @@
+# This is a Mosquitto configuration file that creates a listener on port 1883
+# that allows unauthenticated access.
+
+listener 1883
+allow_anonymous true
diff --git a/ros3rag.coordinator b/config/ros3rag.coordinator
similarity index 100%
rename from ros3rag.coordinator
rename to config/ros3rag.coordinator
diff --git a/config/web-config.yaml b/config/web-config.yaml
new file mode 100644
index 0000000..7a82698
--- /dev/null
+++ b/config/web-config.yaml
@@ -0,0 +1,3 @@
+image_directory: "/shared_directory_images"
+mqtt_server: "mosquitto"
+docker: true
diff --git a/docker-compose.yml b/docker-compose.yml
index e71c853..f656f09 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,65 +1,73 @@
 version: '3'
 services:
-  ros_core:
-    build: .
-    network_mode: host
-    user: "user"
-    command: ['roscore']
+  # ros_core:
+  #   build: "robotic-controller"
+  #   user: "user"
+  #   command: ['/entrypoint.sh', 'roscore']
 
-  ros_place_a:
-    build: .
-    network_mode: host
-    user: "user"
-    # TODO: update command
-    command: ['rosrun', 'cgv_connector', 'dummy_rag_connector']
+  # ros_place_a:
+  #   build: "robotic-controller"
+  #   user: "user"
+  #   # TODO: update command
+  #   command: ['/entrypoint.sh', 'rosrun', 'cgv_connector', 'dummy_rag_connector']
 
   ros_place_b1:
-    build: .
-    network_mode: host
+    build: "robotic-controller"
     user: "user"
-    # TODO: update command
-    command: ['rosrun', 'cgv_connector', 'dummy_rbg_connector']
+    command: ['/entrypoint.sh', 'roslaunch', 'ccf_immersive_sorting', 'noop-sim-cell_ceti-table-1-placeworld.launch']
 
-  ros_place_b1:
-    build: .
-    network_mode: host
-    user: "user"
-    # TODO: update command
-    command: ['rosrun', 'cgv_connector', 'dummy_rbg_connector']
+  ros_place_b2:
+    build: "robotic-controller"
+    command: ['/entrypoint.sh', 'roslaunch', 'ccf_immersive_sorting', 'noop-sim-cell_ceti-table-2-placeworld.launch']
+    volumes:
+      - "/tmp/.X11-unix:/tmp/.X11-unix:rw"
+      - "/tmp/.docker.xauth:/tmp/.docker.xauth:rw"
+    environment:
+      - "XAUTHORITY=/tmp/.docker.xauth"
+      - "DISPLAY=$DISPLAY"
+    devices:
+      - "/dev/dri"
+    user: "ros"
 
   coordinator:
     build: coordinator
-    network_mode: host
     volumes:
-      - "./coordinator/examples/ros3rag.coordinator:/config.coordinator"
+      # - "./coordinator/examples/ros3rag.coordinator:/config.coordinator"
+      - "./config/ros3rag.coordinator:/config.coordinator"
     # TODO: remove --dry-run
     entrypoint: ["/bin/bash", "-c", "./build/install/coordinator/bin/coordinator /config.coordinator --dry-run"]
 
   rag_place_a:
     build: ros3rag
-    network_mode: host
     environment:
       - "TARGET=ros3rag.placeA"
+      - "CONFIG_FILE=/ros3rag/config-a-docker.yaml"
+    volumes:
+      - "./config/config-a-docker.yaml:/ros3rag/config-a-docker.yaml"
 
   rag_place_b:
     build: ros3rag
-    network_mode: host
     environment:
       - "TARGET=ros3rag.placeB"
+      - "CONFIG_FILE=/ros3rag/config-b-docker.yaml"
+    volumes:
+      - "./shared_directory_images:/ros3rag/ros3rag.placeB/images"
+      - "./config/config-b-docker.yaml:/ros3rag/config-b-docker.yaml"
 
-  web_rag:
+  web:
     build: web-ros3rag
-    network_mode: host
+    volumes:
+      - "./shared_directory_images:/shared_directory_images"
+      - "./config/web-config.yaml:/app/config.yaml"
     ports:
       - "8050:8050"
 
   mosquitto:
     image: eclipse-mosquitto
     container_name: mqtt
-    network_mode: host
     restart: unless-stopped
-    # volumes:
-    #   - ./docker/mosquitto.conf:/mosquitto/config/mosquitto.conf
-    ports:
-      - "1883:1883"
-      - "9001:9001"
+    volumes:
+      - ./config/mosquitto.conf:/mosquitto/config/mosquitto.conf
+    # ports:
+    #   - "41883:1883"
+    #   - "49001:9001"
diff --git a/robotic-controller/Dockerfile b/robotic-controller/Dockerfile
index 798ad63..79f054a 100644
--- a/robotic-controller/Dockerfile
+++ b/robotic-controller/Dockerfile
@@ -1,5 +1,7 @@
 FROM ros:noetic-ros-core
 
+RUN sed -i 's/^deb/deb [trusted=yes]/' /etc/apt/sources.list.d/ros1-latest.list
+
 # update and install dependencies
 RUN apt-get update && apt-get upgrade -y && apt-get install -y \
     python3-osrf-pycommon \
@@ -40,6 +42,8 @@ RUN apt-get install -y \
     ros-noetic-moveit-ros-visualization \
     ros-noetic-joint-state-publisher-gui
 
+RUN apt-get install -y \
+    libnng1 libnng-dev
 
 ENV HOME /home/user
 RUN useradd --create-home --home-dir $HOME user && chmod -R u+rwx $HOME && chown -R user:user $HOME
@@ -54,7 +58,7 @@ RUN rosdep update
 
 # temporary switch to root to be able to install the ROS package dependencies of the workspace
 USER root
-RUN rosdep install --from-paths ${HOME}/catkin_ws -i -y
+RUN rosdep install --from-paths ${HOME}/catkin_ws -i -y -r
 USER user
 
 RUN ls -al /home/user
diff --git a/ros3rag b/ros3rag
index eafdc07..3197411 160000
--- a/ros3rag
+++ b/ros3rag
@@ -1 +1 @@
-Subproject commit eafdc0741cba0abb82a88c295d1a3d365ef2a04b
+Subproject commit 31974114f8867e38907a5100ad0b9a33f78aa076
diff --git a/web-ros3rag b/web-ros3rag
index 28f4dd8..5252118 160000
--- a/web-ros3rag
+++ b/web-ros3rag
@@ -1 +1 @@
-Subproject commit 28f4dd83d8cd993c8a94bc129c85439048f24d90
+Subproject commit 525211869b81bbaaab0e56f267dd5c831f709720
-- 
GitLab