slow simulation speed down

Typically: "How do I... ", "How can I... " questions
Post Reply
need2know
Posts: 13
Joined: 29 Jul 2024, 09:53

slow simulation speed down

Post by need2know »

Hello,

how can i lower the speed of the current simulation in a lua script (i do not want to slow the whole simulation down, but part of it. i want to start with default speed, then slow down and get back to the default simulation speed (50ms)).
I tried to decrease the simulation step time dt as shown:

Code: Select all

    --lower speed
    sim.setFloatParam(sim.floatparam_simulation_time_step, 0.025)
    sim.addLog(sim.verbosity_scriptinfos, "set lower simulation speed (cycle-time: 25ms)") 
I found this parameter in this forum, but it doesnt work... is it already deprecated or did i do another mistake?

Cheers

fferri
Posts: 1333
Joined: 09 Sep 2013, 19:28

Re: slow simulation speed down

Post by fferri »

That is not simulation speed, but the amount of time simulated in one simulation step.

See also Variable Step Size: Don't!

Btw I don't think you can change it during simulation, so you'll have to perform one simulation with a time step, then save the state (pos, vel, etc) of all objects, stop the simulation, set the state of all objects, set the time step, and start the simulation to run the second part of the simulation with a smaller time step.

need2know
Posts: 13
Joined: 29 Jul 2024, 09:53

Re: slow simulation speed down

Post by need2know »

Thank you for the hint!

I want to reach the same functionality programmatically like the two toolbar-buttons (turtle/minus - rabbit/plus) in the simulation menu bar do.

Here it is possible to change the whole simulation speed by decreasing/increasing the simulation step time on one hand or by increasing/decreasing the simulation passes during one rendering pass. This can by done while the simulation is running.

cheers

coppelia
Site Admin
Posts: 10714
Joined: 14 Dec 2012, 00:25

Re: slow simulation speed down

Post by coppelia »

I want to reach the same functionality programmatically like the two toolbar-buttons (turtle/minus - rabbit/plus) in the simulation menu bar do.
you can do this with:

Code: Select all

sim.setIntProperty(sim.handle_scene, 'speedModifier', modifier)
Where modifier is an integer value between -3 and 6

Cheers

Post Reply