Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lane detection ROS2 node #50

Merged
merged 34 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
25ce097
Test base image build
leungjch Jan 28, 2024
5b93f75
Check devel image
leungjch Feb 1, 2024
60f693e
Add working node with new infra + space optimized runtime image
leungjch Feb 2, 2024
b8f6279
Merge branch 'main' into justin/lane-detection-new
leungjch Feb 2, 2024
4fd7e21
Revert watod-config and perception docker compose
leungjch Feb 3, 2024
5bdb733
Merge branch 'main' into justin/lane-detection-new
leungjch Feb 9, 2024
2de12d5
Delete unnecessary files
leungjch Feb 9, 2024
b173cb4
Delete unnecessary files
leungjch Feb 9, 2024
786d9e8
Delete unnecessary files
leungjch Feb 9, 2024
94ae1e2
Merge branch 'justin/lane-detection-new' of https://github.com/WATono…
leungjch Feb 9, 2024
e040f87
Add publishing lane detection message
leungjch Feb 12, 2024
cac12e7
Add launch and config files
leungjch Feb 13, 2024
508410d
Format
leungjch Feb 19, 2024
1187366
Merge branch 'main' into justin/lane-detection-new
Gongsta Feb 23, 2024
98b8ba2
Fix merge conflict
leungjch Mar 1, 2024
ae1b1d1
Merge branch 'justin/lane-detection-new' of github.com:WATonomous/wat…
Gongsta Mar 8, 2024
722d2e7
Merge branch 'main' into justin/lane-detection-new
Gongsta Mar 8, 2024
161d3d7
Clean up watod-config.sh
Gongsta Mar 8, 2024
8557648
Clean up
Gongsta Mar 8, 2024
c74a2c2
Merge branch 'main' into justin/lane-detection-new
Gongsta Mar 9, 2024
ffa6af5
clean up docker compose
Gongsta Mar 9, 2024
8589ac8
Fix formatting
Gongsta Mar 9, 2024
e634a99
Remove sample msgs
Gongsta Mar 10, 2024
df8715a
Fix lane detection header and save directory
Gongsta Mar 10, 2024
e123860
Add lane_detection_tensorrt submodule
leungjch Mar 11, 2024
7eb837d
Update docs for submodules
leungjch Mar 13, 2024
d25e2ad
Clean up
Gongsta Mar 14, 2024
8a286e3
Add .gitmodules
leungjch Mar 15, 2024
c1f0bf3
Merge branch 'justin/lane-detection-new' of https://github.com/WATono…
leungjch Mar 15, 2024
fbca3e1
Remove clone
leungjch Mar 15, 2024
2f02e85
Address PR comments
leungjch Mar 15, 2024
bbd26f1
Refactor node into hpp and cpp
leungjch Mar 15, 2024
1990ec1
Fix linting
leungjch Mar 15, 2024
8d22ca3
Merge branch 'main' into justin/lane-detection-new
leungjch Mar 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions docker/perception/lane_detection/lane_detection.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BASE_IMAGE=ghcr.io/watonomous/wato_monorepo/base:humble-ubuntu22.04

ARG BASE_IMAGE=ghcr.io/watonomous/wato_monorepo/base:cuda12.2-humble-ubuntu22.04-devel
ARG RUNTIME_IMAGE=ghcr.io/watonomous/wato_monorepo/base:cuda12.2-humble-ubuntu22.04
################################ Source ################################
FROM ${BASE_IMAGE} as source

Expand All @@ -19,6 +19,17 @@ RUN apt-get -qq update && rosdep update && \
################################# Dependencies ################################
FROM ${BASE_IMAGE} as dependencies

RUN apt-get update
# Intall opencv
RUN apt install -y libopencv-dev python3-opencv
RUN export OpenCV_DIR=/usr/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake

# Install TensorRT
RUN apt install -y tensorrt

# Install cuda toolkit
RUN apt-get install -y cuda-toolkit

# 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)
Expand All @@ -43,13 +54,28 @@ 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
ENTRYPOINT ["./wato_ros_entrypoint.sh"]
# ENTRYPOINT ["./wato_ros_entrypoint.sh]

################################ Prod ################################
FROM build as deploy
FROM ${RUNTIME_IMAGE} as deploy

Edwardius marked this conversation as resolved.
Show resolved Hide resolved
# Install runtime libs
RUN apt-get update && apt-get install -y \
ros-humble-cv-bridge \
tensorrt

# Copy the compiled binary to the runtime image
COPY --from=build ${AMENT_WS} ${AMENT_WS}

WORKDIR ${AMENT_WS}

# 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

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

USER ${USER}

ENTRYPOINT ["./wato_ros_entrypoint.sh"]
184 changes: 99 additions & 85 deletions modules/docker-compose.perception.yaml
Original file line number Diff line number Diff line change
@@ -1,85 +1,87 @@
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}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch radar_object_detection radar_object_detection.launch.py"
# radar_object_detection:
leungjch marked this conversation as resolved.
Show resolved Hide resolved
# 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}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# 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}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch camera_object_detection camera_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}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# command: /bin/bash -c "ros2 launch camera_object_detection camera_object_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}:${TAG}"
- "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:main"
target: deploy
image: "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:${TAG}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch lidar_object_detection lidar_object_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}:${TAG}"
# - "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_LIDAR_OBJECT_DETECTION_IMAGE}:${TAG}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# 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}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch traffic_light_detection traffic_light_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}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# 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}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
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}:${TAG}"
# - "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_TRAFFIC_SIGN_DETECTION_IMAGE}:${TAG}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# command: /bin/bash -c "ros2 launch traffic_sign_detection traffic_sign_detection.launch.py"

semantic_segmentation:
build:
context: ..
dockerfile: docker/perception/semantic_segmentation/semantic_segmentation.Dockerfile
cache_from:
- "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:${TAG}"
- "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:main"
target: deploy
image: "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:${TAG}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch semantic_segmentation semantic_segmentation.launch.py"
# semantic_segmentation:
# build:
# context: ..
# dockerfile: docker/perception/semantic_segmentation/semantic_segmentation.Dockerfile
# cache_from:
# - "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:${TAG}"
# - "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:main"
# target: deploy
# image: "${PERCEPTION_SEMANTIC_SEGMENTATION_IMAGE}:${TAG}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# command: /bin/bash -c "ros2 launch semantic_segmentation semantic_segmentation.launch.py"

lane_detection:
# add gpus all below

build:
context: ..
dockerfile: docker/perception/lane_detection/lane_detection.Dockerfile
Expand All @@ -90,17 +92,29 @@ services:
image: "${PERCEPTION_LANE_DETECTION_IMAGE}:${TAG}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch lane_detection lane_detection.launch.py"
# command: /bin/bash -c "ros2 launch lane_detection lane_detection.launch.py"
command: /bin/bash -c "ros2 run lane_detection lane_detection"
volumes:
# mount the model (ufldv2_culane_res34_320x1600.onnx)
- /mnt/wato-drive2/perception-weights/tensorrt_model/ultra_fast_lane_detection_v2/resource/model/ufldv2_culane_res34_320x1600.onnx:/home/bolty/ament_ws/build/lane_detection/resource/model/ufldv2_culane_res34_320x1600.onnx
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]


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}"
security_opt:
- seccomp:${MONO_DIR}/modules/seccomp_profile.json
command: /bin/bash -c "ros2 launch tracking tracking.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}"
# security_opt:
# - seccomp:${MONO_DIR}/modules/seccomp_profile.json
# command: /bin/bash -c "ros2 launch tracking tracking.launch.py"
95 changes: 77 additions & 18 deletions src/perception/lane_detection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,85 @@
# cmake_minimum_required(VERSION 3.8)
# project(lane_detection)

# if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# add_compile_options(-Wall -Wextra -Wpedantic)
# endif()

# # find dependencies
# find_package(ament_cmake REQUIRED)
# # uncomment the following section in order to fill in
# # further dependencies manually.
# # find_package(<dependency> REQUIRED)

# if(BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
# # the following line skips the linter which checks for copyrights
# # comment the line when a copyright and license is added to all source files
# set(ament_cmake_copyright_FOUND TRUE)
# # the following line skips cpplint (only works in a git repo)
# # comment the line when this package is in a git repo and when
# # a copyright and license is added to all source files
# set(ament_cmake_cpplint_FOUND TRUE)
# ament_lint_auto_find_test_dependencies()
# endif()

# ament_package()

cmake_minimum_required(VERSION 3.8)
project(lane_detection)
set(ProjectName "lane_detection")
set(CUDA_TOOLKIT_ROOT_DIR "/usr/local/cuda")
SET(CMAKE_CUDA_COMPILER /usr/local/cuda-12.2/bin/nvcc)
SET(CUDACXX /usr/local/cuda-12.2/bin/nvcc)
project(${ProjectName} LANGUAGES CXX CUDA)

# set(CUDA_NVCC_EXECUTABLE "/usr/local/cuda/bin/nvcc")


# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
### TensorRT model ###

# Select build system and set compile options
include(${CMAKE_CURRENT_LIST_DIR}/src/tensorrt_model/common_helper/cmakes/build_setting.cmake)

add_executable(lane_detection src/lane_detection_node.cpp)

# Link ImageProcessor module
add_subdirectory(./src/tensorrt_model/ultra_fast_lane_detection_v2/image_processor image_processor)
target_include_directories(${ProjectName} PUBLIC ./src/tensorrt_model/ultra_fast_lane_detection_v2/image_processor)
target_link_libraries(${ProjectName} ImageProcessor)

# For OpenCV
find_package(OpenCV REQUIRED)
target_include_directories(${ProjectName} PUBLIC ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${ProjectName} ${OpenCV_LIBS})

# Copy resouce
file(COPY ${CMAKE_CURRENT_LIST_DIR}/src/tensorrt_model/ultra_fast_lane_detection_v2/resource/model DESTINATION ${CMAKE_BINARY_DIR}/resource)
add_definitions(-DRESOURCE_DIR="${CMAKE_BINARY_DIR}/resource/")


### End of TensorRT model ###

find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(CUDA REQUIRED)


install(TARGETS
lane_detection
DESTINATION lib/${PROJECT_NAME})

ament_package()
ament_target_dependencies(lane_detection rclcpp OpenCV std_msgs sensor_msgs cv_bridge image_transport)
ament_package()
12 changes: 12 additions & 0 deletions src/perception/lane_detection/launch/lane_detection.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():

return LaunchDescription([
Node(
package='lane_detection',
executable='lane_detection',
name='lane_detection',
)
])
Loading
Loading