Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 1310 times)
0 Members and 1 Guest are viewing this topic.
Offline JamesColburn

Junior Newbie




Java games rock!


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

Hi,

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,
James

Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #1 - Posted 2005-06-05 14: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 14: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 Member




Java games rock!


« Reply #3 - Posted 2005-06-05 15: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.

http://en.wikipedia.org/wiki/Runge-Kutta_method

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

Junior Member




Odejava games rock!


« Reply #4 - Posted 2005-07-02 07: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 07: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.

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2005-08-02 07: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).

Cheers,

Will.


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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (24 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org 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‑gaming.org
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!