Skip to content

FIX: Corrected behaviour of TrackedPoseDriver when no device is connected. #1823

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

Merged
merged 24 commits into from
Mar 3, 2025

Conversation

ekcoh
Copy link
Collaborator

@ekcoh ekcoh commented Jan 29, 2024

Description

This fix is intended to fix reported behaviour in ISXB-699
.

Changes made

Modified behaviour so that when position and rotation are assigned actions, they are evaluated similar to tracking state is such a way that they may only be applied if the binding is associated with a resolved control. If not, the evaluated tracking state will not contain the flag for the corresponding transform. This applies to ignoreTrackingState == false.

Modified behavior so that when entering playmode with ignoreTrackingState == true, the transform of the associated GameObject is preserved rather then forcibly reset to identify transform. This is achieved by initialising the internal m_CurrentPosition and m_CurrentRotation based on the local transform of the associated GameObject.

Added a test case that is mimicking the reported behavior.

Notes

Requesting insights from XR team regarding any implications this might have since behavior wasn't previously covered properly in existing test cases. It also changes the behaviour commented inline in the implementation.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

…cted with an additional test case mimicking the reported scenario.
@ekcoh ekcoh added the work in progress Indicates that the PR is work in progress and any review efforts can be post-poned. label Jan 29, 2024
@smnwttbr smnwttbr marked this pull request as ready for review November 11, 2024 03:21
@Pauliusd01
Copy link
Collaborator

@smnwttbr I don't have any XR devices so I'll add an XR QA instead. @UnityRyanC

@Pauliusd01 Pauliusd01 requested review from UnityRyanC and removed request for Pauliusd01 November 11, 2024 08:29
@UnityRyanC
Copy link

I won't be able to test this PR as I don't have a Mac (which the bug mentions was where the issue was reproduced on). I spoke with Manuel Gonzalez Solano, who does testing on PolySpatial and Apple Vision OS, who'll be able to test this once he's free later this week.

I don't have permission to update reviewers on this PR, so @Pauliusd01 could you update the PR for me please?

@Pauliusd01
Copy link
Collaborator

I won't be able to test this PR as I don't have a Mac (which the bug mentions was where the issue was reproduced on). I spoke with Manuel Gonzalez Solano, who does testing on PolySpatial and Apple Vision OS, who'll be able to test this once he's free later this week.

I don't have permission to update reviewers on this PR, so @Pauliusd01 could you update the PR for me please?

Okay, I dmed him on slack since I can't find him on github by name.

@Pauliusd01 Pauliusd01 removed the request for review from UnityRyanC November 13, 2024 07:25
@mangosol
Copy link

@Pauliusd01 can you add me as reviewer? I don't seem to have permission to add myself

@Pauliusd01 Pauliusd01 requested a review from mangosol November 14, 2024 07:11
Copy link

@mangosol mangosol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the isxb-699-trackedposedriver-fix branch against a new Universal 3D project created and run using Unity Editor 6000.0.26f1 apple silicon and 2022.3.51f1 apple silicon, on an M1 macOS machine.

I did observe that the non-origin position and rotation was preserved on GameObjects having Tracked Pose Driver components if I left the Ignore Tracking State checkbox enabled.

If I check the Ignore Tracking State checkbox, GameObjects having Tracked Pose Driver component and set at non-origin position and rotation are once again returned to origin position and rotation when PlayMode starts

I also observed that setting Update Type = Before Render with Ignore Tracking State checked, non-origin rotations and positions are preserved when starting PlayMode

@mangosol
Copy link

mangosol commented Dec 4, 2024

I've also bound input actions to change position and rotation on GameObjects having TrackedPosedDriver component, and I observe the following:

  • When TrackedPoseDriver is configured with Ignore Tracking State unchecked, I am able to modify position and rotation, and the updated values persist.
  • When TrackedPoseDriver is configured with Ignore Tracking State checked, and Updated Type is set Update and Before Render || Update, and Tracking Type is set to Rotation and Position, then any changes made to position and rotation are reset immediately after applied (likely on next frame).
  • When TrackedPoseDriver is configured with Ignore Tracking State checked, and Updated Type is set Update and Before Render || Update, and Tracking Type is set to Rotation only, then any changes made to rotation are reset immediately after applied (likely on next frame). Position changes are applied successfully and persist.
  • When TrackedPoseDriver is configured with Ignore Tracking State checked, and Updated Type is set Update and Before Render || Update, and Tracking Type is set to Position only, then any changes made to position are reset immediately after applied (likely on next frame). Rotation changes are applied successfully and persist.

@ekcoh
Copy link
Collaborator Author

ekcoh commented Feb 17, 2025

I've also bound input actions to change position and rotation on GameObjects having TrackedPosedDriver component, and I observe the following:

  • When TrackedPoseDriver is configured with Ignore Tracking State unchecked, I am able to modify position and rotation, and the updated values persist.
  • When TrackedPoseDriver is configured with Ignore Tracking State checked, and Updated Type is set Update and Before Render || Update, and Tracking Type is set to Rotation and Position, then any changes made to position and rotation are reset immediately after applied (likely on next frame).
  • When TrackedPoseDriver is configured with Ignore Tracking State checked, and Updated Type is set Update and Before Render || Update, and Tracking Type is set to Rotation only, then any changes made to rotation are reset immediately after applied (likely on next frame). Position changes are applied successfully and persist.
  • When TrackedPoseDriver is configured with Ignore Tracking State checked, and Updated Type is set Update and Before Render || Update, and Tracking Type is set to Position only, then any changes made to position are reset immediately after applied (likely on next frame). Rotation changes are applied successfully and persist.

Thanks for the feedback @mangosol , I have taken this old PR back again since @smnwttbr worked on it to conclude this. How should I interpret your assessment, is it in line with what you would expect? Any additional feedback/perspective from @chris-massie?

@ekcoh
Copy link
Collaborator Author

ekcoh commented Feb 17, 2025

I tested the isxb-699-trackedposedriver-fix branch against a new Universal 3D project created and run using Unity Editor 6000.0.26f1 apple silicon and 2022.3.51f1 apple silicon, on an M1 macOS machine.

I did observe that the non-origin position and rotation was preserved on GameObjects having Tracked Pose Driver components if I left the Ignore Tracking State checkbox enabled.

If I check the Ignore Tracking State checkbox, GameObjects having Tracked Pose Driver component and set at non-origin position and rotation are once again returned to origin position and rotation when PlayMode starts

I also observed that setting Update Type = Before Render with Ignore Tracking State checked, non-origin rotations and positions are preserved when starting PlayMode

Thanks for the feedback @mangosol , I have taken this old PR back again since @smnwttbr worked on it to conclude this. How should I interpret your assessment, is it in line with what you would expect? Any additional feedback/perspective from @chris-massie?

@mangosol
Copy link

Thanks for the feedback @mangosol , I have taken this old PR back again since @smnwttbr worked on it to conclude this. How should I interpret your assessment, is it in line with what you would expect? Any additional feedback/perspective from @chris-massie?

I do not have sufficient context on whether the behavior I observed is expected or not; my assessment is meant to describe current behavior for either you or any other stakeholder with more in depth knowledge of functional requirements to determine if the current behavior is expected or not given the changes in this PR. I'm happy to sign off if behavior is in line with requirements

@ekcoh
Copy link
Collaborator Author

ekcoh commented Feb 20, 2025

Thanks for the feedback @mangosol , I have taken this old PR back again since @smnwttbr worked on it to conclude this. How should I interpret your assessment, is it in line with what you would expect? Any additional feedback/perspective from @chris-massie?

I do not have sufficient context on whether the behavior I observed is expected or not; my assessment is meant to describe current behavior for either you or any other stakeholder with more in depth knowledge of functional requirements to determine if the current behavior is expected or not given the changes in this PR. I'm happy to sign off if behavior is in line with requirements

OK, thanks, I will do a review of this then and assess it and then make a decision based on that. Thanks for testing this through and carefully documenting observations. Its helpful.

… state if position and/or rotation actions have a resolved control that could drive input. Additionally fixed so that ignoreTrackingState == true, doesn't reset to identity, but preserve the configured transform of the associated GameObject.
@ekcoh
Copy link
Collaborator Author

ekcoh commented Feb 21, 2025

This PR have been updated based on reviewing implementation and previous suggested fix. I have updated the PR description accordingly. It would be fantastic if it would be possible to reassess this fix and ensure there are no regressive behavior in XR domain. @mangosol @chris-massie

@ekcoh ekcoh requested review from mangosol and ritamerkl February 21, 2025 14:44
@ekcoh ekcoh removed the work in progress Indicates that the PR is work in progress and any review efforts can be post-poned. label Feb 24, 2025
Copy link
Collaborator

@ritamerkl ritamerkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. I suggest outsourcing the HasResolvedControl method since it could be useful in more cases.

Copy link
Collaborator

@vrdave-unity vrdave-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor tweaks.

…ility as well as used cached evaluations for resolved bindings to avoid dual evaluation.
@ekcoh ekcoh requested a review from vrdave-unity February 27, 2025 12:13
Copy link
Collaborator

@vrdave-unity vrdave-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good. I don't think it should impact performance too much since the HasResolvedControl calls only happen during the first update.

@ekcoh
Copy link
Collaborator Author

ekcoh commented Feb 28, 2025

@chris-massie I have applied all your suggestions to the PR and re-run CI on the branch. Hence requesting re-review. Additionally do you think an additional QA pass is needed from @mangosol or other XR QA before this lands or not?

Copy link
Collaborator

@chris-massie chris-massie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested these changes out with the XRI simulator and it seemed to work as I expected where the existing pose is retained if there's no device. If I connect the device late the Transform stays at the initialized pose until a change from (0, 0, 0) happens on the device, at which point it updates as expected.

@ekcoh
Copy link
Collaborator Author

ekcoh commented Feb 28, 2025

Thanks @chris-massie and @vrdave-unity for the latest reviews and testing, it was very valuable. I will get this merged based on this.

@ekcoh ekcoh merged commit 581d5da into develop Mar 3, 2025
94 checks passed
@ekcoh ekcoh deleted the isxb-699-trackedposedriver-fix branch March 3, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants