4 __all__ = (
'LazyTransport',)
12 """Called when you call LazyTransport()""" 13 obj = type.__call__(cls, *args, **kwargs)
19 __metaclass__ = MetaLazyTransport
22 super(LazyTransport, self).
__init__()
29 rospy.Timer(rospy.Duration(5),
33 if not rospy.get_param(
'~lazy',
True):
40 '[{name}] subscribes topics only with' 41 " child subscribers. Set '~lazy' as False" 42 ' to have it always transport message.' 43 .format(name=rospy.get_name()))
46 raise NotImplementedError(
'Please overwrite this method')
49 raise NotImplementedError(
'Please overwrite this method')
52 rospy.logdebug(
'[{topic}] is subscribed'.format(topic=args[0]))
58 rospy.logdebug(
'[{topic}] is unsubscribed'.format(topic=args[0]))
59 if not rospy.get_param(
'~lazy',
True):
64 if pub.get_num_connections() > 0:
73 assert len(args) < 3
or args[2]
is None 74 assert kwargs.get(
'subscriber_listener')
is None 75 kwargs[
'subscriber_listener'] = self
77 pub = rospy.Publisher(*args, **kwargs)
78 self._publishers.append(pub)