Skip to content

Commit

Permalink
Merge pull request #1110 from ros/rostopic_long
Browse files Browse the repository at this point in the history
fix rostopic prining long integers
  • Loading branch information
dirk-thomas authored Jul 21, 2017
2 parents f851ca4 + 775160f commit 6814ebb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/rostopic/src/rostopic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
#TODO: lazy-import rospy or move rospy-dependent routines to separate location
import rospy

try:
long
except NameError:
long = int


class ROSTopicException(Exception):
"""
Base exception class of rostopic-related errors
Expand Down Expand Up @@ -687,7 +693,7 @@ def _sub_str_plot_fields(val, f, field_filter):
"""recursive helper function for _str_plot_fields"""
# CSV
type_ = type(val)
if type_ in (bool, int, float) or \
if type_ in (bool, int, long, float) or \
isinstance(val, genpy.TVal):
return f
# duck-type check for messages
Expand All @@ -708,7 +714,7 @@ def _sub_str_plot_fields(val, f, field_filter):
val0 = val[0]
type0 = type(val0)
# no arrays of arrays
if type0 in (bool, int, float) or \
if type0 in (bool, int, long, float) or \
isinstance(val0, genpy.TVal):
return ','.join(["%s%s"%(f,x) for x in range(0,len(val))])
elif _isstring_type(type0):
Expand Down Expand Up @@ -757,7 +763,7 @@ def _sub_str_plot(val, time_offset, field_filter):

if type_ == bool:
return '1' if val else '0'
elif type_ in (int, float) or \
elif type_ in (int, long, float) or \
isinstance(val, genpy.TVal):
if time_offset is not None and isinstance(val, genpy.Time):
return str(val-time_offset)
Expand All @@ -783,7 +789,7 @@ def _sub_str_plot(val, time_offset, field_filter):
type0 = type(val0)
if type0 == bool:
return ','.join([('1' if v else '0') for v in val])
elif type0 in (int, float) or \
elif type0 in (int, long, float) or \
isinstance(val0, genpy.TVal):
return ','.join([str(v) for v in val])
elif _isstring_type(type0):
Expand Down

0 comments on commit 6814ebb

Please sign in to comment.