From 10d0aa9b7d938d46d8d3377b65334c1072cdc5a5 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Sun, 4 Jun 2023 14:09:22 +0200 Subject: [PATCH 1/3] point to `ros_msft_mrtk` for Hololens support The current codebase for Hololens support is over there. The installation and usage instructions are more streamlined there as well. --- README.md | 151 ++---------------------------------------------------- 1 file changed, 4 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index 1fbe9fb3..5418ddf8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ The current set of features include: - Generation of all builtin ROS types - Support for publishers and subscriptions - Support for clients and services -- Cross-platform support (Linux, Windows, Windows IoT Core, UWP) +- Cross-platform support (Linux, Windows) + - For using ROS 2 with Hololens see https://github.com/ms-iot/ros_msft_mrtk What's missing? --------------- @@ -33,14 +34,13 @@ Lots of things! - Actions - Tests - Documentation -- More examples (e.g. IoT, VB, UWP, HoloLens, etc.) +- More examples Sounds great, how can I try this out? ------------------------------------- First of all install the standard ROS2 dependencies for your operating system -of choice (**NOTE**: only do this if building Windows Desktop or Linux. For UWP, -see the relevant section below): https://github.com/ros2/ros2/wiki/Installation#building-from-source +of choice: https://github.com/ros2/ros2/wiki/Installation#building-from-source Next make sure you've either installed .Net Core (preferred) https://www.microsoft.com/net/learn/get-started or Mono @@ -56,8 +56,6 @@ interface definitions, those must also be included in the `ros2_dotnet` workspac in order for .NET bindings to be generated. (NOTE: if you wish to build the core of ROS2 from source, everything through the `rcl` layer is required.) -For running within UWP (Universal Windows Platform) applications, the entire -core of ROS2 must be compiled for UWP compatibility. Windows (Desktop) ----------------- @@ -95,46 +93,6 @@ vcs import ~/ros2_dotnet_ws/src < ros2_dotnet_foxy.repos colcon build ``` -Universal Windows Platform (Win32, Win64) ----------------------------------------------- -We'll build this in two steps, first `ament` (the build system) and related tools -which will run natively on the host, followed by ROS2 itself, built for UWP and -the target architecture. - -If you have previously installed ROS2 dependencies (OpenSSL, tinyxml, log4cxx, -etc) it is strongly recommended to uninstall those dependencies before building -to avoid any non-UWP binaries getting pulled into the build. - -ament ------ - -``` -md \dev\ament\src -cd \dev\ament -curl -sk https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/main/ament_dotnet_uwp.repos -o ament_dotnet_uwp.repos -vcs import src < ament_dotnet_uwp.repos -colcon build --merge-install -call install\local_setup.bat -``` - -UWP ---- - -Replace `%TARGET_ARCH%` with Win32 or x64 - -``` -md \dev\ros2\src -cd \dev\ros2 -curl -sk https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/main/ros2_dotnet_uwp.repos -o ros2_dotnet_uwp.repos -vcs import src < ros2_dotnet_uwp.repos -cd \dev\ament -call install\local_setup.bat -cd \dev\ros2 -colcon build --merge-install --packages-ignore rmw_fastrtps_dynamic_cpp rcl_logging_log4cxx rcl_logging_spdlog ros2trace tracetools_launch tracetools_read tracetools_test tracetools_trace --cmake-args -A "%TARGET_ARCH%" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.17763 -DTHIRDPARTY=ON -DINSTALL_EXAMPLES=OFF -DBUILD_TESTING=OFF -DRCL_LOGGING_IMPLEMENTATION=rcl_logging_noop -``` - -Now you can just run a bunch of examples. - ### Publisher and subscriber Publisher: @@ -178,104 +136,3 @@ ros2 run rcldotnet_examples rcldotnet_listener ``` Enjoy! - -## Using generated DLLs in your UWP application from Visual Studio - -Create a new Visual Studio project (Visual C# - Windows Universal - Empty app). - -In Solution Explorer panel: -``` -right click on Universal Windows project - Add - Existing item... -``` -and include every DLL file from `{your_ros2_uwp_ws}\install\bin`. Now select all of these files in Solution Explorer and check/set the properties: -``` -Build action: Content -Copy to output directory: Copy always -``` -This allows you to retrieve the files in the same directory as the assembly. - -Next step, in Solution Explorer panel: -``` -right click on References - Add reference... -``` -and include `{your_ros2_uwp_ws}\install\lib\rcldotnet\dotnet\rcldotnet_assemblies.dll`, `{your_ros2_uwp_ws}\install\lib\rcldotnet\dotnet\rcldotnet_common.dll` and `{your_ros2_uwp_ws}\install\lib\std_msgs\dotnet\std_msgs_assemblies.dll`. - -Now you can include your ROS2 code in MainPage.xaml.cs script, compile your project and run it on HoloLens Emulator or HoloLens physical device. - -## Using generated DLLs in your UWP application from Unity -**NOTE: _Tested on `Unity 2018.2.8f1`_** - -Create a new Unity project and set up the following editor properties. - -### Build Settings -Set your target platform properly: -``` -File - Build Settings - Universal Windows Platform - Switch Platform -``` -then set UWP build settings: -``` -Target Device: HoloLens -Build Type: D3D -SDK: Latest installed -Visual Studio Version: Latest installed -Build and Run on: Local Machine and Windows Phone -Build Configuration: Release -``` -and let unchecked the rest. - -### Player Settings - -- Other Settings - - **Configuration** - ``` - Scripting Runtime Version: .NET 4.x Equivalent - Scripting Backend: .NET - Api Compatibility Level: .NET 4.x - ``` - -- Publishing Settings - - **Capabilities** - - [x] InternetClient - - [x] InternetClientServer - - [x] PrivateNetworkClientServer - -- XR Settings - - [x] Virtual Reality Supported - - Virtual Reality SDKs - > Windows Mixed Reality - -### Add files -Create Assets/Plugins and Assets/Scripts folders. - -In Plugins folder include every DLL file from `{your_ros2_uwp_ws}\install\bin`. Also include `{your_ros2_uwp_ws}\install\lib\rcldotnet\dotnet\rcldotnet_assemblies.dll`, `{your_ros2_uwp_ws}\install\lib\rcldotnet\dotnet\rcldotnet_common.dll` and `{your_ros2_uwp_ws}\install\lib\std_msgs\dotnet\std_msgs_assemblies.dll`. - -In Scripts folder create your C# scripts and attach them to a scene GameObject to execute them when the app starts. - -Finally, build your project to generate a Visual Studio solution. -``` -File - Build Settings - Build -``` - -### Unity generated Visual Studio solution -Open the VS solution generated after building your Unity project. -In Solution Explorer panel: -``` -right click on Universal Windows project - Add - Existing item... -``` -and include every DLL file from `{your_ros2_uwp_ws}\install\bin`. Now select all of these files in Solution Explorer and check/set the properties: -``` -Build action: Content -Copy to output directory: Copy always -``` -This allows you to retrieve the files in the same directory as the assembly. - -Next step, in Solution Explorer panel: -``` -right click on References - Add reference... -``` -and include `{your_ros2_uwp_ws}\install\lib\rcldotnet\dotnet\rcldotnet_assemblies.dll`, `{your_ros2_uwp_ws}\install\lib\rcldotnet\dotnet\rcldotnet_common.dll` and `{your_ros2_uwp_ws}\install\lib\std_msgs\dotnet\std_msgs_assemblies.dll`. - -Finally compile your project for UWP (32 bits) and run it on HoloLens Emulator or HoloLens physical device. From 5bf528bf67f04ba382acad520b6c7e376b9540df Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Sun, 4 Jun 2023 14:14:19 +0200 Subject: [PATCH 2/3] move uwp repos to workflows folder When enabling the CI for UWP again one might look at the more up to date ones from http://aka.ms/ros/mrtk_native. --- .github/workflows/build_uwp.yml | 4 ++-- ament_dotnet_uwp.repos => .github/workflows/uwp_ament.repos | 0 .../workflows/uwp_ros2_dotnet.repos | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename ament_dotnet_uwp.repos => .github/workflows/uwp_ament.repos (100%) rename ros2_dotnet_uwp.repos => .github/workflows/uwp_ros2_dotnet.repos (100%) diff --git a/.github/workflows/build_uwp.yml b/.github/workflows/build_uwp.yml index dd1da2a1..3f808b13 100644 --- a/.github/workflows/build_uwp.yml +++ b/.github/workflows/build_uwp.yml @@ -32,7 +32,7 @@ jobs: run: | md \dev\ament\src cd \dev\ament - copy ${{github.workspace}}\ament_dotnet_uwp.repos . + copy ${{github.workspace}}\.github\workflows\uwp_ament.repos . vcs import src < ament_dotnet_uwp.repos vcs branch shell: cmd @@ -47,7 +47,7 @@ jobs: run: | md \dev\ros2\src cd \dev\ros2 - copy ${{github.workspace}}\ros2_dotnet_uwp.repos . + copy ${{github.workspace}}\.github\workflows\uwp_ros2_dotnet.repos . vcs import src < ros2_dotnet_uwp.repos rd /s /q src\ros2_dotnet\ros2_dotnet xcopy /e /i ${{github.workspace}} src\ros2_dotnet\ros2_dotnet diff --git a/ament_dotnet_uwp.repos b/.github/workflows/uwp_ament.repos similarity index 100% rename from ament_dotnet_uwp.repos rename to .github/workflows/uwp_ament.repos diff --git a/ros2_dotnet_uwp.repos b/.github/workflows/uwp_ros2_dotnet.repos similarity index 100% rename from ros2_dotnet_uwp.repos rename to .github/workflows/uwp_ros2_dotnet.repos From c94c50ffce9d235cd7702bb7a7585b4d306ee577 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Sun, 11 Jun 2023 11:34:56 +0200 Subject: [PATCH 3/3] add section to better explain UWP support --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5418ddf8..345589e3 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ The current set of features include: - Generation of all builtin ROS types - Support for publishers and subscriptions - Support for clients and services -- Cross-platform support (Linux, Windows) - - For using ROS 2 with Hololens see https://github.com/ms-iot/ros_msft_mrtk +- Cross-platform support (Linux, Windows, Windows IoT Core, UWP) What's missing? --------------- @@ -40,7 +39,8 @@ Sounds great, how can I try this out? ------------------------------------- First of all install the standard ROS2 dependencies for your operating system -of choice: https://github.com/ros2/ros2/wiki/Installation#building-from-source +of choice (**NOTE**: only do this if building Windows Desktop or Linux. For UWP, +see the relevant section below): https://github.com/ros2/ros2/wiki/Installation#building-from-source Next make sure you've either installed .Net Core (preferred) https://www.microsoft.com/net/learn/get-started or Mono @@ -93,6 +93,14 @@ vcs import ~/ros2_dotnet_ws/src < ros2_dotnet_foxy.repos colcon build ``` +Universal Windows Platform (Win32, Win64) +----------------------------------------- + +For running within UWP (Universal Windows Platform) applications, the entire core of ROS2 must be compiled for UWP compatibility. + +See the [Mixed Reality Toolkit for ROS 2](https://github.com/ms-iot/ros_msft_mrtk) which provides instructions, scripts and binary packages to set up an UWP application for Hololens. +This Toolkit builds upon this and core ROS 2 packages that provide support for UWP. + ### Publisher and subscriber Publisher: