Skip to content
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

Fix echo for big array messages #126

Merged
merged 1 commit into from
Aug 1, 2018

Conversation

yechun1
Copy link
Contributor

@yechun1 yechun1 commented Jul 25, 2018

Issue1: ros2 topic echo pointcould2(big arrays), has no response, updated the logical to make more sensible.

a. (by default) full_length=false, truncate_length=128, then print max 128 (fix big arrays issue)

b. pass truncate_length=X, then print max X.

c. pass full_length=true (whatever truncate_length), then set truncate_length=None and print full_length.

Issue2: pass truncate_length to _convert_value(), this should be required.

Signed-off-by: Chris Ye chris.ye@intel.com

connect to #127

@dirk-thomas dirk-thomas added the in review Waiting for review (Kanban column) label Jul 25, 2018
@sloretz sloretz self-requested a review July 26, 2018 16:52
@@ -201,7 +201,7 @@ def msg_to_ordereddict(msg, truncate_length=None):
# We rely on __slots__ retaining the order of the fields in the .msg file.
for field_name in msg.__slots__:
value = getattr(msg, field_name, None)
value = _convert_value(value)
value = _convert_value(value, truncate_length)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since truncate_length is a keyword argument please pass it explicitly as such: truncate_length=truncate_length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dirk-thomas thanks for review, updated the code.

Issue1: ros2 topic echo pointcould2(big arrays), has no response, updated the logical to make more sensible.

    a. (by default) full_length=false, truncate_length=128, then print max 128 (fix big arrays issue)

    b. pass truncate_length=X, then print max X.

    c. pass full_length=true (whatever truncate_length), then set truncate_length=None and print full_length.

Issue2: missed truncate_length to _convert_value().
    Since truncate_length is a key argument, pass it explicitly to _convert_value()

Signed-off-by: Chris Ye <chris.ye@intel.com>
Copy link
Member

@mikaelarguedas mikaelarguedas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @yechun1 for the patch!

@mikaelarguedas
Copy link
Member

One surprising thing (but not directly related to this change) is that we sometimes end up with '...' and sometimes with '.....' for the truncated part (note it's 5 and not 6 dots, pretty surprising).

As this is a minor detail compared to the improvement provided by this PR, I'll merge this as is a look at or ticket the minor display hiccup

e.g.:

$ ros2 topic echo /image sensor_msgs/Image -l 3
header:
  stamp:
    sec: 0
    nanosec: 0
  frame_id: '29'
height: 240
width: 320
encoding: bgr...
is_bigendian: 0
step: 960
data: [0, 0, 0, '...']
$ ros2 topic echo /image sensor_msgs/Image -l 2
header:
  stamp:
    sec: 0
    nanosec: 0
  frame_id: '12'
height: 240
width: 320
encoding: bg...
is_bigendian: 0
step: 960
data: [0, 0, '.....']

@dirk-thomas
Copy link
Member

As this is a minor detail compared to the improvement provided by this PR, I'll merge this as is a look at or ticket the minor display hiccup

Is the "minor display hiccup" introduced by this PR or can it be reproduced without? If it is the former this shouldn't be merged until the "hiccup" is addressed. If it is the latter this can be safely merged and the "hiccup" should be fixed (or at least ticketed if the time to fix it is significant).

@mikaelarguedas
Copy link
Member

As the truncation doesnt work without this patch, not sure how to reproduce it without applying this.

I'll have a quick look at the hiccup later today and will merge this + ticket or fix the hiccup before end of day

@yechun1
Copy link
Contributor Author

yechun1 commented Aug 1, 2018

root caused the issue related with previous code which inside nested _convert_value function.

Execute: "ros2 topic echo /topic -l 2"

with test code, first time convert data to (first if, for t in (bytes, list, str, tuple))

value [0, 0, '...']
k in value [0, 0, '...']
k: 0
k: 0
k: ...

second time call nested convert_value by (second elfi, for t in (list, tuple))
when k=...
len(k) = 3, truncate_length = 2.
convert the '...' as real data as '..' and append another '...'
so the result is "....."

while "ros2 topic echo /topic -l 3" is correct
when k='...'
if (len("...") > truncate_length) is not ture. skip convert.

Is it possible to remove nested function for _convert_value, it's a little difficult to understand.

@mikaelarguedas
Copy link
Member

Thanks @yechun1 for looking into it. I ticketed it at #129 so that this can be merged and backported

@mikaelarguedas
Copy link
Member

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@mikaelarguedas mikaelarguedas merged commit be38ea4 into ros2:master Aug 1, 2018
@mikaelarguedas mikaelarguedas removed the in review Waiting for review (Kanban column) label Aug 1, 2018
@yechun1 yechun1 deleted the fix_topic_echo_issue branch August 2, 2018 00:36
@sloretz sloretz mentioned this pull request Aug 15, 2018
12 tasks
esteve pushed a commit to esteve/ros2cli that referenced this pull request Dec 16, 2022
* Complete launch file name for launch files not arguments

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Expose get_launch_file_paths

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Suppress invalid file completions

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Complete launch files in first argument

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Don't complete recursive launch files

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Typo in comment

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* style

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Add is_launch_file and expose it

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Reuse argcomplete machinery for paths

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* dict() instead of dictionary comprehension

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Remove unnecessary basename() call

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Compatibility with argcomplete==1.8.1

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* is_launch_file takes normal arg

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants