Empty (zero) cache after adding a new link

I am comparing the positions, velocities, and accelerations of all joints of a reduced coordinate articulation of before modification of the articulation.

A problem that I am running into is that the cache after removing one link and adding two links is completely different from the one before it.

###############
Cache Before
Total links: 4
Link: 00, #DOF: 0
Link: 01, #DOF: 3
DOF#: 00, pos: -0.171169, vel: 2.341829, acc: 1.350225
DOF#: 01, pos: 0.013825, vel: 0.003734, acc: 0.012243
DOF#: 02, pos: 0.169783, vel: -2.398318, acc: -1.333715
Link: 02, #DOF: 3
DOF#: 00, pos: 0.029466, vel: -3.594535, acc: -0.850073
DOF#: 01, pos: -0.000547, vel: 0.001797, acc: 0.027975
DOF#: 02, pos: -0.029153, vel: 3.711052, acc: 0.823300
Link: 03, #DOF: 1
DOF#: 00, pos: 0.010431, vel: -0.079772, acc: 9.429325

Cache After
Total links: 5
Link: 00, #DOF: 0
Link: 01, #DOF: 3
DOF#: 00, pos: 0.000000, vel: 0.000000, acc: 0.000000
DOF#: 01, pos: 0.000000, vel: 0.000000, acc: 0.000000
DOF#: 02, pos: 0.000000, vel: 0.000000, acc: 0.000000
Link: 02, #DOF: 3
DOF#: 00, pos: 0.000000, vel: 0.000000, acc: 0.000000
DOF#: 01, pos: 0.000000, vel: 0.000000, acc: 0.000000
DOF#: 02, pos: 0.000000, vel: 0.000000, acc: 0.000000
Link: 03, #DOF: -1
Link: 04, #DOF: -1

###############

I made it print an error (‘Error in DOF’) when it thinks there are more than 3 DOF.
Here is the github Gist(https://gist.github.com/xgerrmann/e02fd0d0f8938912a1db94ec3f61271c) that makes it print the articulation.

In the documentation (http://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/Articulations.html?highlight=pxarticulationcache#pxarticulationcache) it says:

if the properties of an articulation change (a link is added/removed, degrees of freedom are changed, etc.), it is necessary to destroy the cache and recreate it.

Therefore I have tried 2 options:

  • Releasing the Cache and creating a new cache after the link removal and addition before printing :
    gArticulation->releaseCache(*articulationCache);
    articulationCache = gArticulation->createCache();
    This leads to the above two caches.
  • NOT releasing the Cache and NOT creating a new cache after the link removal and addition. This leads to the two caches below

The caches are printed directly before and after the change in the articulation, no simulation step is performed.

###############
Cache Before
Total links: 4
Link: 00, #DOF: 0
Link: 01, #DOF: 3
DOF#: 00, pos: -0.174200, vel: -0.884682, acc: 0.462490
DOF#: 01, pos: 0.014501, vel: -0.001902, acc: 0.001100
DOF#: 02, pos: 0.173453, vel: 0.880688, acc: -0.461070
Link: 02, #DOF: 3
DOF#: 00, pos: 0.024137, vel: 2.789940, acc: -0.879147
DOF#: 01, pos: -0.000738, vel: -0.000452, acc: 0.002239
DOF#: 02, pos: -0.025454, vel: -2.791912, acc: 0.846920
Link: 03, #DOF: 1
DOF#: 00, pos: 0.004466, vel: 0.204585, acc: 7.778864

Cache After
Total links: 5
Link: 00, #DOF: 0
Link: 01, #DOF: 3
DOF#: 00, pos: -0.174200, vel: -0.884682, acc: 0.462490
DOF#: 01, pos: 0.014501, vel: -0.001902, acc: 0.001100
DOF#: 02, pos: 0.173453, vel: 0.880688, acc: -0.461070
Link: 02, #DOF: 3
DOF#: 00, pos: 0.024137, vel: 2.789940, acc: -0.879147
DOF#: 01, pos: -0.000738, vel: -0.000452, acc: 0.002239
DOF#: 02, pos: -0.025454, vel: -2.791912, acc: 0.846920
Link: 03, #DOF: -1
Link: 04, #DOF: -1
###############

In each case I made the following observations/hypotheses:

  • In the case where I release the cache and recreate it:
    • The number of DOF of the inbound joints seem to be incorrect: -1 where I expect 3 and 1
    • All positions, velocities, and accelerations are suddenly zero.
  • In the case where I do NOT release and NOT recreate the cache:
    • The velocities of the first two links seem to be identical to before removing and adding the links.
    • Also here, the DOF are incorrect: -1 where I expect 3 and 1

Can someone tell me how to properly get the cache data from the articulation after modifying the articulation in such a way that the DOF are as expected so that I can obtain the position, velocity and acceleration data of the new links?

Any help would be very much appreciated.