ZMQ remote API failing after the same amount of runs of a simulation

Report crashes, strange behaviour, or apparent bugs
Post Reply
Llamas0001
Posts: 3
Joined: 06 Feb 2024, 20:00

ZMQ remote API failing after the same amount of runs of a simulation

Post by Llamas0001 »

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.

This is the error I am getting.

Code: Select all

[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'
Any help would be appreciated! Thanks!!

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

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by coppelia »

Hello,

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.

Cheers

Llamas0001
Posts: 3
Joined: 06 Feb 2024, 20:00

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by Llamas0001 »

Hi,

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!

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

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by coppelia »

Can you provide a minimalistic Python client code that would trigger that error? (maybe with a related minimalistic scene)

Cheers

Llamas0001
Posts: 3
Joined: 06 Feb 2024, 20:00

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by Llamas0001 »

Code: Select all

#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.

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

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by coppelia »

Thanks, with that I can reproduce the bug. Need to investigate more...

Cheers

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

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by coppelia »

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).

Cheers

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

Re: ZMQ remote API failing after the same amount of runs of a simulation

Post by coppelia »

Hello again,

the bug has been identified and will be fixed for CoppeliaSim V4.7, out within a few weeks.
Thanks for reporting it!

Cheers

Post Reply