I need your help to clarify some concepts regarding the operation of the simulator and to write properly a child script. My doubts come around the topics of "simulation step" and the "simulation dt". My following comments are based on simulation default values.
As far as I know, on the one hand, the simulator performs a "simulation step" each 5ms, and for example, functions inside child scripts, such as "sysCall_actuation" are executed each 5ms.
On the other hand, by default the "simulation dt" last 50ms, and it is the predefined timestep for running simulations in synchronous mode. That is, using a Remote API, such as Python, whatever value that I would like to change in a joint, can be updated each 50ms. That is, each "simulation dt" involves 10 simulation steps.
Then, supposing that all the previous is correct, I am trying to optimize a for loop in a Python Remote API file, which performs actuation in the simulation many times (several "simulation dt") and I would like to move these instructions to a Lua child script to optimize execution time of my experiment, passing only once the values that have to be updated each 50ms.
Pseudo example of the for loop:
Code: Select all
Some values of the "final_angle" list that are updated after each "simulation dt"
for n in range (0, 100):
sim.setJointTargetPosition(handler.jd1a, final_angle[0])
sim.setJointTargetPosition(handler.jd1l, final_angle[1])
sim.setJointTargetPosition(handler.jd3a, final_angle[2])
sim.setJointTargetPosition(handler.jd3l, final_angle[3])
sim.setJointTargetPosition(handler.ji1a, final_angle[4])
sim.setJointTargetPosition(handler.ji1l, final_angle[5])
sim.setJointTargetPosition(handler.ji3a, final_angle[6])
sim.setJointTargetPosition(handler.ji3l, final_angle[7])
client.step()
- How can I make a parameter update each 50ms using a child script with a single call to a script function with all the information needed to update the values of the parameters several time steps?
Regards!