escalating cpu load with simxGetFloatSignal (pyRemoteApi)

Report crashes, strange behaviour, or apparent bugs
Post Reply
el_Raimundo

escalating cpu load with simxGetFloatSignal (pyRemoteApi)

Post by el_Raimundo »

Hi,
I have encountered a problem when trying to stream values from vrep with simxGetFloatSignal in python.
Cpu usage of python is skyrocketing and effectively blocking my system when a lot of signals are being created - despite clearing the signals immediately after retrieving their values.
Let's assume there are 100 Float Signals from vrep continuously updated during a simulation run. After a while, the simulation is remotely stopped and restarted, 100 new FloatSignals are created in vrep and then streamed with simxGetFloatSignal, and so on and so forth for several simulation runs.
When the signals have unique names for each simulation run, cpu usage of python (not vrep) is drastically increasing over time.
I was able to reproduce the problem with the following minimal python code (the signals are created in vrep accordingly):

Code: Select all

import vrep
from time import sleep, time

if __name__ == "__main__":
    clientID = vrep.simxStart('127.0.0.1', 19997, False, True, 2000, 10) 
    for i in range(1000): # each iteration of this loop should use unique signal names 
        vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot)     
        for step in range(10):
                then = time()
                values = []
                for j in range(100): # 100 signals
                    sig_name = "FS_" + str(i) + str(j)
                    ret, val = vrep.simxGetFloatSignal(clientID, sig_name, vrep.simx_opmode_streaming)
                    if ret !=0:
                        print "error", ret
                    values.append(val)
                    vrep.simxClearFloatSignal(clientID, sig_name, vrep.simx_opmode_oneshot)
                now = time()
                print "fetched values in", now - then, "seconds"
                sleep(0.5)
        vrep.simxStopSimulation(clientID, vrep.simx_opmode_oneshot)
        sleep(2)
any ideas?
thanks a lot in advance,
raimund

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

Re: escalating cpu load with simxGetFloatSignal (pyRemoteApi

Post by coppelia »

Hello Raimund,

it is not enough to clear a signal, you should also stop streaming it. When you start streaming a signal, streaming will go on even if the signal is non-existent (since it could be created any time again on the V-REP side).

To stop streaming, use the operation mode simx_opmode_discontinue.

Cheers

el_Raimundo

Re: escalating cpu load with simxGetFloatSignal (pyRemoteApi

Post by el_Raimundo »

great! simple and immediate relief.
thanks
raimund

Post Reply