Jump to content

[SOLVED] Angular motor for hinge joint


photo

Recommended Posts

Hello,

 

I have troubles setting the velocity for the angular motor from a hinge joint. The hinge joint is used to connect to bodies of a ragdoll. Whichever value I'm passing to setAngularVelocity(), it doesn't have any effect, getCurrentAngularVelocity() and getCurrentAngularAngle() report always zero and, as expected, the ragdoll remains unchanged.

 

The angular limits are set to [-180,180], setAngularVelocity() and getCurrentAngularVelocity() are invoked from flush(), both bodies are of type BodyRigid. Here are the other joint properties copied from the .world file:



						<joint type="JointHinge" id="556913716">
							<body_0>2077312703</body_0>
							<body_1>865892762</body_1>
							<axis_0>1 0 0</axis_0>
							<axis_1>1 0 0</axis_1>
							<angular_damping>16</angular_damping>
							<angular_limit_from>-180</angular_limit_from>
							<angular_limit_to>180</angular_limit_to>
							<num_iterations>4</num_iterations>
							<linear_restitution>1</linear_restitution>
							<angular_restitution>1</angular_restitution>
							<linear_softness>1</linear_softness>
							<angular_softness>1</angular_softness>
							<anchor_0>0 0 -1</anchor_0>
							<anchor_1>0 0 -1</anchor_1>
						</joint>

Thank you for any help

 

Cheers, Helmut

 

Link to comment

Hello Silent,

 

thank you very much for offering that. Let me give you a short description about our project:

 

Basically what we want to do is playing back an animation on a ragdoll mesh. In contrast to a framebased ragdoll animation we want the animation to interact with the environment, i.e. if a collision occurs, the animation should be adjusted or interrupted and it should result in an impulse on the whole ragdoll.

I know the ragdoll_8 example, which shows the usage of the setVelocityTransform() method for solving the IK task of the collision with the ground.

Our ragdoll lives in a zero gravity environment and is surrounded by other moving objects, therefore I cannot transform this problem into an IK task.

 

The best solution we have found so far is the following:

The ObjectSkinnedMesh which owns the ragdoll is cloned. The cloned mesh is playing back the animation. The pivot of the ragdoll matches to the pivot of the cloned mesh. During flush() the importLayer() method is used to copy the ragdolls bone configuration into a new layer.

Then we iterate over all bones and calculate the difference in world coordinates for a set of points along the respective bone. Those differences are directly translated into force vectors which are applied on the rigid body representing the respective bone.

I have drawn a picture:

 

post-990-0-67480500-1438348280_thumb.png

 

Since my initial posting this method has been improved and I must say it works quite well already for our needs. This method has been implemented in the frog_animator.h.

 

Our second idea is actually the reason for this topic: Instead of applying forces I would like to use the angular motor to bring at least the hinge joints of the rigid body into the correct position. This method is implemented in the file frog_animator2.h, but I couldn't get it working.

 

In our real project we are using a model of a frog, consisting of several automatically generated ball joints and a few manually created hinge joints.

For testing purposes I have created a small tube, consisting only of 3 rigid bodies of equal mass and size and 2 hinge joints.

In the attached project you find only the animated tube, a plane and a camera circling around tube (the red tube is the cloned mesh, the green tube is the ragdoll).

 

In unigine_project.cpp there is a define at line 9 and 10, called FROGANIMATOR_IMPLEMENTATION, it can be either FrogAnimator (which is the first method of applying forces) or FrogAnimator2 (which tries to modify one of the hinge joints)

 

Thank you very much for having a look at it. The FrogAnimator in the attachment is an older version, we have improved it and it is working quite well with the real frog model. Still it would be good to know why FrogAnimator2 fails to set the angle of the angular motor.

I could imagine to mix both techniques, using the angular motor for animating hinge joints and forces for adjusting bodies attached to ball joints. (Regarding numerical stability I think the approach of adjusting the angular motor should be superior to the approach of applying forces, because the animation itself are only rotations). Anyway thats just my guess.

 

Thank you very much and cheers

 Helmut

ragdoll_animation_tube.zip

Link to comment

Hi Helmut,

 

Thank you for the detailed description! I will pass all this information to our dev team.

 

In few words - what should we see in theory if everything is working fine? To my opinion is that FrogAnimator2 should behave similar to FrogAnimator. Is that correct?

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hello Silent,

 

in the final version it should, yes, but not in the version I have sent to you. I have only implemented one of the two joints so far in the version if have sent you (and the sign of the rotation could also be wrong).

So in case it is working there should be a single joint rotation visible when you use the FrogAnimator2.

Additionally there is a lot of text ouput on the screen, showing the angle the joint should aim for and the current angle.

 

Thanks again for looking at this.

 Cheers, Helmut

Link to comment
  • 6 months later...

Ok,

 

the main question is more about applying a torque to a joint as I asked the question in the other thread.

 

An answer to that would be great as we are a bit struggeling atm with a good solution and I want to check all possibilities.

 

Thx.

Werner

Link to comment
  • 3 weeks later...

Hi,

 

We are deeply sorry for the late reply.

 

We've examined the test scene you sent earlier.

 

To enable spinning you should use both setAngularVelocity() and setAngularTorque().

Also make sure you provide positive argument to setAngularTorque(), because negative values have the same effect as 0.0f - they disable angular motor.

But negative angular velocity values are meaningful - they change spinning direction.

Link to comment
×
×
  • Create New...