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)
thanks a lot in advance,
raimund