Rigid joints

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Rigid joints

Postby Stucuk » Thu May 05, 2016 1:50 am

If you take the main bodies properties (momentum/etc) and apply it to the part that has been separated, wouldn't the separated part act wrong.

I am thinking about wheel size as an example, a smaller wheel will rotate faster than a larger wheel with the same rotation, wouldn't the same be true if you separated the part but kept its rotation/momentum. Especially if the part is at the far edge of the main body (Where it shouldn't rotate around its self like if it was near the center)
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Rigid joints

Postby JoeJ » Thu May 05, 2016 3:36 am

You would need to set velocity for the new split bodies like this:
Code: Select all
sVec3 v = oldBody.velocity,
w = oldBody.omega,
c = oldBody.centerOfMass;
splitBody.velocity = v + w.Cross (splitBody.centerOfMass- c);
remainingBody.velocity = v + w.Cross (remainingBody.centerOfMass- c);


I am thinking about wheel size as an example, a smaller wheel will rotate faster than a larger wheel with the same rotation, wouldn't the same be true if you separated the part but kept its rotation/momentum. Especially if the part is at the far edge of the main body (Where it shouldn't rotate around its self like if it was near the center)


Disagree, i think it will keep angular velociry unchanged, so:
Code: Select all
splitBody.omega = w;


Correct me if i'm wrong :!:
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Rigid joints

Postby Stucuk » Thu May 05, 2016 7:16 am

JoeJ wrote:Correct me if i'm wrong :!:

I could easily be wrong. But i keep thinking about if you attached a part to a wheel's center and you then detached it that it would be spinning on the spot like the wheel but if you had it attached at the outer edge, it wouldn't really be spinning that much, it would be more momentum than rotation.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Rigid joints

Postby misho » Thu May 05, 2016 2:39 pm

Stucuk wrote:If you take the main bodies properties (momentum/etc) and apply it to the part that has been separated, wouldn't the separated part act wrong.


I was experimenting with a rigid joint:

  • I joined a child body to a parent body along roll axis
  • I started to rotate parent on a pitch axis
  • I then severed the link
  • Child body was flung away from parent body, plus it had itself a rotation on pitch axis.

I didn't have to add any rotations or velocities, because the bodies were never merged into a single body, they were just linked. That's why I would prefer to keep using rigid joints, instead of merging 2 bodies into one, and then again (when separating objects) creating 2 bodies out of one. The rigid joint approach seems a lot more intuitive to me. Except, they seem to be unstable, and as Julio suggested, Compound collision would be a "safer" approach, if not as intuitive.

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

Re: Rigid joints

Postby misho » Thu May 05, 2016 2:42 pm

Stucuk wrote:I am thinking about wheel size as an example, a smaller wheel will rotate faster than a larger wheel with the same rotation


That's wrong. If the large and small wheel have exactly the same "rotation" (angular speed, or omega) then they rotate at the same rate (RPM, radians/sec, whatever). What you are confusing is the point on the edge of each wheel. The point on the edge of the large wheel will have a larger velocity magnitude than the point on the smaller wheel.

Stucuk wrote:If you take the main bodies properties (momentum/etc) and apply it to the part that has been separated, wouldn't the separated part act wrong.


I was experimenting with a rigid joint:

  • I joined a child body to a parent body along roll axis
  • I started to rotate parent on a pitch axis
  • I then severed the link
  • Child body was flung away from parent body, plus it had itself a rotation on pitch axis.

This result looked natural and correct to me...

I didn't have to add any rotations or velocities, because the bodies were never merged into a single body, they were just linked. That's why I would prefer to keep using rigid joints, instead of merging 2 bodies into one, and then again (when separating objects) creating 2 bodies out of one. The rigid joint approach seems a lot more intuitive to me. Except, they seem to be unstable, and as Julio suggested, Compound collision would be a "safer" approach, if not as intuitive.

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

Re: Rigid joints

Postby Stucuk » Thu May 05, 2016 6:12 pm

I know joints will work right(Since the child already had its own body with its own forces acting on it), i was on about the method of removing the child from the parent's compound collision and creating a new child using the parents "properties"(Forces/velocity/omega/etc).

With the large and small wheel, by rotation i meant that if they had the same omega speed that the smaller wheel would take less time to do a revolution so if you apply the same omega speed to the child (Which is likely smaller than the main parent body) that its revolutions would be alot faster than it should be (Since it should revolve at the same speed it was before it was split). With the effect being worse the further from the center it gets where it should be revolving slower.

EDIT:

Lets say you have a 2d ship thats a circle. And you attach two devices onto it, one in the center and one at the edge. The ship spins on the spot (no movement except rotation) and then releases both devices. The one located at the center should spin on the spot with no momentum. The one located at the edge should fly away with momentum but have little rotation.

If the parent properties were applied to the child after it was created (Removed from compound and new body made for child) the device at the edge would rotate on the spot. Thats what i meant. If done with compounds(And no joints) i don't see how you can easily avoid this situation.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Rigid joints

Postby JoeJ » Fri May 06, 2016 1:45 am

Lets say you have a 2d ship thats a circle. And you attach two devices onto it, one in the center and one at the edge. The ship spins on the spot (no movement except rotation) and then releases both devices. The one located at the center should spin on the spot with no momentum. The one located at the edge should fly away with momentum but have little rotation.


We agree upon linear velocity and momentum, but for the angular part you're wrong:
While being connected, all 3 bodies have the same angular velocity (no matter how far from the center of rotation).

Then when the connection breaks, there's no force trying to change that, so they'll just keep rotating at equal angular velocity.
Angular momentum decreases because moment of inertia reduces for all bodies, but the sum of all 3 angular momentum must be equal to the state before the break.

Makes sense?
Sometimes physics laws are hard to believe, i have my own cases where i resist to believe what they tell me :)
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Rigid joints

Postby misho » Fri May 06, 2016 2:50 pm

JoeJ wrote:We agree upon linear velocity and momentum, but for the angular part you're wrong:
While being connected, all 3 bodies have the same angular velocity (no matter how far from the center of rotation).


Stucuk, you are outvoted :wink: Angular velocity is a finite value, no matter how "big" the wheel is. But I understand how the confusion can set in: suppose you have an 18-wheeler truck, and a go-cart. Obviously, their wheel sizes are vastly different. If they move down the road at same LINEAR speed, go-cart's wheel will spin a LOT faster (its angular velocity will be higher). That's because the smaller wheel's circumference is smaller, so it needs to "lay" a lot more of it to move at the same speed as the 18-wheeler tire.

Conversely, if the both wheels are spinning at the same RPM (angular velocity), the go-cart will move a lot slower LINEARLY.

Now, let's focus on the rigid joint problem: :lol: I have 2 paths to choose:

  1. Connect the bodies with rigid joints. For that, I have to fix the NewtonUpdate time step much higher than my 20-60 FPS so that the joints (hopefully) become stable
  2. Destroy/Create new bodies as the objects are detached/attached, using bodies collision transform matrices to position/align visual objects, all the while hoping that the new bodies will properly behave with respect to inherited momentums.

I think I will opt for #1 for now (even though JoeJ and Julio suggested #2 is the "safer" way) because #2 will involve a major restructuring of my Entity-Body setup, and there are still unknowns about how the bodies will behave.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Rigid joints

Postby Stucuk » Fri May 06, 2016 9:11 pm

Ignore the wheels already, bad example. Your missing the point i was trying to make.

Round about is the perfect example:
Image

Lets say you attached a device that would hold a ball and release it to the roundabout. If you placed it in the center the ball should mostly just rotate on the spot when released. But if you had it placed at the edge the ball should fly away when released.

If you did the following:
1. Remove part from main body's compound collision
2. Create new body for part
3. Apply main bodies properties (momentum, angular velocity, etc)

Then you would be telling the ball to rotate on the spot (With no momentum) since the compound body wouldn't have any momentum. Even if the ball was located at the edge. This is the point i was trying to make about the compound solution, i don't see how it can simulate correctly unless you somehow work out the appropriate properties for the new body based on its old position on the compound and the velocities that the compound were under.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Rigid joints

Postby misho » Fri May 06, 2016 9:51 pm

Well now that you clarified it, yes, I absolutely agree with you. Unless there is something internal in the solver that works this out (which I doubt, because collision doesn't have body properties) this wouldn't work, or, it would have to be calculated as the new body is created... which could get pretty hairy in itself.

Honestly, I'm a little surprised that there isn't a more robust system in place that deals with the case of "compound bodies", which is probably the best way to describe this. that's why I think the joints are the way to go.

I also wanted to ask: Is CustomHinge the best hinge/joint type to rigidly connect 2 objects? What are the constraints used for?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Rigid joints

Postby JoeJ » Sat May 07, 2016 1:00 am

Lets say you attached a device that would hold a ball and release it to the roundabout. If you placed it in the center the ball should mostly just rotate on the spot when released. But if you had it placed at the edge the ball should fly away when released.


That's handled by this code i've posted before:
Code: Select all
sVec3 v = oldBody.velocity,
w = oldBody.omega,
c = oldBody.centerOfMass;
detachingBody.velocity = v + w.Cross (detachingBody.centerOfMass - c);
remainingBody.velocity = v + w.Cross (remainingBody.centerOfMass - c);

detachingBody.omega = w;
remainingBody.omega = w; // unnecessary, already is

oldBody is initial compound,
remainingBody is the same compound wihout the detaching body
detachingBody is the new body.

Just set velocities like this that's all you need to do - no problem.

The discussion was about Stucuks assumption the detachingBody would have less angular velocity which is wrong.

Honestly, I'm a little surprised that there isn't a more robust system in place that deals with the case of "compound bodies", which is probably the best way to describe this. that's why I think the joints are the way to go.

I also wanted to ask: Is CustomHinge the best hinge/joint type to rigidly connect 2 objects? What are the constraints used for?


Compounds are robust - Julio could do those velocity settings automatitcally eventually.
But the user would be still responsible to set mass and moment of inertia values so he needs to care anyways.

The hinge is not ideal, for orientation it ends up using 2 angular rows to fix only 1 dof,
and the rest is done using linear rows.
It should work better to either use 3 linear or 3 angular rows - worth to test both (by creating your own joint).

What i would do is this:
Keep your hinge approach as a reference to compare it with the compound approach - they should react similar on detachement. (You need proper visuals here to compare, do they work now?)

When compound approach works, you may still need a joint for the transition (coupling two separated spaceship parts together) to simulate any nut and bolt or snapping mechanics.

Then when both parts are in place, change positions directly to eliminate any remaining tiny error, remove the joint and make the compound.

The necessary joint would need motors for both rotation and position to operate smoothly.
JoesRagdollJoint in StandartJoints.cpp demo has motor for orientation.
Adding motor for position would be a small change.

However, if ship control is accurate enough no joint is needed and you can go to compound directly.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 41 guests