Hard joint gets an offset over time

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Hard joint gets an offset over time

Postby misho » Fri Sep 07, 2018 1:03 pm

Hi all!

I'm using hard joints to link parts of the rocket and launch it into space. All is well, except over time, the two joined parts become misaligned by a small amount. This results in the loss of axial symmetry, which in turn results in a small torque when the rocket engine is fired, slightly turning the rocket assembly in pitch or yaw axis.

Is there a parameter in Newton that will improve the accuracy of the alignment over time? In other words, can I "strengthen" the hard joint? I don't care about the performance impact, as I have relatively small number of joined parts in the rocket assembly.

Thanks!
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby misho » Sat Sep 08, 2018 5:54 pm

Any ideas, anyone?

I've tried setting joint parameters as such:

Code: Select all
         pHinge->SetFriction(1000.0f);
         pHinge->SetStiffness(1.00f);


But no luck.

As a temporary fix, I wrote a function that goes through all my joints, and re-sets the objects to their initial positions (without breaking a link), and that works. I suppose I could set this to run every one second or so, but that seems too kludgy...

Misho
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby Julio Jerez » Sat Sep 08, 2018 7:44 pm

if you set the friction to 1000 it will definably drift, the line pHinge->SetFriction(1000.0f);

means that the joint will apply force to keeps the constraint upto 1000 newton-meter of torque
once the needed torque is larger that that, it will apply only 1000.00 so if the needed torque is say
1200 there will be a net torque of 200 acting of the axis, therefore the joint will drift.

where did to get the 1000 figure from? if you want to make a fix joint out of a hinge, try making the
friction maybe 10 time stronger. do not make infinite, but 1000 may be too low.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint gets an offset over time

Postby misho » Sun Sep 09, 2018 3:15 pm

Julio Jerez wrote:where did to get the 1000 figure from? if you want to make a fix joint out of a hinge, try making the
friction maybe 10 time stronger. do not make infinite, but 1000 may be too low.


Actually, just a guess. there were no applicable examples on this parameter, and no explanations on wiki that I could find. I figured 1000 would be a "high" value.

I tried a value 10x higher (10000) but that didn't have any effect...

[EDIT] Also tried 100x and 1000x, no effect. Two hard-joined bodies still drift in alignment.

Misho
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby JoeJ » Mon Sep 10, 2018 2:29 am

We talked about this already. The proper solution would be to use compounds instead joints if the body should behave like a single one. Then, when a part is detached (detaching lower piece of a rocket) you can split the compound.
For more complicated things, e.g. a robotic arm putting out a satellite, you could make an initial compound of shuttle, arm and satellite, and then split the compound and enable joints to drive the arm to put the satellite to outer space.

I assume the difficulty with this is to preserve masses and moments of inertia so there are no non smooth changes or violations of the real world data you're eventually using for this. But even if you'd fail to do this perfectly, it would not be very noticeable.

Using joints however to emulate fixed links will always cause issues simulating space crafts i'm afraid of.


Edit:
The friction values in joint define their max force they are allowed to use. For a rigid joint, you don't want to use this. Not using it means the engine will make it as rigid as possible. But since this is a process of solving constraints in discrete timesteps, some error is unavaoidable. Compounds are a single rigid body. No constraints, no error.
User avatar
JoeJ
 
Posts: 1147
Joined: Tue Dec 21, 2010 6:18 pm

Re: Hard joint gets an offset over time

Postby misho » Mon Sep 10, 2018 3:25 am

Yes, I remember we talked about this. I was hoping that I missed something and/or there was some new functionality added to the CustomJoint.

I agree with your approach - compounds would be ideal for simple cases. However, my problem is that spacecraft dynamics change GREATLY during the launch. For example, a rocket loses 90% of its mass (fuel) during launch, and by the time the fuel is spent, it is just an empty shell. Think of it as a full (heavy) vs empty (light) beer can with a weight (representing payload) on top. Since I can't assign different masses to collisions inside compounds, the one Newton body containing the compound would have to have uniform mass, which would be extremely unrealistic. For example, a rocket is bottom heavy (full of fuel) during the early stages of the launch, becoming top heavy towards the end of the launch (top is where the payload is). This greatly affects the dynamics.

Sure - I could be re-calculating MOI on the fly, and keep changing CG, but that kind of re-invents the wheel and defeats the purpose of Physics Engine. And that's just the MOI/CG - I'm also calculating drag forces and restoring forces on a per-body level, taking into account drag coefficient etc. Think about how much math would I have to crunch through if I had to figure out drag coefficient of all the different shapes the launch stack can be in... :roll:

Misho
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby JoeJ » Mon Sep 10, 2018 6:44 am

misho wrote:Sure - I could be re-calculating MOI on the fly, and keep changing CG, but that kind of re-invents the wheel and defeats the purpose of Physics Engine.


No, we speak about a RIGID body simulator. Adapting CG, mass and MOI is exactly what you should be doing, and also it is your responsibility to model non rigid effects.

misho wrote:'m also calculating drag forces and restoring forces on a per-body level, taking into account drag coefficient etc. Think about how much math would I have to crunch through if I had to figure out drag coefficient of all the different shapes the launch stack can be in...


This boils down to a simple summation of forces and torques relative to the compount parent. The math is simple and no solve is necessary or involved. It's no problem at all. I've gone through this as well (but that dates some years back, so i'm rusty with it.)


The only valid argument for using joints is that this way you can indeed model more complex inertia, but using asymmetric inertia you will get very close for those symmetrical and axis aligned shapes used for space crafts. The results will be much better overall i'm sure.
User avatar
JoeJ
 
Posts: 1147
Joined: Tue Dec 21, 2010 6:18 pm

Re: Hard joint gets an offset over time

Postby Julio Jerez » Mon Sep 10, 2018 7:36 am

is the drift along the hinge axis?
you are using a hinge to make a rigid joint by adding friction to the pin, and that's like forcing a rusty door the to move, when you let go, it stays on that last position and that is what the hinge is doing.
The friction simply means it needs more torque to move, but once it moves it stays on that position.
there are other function on the hinge to do what you want.

are you using a hinge because is a moving part?
or you just one a rigid joint?
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint gets an offset over time

Postby misho » Mon Sep 10, 2018 10:49 am

JoeJ wrote:No, we speak about a RIGID body simulator. Adapting CG, mass and MOI is exactly what you should be doing, and also it is your responsibility to model non rigid effects.


I thought about this a bit more, and of course, you're correct - it wouldn't be that hard to recalculate MOI, Drag etc. on the fly. At this point, however, I simply can't afford the time for what would be a substantial re-write of the code. I'll stick with a periodic parts re-align approach - it seems to be working and it is definitely not CPU intensive. I'll see how that works, and I'll keep the compound approach in mind if this gets any uglier than it is... :roll:

Misho
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby misho » Mon Sep 10, 2018 10:56 am

Julio Jerez wrote:is the drift along the hinge axis?


My joint is a dCustomHinge class, and I just use it as a way to rigidly attach parts. Therefore, I don't define hinge axes (or, they are whatever the default is upon creation of the dCustomHinge).

Drift is along a Z axis of the BODIES, in my case, a yaw axis (X being pitch axis and Y being roll (longitudinal) axis). It probably happens because I pitch the rocket assembly into a gravity turn (after the launch) and the parts are under stresses in up-down (Z) axis. I can easily test that by not performing a pitchover maneuver, but launching straight up.

Julio Jerez wrote:are you using a hinge because is a moving part?
or you just one a rigid joint?


No, NOT a moving part... I want a perfectly rigid joint. In the real world, the rocket parts are rigidly bolted to each other, with explosives that go off and destroy the bolts during separation (staging).

Misho
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby Julio Jerez » Mon Sep 10, 2018 11:30 am

when you set you joint thsi you called this function
Code: Select all
hinge->EnableMotor(false, 0.0);
hinge->SetAsSpringDamper(false, 0.0, 0.0, 0.0)
hinge->EnableLimits(true);
hinge->SetLimits(0.0, 0.0);


that will make a fix joint and you do not even have to set friction.

you say you are setting friction and that's not hwo a fix join work, a fix join soul no have any friction.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint gets an offset over time

Postby misho » Mon Sep 10, 2018 12:29 pm

Julio Jerez wrote:when you set you joint thsi you called this function
Code: Select all
hinge->EnableMotor(false, 0.0);
hinge->SetAsSpringDamper(false, 0.0, 0.0, 0.0)
hinge->EnableLimits(true);
hinge->SetLimits(0.0, 0.0);


that will make a fix joint and you do not even have to set friction.

you say you are setting friction and that's not hwo a fix join work, a fix join soul no have any friction.


Thanks Julio,

I didn't have the first two setting, I just tested with them (and removed friction), and sadly, there is no change, the joint is still slipping... :cry:
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby Julio Jerez » Mon Sep 10, 2018 1:34 pm

I do not know what could that be.
The joint should be rigid, unless there are some rows that are making the system singular.
was this ever working?
can you make a repro in your MishosRocketTest demo, so that I can debug it.

My guess is that there are some bad rows making the row that is drifting a linear combination of some other row. either a linear combination of a near linear combination
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint gets an offset over time

Postby misho » Mon Sep 10, 2018 1:59 pm

Thanks Julio!

Julio Jerez wrote:The joint should be rigid, unless there are some rows that are making the system singular. was this ever working?


No, I don't think this was ever working, but I started to notice it recently, as I am performing full-length real time launches (small offset causes a small torque which, during long engine burn, becomes cumulative and very prominent). Not sure what you mean by "bad rows"...

Julio Jerez wrote:can you make a repro in your MishosRocketTest demo, so that I can debug it.


Yes, I can try. Basically, to repro it, you need two heavy cylindrical bodies, in zero G, one on top of the other end to end, and connected with a dCustomHinge. Align them axially so that they appear as one cylinder. Then, apply torque to one of them. After a bit of rotation, there should be a seam visible where they connect - that's the slippage I am referring to.

I'll put together a test case and send it to you.

[EDIT] LOL I just realized that you, dear sir, have included MishosRocketTest.cpp in your demosSandbox project. Not a big deal, although your users will wonder who Misho is and why it doesn't do anything, since the thrust interface is missing from the PhysicsUtils.cpp :mrgreen:
Last edited by misho on Mon Sep 10, 2018 2:33 pm, edited 1 time in total.
misho
 
Posts: 525
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint gets an offset over time

Postby Dave Gravel » Mon Sep 10, 2018 2:32 pm

Maybe it don't have any relations with your problem but you can give it a try.
Try to set the body with zero NewtonBodySetLinearDamping and zero NewtonBodySetAngularDamping.
If you already use it, try without.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 690
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Next

Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 3 guests