Skip to content

Commit

Permalink
Merge pull request #136 from introlab/ros2
Browse files Browse the repository at this point in the history
Ros2 (Addressing #131 #107)
  • Loading branch information
matlabbe authored Dec 11, 2022
2 parents b0b5d24 + 8cf1bfc commit c2f47bd
Show file tree
Hide file tree
Showing 29 changed files with 1,753 additions and 83 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CMake

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
BUILD_TYPE: Release

jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04, ubuntu-18.04]

steps:
- name: Install dependencies
run: |
DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get -y install libopencv-dev qtbase5-dev git cmake software-properties-common
- uses: actions/checkout@v2

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}


59 changes: 59 additions & 0 deletions .github/workflows/ros1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: ros1

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: Build on ros ${{ matrix.ros_distro }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04]
include:
- os: ubuntu-20.04
ros_distro: 'noetic'
- os: ubuntu-18.04
ros_distro: 'melodic'

steps:
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ matrix.ros_distro }}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install ros-${{ matrix.ros_distro }}-cv-bridge qtbase5-dev
- name: Setup catkin workspace
run: |
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
mkdir -p ${{github.workspace}}/catkin_ws/src
cd ${{github.workspace}}/catkin_ws/src
catkin_init_workspace
cd ..
catkin_make
- uses: actions/checkout@v2
with:
path: 'catkin_ws/src/find_object_2d'

- name: caktkin_make
run: |
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
source ${{github.workspace}}/catkin_ws/devel/setup.bash
cd ${{github.workspace}}/catkin_ws
catkin_make -DSETUPTOOLS_DEB_LAYOUT=OFF
catkin_make install
58 changes: 58 additions & 0 deletions .github/workflows/ros2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

name: ros2

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: Build on ros2 ${{ matrix.ros_distro }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
ros_distro: [foxy, galactic, humble]
include:
- ros_distro: 'foxy'
os: ubuntu-20.04
- ros_distro: 'galactic'
os: ubuntu-20.04
- ros_distro: 'humble'
os: ubuntu-22.04

steps:
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ matrix.ros_distro }}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install ros-${{ matrix.ros_distro }}-cv-bridge qtbase5-dev
- name: Setup ros2 workspace
run: |
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
mkdir -p ${{github.workspace}}/ros2_ws/src
cd ${{github.workspace}}/ros2_ws
colcon build
- uses: actions/checkout@v2
with:
path: 'ros2_ws/src/find_object_2d'

- name: colcon build
run: |
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
cd ${{github.workspace}}/ros2_ws
colcon build --event-handlers console_direct+
80 changes: 66 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
cmake_minimum_required(VERSION 2.8.5)
cmake_minimum_required(VERSION 3.5)

# Detect if it is called by catkin
SET(CATKIN_BUILD FALSE)
SET(COLCON_BUILD FALSE)

# Detect if it is called by catkin (ros1)
IF(CATKIN_TOPLEVEL OR CATKIN_BUILD_BINARY_PACKAGE OR CATKIN_SKIP_TESTING OR CATKIN_ENABLE_TESTING OR CATKIN_DEVEL_PREFIX)
SET(CATKIN_BUILD TRUE)
ENDIF(CATKIN_TOPLEVEL OR CATKIN_BUILD_BINARY_PACKAGE OR CATKIN_SKIP_TESTING OR CATKIN_ENABLE_TESTING OR CATKIN_DEVEL_PREFIX)
ELSE()
# Detect if it is called by colcon (ros2)
string(FIND ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} POS)
IF(${POS} EQUAL -1)
SET(COLCON_BUILD TRUE)
ENDIF()
ENDIF()

MESSAGE(STATUS "CATKIN_BUILD=${CATKIN_BUILD}")
MESSAGE(STATUS "COLCON_BUILD=${COLCON_BUILD}")
SET(ROS_BUILD FALSE)
IF(CATKIN_BUILD OR COLCON_BUILD)
SET(ROS_BUILD TRUE)
ENDIF()

IF(NOT CATKIN_BUILD)
IF(NOT ROS_BUILD)
#Standalone build
PROJECT( Find-Object )
ELSE()
#ROS catkin build
#ROS build
PROJECT( find_object_2d )
MESSAGE(STATUS "ROS_DISTRO=$ENV{ROS_DISTRO}")
ENDIF()

# Catkin doesn't support multiarch library path,
Expand Down Expand Up @@ -130,7 +145,7 @@ ENDIF()

CONFIGURE_FILE(Version.h.in ${PROJECT_SOURCE_DIR}/include/${PROJECT_PREFIX}/Version.h)

IF(NOT CATKIN_BUILD)
IF(NOT ROS_BUILD)
#Standalone build
IF(WIN32 AND NOT MINGW)
ADD_DEFINITIONS("-wd4251")
Expand Down Expand Up @@ -358,14 +373,14 @@ IF(NOT CATKIN_BUILD)
ENDIF(APPLE)
MESSAGE(STATUS "--------------------------------------------")

ELSE()
ELSEIF(CATKIN_BUILD)
#ROS Catkin build

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
cv_bridge roscpp rospy sensor_msgs std_msgs image_transport message_filters tf message_generation
cv_bridge roscpp sensor_msgs std_msgs image_transport message_filters tf message_generation
)

## Generate messages in the 'msg' folder
Expand All @@ -392,7 +407,7 @@ ELSE()
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
CATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs image_transport message_filters tf message_runtime
CATKIN_DEPENDS cv_bridge roscpp sensor_msgs std_msgs image_transport message_filters tf message_runtime
DEPENDS OpenCV
)

Expand All @@ -405,12 +420,49 @@ ELSE()
## Install ##
#############
## Mark other files for installation (e.g. launch and bag files, etc.)
install(FILES
launch/find_object_3d_kinect2.launch
launch/find_object_3d_zed.launch
launch/find_object_2d.launch
launch/find_object_3d.launch
install(DIRECTORY
launch/ros1
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)
ELSE() # COLCON_BUILD
#ROS Colcon build

find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(message_filters REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)

## Generate messages and services
rosidl_generate_interfaces(${PROJECT_NAME}
msg/ObjectsStamped.msg
msg/DetectionInfo.msg
DEPENDENCIES std_msgs sensor_msgs
)
ament_export_dependencies(rosidl_default_runtime)

###########
## Build ##
###########
ADD_SUBDIRECTORY( src )

#############
## Install ##
#############
install(DIRECTORY
launch/ros2/.
DESTINATION share/${PROJECT_NAME}/launch
)

ament_package()
ENDIF()

Loading

0 comments on commit c2f47bd

Please sign in to comment.