Automatic height offset in Unity livelink not working correctly

I am trying to correctly apply height offsets to the avatars displayed via ZED Unity LiveLink, but I am having trouble understanding how the height offset is applied, and why it is not applied correctly.

Looking at the image below, it is clear that the avatars (which are identical btw) are not all correctly placed on the floor plane. The ankle height offset for all avatars is equal to 0.1 so there is no difference there.

Any idea why this is happening?

EDIT: I notice that I have no tagInvisibleToZED layer in my application as referenced to here ( Body Tracking - Stereolabs) - note that is not the livelink application. The Zed skeleton animator script has raycast detection layers of “Nothing”. Could this be the issue?

Edit 2: I created a layer with a plane at y=0 and assigned it to “Raycast detection layer” and “Layers to hit” of all avatars, but I still get the issue.

Hi @haakonflaar,

The automatic height offset will raycast and find the height difference between the soles and the ground.

Thanks to your report, I noticed a wrong comment in the code:

The Zed skeleton animator script has raycast detection layers of “Nothing”. Could this be the issue?

Explicitly not, this is a miscomment/misnamed variable, these are the layers ignored by the Physics.Raycast. I’ll update it. It should not include the ground layers, hence the default value of “Nothing” so that everything is ground.

The automatic offset can take a little bit of time to update, but it should not stay wrong for more than a couple of seconds.

  • What does the setup look like?
  • If I understand correctly, you want to use the automatic offset, is that right?
    • Did you enable it in the ZEDBodyTrackingManager script?
    • Does the manual offset work correctly?
  • Did you enable other animation adjustment features? (foot IK, skeleton smoothing…)
  • Also, in the ZEDSkeletonAnimator.cs script, can you see if the ray casts actually hit something? Around those lines: ZEDSkeletonAnimator.cs:300
  • What does the setup look like?

Right now I am replaying skeleton data I’ve recorded previously. The avatars are animated identically as when running the setup live.

  • If I understand correctly, you want to use the automatic offset, is that right?
    Did you enable it in the ZEDBodyTrackingManager script?
    Does the manual offset work correctly?

All yes

  • Did you enable other animation adjustment features? (foot IK, skeleton smoothing…)

Smoothing is on, foot IK off, foot locking on (although foot locking does not seem to do anything)

  • Also, in the ZEDSkeletonAnimator.cs script, can you see if the ray casts actually hit something? Around those lines: ZEDSkeletonAnimator.cs:300

Yes, it does hit:
Raycast hit: True with position: (0.09, 0.00, -2.40) and normal: (0.00, 1.00, 0.00) and distance: 0,9413501 and collider: Plane (UnityEngine.MeshCollider)
Position with y=0 seems right.

The avatars are being automatically offsetted - if I adjust the ankle height offset their height will change, however, avatars standing in about the same fashion are not all correctly placed on the floor.

@haakonflaar

Weird, if it does hit at this point, it should be passed correctly in the next steps.
Can you see if ComputeRootHeightOffsetFromRaycastInfo runs correctly?
Checking the values and all. This produces the offset used for the automatic offset if it’s enabled.

@JPlou

Can’t see anything specifically wrong there.

In the image below I have logged the position of each ankle of the two avatars standing upright next to each other. The gap to the floor is not major but it is significant, specially since one avatar is above ground and the other below.

image

I have set the avatar threshold to really low, so both avatars should be pretty much placed dead on the ground, if I am not mistaken?

image

Edit: It does seem like the offsets should be correct - I don’t understand why it is clearly visible that one avatar is way below the other. In the image below I have set ankle height offset to 0 and it is re-calculating offset basically every frame:

@JPlou

Can’t see anything specifically wrong there.

In the image below I have logged the position of each ankle of the two avatars standing upright next to each other. The gap to the floor is not major but it is significant, specially since one avatar is above ground and the other below.

image

I have set the avatar threshold to really low, so both avatars should be pretty much placed dead on the ground, if I am not mistaken?

image

[Discourse post]

@haakonflaar

I’ve found an issue in the height offsetter’s code, maybe that’s it.
On this line in LowestFootIsCloseToGround, it should do the opposite check: offsetL >= offsetR.
In the current state, I think it does the opposite of what it should.

  • Can you check if it fixes it on your side?

For the parameters you’re using:

  • For the height offsetter, you’re right, it should be “satisfied” only if the lowest foot’s distance to the ground is less than Dist Close To Floor.

  • For the IK, the thresholds should be broader, it will start applying IK to stick the foot at the floor’s height between Leave Ground State and Enter Ground State. The foot will also not move if the movement is less than the Threshold Foot Lock.

  • Side note, did you also change the lerp duration in the LerpAutoOffset coroutine? It may cause issues if it’s more than the frequency of the checks.

@JPlou

Somewhat better - getting this bobbing effect now (1s between each check here):

Pretty much default settings:

image

@haakonflaar

What happens if you set a very low Lerp duration so that it’s pretty much instantaneous?

I think it’s related to checks being made while changes are being made, somehow breaking said checks.

@JPlou

Hmm, back to the original problem if I do that I’m afraid - some avatars under ground and some over.

Strange problem this, and a lot of logic to unpack.

@haakonflaar

The issue for me right now is that I have difficulties reproducing the problem on my side, it works as expected both with the Fusion and mono senders.
The stability of the input data may play a role. Is it moving a lot if the automatic offset is not active?

fusion.mkv (1.4 MB)

Side note, the foot locking will only be active if the foot IK is active.

Would it be possible for you to send a sample project reproducing the issue, along with data to test, either here or via support@stereolabs.com?

@JPlou

Thanks for the help :slight_smile:

I ended up writing logic to manually offset the avatars at each time step. That does the trick for my replay data at least.

As for running it live, I will continue to use your automatic height offset logic, and I’ll report back if I have significant issues there as well.

1 Like