Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Bodies oscilate like crazy when attached with a JointFixed  (Read 1497 times)
0 Members and 1 Guest are viewing this topic.
Offline JamesColburn

Junior Newbie

Java games rock!

« Posted 2005-06-05 10:50:02 »


I'm simulating basic Lego blocks and I've attached a number of simple Bodies, each comprised of a single GeomBox, together with fixed joints. Depending on collisions these joints will have to be broken during the simulation, which is why they are not just a single Body with a bunch of GeomTransforms.

I've connected a number in series as an extension from a main chassis (imagine 4+ blocks extending out like an 'arm' with only the root block attached to the chassis).  My problem is that  when the simulation starts, the arm wiggles a little, and then the wiggle accelerates until the arm is throwing itself around like crazy. If I construct the arm with smaller blocks with more balanced connections (i.e. not at the tips but in the centre) the wiggling can be eliminated or at least reduced.  The larger constructions, however, are valid and can be held static with real Lego and should, I think, be able to be simulated.

I'm a newbie and I've obviously missed some physics setting for the joint or the world or something. It seems like the simulator is trying to make corrections and these corrections are compounding the error. I've tried playing with the ErrorReductionParameter, MaxCorrectionVelocity and ContactSurfaceThickness in the world, as well as the ERP and CFM in the Joint (althoughf for a fixed joint these parameters don't seem to be used) - but to no avail.

I'm using the newest code checked out from CVS.

Does anyone have any suggestions?

Thanks in advance,

Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #1 - Posted 2005-06-05 12:18:49 »

I don't really know much about ODEJava or what you're using, but I can explain some typical scenarios where numerical integration can cause trouble. It is evident that there must be some kind of spring-like force attaching the two bodies at the joint. Two possibilities come to mind (I'm just guessing here):

1) Undamped oscillation. If there is no friction, things will never improve. Actually, they may randomly get worse because of numerical inaccuracies.

2) Suppose you use Euler's method for stepwise numerical integration. If there is a linear damping force, which would normally cause the oscillation to die out exponentially, numerical trouble might cause the damping force to not only reverse the velocity, but also  increase the speed! It is of course impossible in the real world, but since you have some fixed timestep, intead of an infinitely small one, this can happen. One solution is to decrease the time step.

I have reason to believe that there might be trouble if

mass(of oscillating body) < frictionConstant * timeStep ,

but it depends a lot on how your program does these things. Try playing with mass and friction. Be sure to tell me if I've been too technical.
Offline JamesColburn

Junior Newbie

Java games rock!

« Reply #2 - Posted 2005-06-05 12:32:49 »

Thanks. And no, not too technical.

I'll try playing with those params and see what happens. I'll post my results.

On another note:
You mentioned using 'Euler's method for stepwise numerical integration'. An engineering friend mentioned something about potential problems with using Euler's method when simulating physics and suggested I use *some alternative*. I say *some alternative* because I wasn't really listening to him at the time, I was too busy trying to get my boxes to draw right.

Now it seems like I should have been taking notes.

Is there some way to change to this *alternative* method with Ode/OdeJava? What is this other method? Do people think this is the right thing to do?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #3 - Posted 2005-06-05 13:20:20 »

I don't know which method OdeJava uses, and I have never used it. That's why I'm only guessing. You may want to be sure that this is actually the problem before you start doing a lot of stuff.

But if you can, it might be an idea to use a Runge-Kutte method. There are other methods as well.

There is lots of info on wikipedia, look up numerical integration or something similar if you're interested.
Offline NewbTon

Junior Devvie

Odejava games rock!

« Reply #4 - Posted 2005-07-02 05:38:06 »

Try to call body.adjustMass() AFTER you've added it to the world (not before). It did wonders for my simulation.
Offline William Denniss

JGO Coder

Projects: 2

Fire at will

« Reply #5 - Posted 2005-08-02 05:10:41 »

Try to call body.adjustMass() AFTER you've added it to the world (not before). It did wonders for my simulation.

I found this too.  This is one of those things were Odejava being object orientated doesn't exactly fit with ODE.  You *expect* that the order of method calls doesn't matter, since they are just objects, but since ODE under the hood isn't, it does seem to matter.


Offline William Denniss

JGO Coder

Projects: 2

Fire at will

« Reply #6 - Posted 2005-08-02 05:13:33 »

Using the JointFixed is not recommended in the ODE docs, though I understand what you are trying to do.

A work-around is to add the geoms to the Body and don't use joints, then when you need to detach one, simply remove it from the body and attach it to a new independant body (you shouldn't even need to re-create it).



Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

bilznatch (21 views)
2015-08-04 11:03:17

SHC (39 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (45 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (51 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!