Incorrect body velocites by using get_actor_rigid_body_states


I am using Isaac Gym for rope simulation where the rope model is a series of connected bodies with spherical joints, and I try to print the velocity of the body (or the link) by using the function ‘get_actor_rigid_body_states()’. However, from the visualization and the printed position information I can confirm two end bodies of the rope are manipulated to be hung statically in the air by constantly applying a spring-damping force, the velocity of the first end body is non-zero, and looks quite large numbers (~0.4m/s on the x-axis) which is not correct. I wonder if there is any incorrect operation I did? When there is no force applied and only gravity, the rope will fall down to the ground and the velocity is correct to be around zero.

In two figures, one is the rendered rope which keeps static for long enough, the second is the printed velocities, positions, and applied force to the first body of the rope, where the positions stay almost the same, but the velocities are quite large to be apparently incorrect.

TL;DR printed velocities are inconsistent according to printed positions between each frame and the visualization after applying force.

Thank you in advance for any possible help or idea on solving this problem.

How were you expecting the velocities to behave?

Hi noshaba,
The rope is hung in the air statically, so the velocities should be around zero, but now the velocity on the x-direction is around 0.4m/s, where the difference is too large.

Just curious, how did you apply the spring damping force?

This post might help:

start with only four links and check if this problem goes away, if it does, it’s probably because of the large number of joints. I’m wondering how you you added spherical joints? I couldn’t find them in the documents. Are you putting 3 revolute joints together to make a spherical one?
Another guess is that the solver is not converging to a solution! what’s the simulation step length? how many sub steps?

Hi BlackMambaz,
I simply apply a PD controller to drag the end of the rope to a certain position in the air, what’s interesting is that with such PD controller where the velocity is non-zero, the rope can actually stay statically.

Hi Abi64,
Thanks for the suggestion, I’ll give it a try. As you said, I added spherical joints by adding three revolute joints between two bodies. Here are my parameter settings in Isaac Gym:

sim_params.dt = dt = 1.0 / 60.0
sim_params.physx.solver_type = 1
sim_params.physx.num_position_iterations = 6
sim_params.physx.num_velocity_iterations = 0
sim_params.physx.num_threads = 16
sim_params.physx.use_gpu = True
sim_params.up_axis = gymapi.UP_AXIS_Z
sim_params.gravity = gymapi.Vec3(0.0, 0.0, -9.8)

I checked the post you shared with me and it looks quite related to my case now, really appreciate your help!

I see! reduce the dt to maybe 0.001 and increase the sub steps to see if it makes any difference.
Another thing you can try is that instead of using a position controller for holding the both ends of the rope, fix one end of the rope which I guess would be the base link using this:
asset_options.fix_base_link = True
And fix the other end using your position controller, see if it works or not.
also use smaller value for Kp(stiffness) and higher value for Kd(damping), it should help…

Hi Abi64,
Sorry for the late reply. Thanks for your suggestions. I tried:

  1. reducing the dt to 0.001 and increasing num_position_iterations from 6 to 9, and adjusting kp and pd, the velocity reduced to around 0.01m/s, which gets better, but is still incorrect.
  2. fixing the base link, the velocity of the base link is 0m/s as expected, but the velocity of another end is around 0.5m/s, which is similar to previous results.

I guess so far I need to give up using velocities and only use positions for my purpose. Anyway, you provided me with a lot of help, really appreciate this.

No problem! I see! I’m guessing it’s due to the large number of links or the solver is not converging, in Matlab Simscape you can see if the simulation is stock and it’s not converging but here you can’t see it. What do you get from calculating the derivative of the position? is it equal to the velocity?
Using PhysX might not be the best way to simulate a flexible thing like a rope, you should use Flex as it’s designed for such purpose. Have you tried that?

Hi Abi64,

Really thanks for your help. Actually, I made a very silly mistake. I should use an attractor instead of manually applying a PD controller to the rope. When I use attractor, the problem of incorrect velocities can be solved well.

1 Like

Thanks for sharing how you resolved it, very interesting! so for controlling the position, speed and acceleration of bodies we should use attractors instead of applying direct force to them.
Did you try Flex btw?

I didn’t try Flex yet, though Flex provides a good implementation for softbody like 3D soft objects. I’ll probably try it after I finish my current project.

In the example folder of isaacgym, there is actually a demo code “” providing how to use attractors which function exactly the same as applying spring-damper force to it, but much more stable than manually applying the force since the velocity is more accurate.

I was watching this video, it seems like Flex is as good as ANSYS in simulating flexible materials and it works in real time!, there was no link to the paper though.