Skip to content

Commit

Permalink
Show stat for echoing non ROS message
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Sep 29, 2016
1 parent aed4afa commit 47adb6d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tools/rostopic/src/rostopic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def custom_strify_message(self, val, indent='', time_offset=None, current_time=N
if type_information and type_information.startswith('uint8['):
val = [ord(x) for x in val]
if value_transform is not None:
val = value_transform(val)
val = value_transform(val, type_information)
return genpy.message.strify_message(val, indent=indent, time_offset=time_offset, current_time=current_time, field_filter=field_filter, fixed_numeric_width=fixed_numeric_width)

def callback(self, data, callback_args, current_time=None):
Expand Down Expand Up @@ -1388,12 +1388,15 @@ def eval_fn(m):
sys.stderr.write("Network communication failed. Most likely failed to communicate with master.\n")

def create_value_transform(echo_nostr, echo_noarr):
def value_transform(val):
def value_transform(val, type_information=None):
if not isinstance(val, genpy.Message):
if echo_nostr and isinstance(val, str):
return None
elif echo_noarr and isinstance(val, list):
return None
if type_information is None:
return val
if echo_noarr and '[' in type_information:
return ('<array type: %s, length: %s>' %
(type_information.rstrip('[]'), len(val)))
elif echo_nostr and 'string' in type_information:
return '<string length: %s>' % len(val)
return val

class TransformedMessage(genpy.Message):
Expand Down

0 comments on commit 47adb6d

Please sign in to comment.