Skip to content

Commit

Permalink
Merge branch 'main' into mkchiu/traffic_sign_detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Miniapple8888 authored Mar 1, 2024
2 parents 59dcb7b + 7a88671 commit c584a82
Show file tree
Hide file tree
Showing 13 changed files with 238 additions and 41 deletions.
77 changes: 77 additions & 0 deletions .github/templates/check_src_changes/action.yml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions .github/templates/check_src_changes/check_src_changes.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .github/templates/docker_context/action.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
12 changes: 12 additions & 0 deletions .github/templates/docker_context/docker_context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/build_and_unitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ 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

- 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"
Expand Down Expand Up @@ -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!"
4 changes: 2 additions & 2 deletions modules/docker-compose.perception.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions src/perception/camera_object_detection/config/eve_config.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 0 additions & 7 deletions src/perception/camera_object_detection/config/sim_config.yaml

This file was deleted.

42 changes: 42 additions & 0 deletions src/perception/camera_object_detection/launch/eve_launch.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 0 additions & 26 deletions src/perception/camera_object_detection/launch/sim_launch.py

This file was deleted.

0 comments on commit c584a82

Please sign in to comment.