How it is possilble to set the timestep and related physics behaviour?

Hi guys,
I’m trying to use Blender like a simulator for robots and to control it externally through python.
I think that my process can take a lot of cpu time and that the time that it will take will change but this must not affect the simulation, I don’t need the real time… that’s the matter I think. What can I do to tell to blender every time that it have to make other component work like it passed only 1 time step?

Hello there! First of all I must ask you to follow this( ) thread as I intend to merge all of the robotic oriented BGE threads.

However I don’t understand your question, English is my third language so please bear with me.

I hope that some day english will become my 4th or at least 5th language actually it is something i try to use…
My point is: I think that bge tries always to run in real time so if you spend some time in an external algorithm like AI stuff, bge will do a lot of physical steps to keep time aligned with time elapsed in real world… I’m not sure of this but this is my hypothesis… and I want to avoid this…
I hope that this time I was more clear

Hmmm…So what you’re saying is that blender skips frames when AI and such requires much computational power? And you want to see all the frames? Use the “Game” drop-down menu and tick “Enable All Frames”.

Hope that helps.

You can switch on Game>Enable all frames.
With this options I think the BGE will not “timeout” logic ticks. On the other hand your simulation might run slower or with variable speed.

I hope it helps

thanks, I’ll give it a try…
just I’d like to be sure that it doesn’t only not lose any logic tick but also that physics uses a fixed timestep…
any idea on where to look at in the source code?

there are some methods to do that.

#physicstickrate should be twice logictickrate
GameLogic.setLogicTickRate = 60
GameLogic.setPhysicsTickRate = 120

one of them should be double the value of the other, and i think its the right one which is doubled above. dont ask me why, i can suspect but i dont know.

just search this forum or the web for the functions.

some other interesting functions are hidden inside the GameLogic object.

just do the following in an script and see your self:

g = GameLogic
print dir(g)

this will output all the methods and properties of the GameLogic Module in the Console.

if your framerate should be equal to 100, you would have 10 milliseconds per logictick. once your logic (python and controllers) takes longer than 10 milliseconds to execute, you will have less than 100 frames - frames will be lost.
cant circumvent that magically.

so the best way to solve this would either be:
take out the python which needs the long execution times and replace it with a c class which does the math (good)
reduce the amount of ticks per second to calculate lesser times (bad)
unspagettify, simplify, keep dry (dry = dont repeat yourself) and hope, that you can clean the python well enough to reduce its execution time.

hope this could help

I’m not worried about loosing frames…
In the end I can take some video or something like that and build demo of the behaviour of my simulator…
what i want is a “deterministic” simulator…
so i don’t want that it takes into account the time spent in processing and changes the behaviour on different machine… I want that the virtual time used for physics and logic is alwyas constant even if the real time is different…
does this fit with the option show all frame?
One example could be that in frame 1 the system take a time X to do physics,logic and rendering, and they use a virtual time T to calculate system behaviour.
then in frame 2 it takes 2X or 3x (or even 0.1X) to do the same but I want that for physics and logic use the same amount of virtual time T to calculate system behaviour.
no matter what happens to the screen… for the moment…
It is similar to offline rendering with physics on… (i’m realizing right now that this can be the usefu keyword to search… sorry for your time)