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

Update Readme to point to http://aka.ms/ros/mrtk for Hololens support #113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/build_uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
145 changes: 5 additions & 140 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ 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?
-------------------------------------
Expand All @@ -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)
-----------------
Expand Down Expand Up @@ -96,44 +94,12 @@ 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.
For running within UWP (Universal Windows Platform) applications, the entire core of ROS2 must be compiled for UWP compatibility.

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.
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

Expand Down Expand Up @@ -178,104 +144,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.