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

build: fix Ros2 humble build #36

Merged
merged 13 commits into from
Jun 12, 2024
47 changes: 47 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: ROS2 CI

on:
pull_request:
branches:
- 'develop'
- 'ros2'
push:
branches:
- 'ros2'

jobs:
test_environment:
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
ros_distribution:
- humble
- iron
- rolling
include:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add CI/CD build test for humble, iron and rolling

# Humble Hawksbill (May 2022 - May 2027)
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest
ros_distribution: humble
ros_version: 2
# Iron Irwini (May 2023 - May 2028)
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest
ros_distribution: iron
ros_version: 2
# Rolling Ridley (June 2020 - Present)
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest
ros_distribution: rolling
ros_version: 2
container:
image: ${{ matrix.docker_image }}
steps:
- name: checkout
uses: actions/checkout@v2
- name: install deps
run: sudo apt-get -y install qtbase5-dev libqt5serialport5-dev
- name: build and test
uses: ros-tooling/action-ros-ci@master
with:
target-ros2-distro: ${{ matrix.ros_distribution }}
vcs-repo-file-url: ""
skip-tests: true
37 changes: 18 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ endif()

add_subdirectory(witmotion-uart-qt)

#set(CMAKE_AUTOMOC ON)
#qt5_wrap_cpp(MOC_SOURCES include/witmotion_ros.h)
include_directories(include)
include_directories(/opt/ros/humble/include/tf2_geometry_msgs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed any hardcoded path to ensure it will compile on all ROS2 deployments like robostack, source builds, etc.

include_directories(witmotion-uart-qt/include)
#add_library(witmotion_ros src/witmotion_ros.cpp include/witmotion_ros.h)


find_package(ament_cmake REQUIRED)
Expand Down Expand Up @@ -54,27 +50,30 @@ add_library(witmotion_ros

message(WARNING "tf2_geometry_msgs include dir: ${tf2_geometry_msgs_INCLUDE_DIRS} ")

#find_package(Qt5 REQUIRED COMPONENTS Core SerialPort)
set(INCLUDE_DIRS ${ament_cmake_INCLUDE_DIRS} ${tf2_INCLUDE_DIRS}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change CMAKE style dependency management to more idiomatic ament_target_dependencies

${tf2_geometry_msgs_INCLUDE_DIRS} ${rclcpp_INCLUDE_DIRS}
${std_srvs_INCLUDE_DIRS} ${sensor_msgs_INCLUDE_DIRS}
${geometry_msgs_INCLUDE_DIRS} ${nav_msgs_INCLUDE_DIRS}
${rosgraph_msgs_INCLUDE_DIRS} ${std_msgs_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5SerialPort_INCLUDE_DIRS} ${rcl_interfaces_INCLUDE_DIRS}
${rclcpp_lifecycle_INCLUDE_DIRS} ${lifecycle_msgs_INCLUDE_DIRS})
include_directories(${INCLUDE_DIRS})

set(dependencies
tf2
tf2_geometry_msgs
rclcpp
std_srvs
sensor_msgs
std_msgs
rcl_interfaces
rclcpp_lifecycle
lifecycle_msgs
)
ament_target_dependencies(witmotion_ros ${dependencies})

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()


set(LIBRARY_DIRS ${ament_cmake_LIBRARIES} ${tf2_LIBRARIES}
${tf2_geometry_msgs_LIBRARIES} ${rclcpp_LIBRARIES} ${std_srvs_LIBRARIES}
${sensor_msgs_LIBRARIES} ${geometry_msgs_LIBRARIES}
${nav_msgs_LIBRARIES} ${rosgraph_msgs_LIBRARIES}
${std_msgs_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5SerialPort_LIBRARIES} ${rcl_interfaces_LIBRARIES} ${rclcpp_lifecycle_LIBRARIES} ${lifecycle_msgs_LIBRARIES})

#target_link_libraries(another PUBLIC one)
set(LIBS ${ament_cmake_LIBRARIES} ${tf2_LIBRARIES}
${tf2_geometry_msgs_LIBRARIES} ${rclcpp_LIBRARIES} ${std_srvs_LIBRARIES}
${sensor_msgs_LIBRARIES} ${geometry_msgs_LIBRARIES}
${nav_msgs_LIBRARIES} ${rosgraph_msgs_LIBRARIES}
${std_msgs_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5SerialPort_LIBRARIES} ${rcl_interfaces_LIBRARIES} ${rclcpp_lifecycle_LIBRARIES} ${lifecycle_msgs_LIBRARIES})

target_link_libraries(witmotion_ros ${LIBRARY_DIRS} witmotion-uart Qt5::Core Qt5::SerialPort)


Expand Down
18 changes: 16 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@
<package format="3">
<name>witmotion_ros</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<description>Witmotion IMU sensor driver for ROS</description>
<maintainer email="[email protected]">pi</maintainer>
<license>TODO: License declaration</license>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>tf2_geometry_msgs</depend>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add depend to ensure rosdep can install all required dependencies

<depend>rclcpp</depend>
<depend>std_srvs</depend>
<depend>rcl_interfaces</depend>
<depend>rclcpp_lifecycle</depend>
<depend>lifecycle_msgs</depend>
<depend>qtbase5-dev</depend>
<depend>libqt5-serialport</depend>
<depend>boost</depend>
<depend>nav_msgs</depend>
<depend>std_msgs</depend>
<depend>tf2</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
Loading