-
-
Notifications
You must be signed in to change notification settings - Fork 196
Fix acceleration axis and leg tweaks #1014
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
base: main
Are you sure you want to change the base?
Conversation
0f53831
to
9f6ff6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't affect skating-correction since the magnitude of acceleration is not being changed. The logic looks good as far as I can tell
Not really. Some code uses only the two components, like private fun correctUnlockedFootTracker(footPosition: Vector3, previousFootPosition: Vector3, previousFootPositionCorrected: Vector3, footVelocity: Vector3, framesUnlocked: Int): Vector3 {
var newFootPosition = footPosition
var footDif = footPosition - previousFootPositionCorrected
footDif = Vector3(footDif.x, 0f, footDif.z) |
That is a positional correction, the acceleration is not used like that, I just checked. Mocap mode does use the acceleration direction though so this will help that! |
server/desktop/src/main/java/dev/slimevr/desktop/tracking/trackers/hid/TrackersHID.kt
Outdated
Show resolved
Hide resolved
@ImUrX is anything else required for this PR to be merged? |
You need to wait for more reviewers |
I though that two reviwers are enough. Should we ping someone to make a review? |
server/desktop/src/main/java/dev/slimevr/desktop/tracking/trackers/hid/TrackersHID.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code itself looks good but testing with official SlimeVR trackers, looking at the values on the GUI (not the preview), it still seems like the original way was the right way (Vector3(v.y, v.x, v.z)
). Maybe it'd be worth looking in the firmware if the acceleration is transformed.
However, the accel arrows preview and the local -> global conversion for accel are both broken in some way
@Stermere id don't know if the fusion does the order right, but, at least, they in the right order during packet formation. If you like I could take the original On the other hand, if the bug is in the fustion, than the firmware has to be fixed instead of tuning the server for the firmware. At least, we could define a new version of protocol. The reason is because slime wants to be a kind of opensource standard for VR. The current acceleratoin offsets is defenetely wrong. Some code may work better now because it was tuned for the current wrong offsets. That could work for now but it can be so for a robust code evolution. |
rebased |
@Eirenliel @sctanf Do I need to made another rebase? when it will be merged? |
@sctanf Did you post a hardware tracker axis or a slime VR axis? |
The PR made acceleration conversion based on existing quaternion conversions. |
This should be what a device reports, with axes local to the device |
Yes, that is what is expected on input at this PR |
fun axisOffset(v: Vector3): Vector3 = Vector3(v.x, v.z, -v.y) | ||
private val rotationOffset = Quaternion(INV_SQRT_TWO, -INV_SQRT_TWO, 0f, 0f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The axes may need to be rotated along the device before remap
fun axisOffset(v: Vector3): Vector3 = Vector3(v.x, v.z, -v.y) | |
private val rotationOffset = Quaternion(INV_SQRT_TWO, -INV_SQRT_TWO, 0f, 0f) | |
fun axisRemap(v: Vector3): Vector3 = Vector3(v.x, v.z, -v.y) | |
private val rotationOffset = Quaternion(INV_SQRT_TWO, -INV_SQRT_TWO, 0f, 0f) | |
fun axisOffset(v: Vector3): Vector3 = axisRemap(rotationOffset.sandwich(v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axisOffset
is an optimized version for rotationOffset.sandwich(v)
It either one or another, they are the same.
BTW, I would recommend to
- store only normalized rotations
- use a raw rotation function, which needs ~15 multiplications (wiki), or at least use two quaternion multiplications. Current
sandwich
code uses quaternion inversion, which us slow. With current state of Koltin you will not feel the difference. However, in the future, with Project Valhalla, Quaternion can be optimized a lot, so the division will be bottleneck. I am thinking about SlimeVR server running on lightweight XR headsets directly, not PC.
The accel axises are definitely wrong in this PR, front and top are swapped when testing it with current slimevr fw for both BNO and ICM. |
i would expect they are swapped also somewhere else, if the server shows the expected axis structure before this PR |
rotation is corrected for the change in system, but the axes between the two systems are already aligned, the accelerometer data most likely do not need to be remapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done testing with actual trackers with the latest firmware. With the latest firmware, trackers send accelerometer axises the same way as rotations, so they should have the same transformations. See here for the changes you might need to make to your firmware: https://github.com/SlimeVR/SlimeVR-Tracker-ESP/blob/cd97d17d9a9834051b44629c711399218dcc8868/src/sensors/sensor.cpp#L34
This also changes the comment for the transformations to clarify why this transformation is required and what do we even do with it (it's not converting to OpenGL axises).
server/core/src/main/java/dev/slimevr/tracking/trackers/Tracker.kt
Outdated
Show resolved
Hide resolved
…r.kt Co-authored-by: Eiren Rain <[email protected]>
Seems like stuff is still broken... Debugging it |
So it seems that the remap is correct and is also needed. I'm trying to understand WHY though. |
@9il @sctanf i started working on it in a separate branch, testing with a gravity vector. FOR SOME REASON, it works when used like this, but I don't understand why we need to apply the axis offset twice... https://github.com/SlimeVR/SlimeVR-Server/tree/accel-mapping-fixes |
@Eirenliel I would like to have but it is hard to understand what is going on. Does firmware uses global coordinate or local coordinate for acceleration? What transformation represent the rotation quaternion? Does Slime expect acceleration vector with substracted gravity or with gravity present? Suggestion to get rid of chaos:
Less transformations along the way. |
P.S. thank you for digging in to this rabbit hole |
@9il do you do any rotations or transformations in firmware? |
@Eirenliel Our firmware uses the same axis as defined in ICM specification (tracker axis). In this case I would say "No". On the other hand, sensor fusion algorithms like VQF has a few axis they operate during fusion, in this terms, "Yes". |
Thanks. And you confirmed that it works with just your changes? I think I know where the issue is in our code... |
I can't confirm our firmware works with SlimeVR, but, it works in our test software. We will test slimeVR later this summer. One thing I would add is that "front", "right", and "up" aren't very descriptive because they are relative to what one had in their had when they think about a specific tracker. Please take a look at Transformation between Left and Right isn't possible with Quaternion. I think this may be a part of the issue. Right-left conversion should be defined with axis permutation and rotation in the same time. What we need to define for firmware and software API is:
![]() |
Fixes #1006
This PR fixes the axis for leg tweaks! However, an additional update of thresholds may be required.
@ImUrX, please test it in standard mode with leg tweaks like skating correction.
I don't have slimes for testing.