How can I define a dynamic force in the Prismatic Joint?

I want to simulate PID control so that the cylinder can move with the velocity I set, but I can’t find any documentation or python code make it. Also, in omniverse, the target velocity is not what I want.

not sure I understand exactly the question here.
So you have a cylinder connected with a prismatic joint and you want that cylinder to move with a given velocity? Then if you dont want to set the target velocity to let the joint drive the body, you can set the linear velocity directly on the cylinder body. Would that work?


HI, Ales
Using the demo in the figure below as an example, the thing I want to do is that as I import a Force changing over time, then the box1 will move with the constent speed, and will not bounce back. The problem is that I cant control the velocity when it move, when the target is set to 10, then the box1 will move back like a spring, when the target is set to 1000, it will not be back but it’s too fast. I haven’t been learning PhysX very long, and I find no documentation about how to fix it. Thank you for your reply


I think what you want is to set just target velocity (leave target position 0) and set Damping not stiffness, something like this:

The equation for the given output force looks like this:

Force or acceleration = stiffness * (targetPosition - position) 
    + damping * (targetVelocity - velocity)

When you set the target position it will try to drive to that position and create the spring effect. The limit is setup as hard limit so there will be no spring effect if you set just the target velocity.

I try to modify the stiffness and damping in this video. As you can see, when the stiffness is set to 0, the joint can’t hold up the arm, and only when I set it to a large number, it works but moves back and forth, so I was wondering if I could just define a variable force in the Prismatic joint, cause I can calculate the thrust of the hydraulic rod(using Prismatic joint instead of hydraulic rod in this video) in the Simulink of Matlab, so that it can be more like a hydraulic rod. Will this approach work?Hoping to get your replay soon, thank you!

Is there a limit set for the prismatic joint? I dont see a limit, would not setting a limit and the target velocity work, the limit would stop the hydraulic arm to move further or not?

As for applying forces, you can apply forces through a python script atm, that could eventually work, but again without a limit the body would move freely and you would most likely have same issue as with applying target velocity.


I just set the limit and it ensure the arm would not move to strange places like that in the video, but it still move back and forth like the start of the video. What I want is making the joint move like the effect achieved through the settings in your last reply.
The problem is very similar to what I said, but it doesn’t seem to be solved

It seems I cant modify the source code, how to apply a dynamic force in the joint, for I didn’t find the function in the Docs about omniverser.

I am still a bit puzzled here, if you set the limit, the limit is hard so there will be no “spring” movement when you hit the limit.
However if you add to the drive targetPosition it will add the spring like movement as it will try to drive towards the position.

Custom joint and ability to define the joint constraint through external code, is something that will be available in next release.

But still if you would apply the limit and set the force to the body, you should have the desired behaviour too. Though I still dont fully understand why in your case the target velocity does not work. Can you maybe share your asset so that I can take a look?

thank you for your reply, here is my asset, and it doesn’t work.
guntongfangzhen4.usd (11.5 MB)
Hoping for your replay

The problem seems to be with masses, the object is modelled in cm and if you add a cube to that scene you can see that its huge (was that intentional?). For rendering this is not an issue for physics however this is, because mass properties are by default computed from the object size, so the mass for these objects is enormous.

Prim: /caimeiji/zuoyeya_up Mass Info: {'mass': 47.40818405151367}
Prim: /caimeiji/you_still Mass Info: {'mass': 1808.787353515625}
Prim: /caimeiji/zuoyaobi Mass Info: {'mass': 1329.47314453125}
Prim: /caimeiji/zuoyeya_down Mass Info: {'mass': 7.938518047332764}
Prim: /caimeiji/guntong Mass Info: {'mass': 2694.8681640625}

So here what I would suggest to add some real mass information. To do that, filter all rigid bodies, select all the rigid bodies, then Add->Physics->Mass. Then you can set mass to individual pieces.

Also if you would like to get it working with the current mass, you would have to increase the iteration could on the bodies significantly and the steps per seconds - simulation stepping on a PhysicsScene.
I was able to get it working, but with quite massive increase of the iteration count and stepping. The joint limit also does not seem right, if I move it to -40 to match the cylinder end correctly, then I had to tweak a bit the damping and stiffness on the limit, as that limit seems to have spring settings after all its not a hard limit but soft limit based on your setup.

Oh,I did not consider the problem of mass, I thought it can be autocomputed, and I did not notice the coordination between size and mass after the model was imported. Thank you very much for helping me to find out the problem!

The auto mass computation works quite well, but one has to pay attention to the units and sizes. I personally usually create a cube next to the model to compare. The cube by default has 1m size (100cm if cm units are used), so its great to just place it there to compare your model against it to see if the model is the right size. Since if not, the autocomputation does not work well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.