diff --git a/docker/perception/camera_segmentation.Dockerfile b/docker/perception/camera_segmentation.Dockerfile index 5e9a2698..de7051db 100644 --- a/docker/perception/camera_segmentation.Dockerfile +++ b/docker/perception/camera_segmentation.Dockerfile @@ -1,6 +1,5 @@ # ================= Dependencies =================== -FROM leungjch/cuda118-tensorrt-base:latest as base - +FROM leungjch/cuda118-tensorrt-base as base # Segmentation Dependencies # Install essential packages and dependencies RUN sudo apt-get update && sudo apt-get install -y \ @@ -26,10 +25,6 @@ RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel RUN pip3 install ninja RUN pip install --no-cache-dir --upgrade requests urllib3 -# fix user permissions when deving in container -COPY docker/fixuid_setup.sh /project/fixuid_setup.sh -RUN /project/fixuid_setup.sh -USER docker:docker ENV DEBIAN_FRONTEND noninteractive # RUN sudo chsh -s /bin/bash @@ -48,7 +43,8 @@ COPY src/wato_msgs/sample_msgs sample_msgs # RUN sudo apt-get install ros-humble-cv-bridge COPY src/perception/camera_segmentation/requirements.txt camera_segmentation/requirements.txt -RUN pip3 install --no-cache-dir --upgrade --trusted-host pypi.org --trusted-host shi-labs.com --trusted-host files.pythonhosted.org -r camera_segmentation/requirements.txt +RUN pip3 install --ignore-installed PyYAML +RUN pip3 install --ignore-installed --no-cache-dir --upgrade --trusted-host pypi.org --trusted-host shi-labs.com --trusted-host files.pythonhosted.org -r camera_segmentation/requirements.txt WORKDIR /home/docker/ament_ws RUN . /opt/ros/$ROS_DISTRO/setup.bash && \ @@ -61,6 +57,13 @@ RUN . /opt/ros/$ROS_DISTRO/setup.bash && \ # Entrypoint will run before any CMD on launch. Sources ~/opt//setup.bash and ~/ament_ws/install/setup.bash COPY docker/wato_ros_entrypoint.sh /home/docker/wato_ros_entrypoint.sh +COPY docker/wato_ros_entrypoint.sh /ros_entrypoint.sh COPY docker/.bashrc /home/docker/.bashrc -ENTRYPOINT ["/usr/local/bin/fixuid", "-q", "/home/docker/wato_ros_entrypoint.sh"] -CMD ["sh", "/home/docker/ament_ws/src/camera_segmentation/camera_segmentation/run.sh"] \ No newline at end of file + +RUN chmod -R 777 /home/docker +RUN sudo mkdir -p -m 777 /.ros +RUN chmod -R 777 /.ros +USER docker:docker + +ENTRYPOINT ["sh", "/home/docker/wato_ros_entrypoint.sh"] +CMD ["/bin/bash", "/home/docker/ament_ws/src/camera_segmentation/camera_segmentation/run.sh"] \ No newline at end of file diff --git a/profiles/docker-compose.perception.yaml b/profiles/docker-compose.perception.yaml index d271d8e0..70468c1b 100644 --- a/profiles/docker-compose.perception.yaml +++ b/profiles/docker-compose.perception.yaml @@ -19,7 +19,8 @@ services: - "${CAMERA_SEGMENTATION_IMAGE:?}:${TAG}" - "${CAMERA_SEGMENTATION_IMAGE:?}:main" image: "${CAMERA_SEGMENTATION_IMAGE:?}:${TAG}" - user: ${FIXUID:?}:${FIXGID:?} + # user: ${FIXUID:?}:${FIXGID:?} + user: root volumes: - ../src/perception/camera_segmentation:/home/docker/ament_ws/src/camera_segmentation - /mnt/wato-drive2/perception-weights/semantic_segmentation:/home/docker/ament_ws/src/camera_segmentation/camera_segmentation/models diff --git a/src/perception/camera_segmentation/camera_segmentation/camera_segmentation_node.py b/src/perception/camera_segmentation/camera_segmentation/camera_segmentation_node.py index 7e8e81be..32872f56 100755 --- a/src/perception/camera_segmentation/camera_segmentation/camera_segmentation_node.py +++ b/src/perception/camera_segmentation/camera_segmentation/camera_segmentation_node.py @@ -43,11 +43,14 @@ def __init__(self): # Fetch parameters from yaml file self.declare_parameter('camera_topic', '/CAM_FRONT/image_rect_compressed') self.declare_parameter('publish_topic', '/camera_segmentation') - camera_topic = self.get_parameter('camera_topic').get_parameter_value().string_value + # camera_topic = self.get_parameter('camera_topic').get_parameter_value().string_value + camera_topic = '/CAM_FRONT/image_rect_compressed' + self.compressed = True publish_topic = self.get_parameter('publish_topic').get_parameter_value().string_value + # Create ROS2 publisher and subscriber - self.publisher_ = self.create_publisher(Image, publish_topic, 10) + self.publisher_ = self.create_publisher(Image if not self.compressed else CompressedImage, publish_topic, 10) self.subscriber_ = self.create_subscription(Image, camera_topic, self.image_callback, 10) self.i = 0 @@ -68,8 +71,12 @@ def __init__(self): self.predictor, self.metadata = self.setup_modules("cityscapes", "/home/docker/ament_ws/src/camera_segmentation/camera_segmentation/models/250_16_dinat_l_oneformer_cityscapes_90k.pth", False) self.cv_bridge = CvBridge() + + print("Done initializing node") def image_callback(self, msg): + self.get_logger().info('Got callback') + # Convert ROS2 image into cv2 if self.compressed: np_arr = np.frombuffer(msg.data, np.uint8) @@ -90,7 +97,7 @@ def image_callback(self, msg): # Convert cv2 image back to a ROS2 image img_msg = self.cv_bridge.cv2_to_imgmsg(out, "bgr8") - + self.get_logger().info("Ran inference") # Publish ROS2 image self.publisher_.publish(img_msg) self.get_logger().info('Publishing image: "%s"' % msg.data) diff --git a/src/perception/camera_segmentation/requirements.txt b/src/perception/camera_segmentation/requirements.txt old mode 100644 new mode 100755 index 932c5593..3e727f4d --- a/src/perception/camera_segmentation/requirements.txt +++ b/src/perception/camera_segmentation/requirements.txt @@ -14,7 +14,7 @@ imutils -f https://shi-labs.com/natten/wheels/cu111/torch1.9/index.html natten==0.14.2 cython -setuptools==59.5.0 +setuptools scipy shapely h5py diff --git a/watod-config.sh b/watod-config.sh index afa7a7fd..6e5ac099 100755 --- a/watod-config.sh +++ b/watod-config.sh @@ -18,6 +18,6 @@ ACTIVE_PROFILES="perception vis_tools data_stream" ## Tag to use. Images are formatted as : with forward slashes replaced with dashes. ## DEFAULT = -TAG="justin" +TAG="rijin" FOXGLOVE_BRIDGE_PORT=5772