I am trying to run a lot of simulations in python and without fail it will stop working at the same point after running fine until that point.
With each simulation I am resetting the enviroment using sim.stopSimulation() and then starting it again with sim.startSimulation() after reloading the scene.
The error comes up every time before the simulation starts so I imagine its an issue occuring while its attempting to start the simulation but I am completely lost on what is actually causing the problem.
[Connectivity >> ZMQ remote API server@addOnScript:error] [string "Connectivity >> ZMQ remote API server@addOnSc..."]:439: [string "Connectivity >> ZMQ remote API server@addOnSc..."]:402: Trying to send data to Python where a receive is expected
stack traceback:
[C]: in function 'error'
[string "Connectivity >> ZMQ remote API server@addOnSc..."]:402: in field 'send'
[string "Connectivity >> ZMQ remote API server@addOnSc..."]:511: in function 'coroutineMain'
stack traceback:
[C]: in function 'error'
[string "Connectivity >> ZMQ remote API server@addOnSc..."]:494: in field 'resumeCoroutine'
[string "Connectivity >> ZMQ remote API server@addOnSc..."]:439: in field 'handleQueue'
[string "Connectivity >> ZMQ remote API server@addOnSc..."]:643: in function 'sysCall_nonSimulation'
can you tell me what revision of V4.6 you are running? You should have revision 16, or better 18.
Also, make sure you upgraded the related pip package too.
I am running revision 18 of V4.6 and im running 2.0.3 of the API as far as I can tell both of these are as updated as they can be so I am at a bit of a loss! I made sure both were updated before testing it to make sure it wasnt a problem with the version!
#python
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
print("Program Started")
client = RemoteAPIClient()
sim = client.require('sim')
def reload():
sim.loadScene(sim.getStringParam(sim.stringparam_scenedefaultdir) + '/minScene.ttt')
sim.loadScene(sim.getStringParam(sim.stringparam_scenedefaultdir) + '/minScene.ttt')
rightJoint = sim.getObject('/dr20/rightWheelJoint_')
leftJoint = sim.getObject('/dr20/leftWheelJoint_')
objHandle = sim.getObject('/dr20')
robotSize=sim.getObjectSizeFactor(objHandle)
#Numbers here taken from the built in script for the dr20 robot
v0 = 0.4*robotSize
wheelDiameter = 0.085*robotSize
interWheelDistance = 0.4*robotSize
for i in range(10000):
reload()
sim.setStepping(True)
sim.startSimulation()
for j in range(100):
p = sim.getModelProperty(objHandle)
sim.setModelProperty(objHandle, p)
sim.setJointTargetVelocity(leftJoint, 5*2/wheelDiameter)
sim.setJointTargetVelocity(rightJoint, 5*2/wheelDiameter)
sim.step()
print("run " , i)
sim.stopSimulation()
while sim.getSimulationState()!=sim.simulation_stopped:
pass
This code reproduces the crash! I think its more to do with time than what the code itself is doing as it takes around an hour-2 hours to crash! For me it crashed on run 4970.
The minScene is just a blank scene with a dr20 in it.
From first tests, it appears that sim.loadScene is the culprit. This bug somehow also happens with sim.loadModel.
A first workaround would be to avoid constantly reloading the same scene/model: after a simulation stop, the scene should anyways be mostly restored to its original state (i.e. just before simulation started).