diff --git a/.github/templates/check_src_changes/action.yml b/.github/templates/check_src_changes/action.yml new file mode 100644 index 00000000..a0dd7fc4 --- /dev/null +++ b/.github/templates/check_src_changes/action.yml @@ -0,0 +1,77 @@ +name: Check source file changes + +outputs: + modified_modules: + description: "Space deliminated list of modified modules" + value: ${{ steps.output-changes.outputs.modified_modules }} + +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Find changed files outside of src directory + id: changed-files-outside-src + uses: tj-actions/changed-files@v42 + with: + files: '!src/**' + + - name: Find changed files inside src/wato_msgs folder + id: changed-files-wato-msgs + uses: tj-actions/changed-files@v42 + with: + files: src/wato_msgs/** + + - name: Find changed files inside src/action folder + id: changed-files-action + uses: tj-actions/changed-files@v42 + with: + files: src/action/** + + - name: Get changed files inside src/interfacing folder + id: changed-files-interfacing + uses: tj-actions/changed-files@v42 + with: + files: src/interfacing/** + + - name: Get changed files inside src/perception folder + id: changed-files-perception + uses: tj-actions/changed-files@v42 + with: + files: src/perception/** + + - name: Get changed files inside src/samples folder + id: changed-files-samples + uses: tj-actions/changed-files@v42 + with: + files: src/samples/** + + - name: Get changed files inside src/simulation folder + id: changed-files-simulation + uses: tj-actions/changed-files@v42 + with: + files: src/simulation/** + + - name: Get changed files inside src/world_modeling folder + id: changed-files-world-modeling + uses: tj-actions/changed-files@v42 + with: + files: src/world_modeling/** + + - name: Create list of changed modules + id: output-changes + env: + INFRASTRUCTURE_CHANGED: > + ${{ steps.changed-files-wato-msgs.outputs.any_changed == 'true' + || steps.changed-files-outside-src.outputs.any_changed == 'true' }} + ACTION_CHANGED: ${{ steps.changed-files-action.outputs.any_changed }} + INTERFACING_CHANGED: ${{ steps.changed-files-interfacing.outputs.any_changed }} + PERCEPTION_CHANGED: ${{ steps.changed-files-perception.outputs.any_changed }} + SAMPLES_CHANGED: ${{ steps.changed-files-samples.outputs.any_changed }} + SIMULATION_CHANGED: ${{ steps.changed-files-simulation.outputs.any_changed }} + WORLD_MODELING_CHANGED: ${{ steps.changed-files-world-modeling.outputs.any_changed }} + + run: ${{ github.action_path }}/check_src_changes.sh + shell: bash \ No newline at end of file diff --git a/.github/templates/check_src_changes/check_src_changes.sh b/.github/templates/check_src_changes/check_src_changes.sh new file mode 100755 index 00000000..5e531b58 --- /dev/null +++ b/.github/templates/check_src_changes/check_src_changes.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -e + +################# Create a space delimited list of modified modules ################# +# Outputs a list of modified modules by comparing changes between main and current commit +# References previous GitHub workflow steps + +# Action +if [ $ACTION_CHANGED == 'true' ]; then + echo "Detected action changes" + MODIFIED_MODULES+="action " +fi + +# Interfacing +if [ $INTERFACING_CHANGED == 'true' ]; then + echo "Detected interfacing changes" + MODIFIED_MODULES+="interfacing " +fi + +# Perception +if [ $PERCEPTION_CHANGED == 'true' ]; then + echo "Detected perception changes" + MODIFIED_MODULES+="perception " +fi + +# Samples +if [ $SAMPLES_CHANGED == 'true' ]; then + echo "Detected samples changes" + MODIFIED_MODULES+="samples " +fi + +# Simulation +if [ $SIMULATION_CHANGED == 'true' ]; then + echo "Detected simulation changes" + MODIFIED_MODULES+="simulation " +fi + +# World-modeling +if [ $WORLD_MODELING_CHANGED == 'true' ]; then + echo "Detected world_modeling changes" + MODIFIED_MODULES+="world_modeling" +fi + +# Infrastructure +if [ $INFRASTRUCTURE_CHANGED == 'true' ]; then + echo "::notice:: Detected infrastructure changes" + MODIFIED_MODULES="infrastructure" +else + echo "::notice:: MODIFIED_MODULES are $MODIFIED_MODULES" +fi + +# Output lis +echo "modified_modules=$MODIFIED_MODULES" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/templates/docker_context/action.yml b/.github/templates/docker_context/action.yml index 0395e2bc..87bfd0e7 100644 --- a/.github/templates/docker_context/action.yml +++ b/.github/templates/docker_context/action.yml @@ -1,5 +1,11 @@ name: Generate Docker Environment +inputs: + modified_modules: + description: "Space deliminated list of modified modules" + required: true + default: '' + outputs: docker_matrix: description: "list of docker compose services" @@ -15,5 +21,7 @@ runs: using: "composite" steps: - id: environment-generator + env: + MODIFIED_MODULES: ${{ inputs.modified_modules }} run: ${{ github.action_path }}/docker_context.sh shell: bash diff --git a/.github/templates/docker_context/docker_context.sh b/.github/templates/docker_context/docker_context.sh index 0d43e0c3..5e35355f 100755 --- a/.github/templates/docker_context/docker_context.sh +++ b/.github/templates/docker_context/docker_context.sh @@ -11,12 +11,24 @@ modules=$(find modules -maxdepth 1 -name "docker-compose*") # Initialize an empty array for JSON objects json_objects=() +# Check for infrastructure changes +TEST_ALL=false +if [[ $MODIFIED_MODULES = "infrastructure" ]]; then + TEST_ALL=true +fi + # Loop through each module while read -r module; do + # Retrieve docker compose service names services=$(docker-compose -f "$module" config --services) module_out=$(echo "$module" | sed -n 's/modules\/docker-compose\.\(.*\)\.yaml/\1/p') + # 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 # Construct JSON object for each service with module and service name diff --git a/.github/workflows/build_and_unitest.yml b/.github/workflows/build_and_unitest.yml index ebced51b..12ef538c 100644 --- a/.github/workflows/build_and_unitest.yml +++ b/.github/workflows/build_and_unitest.yml @@ -24,6 +24,10 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Get Module Changes + id: get-module-changes + uses: "./.github/templates/check_src_changes" + - name: Setup Watod Environment run: ./watod_scripts/watod-setup-env.sh shell: bash @@ -31,7 +35,9 @@ jobs: - name: Generate Docker Environment id: docker-environment uses: "./.github/templates/docker_context" - + with: + modified_modules: ${{ steps.get-module-changes.outputs.modified_modules }} + - name: Generate GitHub Environment id: github-environment uses: "./.github/templates/github_context" @@ -133,3 +139,12 @@ jobs: with: image: ${{ steps.construct-registry-url.outputs.url }} tag: build_${{ env.SOURCE_BRANCH }} + + confirm-build-and-unittest-complete: + name: Confirm Build and Unit Tests Completed + needs: build-and-unittest + runs-on: ubuntu-latest + steps: + - name: Ending + run: | + echo "::notice:: All builds and unit tests completed!" diff --git a/modules/docker-compose.perception.yaml b/modules/docker-compose.perception.yaml index 84d8bf2e..ce2b4053 100644 --- a/modules/docker-compose.perception.yaml +++ b/modules/docker-compose.perception.yaml @@ -29,10 +29,10 @@ services: - driver: nvidia count: 1 capabilities: [ gpu ] - command: /bin/bash -c "ros2 launch camera_object_detection nuscenes_launch.py" + command: /bin/bash -c "ros2 launch camera_object_detection eve_launch.py" volumes: - /mnt/wato-drive2/perception_models/yolov8s.pt:/perception_models/yolov8s.pt - - /mnt/wato-drive2/perception_models/traffic_signs_v0.pt:/perception_models/traffic_signs_v0.pt + - /mnt/wato-drive2/perception_models/traffic_signs_v0.pt:/perception_models/traffic_signs_v1.pt lidar_object_detection: build: diff --git a/src/perception/camera_object_detection/camera_object_detection/yolov8_detection.py b/src/perception/camera_object_detection/camera_object_detection/yolov8_detection.py index b5ad2ea8..f5822173 100755 --- a/src/perception/camera_object_detection/camera_object_detection/yolov8_detection.py +++ b/src/perception/camera_object_detection/camera_object_detection/yolov8_detection.py @@ -34,8 +34,8 @@ def __init__(self): self.declare_parameter("camera_topic", "/camera/right/image_color") self.declare_parameter("publish_vis_topic", "/annotated_img") self.declare_parameter("publish_detection_topic", "/detections") - self.declare_parameter("model_path", "/perception_models/yolov8s.pt") - self.declare_parameter("image_size", 480) + self.declare_parameter("model_path", "/perception_models/yolov8m.pt") + self.declare_parameter("image_size", 1024) self.declare_parameter("compressed", False) self.camera_topic = self.get_parameter("camera_topic").value diff --git a/src/perception/camera_object_detection/config/deepracer_config.yaml b/src/perception/camera_object_detection/config/deepracer_config.yaml index 542efa7a..88a2e959 100755 --- a/src/perception/camera_object_detection/config/deepracer_config.yaml +++ b/src/perception/camera_object_detection/config/deepracer_config.yaml @@ -3,5 +3,5 @@ camera_object_detection_node: camera_topic: /camera_pkg/display_mjpeg publish_vis_topic: /annotated_img publish_obstacle_topic: /obstacles - model_path: /perception_models/yolov8s.pt - image_size: 480 + model_path: /perception_models/yolov8m.pt + image_size: 1024 diff --git a/src/perception/camera_object_detection/config/eve_config.yaml b/src/perception/camera_object_detection/config/eve_config.yaml new file mode 100755 index 00000000..efac49fa --- /dev/null +++ b/src/perception/camera_object_detection/config/eve_config.yaml @@ -0,0 +1,23 @@ +left_camera_object_detection_node: + ros__parameters: + camera_topic: /camera/left/image_color + publish_vis_topic: /camera/left/annotated_img + publish_detection_topic: /camera/left/detections + model_path: /perception_models/yolov8m.pt + image_size: 1024 + +center_camera_object_detection_node: + ros__parameters: + camera_topic: /camera/center/image_color + publish_vis_topic: /camera/center/annotated_img + publish_detection_topic: /camera/center/detections + model_path: /perception_models/yolov8m.pt + image_size: 1024 + +right_camera_object_detection_node: + ros__parameters: + camera_topic: /camera/right/image_color + publish_vis_topic: /camera/right/annotated_img + publish_detection_topic: /camera/right/detections + model_path: /perception_models/yolov8m.pt + image_size: 1024 diff --git a/src/perception/camera_object_detection/config/nuscenes_config.yaml b/src/perception/camera_object_detection/config/nuscenes_config.yaml index 6dff0554..6251c4b0 100755 --- a/src/perception/camera_object_detection/config/nuscenes_config.yaml +++ b/src/perception/camera_object_detection/config/nuscenes_config.yaml @@ -3,6 +3,6 @@ camera_object_detection_node: camera_topic: /CAM_FRONT/image_rect_compressed publish_vis_topic: /annotated_img publish_obstacle_topic: /obstacles - model_path: /perception_models/yolov8s.pt + model_path: /perception_models/yolov8m.pt image_size: 640 compressed: true diff --git a/src/perception/camera_object_detection/config/sim_config.yaml b/src/perception/camera_object_detection/config/sim_config.yaml deleted file mode 100755 index ec13a71b..00000000 --- a/src/perception/camera_object_detection/config/sim_config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -camera_object_detection_node: - ros__parameters: - camera_topic: /camera/right/image_color - publish_vis_topic: /annotated_img - publish_obstacle_topic: /obstacles - model_path: /perception_models/yolov8s.pt - image_size: 480 diff --git a/src/perception/camera_object_detection/launch/eve_launch.py b/src/perception/camera_object_detection/launch/eve_launch.py new file mode 100755 index 00000000..94ac35df --- /dev/null +++ b/src/perception/camera_object_detection/launch/eve_launch.py @@ -0,0 +1,42 @@ +from launch import LaunchDescription +from launch_ros.actions import Node +from ament_index_python.packages import get_package_share_directory +import os + + +def generate_launch_description(): + ld = LaunchDescription() + config = os.path.join( + get_package_share_directory('camera_object_detection'), + 'config', + 'eve_config.yaml' + ) + + # nodes + left_camera_object_detection_node = Node( + package='camera_object_detection', + executable='camera_object_detection_node', + name='left_camera_object_detection_node', + parameters=[config] + ) + + center_camera_object_detection_node = Node( + package='camera_object_detection', + executable='camera_object_detection_node', + name='center_camera_object_detection_node', + parameters=[config] + ) + + right_camera_object_detection_node = Node( + package='camera_object_detection', + executable='camera_object_detection_node', + name='right_camera_object_detection_node', + parameters=[config] + ) + + # finalize + ld.add_action(left_camera_object_detection_node) + ld.add_action(center_camera_object_detection_node) + ld.add_action(right_camera_object_detection_node) + + return ld diff --git a/src/perception/camera_object_detection/launch/sim_launch.py b/src/perception/camera_object_detection/launch/sim_launch.py deleted file mode 100755 index 12af5eb0..00000000 --- a/src/perception/camera_object_detection/launch/sim_launch.py +++ /dev/null @@ -1,26 +0,0 @@ -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - - -def generate_launch_description(): - ld = LaunchDescription() - config = os.path.join( - get_package_share_directory('camera_object_detection'), - 'config', - 'sim_config.yaml' - ) - - # nodes - camera_object_detection_node = Node( - package='camera_object_detection', - executable='camera_object_detection_node', - name='camera_object_detection_node', - parameters=[config] - ) - - # finalize - ld.add_action(camera_object_detection_node) - - return ld