Skip to content

Commit

Permalink
Merge branch 'main' into openpcdet-dan
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrhuynh authored Mar 25, 2024
2 parents fc8d18a + 5de7050 commit 0efbca2
Show file tree
Hide file tree
Showing 81 changed files with 2,065 additions and 350 deletions.
11 changes: 11 additions & 0 deletions .github/templates/docker_context/docker_context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ while read -r module; do
services=$(docker-compose -f "$module" config --services)
module_out=$(echo "$module" | sed -n 's/modules\/docker-compose\.\(.*\)\.yaml/\1/p')

# Skip simulation module
if [[ 'simulation' = $module_out ]]; then
continue
fi

# Only work with modules that are modified
if [[ $MODIFIED_MODULES != *$module_out* && $TEST_ALL = "false" ]]; then
continue
fi

# Loop through each service
while read -r service_out; do
# Temporarily skip perception services that have too large image size
if [[ "$service_out" == "lane_detection" ]] || \
[[ "$service_out" == "camera_object_detection" ]] || \
[[ "$service_out" == "semantic_segmentation" ]]; then
continue
fi
# Construct JSON object for each service with module and service name
json_object=$(jq -nc --arg module_out "$module_out" --arg service_out "$service_out" \
'{module: $module_out, service: $service_out}')
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build_and_unitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
setup-environment:
name: Setup environment
name: Setup Environment
runs-on: ubuntu-latest

outputs:
Expand All @@ -29,7 +29,9 @@ jobs:
uses: "./.github/templates/check_src_changes"

- name: Setup Watod Environment
run: ./watod_scripts/watod-setup-env.sh
run: |
MODULES_DIR="$GITHUB_WORKSPACE/modules"
. ./watod_scripts/watod-setup-env.sh
shell: bash

- name: Generate Docker Environment
Expand All @@ -43,7 +45,7 @@ jobs:
uses: "./.github/templates/github_context"

build-and-unittest:
name: Build Image and Run Unit Testing Suite
name: Build/Test
runs-on: ubuntu-latest
needs: setup-environment

Expand Down Expand Up @@ -124,9 +126,7 @@ jobs:
${{ steps.construct-registry-url.outputs.url }}:${{ env.SOURCE_BRANCH }}
cache-from: |
${{ steps.construct-registry-url.outputs.url }}:build_${{ env.SOURCE_BRANCH }}
${{ steps.construct-registry-url.outputs.url }}:${{ env.SOURCE_BRANCH }}
${{ steps.construct-registry-url.outputs.url }}:${{ env.TARGET_BRANCH }}
cache-to: type=inline
${{ steps.construct-registry-url.outputs.url }}:build_${{ env.TARGET_BRANCH }}
builder: ${{ steps.buildx.outputs.name }}
target: deploy

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/linting_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches:
- main
types:
- unlabeled
- labeled
- synchronize

Expand Down Expand Up @@ -51,4 +52,4 @@ jobs:
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'auto-lint'
});
});
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ code_server_config/*/start_code_server.sh
.env
.vscode/
ssh_config/

watod-config.local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN rm requirements.txt

# Install Rosdep requirements
COPY --from=source /tmp/colcon_install_list /tmp/colcon_install_list
RUN apt-fast install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list)
RUN apt-get update && apt-fast install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list)

# Copy in source code from source stage
WORKDIR ${AMENT_WS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ FROM ${BASE_IMAGE} as source
WORKDIR ${AMENT_WS}/src

# Copy in source code
COPY src/simulation/carla_sim carla_sim
COPY src/wato_msgs/sample_msgs sample_msgs
COPY src/perception/depth_estimation depth_estimation

# Scan for rosdeps
RUN apt-get -qq update && rosdep update && \
Expand Down

This file was deleted.

23 changes: 23 additions & 0 deletions docker/simulation/carla_notebooks/carla_notebooks.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG CARLA_VERSION=0.9.13
FROM carlasim/carla:${CARLA_VERSION} AS wato_carla_api

FROM python:3.8.16-slim-bullseye
ARG CARLA_VERSION=0.9.13

RUN pip3 install carla==${CARLA_VERSION} jupyter tensorflow-probability
RUN apt-get update && apt-get install -y curl git wget unzip && apt remove python3-networkx

COPY --from=wato_carla_api --chown=root /home/carla/PythonAPI/carla/agents /usr/local/lib/python3.8/site-packages/agents

WORKDIR /home/bolty/carla_notebooks
COPY src/simulation/carla_notebooks /home/bolty/carla_notebooks

WORKDIR /home/bolty
# Setup CARLA Scenario Runner
# The last sed command replaces hero (default ego vehicle name) with another ego vehicle name
RUN git clone https://github.com/carla-simulator/scenario_runner.git && \
cd scenario_runner && pip3 install -r requirements.txt && \
sed -i s/hero/ego/g /home/bolty/scenario_runner/srunner/tools/scenario_parser.py
WORKDIR /home/bolty

WORKDIR /home/bolty/carla_notebooks
109 changes: 109 additions & 0 deletions docker/simulation/carla_ros_bridge/carla_ros_bridge.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
ARG BASE_IMAGE=ghcr.io/watonomous/wato_monorepo/base:foxy-ubuntu20.04

ARG CARLA_VERSION=0.9.13
FROM carlasim/carla:${CARLA_VERSION} AS wato_carla_api

################################ Source ################################
FROM ${BASE_IMAGE} as source

WORKDIR ${AMENT_WS}/src

# Download ROS Bridge
RUN git clone --depth 1 --branch master --recurse-submodules https://github.com/carla-simulator/ros-bridge.git && \
cd ros-bridge && \
git checkout e9063d97ff5a724f76adbb1b852dc71da1dcfeec && \
cd ..

# Fix an error in the ackermann_control node
RUN sed -i s/simple_pid.PID/simple_pid.pid/g ./ros-bridge/carla_ackermann_control/src/carla_ackermann_control/carla_ackermann_control_node.py

# Copy in source code
COPY src/simulation/carla_config carla_config
COPY src/wato_msgs/simulation ros_msgs

# Scan for rosdeps
RUN apt-get -qq update && rosdep update --rosdistro foxy && \
rosdep install --from-paths . -r -s \
| grep 'apt-get install' \
| awk '{print $3}' \
| sort > /tmp/colcon_install_list

################################# Dependencies ################################
FROM ${BASE_IMAGE} as dependencies

# Install dependencies
RUN apt-get update && \
apt-fast install -qq -y --no-install-recommends lsb-release \
libglu1-mesa-dev xorg-dev \
software-properties-common \
build-essential \
python3-rosdep \
python3-rospkg \
python3-colcon-common-extensions \
python3-pygame \
ros-$ROS_DISTRO-tf2-geometry-msgs \
ros-$ROS_DISTRO-tf2-eigen \
ros-$ROS_DISTRO-ackermann-msgs \
ros-$ROS_DISTRO-derived-object-msgs \
ros-$ROS_DISTRO-cv-bridge \
ros-$ROS_DISTRO-vision-opencv \
ros-$ROS_DISTRO-rqt-image-view \
ros-$ROS_DISTRO-rqt-gui-py \
qt5-default \
ros-$ROS_DISTRO-pcl-conversions \
ros-$ROS_DISTRO-resource-retriever \
ros-$ROS_DISTRO-yaml-cpp-vendor \
ros-$ROS_DISTRO-urdf \
ros-$ROS_DISTRO-map-msgs \
ros-$ROS_DISTRO-laser-geometry \
ros-$ROS_DISTRO-interactive-markers \
ros-$ROS_DISTRO-rviz2

# Install Rosdep requirements
COPY --from=source /tmp/colcon_install_list /tmp/colcon_install_list
RUN apt-fast install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list)

# Copy in source code from source stage
WORKDIR ${AMENT_WS}
COPY --from=source ${AMENT_WS}/src src

# Dependency Cleanup
WORKDIR /
RUN apt-get -qq autoremove -y && apt-get -qq autoclean && apt-get -qq clean && \
rm -rf /root/* /root/.ros /tmp/* /var/lib/apt/lists/* /usr/share/doc/*

################################ Build ################################
FROM dependencies as build

ARG CARLA_VERSION

#Install Python Carla API
COPY --from=wato_carla_api --chown=root /home/carla/PythonAPI/carla /opt/carla/PythonAPI
WORKDIR /opt/carla/PythonAPI
RUN python3.8 -m easy_install pip && \
pip3 install carla==${CARLA_VERSION} && \
pip install simple-pid==2.0.0 && \
pip install transforms3d==0.4.1 && \
pip install pexpect==4.9.0 && \
pip install networkx==3.1

WORKDIR ${AMENT_WS}/src

# Build ROS2 packages
WORKDIR ${AMENT_WS}
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--cmake-args -DCMAKE_BUILD_TYPE=Release

# 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
ENTRYPOINT ["./wato_ros_entrypoint.sh"]

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

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

USER ${USER}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ FROM ${BASE_IMAGE} as source
WORKDIR ${AMENT_WS}/src

# Copy in source code
COPY src/perception/traffic_light_detection traffic_light_detection
COPY src/wato_msgs/sample_msgs sample_msgs
COPY src/simulation/carla_sample_node carla_sample_node
COPY src/wato_msgs/simulation/embedded_msgs embedded_msgs
COPY src/wato_msgs/simulation/path_planning_msgs path_planning_msgs

# Carla specific messages

RUN git clone --depth 1 https://github.com/ros-drivers/ackermann_msgs.git --branch 2.0.2

RUN git clone --depth 1 https://github.com/ros-perception/image_common.git --branch 3.1.8

RUN git clone --depth 1 https://github.com/carla-simulator/ros-carla-msgs.git --branch 1.3.0

# Scan for rosdeps
RUN apt-get -qq update && rosdep update && \
Expand Down
14 changes: 14 additions & 0 deletions docker/simulation/carla_viz/carla_viz.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mjxu96/carlaviz:0.9.13

ENV CARLAVIZ_BACKEND_HOST localhost
ENV CARLAVIZ_BACKEND_PORT 8081
ENV CARLA_SERVER_HOST localhost
ENV CARLA_SERVER_PORT 2000

WORKDIR /home/carla/carlaviz

COPY docker/simulation/carla_viz/carlaviz_entrypoint.sh /home/carla/carlaviz/docker/carlaviz_entrypoint.sh

RUN chmod +x ./docker/carlaviz_entrypoint.sh

ENTRYPOINT ["/bin/bash", "-c", "./docker/carlaviz_entrypoint.sh > /dev/null 2>&1"]
53 changes: 53 additions & 0 deletions docker/simulation/carla_viz/carlaviz_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

is_backend_up=""

function wait_for_backend_up() {
max_wait_time=5
for ((i=0; i<=$max_wait_time; ++i)) do
cat output.txt | grep -q "Connected to Carla Server"
if [ $? == 0 ]; then
is_backend_up="1"
break
fi
sleep 1
done
}

function cleanup_backend() {
backend_pid=$(pidof backend)
kill -9 $backend_pid
echo "Killed Backend process $backend_pid"
}

echo -e "CARLAVIZ_BACKEND_HOST=${CARLAVIZ_BACKEND_HOST}" >> /home/carla/.env
echo -e "CARLAVIZ_BACKEND_PORT=${CARLAVIZ_BACKEND_PORT}" >> /home/carla/.env

echo "Make sure you have launched the Carla server."
echo "Launching backend."
./backend/bin/backend ${CARLA_SERVER_HOST} ${CARLA_SERVER_PORT} |& tee output.txt &
wait_for_backend_up
if [[ -z "$is_backend_up" ]]; then
echo "Backend is not launched. Please check if you have already started the Carla server."
cleanup_backend
exit 1
fi

echo "Backend launched."

echo "Launching frontend"
# enable nginx
service nginx restart
echo "Frontend launched. Please open your browser"
sleep 10
sed -i s/:8081/:$CARLAVIZ_BACKEND_PORT/g /var/www/carlaviz/bundle.js

while [ "$is_backend_up" = "1" ]
do
cat output.txt | grep -q "time-out of"
if [ $? == 0 ]; then
is_backend_up=""
cleanup_backend
exit 1
fi
sleep 5
done
Loading

0 comments on commit 0efbca2

Please sign in to comment.