Software Archive
Read-only legacy content
17061 Discussions

Unity Tip: Understanding Rotational "Snapping" With TrackingAction

MartyG
Honored Contributor III
2,080 Views

Hi everyone,

If you use the TrackingAction RealSense script in Unity to power the rotation of objects then you may notice that the object will sometimes jump out of the desired position.  This occurs particularly when the camera gains and loses tracking of the hand or face.  In the case of using RealSense with avatar  bodies, it can mean that a character's arm leaps sideways or one eyelid half-closes whilst the other remains open.

My company has been researching and experimenting with this problem for over a year and found that there is little that can be done with constraints, rules or custom scripting to minimize the snapping.  Even if you manage to deactivate the TrackingAction at the instant that a snap is about to occur to prevent the object from mis-rotating, the TrackingAction initiates the delayed snap-movement as soon as it is switched on again and re-acquires tracking.  

This is because it reads the current position of the hand or face landmark that a particular TrackingAction is set to and then pulls the rotation angle of the object towards that landmark.  So if you switch off the TrackingAction when your hand is at the side of your body, move your hand towards the center of your chest and switch the TrackingAction back on again, the object will flip sidewards towards the chest where your hand currently is. 

Another phenomenon that we had observed was that if the Virtual World box values of a TrackingAction that is configured for rotation are set to '0' then they are automatically changed to '1' as soon as tracking is acquired.  

1.jpg

If you are wondering why we were using '0' for our rotational Virtual World Box values instead of the default '100': it is because having a Virtual World Box with perfectly spherical objects (like the limb joints in our avatar) seems to achieve nothing at all except generate unsightly giant red boxes in the editor.  We speculate that this is because a sperical object spins on the spot and so can never touch the sides of the box, and that the Virtual World Box would work best with irregularly shaped objects that can make contact with the Bos's boundaries when rotated and have their movement blocked.

Anyway ... since we had observed that a "snap" in the settings of the TrackingAction when the program is running - such as the loss and re-gaining of tracking - can pull an object away from where you want it to be, we speculated that something similar might be happening with the automatic change of our Virtual World Box value from '0' to '1' at program start-up.  

It was possible that the change in VBW values caused a change in the rotational joints at the very start of the program that it could not recover from, making the controls prone to going wrong.  We therefore decided that the best way to avoid this start-up snap might be to simply set the VWB values of every single one of our rotational TrackingActions - both hand and face ones' - to the '1' value by default so that they did not have to be altered by the TrackingAction when tracking was acquired.

2.jpg

When we performed testing of the avatar with the new '1' setting, we found that the smoothness of the joint rotations had increased considerably, with much less jolting during movement and easier achieving of more difficult actions such as lifting the avatar arms above its head.  It wasn't a perfect cure, since the TrackingAction still has other issues to be dealt with, such as producing unwanted direction changes when the wrist is turned slightly, even if the joint is not set to track the wrist joint.  But eliminating the automatic updating of the RWB value had certainly improved the controls of our avatar.

3.jpg

Another way you can precisely customize your Virtual World Box settings is in the 'Center Reference' menu.  By default it is set to 'Self.'  This means that the TrackingAction automatically generates values that will move the center-point of your Virtual World Box away from the absolute center of your object.  Sometimes the values are too tiny to make much of a difference, and sometimes they are as large as '10' or '-10', which can cause a noticable offset in the box's boundaries.

You can avoid this auto-generation of the Center values by choosing the 'Custom' option from the 'Center Reference' menu and then setting all of the Center values manually to '0.'  When your program is run, your Virtual World Box will remain perfectly on-center no matter what.

1.jpg

CONCLUSION

Once you understand how the TrackingAction script can change the rotation angles of your object based on factors such as jumping to a landmark's new position after tracking is acquired or how much you are unconsciously turning your hands sidewards when using your hands to control an object, it makes it easier to design counter-measures for these unwanted angle changes to produce smoother animation and more refined control.

Best of luck!  If you have questions, feel free to ask them in the comments below.

 

 

 

 

 

0 Kudos
33 Replies
xinyang_w_
Beginner
596 Views

After selecting "Access Order Fixed", my hands still chaos, I am out of the left hand, the model is still moving two hands, I want me out of the left hand, my left hand was moving model only, the right hand does not move, I'm out right my model only move his right hand, the left hand does not move

0 Kudos
xinyang_w_
Beginner
596 Views

I re-set. You see, thank you

0 Kudos
MartyG
Honored Contributor III
596 Views

Do the arms on your avatar move?  If they do, please make sure that the left arm's TrackingAction is set to Index 0 and the right arm is set to Index 1.  If your right arm has Index 0 (when it should be Index 1), then when the left arm moves, the right arm will move too.

Here is what my arms look like.

1.jpg

不要在你的頭像的胳膊動?如果他們這樣做,請確保左臂的TrackingAction設置為指數0和右臂被設置為指數1。如果你的右臂有索引0(當它應該是指數1),左手臂的動作那麼當,右臂將移動過。

 

0 Kudos
MartyG
Honored Contributor III
596 Views

I see that you are using my Real World Box values of 200.  You should change the Real World Box Center value from '50' to '100' if you are going to do this.  :)

0 Kudos
xinyang_w_
Beginner
596 Views

1 left all, shoulders, forearms, arms, fingers all the index values are 0,
which hand options: access_order_fixed, continuous Tracking: not checked, real world box dimension: 50.
2 All right, shoulders, forearms, arms, fingers all index values are 1,
which hand options: access_order_fixed, continuous Tracking: Tick, real world box dimension is 50.

0 Kudos
MartyG
Honored Contributor III
596 Views

If you are still having both hands move when only one hand is being moved, the next thing to look at is to make sure that the objects in your left and right hands are totally separate.

If you have linked a piece of your left hand to your right hand model, or a piece of your right hand to your left hand model, then when one is moved, it will pull the connected piece in the other hand.

You can see in my picture of my two arms above that when one arm is selected, only that arm lights up, and nothing in the other arm is highlighted.

如果您仍然有雙手的時候只用一隻手被移動移動,接下來要考慮的是確保你的左手和右手的對象是完全獨立的。

如果您已連接了一塊左手到右手的模型,或一塊你的右手到左手的模型,那麼當一個移動,這將拉動連接件在另一方面。

你可以在我的我的兩個胳膊上面的圖片中看到,當選擇了一條手臂,只手臂補光燈,並沒有在另一只手臂被突出顯示。

0 Kudos
MartyG
Honored Contributor III
596 Views

Yes, that looks correct.  I do not know what else to suggest.  If you attach a zip file of your project folder then I will take a look at it.

是的,這看起來是正確的。我不知道還有什麼建議。如果您將項目的zip文件,然後我會看看它。

0 Kudos
MartyG
Honored Contributor III
596 Views

It was an empty project with no assets in.  There was nothing for me to look at.  Can you check again that you sent me the correct folder please?

這是在沒有資產空項目。沒有什麼讓我看看。你可以再次檢查你送我正確的文件夾嗎?

0 Kudos
xinyang_w_
Beginner
596 Views

Project Name: only, thank you so much!!!

0 Kudos
xinyang_w_
Beginner
596 Views

thank you 

0 Kudos
xinyang_w_
Beginner
596 Views

If you still can not, you can send a message to my mailbox it? I send it to you by way of Email

0 Kudos
MartyG
Honored Contributor III
596 Views

The link still did not work.  I will send you an email at the address you gave me earlier in this conversation so that you can attach your zip to a reply.

0 Kudos
xinyang_w_
Beginner
596 Views

I passed up the link does not support, I use Baidu cloud dish, I'll give you transfer project, my friends can download, I retransmit a ZIP, trouble you! ! !

0 Kudos
Reply