Search Unity

Question HoloLens 2 X Grpc Questions/ Problems

Discussion in 'AR' started by herzogs, Sep 30, 2022.

  1. herzogs

    herzogs

    Joined:
    Aug 10, 2022
    Posts:
    6
    Hey there, I decided it might be better to just make one bug posts containing all questions/ problems so maybe someone can help me with some of them.

    First up my current scenario:
    I want to build an app for the HoloLens 2 that can visualize Data from a Server using gRPC to get those.
    I currently use Grpc.Core.Api, Grpc.Net.Web, Grpc.Net.Web.Client & Google.Protobuf + whatever they depend on. All installed with the NuGet Manager (beside one dependency)

    In the Unity Editor everything works fine and I can see the Data.
    When I build it and deploy it on the HoloLens 2 I can see a Big Box with lots of Red Text (that I can barely read as it#s only on the right Eye?) which sadly does not show anything that helps me so far.

    Holographic Remoting Play Debugging works flawless but since it uses my PC for it it does not help with the Problem I guess.

    I am not 100% sure what the best way is to remote debug on the HoloLens 2. The one option I currently found (attach Unity Debugger) does not work as it gives me the Error tha the Type- or Namespace "Windows" is not found in this script:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace QRTracking.WindowsMR
    4. {
    5.     internal enum FrameTime { OnUpdate, OnBeforeRender }
    6.  
    7.     internal class SpatialGraphNode
    8.     {
    9.         public System.Guid Id { get; private set; }
    10. #if !MIXED_REALITY_OPENXR
    11.             private Windows.Perception.Spatial.SpatialCoordinateSystem CoordinateSystem = null;
    12. #endif
    13.  
    14.         public static SpatialGraphNode FromStaticNodeId(System.Guid id)
    15.         {
    16. #if !MIXED_REALITY_OPENXR
    17.             var coordinateSystem = Windows.Perception.Spatial.Preview.SpatialGraphInteropPreview.CreateCoordinateSystemForNode(id);
    18.             return coordinateSystem == null ? null :
    19.                 new SpatialGraphNode()
    20.                 {
    21.                     Id = id,
    22.                     CoordinateSystem = coordinateSystem
    23.                 };
    24. #else
    25.             return null;
    26. #endif
    27.         }
    28.  
    29.  
    30.         public bool TryLocate(FrameTime frameTime, out Pose pose)
    31.         {
    32.             pose = Pose.identity;
    33.  
    34. #if !MIXED_REALITY_OPENXR
    35.             Quaternion rotation = Quaternion.identity;
    36.             Vector3 translation = new Vector3(0.0f, 0.0f, 0.0f);
    37.                    
    38.             System.IntPtr rootCoordnateSystemPtr = UnityEngine.XR.WindowsMR.WindowsMREnvironment.OriginSpatialCoordinateSystem;
    39.             Windows.Perception.Spatial.SpatialCoordinateSystem rootSpatialCoordinateSystem =
    40.                 (Windows.Perception.Spatial.SpatialCoordinateSystem)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(rootCoordnateSystemPtr);
    41.  
    42.             // Get the relative transform from the unity origin
    43.             System.Numerics.Matrix4x4? relativePose = CoordinateSystem.TryGetTransformTo(rootSpatialCoordinateSystem);
    44.  
    45.             if (relativePose != null)
    46.             {
    47.                 System.Numerics.Vector3 scale;
    48.                 System.Numerics.Quaternion rotation1;
    49.                 System.Numerics.Vector3 translation1;
    50.      
    51.                 System.Numerics.Matrix4x4 newMatrix = relativePose.Value;
    52.  
    53.                 // Platform coordinates are all right handed and unity uses left handed matrices. so we convert the matrix
    54.                 // from rhs-rhs to lhs-lhs
    55.                 // Convert from right to left coordinate system
    56.                 newMatrix.M13 = -newMatrix.M13;
    57.                 newMatrix.M23 = -newMatrix.M23;
    58.                 newMatrix.M43 = -newMatrix.M43;
    59.  
    60.                 newMatrix.M31 = -newMatrix.M31;
    61.                 newMatrix.M32 = -newMatrix.M32;
    62.                 newMatrix.M34 = -newMatrix.M34;
    63.  
    64.                 System.Numerics.Matrix4x4.Decompose(newMatrix, out scale, out rotation1, out translation1);
    65.                 translation = new Vector3(translation1.X, translation1.Y, translation1.Z);
    66.                 rotation = new Quaternion(rotation1.X, rotation1.Y, rotation1.Z, rotation1.W);
    67.                 pose = new Pose(translation, rotation);
    68.                 return true;
    69.             }
    70.             else
    71.             {
    72.                 // Debug.Log("Id= " + id + " Unable to locate qrcode" );
    73.             }
    74. #endif // WINDOWS_UWP
    75.             return false;
    76.         }
    77.     }
    78. }
    Why is Windows not found here? I develop on a Windows PC and the HoloLens is itself a windows PC as well.

    Any ideas how to maybe fix Remote Debugging?
    Did someone got gRPC working and Running on the HoloLens?
    Can someone tell me how to actively use the Debug Windows on the HoloLens 2 to maybe see what the problem is there? (My current prediction is that some .dll either don't work on the HoloLens or don't get transferred, maybe I'm wrong tho)

    Thanks for any help!