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

Typically: "How do I... ", "How can I... " questions
Post Reply
ravi
Posts: 85
Joined: 24 Oct 2016, 08:00

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

Post by ravi » 05 Feb 2018, 06:31

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.

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

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

Post by coppelia » 07 Feb 2018, 17:57

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

ravi
Posts: 85
Joined: 24 Oct 2016, 08:00

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

Post by ravi » 08 Feb 2018, 07:44

Thanks! It worked.

thushal
Posts: 4
Joined: 20 Apr 2018, 02:40

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

Post by thushal » 15 May 2018, 14:37

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,

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

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

Post by coppelia » 18 May 2018, 13:53

Is it possible that you disconnected from the server?
Return value 3 means: timeout and no value

Cheers

thushal
Posts: 4
Joined: 20 Apr 2018, 02:40

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

Post by thushal » 21 May 2018, 02:31

Hey,

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

Thanks a lot!! :)

Post Reply