I am trying to run a set number of trials of a simulation that I have created. Once the robot reaches the goal it stops the simulation so I am trying to create a piece of code that then starts the simulation again until the required number of trials has been reached.
I have tried to use the following code in the lua command line within CoppeliaSIm however it simply doesn't run the simulation whilst it is checking the simulator state inside the while loop.
Code:
Code: Select all
num_trials=10
for i=0,num_trials,1 do
sim.startSimulation()
print("trial number: "..i)
while true do
if sim.getSimulationState()==0 then
break
end
end
end
print("ALL TRIALS finished")
Is there an easy solution to achieve this?
Thanks in advance!