rostopic: #1774 bug fix to type compare on Time/Duration that was causing crash with -p
This commit is contained in:
parent
d2faee6ca0
commit
47cd69be2d
|
@ -360,9 +360,9 @@ from itertools import izip
|
|||
|
||||
def _str_plot_fields(val, f):
|
||||
"""
|
||||
print fields used by _str_plot
|
||||
@param plot: if True, print in plotting-friendly format. non-scalar values are excluded
|
||||
@type plot: bool
|
||||
get CSV representation of fields used by _str_plot
|
||||
@return: list of fields as a CSV string
|
||||
@rtype: str
|
||||
"""
|
||||
s = _sub_str_plot_fields(val, f)
|
||||
if s is not None:
|
||||
|
@ -372,7 +372,7 @@ def _sub_str_plot_fields(val, f):
|
|||
"""recursive helper function for _str_plot_fields"""
|
||||
# CSV
|
||||
if type(val) in [int, float] or \
|
||||
isinstance(val, rospy.Time) or isinstance(val, rospy.Duration):
|
||||
isinstance(val, roslib.rostime.Time) or isinstance(val, roslib.rostime.Duration):
|
||||
return f
|
||||
elif isinstance(val, rospy.Message):
|
||||
sub = [s for s in [_sub_str_plot_fields(getattr(val, a), f+"."+a) for a in val.__slots__] if s]
|
||||
|
@ -403,6 +403,10 @@ def _str_plot(val, time_offset=None):
|
|||
convert value to matlab/octave-friendly CSV string representation.
|
||||
Reads the state of the _echo_nostrs and _echo_noarr global vars to
|
||||
determine which fields are printed.
|
||||
@param val: message
|
||||
@type val: Message
|
||||
@return: comma-separated list of field values in val
|
||||
@rtype: str
|
||||
"""
|
||||
s = _sub_str_plot(val, time_offset)
|
||||
if s is not None:
|
||||
|
@ -421,8 +425,8 @@ def _sub_str_plot(val, time_offset):
|
|||
"""Helper routine for _str_plot."""
|
||||
# CSV
|
||||
if type(val) in [int, float] or \
|
||||
isinstance(val, rospy.Time) or isinstance(val, rospy.Duration):
|
||||
if time_offset is not None and isinstance(val, rospy.Time):
|
||||
isinstance(val, roslib.rostime.Time) or isinstance(val, roslib.rostime.Duration):
|
||||
if time_offset is not None and isinstance(val, roslib.rostime.Time):
|
||||
return str(val-time_offset)
|
||||
else:
|
||||
return str(val)
|
||||
|
@ -530,7 +534,7 @@ class CallbackEcho(object):
|
|||
|
||||
# print fields header for plot
|
||||
if self.plot and self.first:
|
||||
sys.stdout.write("%"+_str_plot_fields(data, 'm')+'\n')
|
||||
sys.stdout.write("%"+_str_plot_fields(data, 'field')+'\n')
|
||||
self.first = False
|
||||
|
||||
if self.offset_time:
|
||||
|
|
Loading…
Reference in New Issue