def initialize(self): # socket for configuration requests self._zmq_context = zmq.Context() self._zmq_config_socket = self._zmq_context.socket(zmq.REQ) self._zmq_config_socket.connect(self._config_uri) # socket for receiving messages rospy.loginfo('Parent listening for messages on zmq socket %s' % self._pub_uri) self._zmq_pub_socket = self._zmq_context.socket(zmq.SUB) self._zmq_pub_socket.connect(self._pub_uri) self._zmq_pub_socket.setsockopt(zmq.SUBSCRIBE, '') self._pub_socket_lock = threading.Lock() # socket for publishing messages rospy.loginfo('Parent publishing messages on zmq socket %s' % self._sub_uri) self._zmq_sub_socket = self._zmq_context.socket(zmq.PUB) self._zmq_sub_socket.connect(self._sub_uri) self._sub_socket_lock = threading.Lock() # used to inspect the local ROS system self._ros_interface = RosInterface(self._ros_master_uri, 'mros_parent', self.ros_message_callback) self._ros_interface_lock = threading.Lock()
def initialize(self): # socket for configuration requests self._zmq_context = zmq.Context() self._zmq_config_socket = self._zmq_context.socket(zmq.REP) self._zmq_config_socket.bind(self._config_uri) # socket for publishing messages rospy.loginfo('Child publishing messages on zmq socket %s' % self._pub_uri) self._zmq_pub_socket = self._zmq_context.socket(zmq.PUB) self._zmq_pub_socket.bind(self._pub_uri) self._zmq_pub_lock = threading.Lock() # socket for receiving messages rospy.loginfo('Child listening for messages on zmq socket %s' % self._sub_uri) self._zmq_sub_socket = self._zmq_context.socket(zmq.SUB) self._zmq_sub_socket.bind(self._sub_uri) self._zmq_sub_socket.setsockopt(zmq.SUBSCRIBE, '') # used to interact the local ROS system self._ros_interface = RosInterface(self._ros_master_uri, 'mros_child', self.local_message_callback) self._remote_message_thread = threading.Thread(target=self.remote_message_thread_func) self._remote_message_thread.start()