def saveDetectionToPBM(self): self.blockSize = 58 self.blockCountPending = 11 self.blockReceived = [False for x in range(self.blockCountPending)] rate = rospy.Rate(10) # 10hz # while self.blockCountPending: # Keep requesting the missing parts until they all arrive pubMsg = NodeBytes() pubMsg.node = 5 # streamid 8, imageid, imagetype (1=current), blocksize 59, range count, range list (start, count), ... # collection, frame, serial type pubMsg.data = [ 8, 0, 0, self.frameNum, 0, 0, 0, 3, self.blockSize, 1, 0, self.blockCountPending ] print "publish" self.pub.publish(pubMsg) missing = self.missingBlocks() prevMissingCount = len(missing) watchdogStart = time.time() timeout = False while not rospy.is_shutdown() and len(missing) > 0 and not timeout: rate.sleep() missing = self.missingBlocks() print "missing blocks ({})={}".format(len(missing), ",".join(map(str, missing))) if (len(missing) != prevMissingCount): prevMissingCount = len(missing) watchdogStart = time.time() watchdogEnd = time.time() if (watchdogEnd - watchdogStart > 3): timeout = True # if (len(missing) == 0): # transfer the filedata to the image data self.copyFileDataToImageData() self.writeImageDataToPBM()
def doImageReturn(self, node, data): # Forward to ROS pubMsg = NodeBytes() pubMsg.node = node pubMsg.data = data self.pubNodeBytes.publish(pubMsg)
#!/usr/bin/env python import time import rospy from beginner_tutorials.msg import NodeBytes pub = rospy.Publisher('byte_commands_to_nodes', NodeBytes, queue_size=1) rospy.init_node('Shutdown', anonymous=True) time.sleep(1) pubMsg = NodeBytes() pubMsg.node = 5 pubMsg.data = [11] pub.publish(pubMsg)