Hard joint behaves like rubber band [SOLVED]

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Hard joint behaves like rubber band [SOLVED]

Postby misho » Wed Mar 27, 2019 3:09 pm

Hi all,

I have a setup where a space capsule on top of a rocket is covered by a Launch Escape System - basically a small but powerful rocket that lifts the capsule away in an emergency. These two Newton objects are joined by a "hard" joint, and all is well in the "normal" modes of operation (when they launch together, they stay connected, etc). However, when I activate the escape rocket, it pulls the capsule away, but the capsule lags behind it a bit as if it is connected with a rubber band:

Image

The escape rocket is powerful, and the capsule is under a high G load when the escape rocket if fired.

Is there any way to make this "hard" joint even harder? I have the latest Newton, and I didn't notice this in older versions of Newton (as in, perhaps last year's versions) ...
Last edited by misho on Thu Mar 28, 2019 6:36 pm, edited 2 times in total.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby Julio Jerez » Wed Mar 27, 2019 3:19 pm

The joint are as good as an exact solve can make them.
try to recreate it in the test you have on the sandbox,
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint behaves like rubber band

Postby misho » Wed Mar 27, 2019 3:39 pm

Thanks Julio, I will! I think the same thing will happen if 2 joined objects are put into a spin by applying torque on one of them. They will be forced apart when the spin is fast enough.

Not sure if something can be done with parameters, to sacrifice solver accuracy in favor of hardness. I know we worked on something similar and you provided a possible solution (Garbage Joint Collection). I did NOT have that on when I was testing, but I am not sure if that would fix this problem.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby Julio Jerez » Wed Mar 27, 2019 3:54 pm

There is a big difference betwen a spinning body and a pushing force. The spinning body problem was a missing derivative bug that was fixed, the error should be limited to a numerical integration error, but not more.
A pushing force like you are describing does not generates that kind of centripetal acceleration.

I am assuming the pushing force is a force and you are not setting the velocity.


Just set the test and let us see what is happening, it should just work.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint behaves like rubber band

Postby misho » Wed Mar 27, 2019 4:00 pm

Oh I see (re: spinning and pushing forces)

Yes, this is a force (NOT setting velocity) supplied by rocket engines. And, to be precise, it is a PULLING force. The top cover has a tower housing rocket engines. The capsule under it is attached to it. The cover then pulls the capsule along with it.

The pushing case would be quite different, as the object below, pushing the object above, would also push it by the virtue of colliding with it. That's how the rest of my rocket works :wink:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby misho » Wed Mar 27, 2019 4:02 pm

Julio, BTW, I apologise it is taking so long, but I am in parallel working on an auto installer for my simulator, so you can test it and have a look at it with the FSX SE you obtained a while ago :wink:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby Julio Jerez » Wed Mar 27, 2019 4:23 pm

I am confused, what do you mean pushing by the virtue of colliding with it.
The way I understand it is.
You have two bodies represented by two cylinders.
One is big an one is small.
The big one is under some force that push both bodies up,
The top one is much smaller and also has a truster the pushes up, the force on the small one is large, because is suppose to help the whole system.
But they detach.
if this is the case, this is a typical mass ratio problem, that should not happens if you are use double and the joint is a hard joint, unless the values are so extreme that numerical tolerance aren't enough.

Did I described correctly?

Just modify the test demo that is in the sandbox, to see what it it.
My guess is that some tolerance that are set to prevent so,Hilary matrices are creating enough residual acceleration that is enough to make the bodies detach.
Some defines are set assuming force will be on the order of million of Newton, if the force is much large generation round and of gs, then that can be possible.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint behaves like rubber band

Postby misho » Wed Mar 27, 2019 4:52 pm

No problem, I will illustrate it:

Image

In the above image, rocket is green, payload is blue, thrust force vector is red, and both systems are moving up

My case, on the left, the rocket is pulling the payload upwards. I am getting a rubber-band gap between the payload and the rocket.

In the case on the right, the rocket is pushing the payload upwards. Also, the payload sits on TOP of the rocket, so the rocket provides the hard platform for the payload, thus I would expect no gap to occur because collisions are doing what they are supposed to... I hope that clarifies it.

I can certainly make a test case in the sandbox.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby Julio Jerez » Wed Mar 27, 2019 5:17 pm

When two bodies are connected by a joint, the collision is disabled, unless you specified that they collide.
So I assume both cases the is not collision.

Just set the test, let use see what is happening.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint behaves like rubber band

Postby misho » Wed Mar 27, 2019 5:24 pm

Julio Jerez wrote:When two bodies are connected by a joint, the collision is disabled, unless you specified that they collide.
So I assume both cases the is not collision.


I see - so the collision is not pushing the payload - the hard hinge is.

I also remembered - my main rocket has 2 boosters attached on the side (just like space shuttle) and I guess the hard joint that connects them is in "shear" mode (not pushing or pulling). I see no problems in that case - but the G forces and loads are much more gradual during the normal rocket launch...

Julio Jerez wrote:Just set the test, let use see what is happening.


Ok! I will get to it ASAP! Remind me, what's the best way to send you the code?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby misho » Thu Mar 28, 2019 3:08 pm

Hi Julio,

I just finished the test case - it clearly illustrates the problem. What's the best way to send it to you? As before, it's a single simple cpp file...
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby Julio Jerez » Thu Mar 28, 2019 3:28 pm

You can post the file here or on a pm.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hard joint behaves like rubber band

Postby misho » Thu Mar 28, 2019 3:41 pm

Julio Jerez wrote:You can post the file here or on a pm.


Excellent, here it is:

There are 2 objects, white is the capsule, and blue, smaller, on top of white, is LAS (rocket).
All the weights and thrust forces are the same as my objects.
When you hit and hold space bar, LAS is given a thrust upwards.
You can see a big gap between them as they move upwards.
The readout in the console shows the value reaches around 4.35 (That's almost 25% of the size of the LAS object)
I'm getting slightly larger gap, but that's probably because I also have gravity on in my sim.

Code: Select all
/* Copyright (c) <2003-2016> <Newton Game Dynamics>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely
*/


#include <toolbox_stdafx.h>
#include "SkyBox.h"
#include "DemoEntityManager.h"
#include "DemoCamera.h"
#include "PhysicsUtils.h"
#include "DemoMesh.h"
#include "OpenGlUtil.h"


// add force and torque to rigid body
static void ApplyGravityForce(const NewtonBody* body, dFloat timestep, int threadIndex)
{
   dFloat Ixx;
   dFloat Iyy;
   dFloat Izz;
   dFloat mass;

   NewtonWorld* const world = NewtonBodyGetWorld(body);
   DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(world);
   DemoEntity* ent = (DemoEntity*)NewtonBodyGetUserData(body);

   dString name = ent->GetName();

   bool bSpaceBar = false;

   if (scene->GetKeyState(' ')) {
      bSpaceBar = true;
   }
   NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz);

   // no gravity for this example
   dVector force(0.0f);
   dVector torque(0.0f);

   if (bSpaceBar)
   {
      force.m_y= 1779288.64f; // LAS rocket motor output, Newtons
   }


   const NewtonBody* otherBody = NULL;
   for (NewtonBody* bodyZ = NewtonWorldGetFirstBody(world); bodyZ; bodyZ = NewtonWorldGetNextBody(world, bodyZ)) {
      if (bodyZ != body) {
         otherBody = bodyZ;
      }
   }

   // pressing P prints out distance between objects...
   if (scene->GetKeyState('P')) {
      dMatrix matrix;
      dVector bodyVectors[2];
      dVector positionVector(0.0f);

      NewtonBodyGetMatrix(body, &matrix[0][0]);
      NewtonBodyGetPosition(body, &positionVector[0]);
      bodyVectors[0] = matrix.UntransformVector(positionVector);

      NewtonBodyGetPosition(otherBody, &positionVector[0]);
      bodyVectors[1] = matrix.UntransformVector(positionVector);

      dVector diff = bodyVectors[1] - bodyVectors[0];
      dFloat distance = dSqrt(diff.DotProduct3(diff));
       //Nominal object distance at the beginning is 35, so we will subtract that here to get to zero as a starting point.
      printf("Object distance: %f  local posit(%f %f %f)\n", distance - 35.0f, diff[0], diff[1], diff[2]);
      dTrace(("Object distance: %f local posit(%f %f %f)\n", distance - 35.0f, diff[0], diff[1], diff[2]));
   }

#ifdef _DEBUG
   dVector posit0(0.0f);
   dVector posit1(0.0f);
   NewtonBodyGetPosition(body, &posit0[0]);
   NewtonBodyGetPosition(otherBody, &posit1[0]);
   dVector diff (posit1 - posit0);
   dFloat distance = dSqrt(diff.DotProduct3(diff));

   dVector veloc;
   NewtonBodyGetVelocity(otherBody, &veloc[0]);
   dTrace(("d(%f) v(%f %f %f)\n", distance, veloc[0], veloc[1], veloc[2]));
#endif

   if(name == "LAS")
      NewtonBodyAddForce(body, &force.m_x);
   if(bSpaceBar)
      printf("Object distance: %f  local posit(%f %f %f)\n", distance-30.0f, diff[0], diff[1], diff[2]);
}


void MishosHingeTest(DemoEntityManager* const scene)
{
   scene->CreateSkyBox();

   NewtonWorld* const world = scene->GetNewton();
   dMatrix offset(dGetIdentityMatrix());
   dVector damp(0.0f, 0.0f, 0.0f);

   dFloat CapsuleMass   = 10387.0f;      // kg
   dFloat LASMass      = 1000.0f;      // kg

   // Make Orion Capsule body...
   NewtonCollision* const CapsuleShape = NewtonCreateCylinder(world, 20.0f, 6.0f, 20.0f, 1, &offset[0][0]);
   NewtonCollision* const CapsuleCompound = NewtonCreateCompoundCollision(world, 0);
   NewtonCompoundCollisionBeginAddRemove(CapsuleCompound);
   NewtonCompoundCollisionAddSubCollision(CapsuleCompound, CapsuleShape);
   NewtonCompoundCollisionEndAddRemove(CapsuleCompound);
   dMatrix matrixCapsule(0.0f, 0.0f, 1.5708f, dVector(0.0f, 0.0f, 0.0f));
   
   DemoMesh* const geometryCapsule = new DemoMesh("Capsule Mesh", scene->GetShaderCache(), CapsuleCompound, "metal_30.tga", "metal_30.tga", "metal_30.tga");
   NewtonBody* const CapsuleBody = CreateSimpleSolid(scene, geometryCapsule, CapsuleMass, matrixCapsule, CapsuleCompound, 0);
   NewtonBodySetForceAndTorqueCallback(CapsuleBody, ApplyGravityForce);
   DemoEntity* const entityCapsule = (DemoEntity*)NewtonBodyGetUserData(CapsuleBody);
   entityCapsule->SetNameID("Capsule");
   NewtonBodySetLinearDamping(CapsuleBody, 0.0f);
   NewtonBodySetAngularDamping(CapsuleBody, &damp[0]);
   geometryCapsule->Release();
   NewtonDestroyCollision(CapsuleCompound);
   NewtonDestroyCollision(CapsuleShape);

   // Make LAS ... 
   NewtonCollision* const LASShape = NewtonCreateCylinder(world, 6.0f, 2.0f, 40.0f, 1, &offset[0][0]);
   NewtonCollision* const LASCompound = NewtonCreateCompoundCollision(world, 0);
   NewtonCompoundCollisionBeginAddRemove(LASCompound);
   NewtonCompoundCollisionAddSubCollision(LASCompound, LASShape);
   NewtonCompoundCollisionEndAddRemove(LASCompound);

   dMatrix matrixLAS(0.0f, 0.0f, 1.5708f, dVector(0.0f, 30.0f, 0.0f));
   DemoMesh* const geometryLAS = new DemoMesh("LAS Stage", scene->GetShaderCache(), LASCompound, "metalblu.tga", "metalblu.tga", "metalblu.tga");
   NewtonBody* const LASBody = CreateSimpleSolid(scene, geometryLAS, LASMass, matrixLAS, LASCompound, 0);
   NewtonBodySetForceAndTorqueCallback(LASBody, ApplyGravityForce);
   DemoEntity* const entityLAS = (DemoEntity*)NewtonBodyGetUserData(LASBody);
   entityLAS->SetNameID("LAS");
   NewtonBodySetLinearDamping(LASBody, 0.0f);
   NewtonBodySetAngularDamping(LASBody, &damp[0]);
   geometryLAS->Release();
   NewtonDestroyCollision(LASCompound);
   NewtonDestroyCollision(LASShape);

#if 0
   dFloat w = 10.0f;
   dVector omega(w, 0.0f, 0.0f, 0.0f);
   NewtonBodySetOmega(CapsuleBody, &omega[0]);
   NewtonBodySetOmega(LASBody, &omega[0]);

   dVector veloc(0.0f, 0.0f, 0.5f * 35.0f * w, 0.0f);
   NewtonBodySetVelocity(LASBody, &veloc[0]);

   veloc.m_z *= -1.0f;
   NewtonBodySetVelocity(CapsuleBody, &veloc[0]);
#endif   

   // Lock these two bodies with a hard hinge...
   dMatrix  mSourceMatrix;
   NewtonBodyGetMatrix(LASBody, &mSourceMatrix[0][0]);
   dCustomHinge* pHinge = NULL;
   pHinge = new dCustomHinge(mSourceMatrix, LASBody, CapsuleBody);
   pHinge->EnableMotor(false, 0.0);
   pHinge->SetAsSpringDamper(false, 0.0, 0.0, 0.0);
   pHinge->EnableLimits(true);
   pHinge->SetLimits(0.0, 0.0);

   dVector origin(matrixCapsule.m_posit);
   origin.m_x -= 120.0f;
   origin.m_y += 60.0f;
   dQuaternion rot;
   scene->SetCameraMatrix(rot, origin);
}

Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Hard joint behaves like rubber band

Postby Dave Gravel » Thu Mar 28, 2019 4:29 pm

Maybe i'm totally wrong.
If I understand good you have both objects linked by a hinge.
Again if I understand good the gap happen when you disconnect this hinge ?
On this case both bodies comeback with the normal collision response.
Is it not just a problem about the surface material friction between objects ?
In the picture one part seen to slide down from inside the other part.

Edited: Sorry I have badly understand the word gap, It's not exactly what I have think at my first read..
Last edited by Dave Gravel on Thu Mar 28, 2019 4:34 pm, edited 1 time in total.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Hard joint behaves like rubber band

Postby misho » Thu Mar 28, 2019 4:34 pm

Hi Dave... no, you got it wrong:

The objects are constantly linked by a hard hinge at all times. The hinge is never broken.

In my diagram, on the left, blue and green objects are joined by hinge. They are joined so that the gap is zero.

When green object has thrust, it pulls on the blue object upwards, but the gap develops, as if they were connected by a rubber band.

When the thrust is gone, the blue object "snaps back" to where it was before and the gap is gone.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 6 guests