diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000..120c6893 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/test_ubuntu.yaml b/.github/workflows/test_ubuntu.yaml new file mode 100644 index 00000000..f04871b7 --- /dev/null +++ b/.github/workflows/test_ubuntu.yaml @@ -0,0 +1,67 @@ +name: Test on Ubuntu +on: + workflow_dispatch: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test_ubuntu: + strategy: + matrix: + os: [ubuntu-22.04] + ros-distribution: [humble] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Install .NET SDK 6.0 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: "6" + + - name: Update apt sources + run: sudo apt update + + - name: Set locale + run: | + sudo apt install -y locales + sudo locale-gen en_US en_US.UTF-8 + sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 + + - name: Setup ROS2 apt sources + run: | + sudo apt install -y software-properties-common curl + sudo add-apt-repository universe + sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null + sudo apt update + + - name: Setup ROS2 + env: + LANG: en_US.UTF-8 + run: | + sudo apt install -y \ + ros-${{ matrix.ros-distribution }}-ros-base ros-dev-tools ros-${{ matrix.ros-distribution }}-test-msgs \ + ros-${{ matrix.ros-distribution }}-fastrtps ros-${{ matrix.ros-distribution }}-rmw-fastrtps-cpp \ + ros-${{ matrix.ros-distribution }}-cyclonedds ros-${{ matrix.ros-distribution }}-rmw-cyclonedds-cpp \ + python3-vcstool + + - name: Invoke build script + env: + LANG: en_US.UTF-8 + run: | + source /opt/ros/humble/setup.bash + ./get_repos.sh + ./build.sh --with-tests + + - name: Invoke test script + env: + LANG: en_US.UTF-8 + run: | + source /opt/ros/humble/setup.bash + ./test.sh diff --git a/.github/workflows/test_windows.yaml b/.github/workflows/test_windows.yaml new file mode 100644 index 00000000..d7a741cf --- /dev/null +++ b/.github/workflows/test_windows.yaml @@ -0,0 +1,85 @@ +name: Test on Windows +on: + workflow_dispatch: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test_windows: + strategy: + matrix: + os: [windows-2019] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Install .NET SDK 6.0 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: "6" + + # setup with colcon fails + # (probably since it is already installed in the toolscache) + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.8" + + - name: Install dependencies + shell: pwsh + run: | # junction is required since Python path is hardcoded + New-Item -ItemType Junction -Path "C:\Python38" -Target $Env:Python3_ROOT_DIR + choco install --no-progress -y vcredist2013 vcredist140 openssl cmake wget + + - name: Install ROS2 dependencies + run: | + wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/asio.1.12.1.nupkg + wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/bullet.3.17.nupkg + wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/cunit.2.1.3.nupkg + wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/eigen.3.3.4.nupkg + wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/tinyxml-usestl.2.6.2.nupkg + wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/tinyxml2.6.0.0.nupkg + choco install --no-progress -y --source . asio bullet cunit eigen tinyxml-usestl tinyxml2 + + - name: Install Python Packages + run: | + python -m pip install -U pip setuptools==59.6.0 + python -m pip install -U catkin_pkg cryptography empy importlib-metadata lark==1.1.1 lxml matplotlib netifaces numpy opencv-python PyQt5 pillow psutil pycairo pydot pyparsing==2.4.7 pyyaml rosdistro rosdep vcstool colcon-common-extensions + + - name: Setup ROS2 + shell: pwsh + run: | + wget.exe --quiet https://github.com/ros2/ros2/releases/download/release-humble-20230213/ros2-humble-20230127-windows-release-amd64.zip + Expand-Archive -Path ros2-humble-20230127-windows-release-amd64.zip -DestinationPath C:\dev + + - name: Invoke Windows build + shell: pwsh + run: | # prevent cmake from searching for higher Python versions in the toolscache + . C:/dev/ros2-windows/setup.ps1 + ./get_repos.ps1 + colcon build ` + --merge-install ` + --event-handlers console_direct+ ` + --cmake-args ` + -DCMAKE_BUILD_TYPE=Release ` + -DBUILD_TESTING=1 ` + -DPython3_ROOT_DIR=C:/Python38 ` + -DPython3_FIND_STRATEGY=LOCATION ` + -DPython3_FIND_REGISTRY=NEVER ` + --no-warn-unused-cli ` + --packages-up-to ros2cs_tests + env: + VisualStudioVersion: "16.0" + + - name: Invoke Windows test script + shell: pwsh + run: | + . C:/dev/ros2-windows/setup.ps1 + ./test.ps1 + env: + VisualStudioVersion: "16.0" diff --git a/README-UBUNTU.md b/README-UBUNTU.md index ef219ab9..c3780e24 100644 --- a/README-UBUNTU.md +++ b/README-UBUNTU.md @@ -47,8 +47,8 @@ sudo apt install patchelf - Clone this project - Source your ROS2 installation ```bash - # Change foxy to whatever version you are using - source /opt/ros/foxy/setup.bash + # Change humble to whatever version you are using + source /opt/ros/humble/setup.bash ``` - Navigate to the top project folder and pull required repositories ```bash diff --git a/README-WINDOWS.md b/README-WINDOWS.md index 605c631b..ab42dc7f 100644 --- a/README-WINDOWS.md +++ b/README-WINDOWS.md @@ -4,7 +4,7 @@ ### Prerequisites -* ROS2 installed on the system (additionally you should go to [Building ROS2 section](https://docs.ros.org/en/foxy/Installation/Windows-Development-Setup.html) and check if all `pip` [Install dependencies](https://docs.ros.org/en/foxy/Installation/Windows-Development-Setup.html#install-dependencies) and [Developer tools](https://docs.ros.org/en/foxy/Installation/Windows-Development-Setup.html#install-developer-tools) are installed) +* ROS2 installed on the system (additionally you should go to [Building ROS2 section](https://docs.ros.org/en/humble/Installation/Windows-Development-Setup.html) and check if all [Prerequisites](https://docs.ros.org/en/humble/Installation/Windows-Development-Setup.html#installing-prerequisites) are installed. * vcstool package - [see here](https://github.com/dirk-thomas/vcstool) * .NET 6.0 sdk - [see here](https://dotnet.microsoft.com/download/dotnet/6.0) * For tests only: xUnit testing framework - [see here](https://xunit.net/) @@ -24,7 +24,7 @@ ### Steps - Clone this project. -- Source your ROS2 installation (`C:\dev\ros2_foxy\local_setup.ps1`) +- Source your ROS2 installation (`C:\dev\ros2_humble\local_setup.ps1`) - Navigate to the top project folder and pull required repositories (`get_repos.ps1`) - You can run script with `--get-custom-messages` argument to fetch extra messages from `custom_messages.repos` file. - It will use `vcstool` to download required ROS2 packages. By default, this will get repositories as set in `${ROS_DISTRO}`. diff --git a/README.md b/README.md index d81541aa..79453351 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Supported OSes: - Ubuntu 22.04 (bash) - Ubuntu 20.04 (bash) - Windows 10 (powershell) -- Windows 11* (powershel) +- Windows 11* (powershell) > \* ROS2 Galactic and Humble support only Windows 10 ([ROS 2 Windows system requirements](https://docs.ros.org/en/humble/Installation/Windows-Install-Binary.html#system-requirements)), but it is proven that it also works fine on Windows 11. @@ -36,7 +36,7 @@ Supported ROS2 distributions: ### Generating custom messages -After cloning the project and importing .repos, you can simply put your message package next to other packages in the `src/ros2` sub-folder. Then, build your project, and you have all messages generated. You can also modify and use the `custom_message.repos` template to automate the process with the `get_repos` script. +After cloning the project and importing .repos, you can simply put your message package next to other packages in the `src/custom_packages` directory. Then, build your project, and you have all messages generated. You can also modify and use the `custom_messages.repos` template to automate the process with the `get_repos` script. ### Build instructions @@ -45,6 +45,12 @@ Please follow the OS-specific instructions for your build: - [Ubuntu 20.04 Instructions](README-UBUNTU.md) - [Windows 10 Instructions](README-WINDOWS.md) +## Examples + +To built the examples pass the `--with-examples` flag to the OS-specific build script. +After sourcing your ROS2 workspace you can execute examples with `ros2 run ros2cs_examples `. +Example commands are shown in the testing section. + ## Testing Make sure your NuGet repositories can resolve `xUnit` dependency. You can call `dotnet nuget list source` to see your current sources for NuGet packages. Please note that `Microsoft Visual Studio Offline Packages` are usually insufficient. You can fix it by adding `nuget.org` repository: `dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json`. @@ -59,7 +65,7 @@ Make sure your NuGet repositories can resolve `xUnit` dependency. You can call ` ```powershell test.sp1 ``` -- Run a manual test with basic listener/publisher examples (you have to source your ROS2 first): +- Run a manual test with basic listener/publisher examples (you have to source your ROS2 first and built with examples): - ubuntu ```bash ros2 run ros2cs_examples ros2cs_talker @@ -70,7 +76,7 @@ Make sure your NuGet repositories can resolve `xUnit` dependency. You can call ` ros2 run ros2cs_examples ros2cs_talker.exe ros2 run ros2cs_examples ros2cs_listener.exe ``` -- Run a manual performance test (you have to source your ROS2 first): +- Run a manual performance test (you have to source your ROS2 first and built with examples): - ubuntu ```bash ros2 run ros2cs_examples ros2cs_performance_talker diff --git a/build.ps1 b/build.ps1 index 8b3d030d..eb0fe3cf 100644 --- a/build.ps1 +++ b/build.ps1 @@ -8,16 +8,21 @@ build with tests .PARAMETER standalone standalone build +.PARAMETER with_examples + build with examples #> Param ( [Parameter(Mandatory=$false)][switch]$with_tests=$false, - [Parameter(Mandatory=$false)][switch]$standalone=$false + [Parameter(Mandatory=$false)][switch]$standalone=$false, + [Parameter(Mandatory=$false)][switch]$with_examples=$false ) $msg="Build started." +$packages=,"ros2cs_core" $tests_switch=0 if($with_tests) { $msg+=" (with tests)" + $packages+="ros2cs_tests" $tests_switch=1 } $standalone_switch=0 @@ -25,6 +30,20 @@ if($standalone) { $msg+=" (standalone)" $standalone_switch=1 } +if ($with_examples) { + $msg+=" (with examples)" + $packages+="ros2cs_examples" +} Write-Host $msg -ForegroundColor Green -colcon build --merge-install --event-handlers console_direct+ --cmake-args -DSTANDALONE_BUILD:int=$standalone_switch -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING:int=$tests_switch --no-warn-unused-cli +&"colcon" build ` +--merge-install ` +--event-handlers console_direct+ ` +--cmake-args ` +-DSTANDALONE_BUILD:int=$standalone_switch ` +-DCMAKE_BUILD_TYPE=Release ` +-DBUILD_TESTING:int=$tests_switch ` +--no-warn-unused-cli ` +--packages-up-to ` +@packages ` +@(colcon list --names-only --base-paths src/custom_packages) diff --git a/build.sh b/build.sh index a3506627..d5a50848 100755 --- a/build.sh +++ b/build.sh @@ -2,27 +2,30 @@ display_usage() { echo "Usage: " - echo "build.sh [--with-tests] [--standalone]" + echo "build.sh [--with-tests] [--standalone] [--with-examples]" echo "" echo "Options:" echo "--with-tests - build with tests." echo "--standalone - standalone version" + echo "--with-examples - built with examples" } if [ -z "${ROS_DISTRO}" ]; then - echo "Source your ros2 distro first (foxy, galactic, humble or rolling are supported)" + echo "Source your ros2 distro first (galactic, humble or rolling)" exit 1 fi TESTS=0 -MSG="Build started." STANDALONE=OFF +PACKAGES="ros2cs_core" +MSG="Build started." while [[ $# -gt 0 ]]; do key="$1" case $key in -t|--with-tests) TESTS=1 + PACKAGES="$PACKAGES ros2cs_tests" MSG="$MSG (with tests)" shift # past argument ;; @@ -31,10 +34,14 @@ while [[ $# -gt 0 ]]; do MSG="$MSG (standalone)" shift # past argument ;; + -e|--with-examples) + PACKAGES="$PACKAGES ros2cs_examples" + MSG="$MSG (with examples)" + shift # past argument + ;; -h|--help) display_usage exit 0 - shift # past argument ;; *) # unknown option shift # past argument @@ -42,8 +49,9 @@ while [[ $# -gt 0 ]]; do esac done -echo $MSG -colcon build \ +echo "$MSG" +colcon list --names-only --base-paths src/custom_packages \ +| xargs -P 1 -d "\n" colcon build \ --merge-install \ --event-handlers console_direct+ \ --cmake-args \ @@ -51,4 +59,5 @@ colcon build \ -DSTANDALONE_BUILD=$STANDALONE \ -DBUILD_TESTING=$TESTS \ -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-rpath,'\$ORIGIN',-rpath=.,--disable-new-dtags" \ ---no-warn-unused-cli +--no-warn-unused-cli \ +--packages-up-to $PACKAGES \ No newline at end of file diff --git a/custom_messages.repos b/custom_messages.repos index 94c30e30..2c798444 100644 --- a/custom_messages.repos +++ b/custom_messages.repos @@ -1,11 +1,11 @@ -# NOTE: Use this file if you want to build with custom messages that reside in a separate remote repo. +# NOTE: Use this file if you want to build with custom packages that reside in a separate remote repo. # NOTE: use the following format #repositories: -# custom_messages/: +# custom_packages/: # type: git # url: # version: -# custom_messages/: +# custom_packages/: # ... # ... diff --git a/ros2_foxy.repos b/ros2_foxy.repos deleted file mode 100644 index 98df9e31..00000000 --- a/ros2_foxy.repos +++ /dev/null @@ -1,33 +0,0 @@ -repositories: - ros2/rosidl_defaults: - type: git - url: https://github.com/ros2/rosidl_defaults.git - version: foxy - ros2/common_interfaces: - type: git - url: https://github.com/ros2/common_interfaces.git - version: foxy - ros2/unique_identifier_msgs: - type: git - url: https://github.com/ros2/unique_identifier_msgs.git - version: foxy - ros2/rcl_interfaces: - type: git - url: https://github.com/ros2/rcl_interfaces.git - version: foxy - ros2/geometry2: - type: git - url: https://github.com/ros2/geometry2.git - version: foxy - ros2/test_interface_files: - type: git - url: https://github.com/ros2/test_interface_files.git - version: foxy - external/build_tools/dotnet_cmake_module: - type: git - url: https://github.com/RobotecAI/dotnet_cmake_module - version: 1.1.0 - external/build_tools/ament_cmake_export_assemblies: - type: git - url: https://github.com/RobotecAI/ament_cmake_export_assemblies - version: master \ No newline at end of file diff --git a/ros2_galactic.repos b/ros2_galactic.repos index 6ff8aa93..028ce8ed 100644 --- a/ros2_galactic.repos +++ b/ros2_galactic.repos @@ -19,10 +19,6 @@ repositories: type: git url: https://github.com/ros2/rcl_interfaces.git version: galactic - ros2/geometry2: - type: git - url: https://github.com/ros2/geometry2.git - version: galactic ros2/test_interface_files: type: git url: https://github.com/ros2/test_interface_files.git diff --git a/ros2_humble.repos b/ros2_humble.repos index 4482abd3..8234ce82 100644 --- a/ros2_humble.repos +++ b/ros2_humble.repos @@ -19,10 +19,6 @@ repositories: type: git url: https://github.com/ros2/rcl_interfaces.git version: humble - ros2/geometry2: - type: git - url: https://github.com/ros2/geometry2.git - version: humble ros2/test_interface_files: type: git url: https://github.com/ros2/test_interface_files.git diff --git a/ros2_rolling.repos b/ros2_rolling.repos index db53c972..5316549e 100644 --- a/ros2_rolling.repos +++ b/ros2_rolling.repos @@ -15,10 +15,6 @@ repositories: type: git url: https://github.com/ros2/rcl_interfaces.git version: master - ros2/geometry2: - type: git - url: https://github.com/ros2/geometry2.git - version: ros2 ros2/test_interface_files: type: git url: https://github.com/ros2/test_interface_files.git diff --git a/src/custom_packages/.gitkeep b/src/custom_packages/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/ros2cs/ros2cs_core/CMakeLists.txt b/src/ros2cs/ros2cs_core/CMakeLists.txt index f6a2f929..4f75188e 100644 --- a/src/ros2cs/ros2cs_core/CMakeLists.txt +++ b/src/ros2cs/ros2cs_core/CMakeLists.txt @@ -38,7 +38,6 @@ find_package(DotNETExtra REQUIRED) find_package(rcl REQUIRED) find_package(rcutils REQUIRED) find_package(rmw REQUIRED) -find_package(rosidl_generator_c REQUIRED) # Only build the library if a C typesupport exists get_rmw_typesupport(typesupport_impls "rmw_implementation" LANGUAGE "c") @@ -133,20 +132,6 @@ option(STANDALONE_BUILD "Deploy standalone libraries with build" OFF) set(ros2_distro "$ENV{ROS_DISTRO}") -# There is an issue with resolving environment variable paths in runtime for "rcpputils" library on ros2 foxy. -# We replacing this library with our patched version. See "resources/rcpputils.diff". -if(ros2_distro STREQUAL "foxy") - if(WIN32) - install(FILES "${CMAKE_CURRENT_LIST_DIR}/../../../resources/foxy/Windows/x86_64/rcpputils.dll" - DESTINATION resources - ) - elseif(UNIX) - install(FILES "${CMAKE_CURRENT_LIST_DIR}/../../../resources/foxy/Linux/x86_64/librcpputils.so" - DESTINATION resources - ) - endif() -endif() - if(STANDALONE_BUILD) find_program(PATCHELF "patchelf") if(UNIX) @@ -232,7 +217,7 @@ if(STANDALONE_BUILD) endif() # Get cyclonedds iceoryx dependency for ros2 galaxy (unix only) - if(UNIX AND NOT ros2_distro STREQUAL "foxy") + if(UNIX) if("${_library_name}" STREQUAL "iceoryx_binding_c" ) fetch_target_lib(iceoryx_binding_c::iceoryx_binding_c) list(APPEND REQ_STANDALONE_LIBS ${iceoryx_binding_c_iceoryx_binding_c_LIB_PATH}) @@ -358,7 +343,7 @@ if(STANDALONE_BUILD) yaml ) - if(UNIX AND NOT ros2_distro STREQUAL "foxy") + if(UNIX) if(ros2_distro STREQUAL "galactic") list(APPEND ros2_standalone_libs iceoryx_binding_c iceoryx_posh iceoryx_utils) else() diff --git a/src/ros2cs/ros2cs_core/package.xml b/src/ros2cs/ros2cs_core/package.xml index a40f4838..47f8903b 100644 --- a/src/ros2cs/ros2cs_core/package.xml +++ b/src/ros2cs/ros2cs_core/package.xml @@ -14,17 +14,10 @@ ament_cmake rosidl_cmake - ros2cs_common - rcl - rcutils - rmw - rosidl_generator_c - - rcl - - ros2cs_common - std_msgs - test_msgs + rcl + rmw + rcutils + ros2cs_common ament_cmake diff --git a/src/ros2cs/ros2cs_examples/CMakeLists.txt b/src/ros2cs/ros2cs_examples/CMakeLists.txt index cf8c062f..67f4350c 100644 --- a/src/ros2cs/ros2cs_examples/CMakeLists.txt +++ b/src/ros2cs/ros2cs_examples/CMakeLists.txt @@ -22,7 +22,6 @@ find_package(ros2cs_core REQUIRED) find_package(std_msgs REQUIRED) find_package(sensor_msgs REQUIRED) find_package(example_interfaces REQUIRED) -find_package(builtin_interfaces REQUIRED) find_package(dotnet_cmake_module REQUIRED) find_package(rosidl_generator_cs REQUIRED) diff --git a/src/ros2cs/ros2cs_examples/package.xml b/src/ros2cs/ros2cs_examples/package.xml index d2190a55..da2b8260 100644 --- a/src/ros2cs/ros2cs_examples/package.xml +++ b/src/ros2cs/ros2cs_examples/package.xml @@ -7,24 +7,16 @@ Apache License 2.0 ament_cmake - dotnet_cmake_module rosidl_generator_cs - rosidl_cmake - example_interfaces - builtin_interfaces - ros2cs_core - ros2cs_common - std_msgs - sensor_msgs + rosidl_cmake - example_interfaces - builtin_interfaces - ros2cs_core - ros2cs_common - std_msgs - sensor_msgs + ros2cs_core + ros2cs_common + std_msgs + sensor_msgs + example_interfaces ament_cmake diff --git a/src/ros2cs/ros2cs_tests/package.xml b/src/ros2cs/ros2cs_tests/package.xml index 380788cd..b8e615fc 100644 --- a/src/ros2cs/ros2cs_tests/package.xml +++ b/src/ros2cs/ros2cs_tests/package.xml @@ -12,10 +12,6 @@ ament_cmake - ros2cs_core - std_msgs - example_interfaces - ros2cs_core std_msgs test_msgs diff --git a/src/ros2cs/rosidl_generator_cs/cmake/rosidl_generator_cs_generate_interfaces.cmake b/src/ros2cs/rosidl_generator_cs/cmake/rosidl_generator_cs_generate_interfaces.cmake index b263cb8c..3f2c3bc4 100644 --- a/src/ros2cs/rosidl_generator_cs/cmake/rosidl_generator_cs_generate_interfaces.cmake +++ b/src/ros2cs/rosidl_generator_cs/cmake/rosidl_generator_cs_generate_interfaces.cmake @@ -137,7 +137,7 @@ file(MAKE_DIRECTORY "${_output_path}") message(STATUS "Generating C# code for ROS interfaces ${_generated_msg_cs_files} and ${_generated_srv_cs_files}") set(ros2_distro "$ENV{ROS_DISTRO}") -if(ros2_distro STREQUAL "foxy" OR ros2_distro STREQUAL "galactic") +if(ros2_distro STREQUAL "galactic") set(PYTHON_CMD ${PYTHON_EXECUTABLE}) else() set(PYTHON_CMD Python3::Interpreter)