19 from rosgraph_msgs.msg
import Log
25 LEVELS = [Log.DEBUG, Log.FATAL, Log.ERROR, Log.WARN, Log.INFO, Log.DEBUG, Log.DEBUG]
26 ROSOUT_PUB = rospy.topics.Publisher(
'/rosout', Log, latch=
True, queue_size=100)
30 Given a NAOqi dict message, publish it in /rosout 31 :param msg: dict corresponding to a NAOqi log message 33 file, function, line = msg[
'source'].split(
':')
37 l = Log(level=LEVELS[msg[
'level']], name=str(msg[
'category']), msg=msg[
'message'], file=file, line=line, function=function)
38 l.header.stamp = rospy.Time(msg[
'timestamp'][
'tv_sec'], msg[
'timestamp'][
'tv_usec'])
43 NODE_NAME =
'nao_logger' 47 NaoqiNode.__init__( self, self.
NODE_NAME )
49 from distutils.version
import LooseVersion
51 rospy.loginfo(
'The NAOqi version is inferior to 2.0, hence no log bridge possible')
59 self.session.connect(
"tcp://%s:%s" % (self.
pip, self.
pport))
63 self.listener.onLogMessage.connect(onMessageCallback)
64 rospy.loginfo(
'Logger initialized')
66 if __name__ ==
'__main__':
69 except RuntimeError
as e:
70 rospy.logerr(
'Something went wrong: %s' % str(e) )
def onMessageCallback(msg)