-
Notifications
You must be signed in to change notification settings - Fork 913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rostopic] Show stat when rostopic echo --noarr/nostr #724
Conversation
b30b6e0
to
5037d5b
Compare
if value_transform: | ||
# this operation is necessary because value_transform does change the type of message | ||
# and that causes not strified values next time | ||
val = value_untransform_fn(val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be easier to read like this:
value_untransform_fn = None
if value_transform:
val, value_untransform_fn = value_transform(val)
text = 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)
if value_untransform_fn is not None:
# this operation is necessary because value_transform does change the type of message
# and that causes not strified values next time
val = value_untransform_fn(val)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I updated the commit.
Looks reasonable to me. |
5037d5b
to
a59ac5a
Compare
Thanks for the feedback, I updated the commit. |
@@ -608,7 +608,8 @@ class CallbackEcho(object): | |||
def __init__(self, topic, msg_eval, plot=False, filter_fn=None, | |||
echo_clear=False, echo_all_topics=False, | |||
offset_time=False, count=None, | |||
field_filter_fn=None, fixed_numeric_width=None): | |||
field_filter_fn=None, value_transform_fn=None, | |||
fixed_numeric_width=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not change the order of existing arguments but add new arguments at the end.
Same below.
I have updated |
Some of the unit tests are currently failing. Please see the referenced Jenkins builds. |
dc650c3
to
9b7b996
Compare
""" | ||
:param plot: if ``True``, echo in plotting-friendly format, ``bool`` | ||
:param filter_fn: function that evaluates to ``True`` if message is to be echo'd, ``fn(topic, msg)`` | ||
:param echo_all_topics: (optional) if ``True``, echo all messages in bag, ``bool`` | ||
:param offset_time: (optional) if ``True``, display time as offset from current time, ``bool`` | ||
:param count: number of messages to echo, ``None`` for infinite, ``int`` | ||
:param field_filter_fn: filter the fields that are strified for Messages, ``fn(Message)->iter(str)`` | ||
:param field_filter_fn: filter the fields that are stringified for Messages, ``fn(Message)->iter(str)`` | ||
:param value_transform_fn: transform the values of Messages, ``fn(Message)->Message`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate of line 622.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I have fixed.
da1963f
to
afbb4b1
Compare
return val, untransform_fn | ||
return value_transform | ||
|
||
def create_field_filter(echo_nostr, echo_noarr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this function is used anywhere outside by now it doesn't filter anything anymore.
afbb4b1
to
b57a5bb
Compare
Removed the field_filter function. |
Since you have removed all unit tests for |
I'm not planning to readd them, because filtering field it not supported after this PR. |
Is this solution OK? I removed the |
|
b57a5bb
to
1da29f8
Compare
@dirk-thomas And also, I found a bug of this code with nested messages as below.
AFTER
|
@ros-pull-request-builder rostest this please |
Test passed. Please review again when you have time. |
The patch looks good. But I was thinking if the effort for transforming and then untransforming the message is necessary. Wouldn't it be easier to just copy the message and update the copied message? For efficiency you could also implement a custom copy operation which already avoids to copy the string / array fields in the first place? |
Thanks for the suggestion. I worked around for a while, and the problem when the transformed message was untransformed will be fixed by correct |
1a62372
to
19fb710
Compare
ping |
1 similar comment
ping |
I am sorry for the late response but I currently have to focus on a different project and don't have much time to review ROS tickets. The patch looks good now. Thank you for iterating on it. I cherry-picked the changed to the kinetic-devel branch with two small cosmetic changes: e0f6397
|
Thanks! |
Should this be another option like
--statarr
?Because this kind of function is not needed for string for me but for only array field.