def on_message(self, ws, message): data = json.loads(message) rosmsg = self.rostype() if not data or data['op'] != 'publish' or data[ 'topic'] != self.topic_name: rospy.logerr( 'Failed to handle message on subscribed topic %s [%s]', self.topic_name, data) return data.pop('_format', None) try: msgconv.populate_instance(data['msg'], rosmsg) self.publisher.publish(rosmsg) except Exception, e: rospy.logerr('Failed to publish message on topic %s. Reason: %s', self.topic_name, str(e))
def on_message(self, ws, message): data = json.loads(message) if not data or data['op'] != 'service_response' or data[ 'service'] != self.service_name: rospy.logerr('Failed to handle message on service type %s [%s]', self.service, data) return try: rosmsg = self.srvtype()._response_class() msgconv.populate_instance(data['values'], rosmsg) # need lock to protect call_id = data.get('id').encode('ascii') with self.lock: self.event_queue[call_id]['result'] = rosmsg self.event_queue[call_id]['event'].set() except Exception, e: rospy.logerr('Failed to call service on %s. Reason: %s', self.service_name, str(e))
def on_message(self, message): data = json.loads(message) ts = get_message_timestamp(data['msg']) #pdb.set_trace() if not comp_and_replace_value(data['topic'], self.topic_type, ts): return rosmsg = self.rostype() if not data or data['op'] != 'publish' or data[ 'topic'] != self.topic_name: rospy.logerr( 'Failed to handle message on subscribed topic %s [%s]', self.topic_name, data) return data.pop('_format', None) try: msgconv.populate_instance(data['msg'], rosmsg) self.publisher.publish(rosmsg) except Exception, e: rospy.logerr('Failed to publish message on topic %s. Reason: %s', self.topic_name, str(e))