Page 1 of 1

Unable to restart the simulation from beginning using Remote API in Python

Posted: 05 Feb 2018, 06:31
by ravi
I am trying to restart the simulation using Remote API in Python.

Below is the code snippet-

Code: Select all

vrep.simxStopSimulation(clientID, vrep.simx_opmode_blocking)
status = vrep.simxStartSimulation(clientID, vrep.simx_opmode_blocking)
if status != 0:
    raise Exception('Failed to reset simulation')
The issue is that after calling this code, the simulation stops but doesn't start. As I can see that the "Start Simulation" button is enabled in the simulator.

Re: Unable to restart the simulation from beginning using Remote API in Python

Posted: 07 Feb 2018, 17:57
by coppelia
Hello,

the reason is that when you send the stop simulation command, it will take several simulation steps until the simulation has halted. So you should wait until it has really stopped, before trying to start it again.

Cheers

Re: Unable to restart the simulation from beginning using Remote API in Python

Posted: 08 Feb 2018, 07:44
by ravi
Thanks! It worked.

Re: Unable to restart the simulation from beginning using Remote API in Python

Posted: 15 May 2018, 14:37
by thushal
Hey,

I am having the same problem but I am using the Matlab remote API. I have tried delaying the call to simxStartSimulation using the 'pause()' function in Matlab and by using a while() loop. However, simxStartSimulation keeps returning 3.

Is this the correct approach?
And is there a way of checking if the simulation has completely halted?

Thanks,

Re: Unable to restart the simulation from beginning using Remote API in Python

Posted: 18 May 2018, 13:53
by coppelia
Is it possible that you disconnected from the server?
Return value 3 means: timeout and no value

Cheers

Re: Unable to restart the simulation from beginning using Remote API in Python

Posted: 21 May 2018, 02:31
by thushal
Hey,

Yes, I was being disconnected from the server. I was accidentally using the temporary remote API server service.

Thanks a lot!! :)