View Full Version : Nervous system
Petr Schreiber
24-09-2007, 15:48
Hi,
I tried to create symmetrical shape and put it "on head" by default.
What happens ?
At least on my PC it starts to rotate counter clock wise.
Maybe it is somehow related to forgotten mysterious prophecy about random ODE mood ( seek any medieval book for the reference ;) ).
Does the same occur on your PC too, or system stays at same position forever ?
Thanks,
Petr
Michael Hartlef
24-09-2007, 15:53
Hi Petr,
what are you doing with ODE? Where is the new TBGL ;D Just kiddin'
I'll check it tonight. I remember something odd and similar when I was trying to code an entity system
for the IBP 3D Pack. On my system (Intel) I got a strange behavior and and on Athlons everythign was fine.
Something math related. What is your CPU?
Petr Schreiber
24-09-2007, 16:03
Hi Mike,
Where is the new TBGL ;D
Good try to make me heartattack :D I am working on it, I am working on it ( even started to write docs :) )
To make situation even more funny, I have AMD Sempron 64bit. So not Intel :)
I presume it could be related to fact ODE uses SINGLEs ( at least classic ODE from offical website ).
Maybe some rounding errors?. How hard is to store integer numbers in SINGLE variable ???
Thanks,
Petr
ErosOlmi
24-09-2007, 16:10
Petr,
for sources so big, better to add as attach file otherwise forum color syntax parser will take a lot of web server CPU. Thanks
I tested and it start in perfect balance but after 2 secs start going down on the left (un-clock) and an infinite pendulus left/right starts. At every left/right it seems loosing a little bit. So it is not a 360 round but a 359.9999, 359.9998, 359.9997, ...
Are you using SINGLE (sorry no time right now to go though source code)? SINGLEs have low precision and if used in math expressions rounding problems are quite sure.
Eros
Petr Schreiber
24-09-2007, 16:36
Hi Eros,
I am sorry, but I like colors :)
I removed the code section and attached whole script.
I am also quite curious why ODE uses SINGLEs by default, I think unprecision is not worth savings in memory ( DOUBLEs are twice as big ), especially in software dedicated to simulations :)
Thanks,
Petr
ErosOlmi
24-09-2007, 16:41
Petr,
thanks a lot. For scripts around 100 lines, seems no problem, but for more than 300 lines it seems our server is suffering a bit :-[
I tried to change all SINGLE to DOUBLE but again same behave. I've not review all the code but just: find(SINGLE) - replace(DOUBLE) rough method.
On my machine it takes about 2/3 secs before to start moving. Maybe we can calculate how many main loops it takes to move and if all the same in all machines, it is quite sure a rounding problem. I will study the script more this night when back from work.
Ciao
Eros
Petr Schreiber
24-09-2007, 16:43
When you add following code to the script ( after objects are created and jointed, but before loop ):
type t_xyzpos
x as dReal
y as dReal
z as dReal
end type
dim pos1 as t_xyzpos at dBodyGetPosition ( mySphereBody(%SPH_LOWESTRIGHT2) )
dim pos2 as t_xyzpos at dBodyGetPosition ( mySphereBody(%SPH_LOWESTLEFT2) )
msgbox 0, STR$(pos1.x)+STR$(pos1.y)+STR$(pos1.z)
msgbox 0, STR$(pos2.x)+STR$(pos2.y)+STR$(pos2.z)
... you will see values are stored without any round off errors !
It is weird. It must be something in ODE.
ODE is compiled already to work with SINGLEs, so re-declarataion sadly cannot help.
If somebody knowing C could recompile ODE.DLL with DOUBLE precision option it would be interesting to see if it makes difference.
I tried even constant simulation step, and it did the same fall.
Interesting is that setting too big step makes ODE crazy and it totally destroys the construction :(
Thanks,
Petr
Michael Hartlef
24-09-2007, 18:25
Everything works like a charm here. ThinBasic 20070909
By working like I charm I mean, that it stays on top for about 2 seconds and then starts falling down and then swing left/right.
First, thanks for the demo... neat to see so much happening, toon shading, shadows, physics, cool mouse interaction with scene!!!
It stays still for a few seconds and does come down on the left side. Would such a structure be in balance in reality? It seems to act as you would think, at least the way I would think, and it falling to the left is correct with the Earth's rotations effects :)
Put a ball on the table and if it moves, with no outside forces, then worry :)
Petr Schreiber
24-09-2007, 18:50
Hi guys,
thanks for the tests.
Did you know clicking using middle mouse button / mouse wheel click allows you to push objects like with finger :) ?
Kent has good point about earth rotation, but as ODE allows to setup gravity, I think it also does not presume Earth conditions for all operations. But good idea!
I am fool I do not backup my work, because I did similar object, like a grid, which was symmetrical and I think it rotated clockwise.
I need to do more tests :)
Thanks,
Petr
ErosOlmi
24-09-2007, 19:31
Ken observation seems very clever!!
Left falling down seems compatible with hearth rotation due to centrifugal force. But I'm not an expert.
Petr Schreiber
24-09-2007, 19:59
Yes,
Kent is very close, I think.
But try to create object like that:
%SPH_UPPER = SphereBody_Create( 2500, 0.25,0, 0.0, 0.0 )
%SPH_LOWERRIGHT = SphereBody_Create( 2500, 0.25,0, 1.0, -1.0 )
%SPH_LOWERLEFT = SphereBody_Create( 2500, 0.25,0, 1.0, 1.0 )
%SPH_LOWESTRIGHT = SphereBody_Create( 2500, 0.25,0, 2.0, -0.5 )
%SPH_LOWESTLEFT = SphereBody_Create( 2500, 0.25,0, 2.0, 0.5 )
%SPH_LOWESTLEFT2 = SphereBody_Create( 2500, 0.25,0, 3.0, 1.0 )
%SPH_LOWESTRIGHT2= SphereBody_Create( 2500, 0.25,0, 3.0, -1.0 )
%SPH_LOWER = SphereBody_Create( 2500, 0.25,0, 4.0, 0.0 )
You will see just thin edge :) of the object ( it is rotate 90° around Y axis ).
So now I would presume it would fall as-is again counter clock wise, to the left.
But it will fall rotating around "new" axis ( before Z, now X ).
;)
Petr
Petr, you just moved the camera from the front to the side. Still the WORLD and model are working the same way, it fell to its side relative to the world not the camera :)
Anyways my observation was more of a joke, I think you guys nailed it earlier...
It's got to be using singles as you guys mentioned earlier. That is funny because we had that discussion about singles and doubles it is funny how the computer uses them and unless you TELL it use this resolution... it makes up numbers and that delayed fall, seems to be that rounding off of numbers in the very small value ranges.
Petr Schreiber
25-09-2007, 13:30
Hi Kent,
I really rotated the object ( its coordinates are different ), not the camera, although it looks like that!
It is like the orignal thing would make a step left, turning about 90°.
So "North, South, East, West" are the same in both cases.
Thanks,
Petr