4 import cPickle
as pickle
15 return '[{node}] [{cls}::{method}] {msg}'.format(
16 node=rospy.get_name(),
17 cls=inspect.stack()[2][0].f_locals[
'self'].__class__.__name__,
18 method=inspect.stack()[2][0].f_code.co_name,
21 return '[{node}] [{func}] {msg}'.format(
22 node=rospy.get_name(),
23 func=inspect.stack()[2][0].f_code.co_name,
49 last_logging_time_table = {}
51 def __call__(self, id, logging_func, period, msg):
52 """Do logging specified message periodically. 54 - id (str): Id to identify the caller 55 - logging_func (function): Function to do logging. 56 - period (float): Period to do logging in second unit. 57 - msg (object): Message to do logging. 59 now = rospy.Time.now()
61 last_logging_time = self.last_logging_time_table.get(id)
63 if (last_logging_time
is None or 64 (now - last_logging_time) > rospy.Duration(period)):
73 id = pickle.dumps(inspect.stack()[1][1:])
78 id = pickle.dumps(inspect.stack()[1][1:])
83 id = pickle.dumps(inspect.stack()[1][1:])
88 id = pickle.dumps(inspect.stack()[1][1:])
93 id = pickle.dumps(inspect.stack()[1][1:])
98 node_name = rospy.get_name()
99 resolved_names = [rosgraph.names.resolve_name(n, node_name)
for n
in names]
100 mappings = rospy.names.get_resolved_mappings()
101 for r_name
in resolved_names:
102 if r_name
in mappings:
105 rospy.logwarn(
"[{node_name}] '{name}' has not been remapped." 106 .format(node_name=node_name, name=name))