Fix calculateInverseDynamics losing one joint DOF for floating bodies #4585
+2
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #4578
The issue here is that the last positional degree of freedom of floating bodies is ignored in calculateInverseDynamics.
This is because the indexing of q does not account for the drop in degree of freedom when converting from a quaternion angle (4 DOF) to an Euler angle (3 DOF).
bullet3/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
Line 12333 in 6bb8d11
With a floating body, baseDofQ is set to be 7.
bullet3/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
Lines 12344 to 12366 in 6bb8d11
q[0] through q[5] are set in the if statement. However the for loop starts at q[7], meaning that q[6] is never set and the last joint position is excluded from the array.
This can be fixed by subtracting 1 from the indexing of q (not clientCmd.m_calculateInverseDynamicsArguments.m_jointPositionsQ as this uses a quaternion) in the case of a floating body.