Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to change the World Coordinate (0,0,0) position in HoloLens to QR Code Position

Discussion in 'AR' started by kb1121, Nov 18, 2022.

  1. kb1121

    kb1121

    Joined:
    Aug 19, 2022
    Posts:
    5
    Hello,
    Ive wrote a program that is a guide to show were different objects are located in are plant the coordinates are saved to a Json file and are loaded depending on which one is selected. I currently have a QR code scanner that the Hologram start there position from this works fine until I exit out of the app then back in the Hologram positions moved depending on where i opened the app at. Is there any way to use a button in the app to change the World (0,0,0) position to were the QR Code is Ive not been able to find anything to help online. Ive tried using World Anchors but can not get them to work. Any help would be Appreciated.
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
    Unity's world origin in an XR app will always be located at the device position when the app was first launched. Rather than move the world origin, why not use a system of Transforms to calculate the necessary offset? For example, base your calculations using the global position of the QR Code rather than Unity's world origin?
     
  3. kb1121

    kb1121

    Joined:
    Aug 19, 2022
    Posts:
    5
    Are you talking about using GPS coordinates to get the location of the QR Code? If so that way wont be accurate enough i need to be within a 1/2".
     
  4. mikeyrafier98

    mikeyrafier98

    Joined:
    May 19, 2022
    Posts:
    37
    Hi, kb1121
    I am not very expert programmer, but I hope I can help.

    AR Foundation used to have "makeContentAppearAt" function, but it has been removed. Maybe because its usability is not very capable, but I hope they will make a better solution. I once tried to move the AR Origin, or XR Origin in latest version, to the desire position. But be caution by this action, the Unity world origin coordinate will be moved.

    As for example, a point of (1,1,1) on before moving the origin will be not the same as after moving, that is because (1,1,1) it used to refer to the previous origin, not the after moving origin. So, this situation should be concerned.

    I don't know exactly if it will be work in your situation. In simple context, when the camera scan the QR code, then able to get the relative coordinate (position, rotation) in world origin, perhaps you can try to move the XR Origin into that coordinate. But there is also one consideration. In the AR Foundation backend, which we cannot crack that much, the system will also know where the original position of this origin.

    When the system always update the camera coordinate (by IMU sensor, etc.), relative to the world coordinate in every frame, there will be possibility it also return the world origin into its first time original coordinate (position, rotation). So, it changing the XR Origin position is not working, then this possibility can be happened.

    As for alternative, I try to make a empty GameObject, named root. This game object will be the world coordinate of all my objects under it as childern. By positioning this root in your desire position, you already have a world coordinate position by your own, without have to worry where is the Unity World Coordinate (0,0,0).

    But, this also be caution, you cannot use transform.position to get the relative object's under the root position, because it will return the position relative to the Unity World Coordinate, not to the root coordinate. You might want to see about how to transform ObjectA --> WorldCoordinate --> Root by homogenous matrix transformation, in order to get ObjectA's position relative to the Root.

    Good luck, and hope it can help.
     
  5. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
    @mikeyrafier98 We added an extension method for MakeContentAppearAt to our Samples project as a suggestion if you want to continue using that API in new projects. See our docs.
     
  6. kb1121

    kb1121

    Joined:
    Aug 19, 2022
    Posts:
    5
    I was able to get the world anchor to work and this fixed most of my issues I was having. The only issue I am having now is my holograms drift away from where I save them they only do this if I am away from were i put the world anchor if i save it near the anchor there is no issues. Is there a way to add more anchors? I am working in a 2,000,000 SQFT factory so i think the distance is casuing most of the issues. I thought about using the QR Codes to aligh the holograms when im nearing there location but im not sure on how to do this.
     
  7. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
  8. kb1121

    kb1121

    Joined:
    Aug 19, 2022
    Posts:
    5
    Ive tried using them but I am still having issues with the holograms drifting. Ive also tried using World Locking tool but still the hologram drift a few inches when a move more then a 100ft away. Is there another way to keep them from drifting?
     
  9. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
    Drift is an inevitable byproduct of body-worn tracking systems such as the HoloLens. You can reduce the likelihood of drift in practical ways, such as:
    • Ensuring your space is well-lit
    • Creating a space rich in feature point density
    • Directing the user to move slowly
    • Removing any reflective surfaces, closing any window shades, etc
    but using built-in tracking you ultimately cannot avoid drift.

    To reduce the impact of drift, you could periodically re-localize against images at known positions in your space as you mentioned before. It doesn't look like Microsoft's OpenXR implementation supports image tracking, but it looks like there are other SDK's available you could use to track images: https://learn.microsoft.com/en-us/w...p/advanced-concepts/qr-code-tracking-overview