Skip to content

Commit

Permalink
updated dockerfile and profile to fix permission error; inference sti…
Browse files Browse the repository at this point in the history
…ll not fixed. print statements included in node files
  • Loading branch information
Rijin committed Dec 1, 2023
1 parent e95711a commit 9d3bc04
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
21 changes: 12 additions & 9 deletions docker/perception/camera_segmentation.Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
Expand All @@ -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 && \
Expand All @@ -61,6 +57,13 @@ RUN . /opt/ros/$ROS_DISTRO/setup.bash && \

# Entrypoint will run before any CMD on launch. Sources ~/opt/<ROS_DISTRO>/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"]

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"]
3 changes: 2 additions & 1 deletion profiles/docker-compose.perception.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/perception/camera_segmentation/requirements.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion watod-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ ACTIVE_PROFILES="perception vis_tools data_stream"
## Tag to use. Images are formatted as <IMAGE_NAME>:<TAG> with forward slashes replaced with dashes.
## DEFAULT = <your_current_github_branch>

TAG="justin"
TAG="rijin"

FOXGLOVE_BRIDGE_PORT=5772

0 comments on commit 9d3bc04

Please sign in to comment.