Skip to content

Commit

Permalink
Clean up dockerfile and docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
leungjch committed Mar 8, 2024
1 parent 90e8be0 commit 60069b8
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ FROM ${PADDLE_INFERENCE_BUILD_URL} as PADDLE_INFERENCE_BUILD
################################ Source ################################
FROM ${BASE_BUILD_IMAGE} as source



WORKDIR ${AMENT_WS}/src

# Copy in the paddle inference library
Expand All @@ -31,10 +29,7 @@ RUN apt-get -qq update && rosdep update && \
################################# Dependencies ################################
FROM ${BASE_BUILD_IMAGE} as dependencies

# install tensorrt
RUN apt update && apt install -y tensorrt

RUN apt update && apt install -y ros-humble-cv-bridge libopencv-dev
RUN apt update && apt install -y tensorrt ros-humble-cv-bridge libopencv-dev

# Install Rosdep requirements
COPY --from=source /tmp/colcon_install_list /tmp/colcon_install_list
Expand All @@ -52,7 +47,6 @@ RUN apt-get -qq autoremove -y && apt-get -qq autoclean && apt-get -qq clean && \
################################ Build ################################
FROM dependencies as build


# Build ROS2 packages
WORKDIR ${AMENT_WS}
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
Expand All @@ -62,18 +56,17 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
# 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 ${AMENT_WS}/wato_ros_entrypoint.sh

# Add /home/bolty/ament_ws/install/semantic_segmentation/lib/semantic_segmentation to LD_LIBRARY_PATH
# Add runtime libraries to path
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/
# Add /usr/local/lib to LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# /home/bolty/ament_ws/install/semantic_segmentation/lib/semantic_segmentation/

ENTRYPOINT ["./wato_ros_entrypoint.sh"]

# ################################ Prod ################################
# FROM build as deploy
FROM build as deploy

# # Source Cleanup and Security Setup
# RUN chown -R $USER:$USER ${AMENT_WS}
# RUN rm -rf src/*
# Source Cleanup and Security Setup
RUN chown -R $USER:$USER ${AMENT_WS}
RUN rm -rf src/*

# USER ${USER}
USER ${USER}
163 changes: 81 additions & 82 deletions modules/docker-compose.perception.yaml
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
version: "3.8"

services:
# radar_object_detection:
# build:
# context: ..
# dockerfile: docker/perception/radar_object_detection/radar_object_detection.Dockerfile
# cache_from:
# - "${PERCEPTION_RADAR_OBJECT_DETECTION_IMAGE:?}:${TAG}"
# - "${PERCEPTION_RADAR_OBJECT_DETECTION_IMAGE:?}:main"
# target: deploy
# image: "${PERCEPTION_RADAR_OBJECT_DETECTION_IMAGE:?}:${TAG}"
# command: /bin/bash -c "ros2 launch radar_object_detection radar_object_detection.launch.py"
radar_object_detection:
build:
context: ..
dockerfile: docker/perception/radar_object_detection/radar_object_detection.Dockerfile
cache_from:
- "${PERCEPTION_RADAR_OBJECT_DETECTION_IMAGE:?}:build_${TAG}"
- "${PERCEPTION_RADAR_OBJECT_DETECTION_IMAGE:?}:build_main"
target: deploy
image: "${PERCEPTION_RADAR_OBJECT_DETECTION_IMAGE:?}:${TAG}"
command: /bin/bash -c "ros2 launch radar_object_detection radar_object_detection.launch.py"

# camera_object_detection:
# build:
# context: ..
# dockerfile: docker/perception/camera_object_detection/camera_object_detection.Dockerfile
# cache_from:
# - "${PERCEPTION_CAMERA_OBJECT_DETECTION_IMAGE:?}:${TAG}"
# - "${PERCEPTION_CAMERA_OBJECT_DETECTION_IMAGE:?}:main"
# target: deploy
# image: "${PERCEPTION_CAMERA_OBJECT_DETECTION_IMAGE:?}:${TAG}"
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [ gpu ]
# command: /bin/bash -c "ros2 launch camera_object_detection nuscenes_launch.py"
# volumes:
# - /mnt/wato-drive2/perception_models/yolov8s.pt:/perception_models/yolov8s.pt
camera_object_detection:
build:
context: ..
dockerfile: docker/perception/camera_object_detection/camera_object_detection.Dockerfile
cache_from:
- "${PERCEPTION_CAMERA_OBJECT_DETECTION_IMAGE:?}:build_${TAG}"
- "${PERCEPTION_CAMERA_OBJECT_DETECTION_IMAGE:?}:build_main"
target: deploy
image: "${PERCEPTION_CAMERA_OBJECT_DETECTION_IMAGE:?}:${TAG}"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [ gpu ]
command: /bin/bash -c "ros2 launch camera_object_detection eve_launch.py"
volumes:
- /mnt/wato-drive2/perception_models/yolov8m.pt:/perception_models/yolov8m.pt

# lidar_object_detection:
# build:
# context: ..
# dockerfile: docker/perception/lidar_object_detection/lidar_object_detection.Dockerfile
# cache_from:
# - "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:${TAG}"
# - "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:${TAG}"
# command: /bin/bash -c "ros2 launch lidar_object_detection lidar_object_detection.launch.py"
# traffic_light_detection:
# build:
# context: ..
# dockerfile: docker/perception/traffic_light_detection/traffic_light_detection.Dockerfile
# cache_from:
# - "${PERCEPTION_TRAFFIC_LIGHT_DETECTION_IMAGE}:${TAG}"
# - "${PERCEPTION_TRAFFIC_LIGHT_DETECTION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_TRAFFIC_LIGHT_DETECTION_IMAGE}:${TAG}"
# command: /bin/bash -c "ros2 launch traffic_light_detection traffic_light_detection.launch.py"
lidar_object_detection:
build:
context: ..
dockerfile: docker/perception/lidar_object_detection/lidar_object_detection.Dockerfile
cache_from:
- "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:build_${TAG}"
- "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:build_main"
target: deploy
image: "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:${TAG}"
command: /bin/bash -c "ros2 launch lidar_object_detection lidar_object_detection.launch.py"
traffic_light_detection:
build:
context: ..
dockerfile: docker/perception/traffic_light_detection/traffic_light_detection.Dockerfile
cache_from:
- "${PERCEPTION_TRAFFIC_LIGHT_DETECTION_IMAGE}:build_${TAG}"
- "${PERCEPTION_TRAFFIC_LIGHT_DETECTION_IMAGE}:build_main"
target: deploy
image: "${PERCEPTION_TRAFFIC_LIGHT_DETECTION_IMAGE}:${TAG}"
command: /bin/bash -c "ros2 launch traffic_light_detection traffic_light_detection.launch.py"

# traffic_sign_detection:
# build:
# context: ..
# dockerfile: docker/perception/traffic_sign_detection/traffic_sign_detection.Dockerfile
# cache_from:
# - "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:${TAG}"
# - "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:${TAG}"
# command: /bin/bash -c "ros2 launch traffic_sign_detection traffic_sign_detection.launch.py"
traffic_sign_detection:
build:
context: ..
dockerfile: docker/perception/traffic_sign_detection/traffic_sign_detection.Dockerfile
cache_from:
- "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:build_${TAG}"
- "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:build_main"
target: deploy
image: "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:${TAG}"
command: /bin/bash -c "ros2 launch traffic_sign_detection traffic_sign_detection.launch.py"

semantic_segmentation:
build:
Expand All @@ -71,38 +71,37 @@ services:
cache_from:
- "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:${TAG}"
- "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:main"
# target: deploy
target: deploy
image: "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:${TAG}"
command: /bin/bash -c "ros2 launch semantic_segmentation semantic_segmentation.launch.py"
volumes:
- /mnt/wato-drive2/perception-weights/semantic_segmentation:/perception_models/semantic_segmentation
# add gpus all
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [gpu]
count: 1
capabilities: [ gpu ]

# lane_detection:
# build:
# context: ..
# dockerfile: docker/perception/lane_detection/lane_detection.Dockerfile
# cache_from:
# - "${PERCEPTION_LANE_DETECTION_IMAGE}:${TAG}"
# - "${PERCEPTION_LANE_DETECTION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_LANE_DETECTION_IMAGE}:${TAG}"
# command: /bin/bash -c "ros2 launch lane_detection lane_detection.launch.py"
lane_detection:
build:
context: ..
dockerfile: docker/perception/lane_detection/lane_detection.Dockerfile
cache_from:
- "${PERCEPTION_LANE_DETECTION_IMAGE}:build_${TAG}"
- "${PERCEPTION_LANE_DETECTION_IMAGE}:build_main"
target: deploy
image: "${PERCEPTION_LANE_DETECTION_IMAGE}:${TAG}"
command: /bin/bash -c "ros2 launch lane_detection lane_detection.launch.py"

# tracking:
# build:
# context: ..
# dockerfile: docker/perception/tracking/tracking.Dockerfile
# cache_from:
# - "${PERCEPTION_TRACKING_IMAGE}:${TAG}"
# - "${PERCEPTION_TRACKING_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_TRACKING_IMAGE}:${TAG}"
# command: /bin/bash -c "ros2 launch tracking tracking.launch.py"
tracking:
build:
context: ..
dockerfile: docker/perception/tracking/tracking.Dockerfile
cache_from:
- "${PERCEPTION_TRACKING_IMAGE}:build_${TAG}"
- "${PERCEPTION_TRACKING_IMAGE}:build_main"
target: deploy
image: "${PERCEPTION_TRACKING_IMAGE}:${TAG}"
command: /bin/bash -c "ros2 launch tracking tracking.launch.py"
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setup Code\n",
"**DO NOT CHANGE THIS!!**\n",
"**RUN THE CELL BELOW FIRST!!**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import carla\n",
"import os\n",
"\n",
"client_name = os.environ.get(\"CLIENT_NAME\", \"DOES NOT EXIST\")\n",
"if client_name == \"DOES NOT EXIST\":\n",
" raise Exception(\"The environment variable for the container name of the carla server has not been set\")\n",
"\n",
"# Connect to the client and retrieve the world object\n",
"client = carla.Client(client_name, 2000)\n",
"world = client.get_world()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Start Adding Code or Markdown Cells Below\n",
"Some helpful code cells are provided below that you may choose to use"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#### SPAWN VEHICLES ####\n",
"\"\"\"\n",
"# Get the blueprint library and filter for the vehicle blueprints\n",
"vehicle_blueprints = world.get_blueprint_library().filter('*vehicle*')\n",
"# Get the map's spawn points\n",
"spawn_points = world.get_map().get_spawn_points()\n",
"\n",
"# Spawn 50 vehicles randomly distributed throughout the map \n",
"# for each spawn point, we choose a random vehicle from the blueprint library\n",
"for i in range(0,50):\n",
" world.try_spawn_actor(random.choice(vehicle_blueprints), random.choice(spawn_points)))\n",
"\"\"\"\n",
"#### SET ALL VEHICLES TO AUTOPILOT\n",
"\"\"\"\n",
"for vehicle in world.get_actors().filter('*vehicle*'):\n",
" vehicle.set_autopilot(True)\n",
"\"\"\""
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
24 changes: 17 additions & 7 deletions watod-config.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## ----------------------- watod Configuration File Override ----------------------------

############################ ACTIVE MODULE CONFIGURATION ############################
## List of active modules to run, defined in docker-compose.yaml.
##
## HINT: You can copy the contents of this file to a watod-config.local.sh
## file that is untrackable by git and readable by watod.
##

############################ ACTIVE MODULE CONFIGURATION ############################
## List of active modules to run, defined in docker-compose.yaml.
## Possible values:
## - infrastructure : starts visualization tools (foxglove and/or vnc and/or data_stream)
Expand All @@ -12,16 +15,23 @@
## - simulation : starts simulation
## - samples : starts sample ROS2 pubsub nodes

ACTIVE_MODULES="infrastructure perception"
# ACTIVE_MODULES=""

################################# MODE OF OPERATION #################################
## Possible modes of operation when running watod.
## Possible values:
## - deploy (default) : runs production-grade containers (non-editable)
## - develop : runs developer containers (editable)

# MODE_OF_OPERATION=""

############################## OPTIONAL CONFIGURATIONS ##############################
############################## ADVANCED CONFIGURATIONS ##############################
## Name to append to docker containers. DEFAULT = "<your_watcloud_username>"
COMPOSE_PROJECT_NAME="j89leung"
FOXGLOVE_BRIDGE_PORT="8771"
# COMPOSE_PROJECT_NAME=""

## Tag to use. Images are formatted as <IMAGE_NAME>:<TAG> with forward slashes replaced with dashes.
## DEFAULT = "<your_current_github_branch>"
TAG="latest"
# TAG=""

# Docker Registry to pull/push images. DEFAULT = "ghcr.io/watonomous/wato_monorepo"
# REGISTRY_URL=""

0 comments on commit 60069b8

Please sign in to comment.