def on_message(self, ws, message):
data = json.loads(message)
ts = get_message_timestamp(data['msg'])
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))
评论列表
文章目录