📚STUDY/👓hololens&MRTK

[holoLens2 개발 튜토리얼] HoloLens 2 fundamentals: develop mixed reality applications (1)

해는선 2022. 1. 15. 16:50

이 글은 다음의 hololens2 fundamentals 튜토리얼을 따라하고, 이를 정리하였습니다.

https://docs.microsoft.com/en-us/learn/paths/beginner-hololens-2-tutorials/

 

HoloLens 2 fundamentals: develop mixed reality applications - Learn

Explore best practices for developing Azure-enabled mixed reality applications with the Mixed Reality Toolkit.

docs.microsoft.com

1. Introduction to the Mixed Reality Toolkit-Set Up Your Project and Use Hand Interaction

1) Introduction to the Mixed Reality Toolkit--Set Up Your Project and Use Hand Interaction

  • Mixed Reality Toolkit(MRTK)는 VR, AR에 대해 혼합현실경험을 만들어주는 cross-platform toolkit.
  • 홀로그래픽 물체를 움직이고, 돌리고, 키우고 줄이는데 있어 개발을 간단하게 만들어 줌.
  • 이 module (튜토리얼)을 끝내면, MRTK 개발을 위한 unity project 설정을 하고, 이를 이용해 개발을 가속화 할 수 있을 것.

 

<배우는 것>

  • 윈도우 혼합현실 개발을 위한 유니티 환경설정
  • MRTK 기초 패키지를 unity로 불러오는 법
  • Unity scene에 mrtk 추가
  • 세가지 기본 MRTK 상호작용 모델을 비교&대조
  • ObjectManipulator를 이용해서 홀로그램 조작

 

 

2) Set up a mixed reality project in Unity with the Mixed Reality Toolkit

  • 먼저 unity project를 windows mixed reality development를 위해 환경설정(구성)을 해야 함.
  • 이 구성은 unity project를 만들 때 마다 수동으로 해야 함.

 

<Universal Windows Platform>

  •  windows mixed reality를 대상으로 하기 위해 unity project를 universal windows platform 앱으로 내보내도록 설정해야 함.
  • 기본적으로 모든 장치를 대상으로 빌드 설정이 되어있음 (변경 가능)
universal windows platform(UWP) : microsoft에서 개발한 .NET core 기반의 어플리케이션 개발 플랫폼. 즉, windows용 클라이언트 어플리케이션 개발 플랫폼.

 

<Create an immersive view>

  • Windows app에는 2D view, immersive view가 존재.
  • 몰입형 뷰(immersive view)가 하나 이상 있다면 mixed reality app, 전혀 없다면 2D apps으로 분류.
  • Virtual Reality Supported를 활성화 해서 몰입형 뷰를 생성하도록 프로젝트를 구성 가능.
  • Vritual reality SDK로는 그냥 windows 10 SDK를 사용.

 

<How are holograms rendered>

  •  mixed reality app에서 scene은 사람 눈 각각에 대해 한 번씩, 총 두 번 렌더링 됨. => 이 방법을 stereoscopic vision이라고 함.
  • 기존 3D 개발과 다르게 계산량이 2배가 됨 => 효율적인 rendering 경로 선택이 중요
  • Single pass instanced rendering은 이 파이프라인을 최적화 => 이걸 기본 설정으로 하는게 좋다.

 

<How to stabilize holograms>

  • Depth Buffer Sharing 허용 => Unity가 생성한 depth map을 Windows Mixed Reality flatform과 공유해서 더 나은 홀로그램 안정성 (stability)를 얻을 수 있음.
  • 16-bit depth를 선택하면 데이터량이 적어져서 bandwidth requirements도 대폭 줄어듦.

 

 

3) Exercise - Configure Unity for Windows Mixed Reality

<Create a new unity project>

  • Unity Hub -> projects -> New (module Prerequisites에 맞게 선택)
  • new project를 만들 때, templates - 3D 선택 -> create

 

<Switch the build platform - unity 2020 이상 기준>

  • (in unity memu) file -> build settings
  • (in build settings) UWP를 선택하고 다음과 같이 설정

  • 이후 Switch Platform을 누르고, 스위칭이 끝나면 X버튼을 눌러 창을 닫는다.

 

4) Import and configure resources

  • MRTK는 unity mixed reality project로 가져올 수 있는 open-source toolkit. 없어도 혼합현실 앱을 만들 수 있지만, 있으면 더 빨리 개발할 수 있음.

 

<MRTK Unity>

  • HoloLens, WMR, OpenVR에서 Unity 개발을 위한 basic building block 제공
  • in-editor simulation을 이용해 즉시 확인 가능
  • core components를 교체가능한 기능을 제공하는 extensible framework로 작동.
  • HoloLens, HoloLens2, Windows Mixed Reality Headsets, OpenVR headsets(HTC Vive, Oculus Rift) 등을 지원.

 

<MRTK Unity foundation package>

  • MRTK foundation package는 project에서 MRTK를 쓰기 위한 유일한 필수 패키지. 2.5.x 버전 이상을 사용해야 함.
  • MRTK가 scene에 추가되고 구성되면 MixedRealityToolkit, MixedRealityPlayspace 두가지 object가 scene hierarchy window에 추가됨.
  • MixedRealityToolkit - toolkit 그 자체 / MixedRealityPlayspace - headset/controller 등 other required system이 scene에서 올바르게 관리되도록 보장.
  • Main camera는 MixedRealityPlayspace의 자식으로 이동

 

<Configuration profile>

  • profile : MRTK core components의 행동을 구성.
  • MixedRealityToolkit object에는 active profile이 포함되어 있으며, Inspector window에서 볼 수 있음.
  • MRTK가 scene에 추가되면, DefaultMixedRealityToolkitConfigurationProfile이 미리 선택됨.
  • MRTK는 지원하는 대부분의 플랫폼&시나리오를 다루는 추가 basic profile 제공. 위에서 미리 선택된 profile은 general use profile이므로 특정 플랫폼에 최적화 하고 싶다면 MRTK가 제공하는 profile을 선택해야 함.

 

<How are customize and configure the default MRTK profiles>

  • default MRTK profiles은 수정 불가능. 대신, 변경하려면 profile을 clone해서 수정 가능.
  • sub-profile을 수정하려면 그것도 복제해야 함.

 

5) Exercise - Import and configure resources

<Import the MRTK Unity foundation package>

  • MRTK를 import하려면 Mixed Reality Feature를 사용해야 함.
  • microsoft download center에서 Mixed Reality Feature tool을 다운받고, exe를 실행.
  • (in MR feature tool) Start -> project folder open -> Discover Features
이때, folder path를 넣기 위해서는 원하는 folder에 들어가서 file path에 _를 입력하고 확인을 누르면 된다.
  • Mixed Reality Toolkit -> Mixed Reality Toolkit Foundation 선택
  • Platform Support -> Mixed Reality OpenXR Plugin 선택 (최신버전으로)
  • get feature 클릭 -> validate 클릭 -> No validation issues were detected 가 나와야 정상!
  • import -> approve => 끝!

 

<Configure the Unity project>

  • warning 창이 뜨면 yes를 누른다.
  • 그러면 MRTK configurator가 뜨는데, 안 뜨면 다음 경로로 들어가서 띄운다.
    Mixed Reality > Toolkit > Utilities > Configure Project for MRTK
  • (in MRTK configurator) Unity OpenXR plugin -> XR Plug-In Management Settings
  • 그 뒤, project setting이 열리는데, XR Plugin management -> UWP(윈도우 로고) 설정에서 OpenXR, Microsoft HoloLens feature set 활성화.
  • XR Plug-In Management Settings -> OpenXR에서 depth 16bit 선택, interaction profile에 microsoft hand interaction profile 추가.
  • 그리고 Apply를 누르면 unity가 재시작.

 

  • 재시작 후, Edit -> project setting -> player -> publishing settings의 package name에 이름 작성 (이는 고유 식별자로써 앱의 고유 번호? 같은 것임. 이게 같으면 기존에 존재하는 앱이 덮어씌워짐)
  • product name은 hololens start menu에 표시됨. _ 을 이름 앞에 넣으면 앞에 정렬되어서 빨리 찾을 수 있음 (개발 시에만)

 

<Create the scene and configure MRTK>

  • (in unity menu) File -> New Scene -> Basic (Built-in) -> create
  • (in unity menu) Mixed Reality -> Toolkit -> Add to Scene and Configure
  • (in Hierarchy window) MixedRealityToolkit object가 선택된 상태로, Inspector window에서 MixedRealityToolkit configuration profile이 DefaultMixedRealityToolkitConfigurationProfile인지 확인
  • (in unity menu) file -> save as => Asset > Scenes 아래에 scene을 저장.

 

6) Interaction models

  • MRTK를 사용하면 6DoF controler, 손, 음성과 같은 다양한 input 사용 가능. 여기서는 세 가지 기본 interactino model과 unity input simulation에 대해 알아볼 것.

 

<Hands and motion controllers model>

  • 한 손 또는 두 손을 사용함.
  • 손으로 직접 조작 (direct manipulation) / 손으로 가리키기 (point and commit) / 컨트롤러 이용 (motion controllers)

 

<Hands-free model>

  • 손을 못 쓰는 상황일 때 음성이나 눈 움직임을 이용함.
  • 음성입력 (voice) / 응시 및 기다림(gaze and dwell)

 

<Gaze and dwell>

  • 눈을 마우스처럼 사용하면 모델! 원거리 입력 모델이라 손이 닿지 않는 것과 상호작용할 때 사용하는게 가장 좋음.
  • 응시 입력 / other commit (시선을 이용하여 대상 지정 후 음성명령, 버튼누르기, 손 제스쳐)

 

<Unity in-editor input simulation>

  • 장면 이동 : WASD(앞왼뒤오), QE(수직이동), right mouse(카메라 회전)
  • hand input 시뮬 : space 누름(오른손 활성화), 왼쪽 shift 누름(왼손 활성화) => 마우스로 움직임)
    마우스 휠(손의 깊이), 마우스 왼쪽 (핀치 제스처), T/Y (뷰에 손 만들기), CTRL 누름 + 마우스이동 (손 회전)

 

7) Exercise - Add hand interaction with object manipulator

<Add a cube to the scene>

  • Cube를 손으로 조작해보자!
  • cube 생성 : GameObject -> 3D Object -> Cube
  • cube 위치 : position (0, -0.1, 0.5), rotation (0, 0, 0), scale (0.1, 0.1, 0.1)
  • Add Component에 Object manipulator, NearInteractionGrabbable 을 추가 (상호작용을 위함)
  • Play button을 눌러 시뮬레이션

 

<Build HoloLens2>

  • 먼저 Unity project를 build 해야 함.
  • File -> Build settings -> add open scenes -> build
  • 저장위치 지정하고, 선택 (그러면 build 됨)

 

  • 그 후 어플리케이션 빌드 및 배포
  • build한 project를 visual studio에서 열고 master/release, ARM64를 선택.
  • hololens를 컴퓨터에 연결한 후 debug -> start without debugging. (그럼 어플이 자동시작됨.)