Restarting the simulation from Matlab remote API

Typically: "How do I... ", "How can I... " questions
Post Reply
Rosuar
Posts: 1
Joined: 12 Feb 2021, 02:50

Restarting the simulation from Matlab remote API

Post by Rosuar »

Hello, I'm pretty new with the software and I'm stuck on a problem:

I'm trying to make a simulation of a dynamic system that is affected by gravity, the problem that I have is that if I run the simulation and then start the matlab script, a part of my model falls down so I want to be able to restart the simulation based on the remote commands that I found:


sim.simxStopSimulation(clientID,sim.simx_opmode_blocking);
sim.simxStartSimulation(clientID,sim.simx_opmode_blocking);


What happens is that the simulation does stop, but won't start again, what am I doing wrong?

Thanks in advance.

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

Re: Restarting the simulation from Matlab remote API

Post by coppelia »

Hello,

try to put some pause between those two commands (or make sure to wait until the simulation has really stopped before restarting it): A stop message will simply trigger a stop procedure, that can take several simulation steps. So, even if your operation mode is blocking, when control returns to your Matlab client, the simulation hasn't stopped yet. If you immediately send a restart command, that might be ignored, since simulation hasn't yet stopped.

Cheers

Post Reply