1414from rosserial_msgs import TopicInfo
1515import sys
1616import os
17+ import logging
1718
1819# for now threads are used, will be changed with asyncio in the future
1920if sys .platform == "esp32" :
2425# rosserial protocol header
2526header = [0xFF , 0xFE ]
2627
28+ logging .basicConfig (level = logging .INFO )
29+
2730# class to manage publish and subscribe
2831# COULD BE CHANGED AFTERWARDS
2932class NodeHandle (object ):
@@ -87,7 +90,7 @@ def _advertise_topic(self, topic_name, msg, endpoint, buffer_size):
8790 try :
8891 register .buffer_size = buffer_size
8992 except Exception as e :
90- print ("No buffer size could be defined for topic negotiation." )
93+ logging . info ("No buffer size could be defined for topic negotiation." )
9194
9295 # serialization
9396 packet = uio .StringIO ()
@@ -164,9 +167,7 @@ def _listen(self):
164167 # incoming object msg initialized
165168 msgobj = self .subscribing_topics .get (inid )[0 ]
166169 except Exception :
167- print (
168- "TX request was made or got message from not available subscribed topic."
169- )
170+ logging .info ("TX request was made or got message from not available subscribed topic." )
170171 # object sent to callback
171172 callback = self .subscribing_topics .get (inid )[1 ]
172173 fdata = msgobj ()
@@ -176,7 +177,7 @@ def _listen(self):
176177 raise ValueError ("Message plus Topic ID Checksum is wrong!" )
177178
178179 except Exception as e :
179- print ("No incoming data could be read for subscribes." )
180+ logging . info ("No incoming data could be read for subscribes." )
180181
181182
182183# functions to be used in class
0 commit comments