B0 Remote API: destroyed all streaming functions for client after detection of inactivity
Posted: 15 Jun 2020, 07:40
I am creating a python script that uses BlueZero Remote API to start the
simulator and stream the vision sensor image, I am on windows and was
successful in getting the image but after about 30sec of simulation time the
script hangs and this message appears in the simulator:
"B0 Remote API: destroyed all streaming functions for client '13gy5Zgaeg' after detection of inactivity"
I would like my user to decide when to stop the simulator and hence stops streaming by a Keyboard Interrupt.
How do I stop this thing from happening?
here is my code snippet:
P.S I went through one similar post, but that didn't work out.
simulator and stream the vision sensor image, I am on windows and was
successful in getting the image but after about 30sec of simulation time the
script hangs and this message appears in the simulator:
"B0 Remote API: destroyed all streaming functions for client '13gy5Zgaeg' after detection of inactivity"
I would like my user to decide when to stop the simulator and hence stops streaming by a Keyboard Interrupt.
How do I stop this thing from happening?
here is my code snippet:
Code: Select all
# python
with b0RemoteApi.RemoteApiClient('b0_Vision', 'b0RemoteApi', 60, False,100) as client:
img = None
def time_callback(msg):
global sim_time
sim_time = round(float(msg[1]),2)
def imageCallback(msg):
img= np.frombuffer(msg[2], dtype=np.uint8)
img.resize([msg[1][1], msg[1][0], 1])
sender.send_image(sim_time, img)
ret, visionSensorHandle = client.simxGetObjectHandle('Vision_sensor',
client.simxServiceCall())
if not ret:
sys.exit(' No Object named "Vision_sensor" found!!')
print(' *Starting simulator*')
print(' *Press ctrl+c to Stop*\n')
dedicatedSub=client.simxCreateSubscriber(imageCallback,1,True)
t1=time.time()
if client.simxStartSimulation(client.simxServiceCall()): # Starting simulator
client.simxGetSimulationTime(client.simxDefaultSubscriber(time_callback))
client.simxGetVisionSensorImage(visionSensorHandle, True,dedicatedSub)
#client.simxGetVisionSensorImage(visionSensorHandle, True,client.simxDefaultSubscriber(imageCallback))
while True:
try:
client.simxSpinOnce() # to get data from waiting queue
except KeyboardInterrupt:
break
client.simxSpinOnce() # Dumping the waiting queue data
client.simxStopSimulation(client.simxServiceCall()) # stopping simulator
print(' *Stopped Simulator*\n')
else:
sys.exit('***Simulator Error!***')