Skip to content

[ros2interface] Add option to include/remove whitespace and comments#527

Merged
audrow merged 6 commits intomasterfrom
audrow/toggle-comments-v2
Jun 10, 2020
Merged

[ros2interface] Add option to include/remove whitespace and comments#527
audrow merged 6 commits intomasterfrom
audrow/toggle-comments-v2

Conversation

@audrow
Copy link
Copy Markdown
Member

@audrow audrow commented Jun 5, 2020

Adds the ability to show an interface's whitespace and comments with the argument --raw or -r, like in ROS1's rosmsg.

Signed-off-by: Audrow <audrow.nash@gmail.com>
@audrow audrow added the enhancement New feature or request label Jun 5, 2020
@audrow audrow requested a review from sloretz June 5, 2020 19:09
Signed-off-by: Audrow <audrow.nash@gmail.com>
@audrow audrow removed the request for review from sloretz June 8, 2020 17:24
Copy link
Copy Markdown
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

To clarify, this PR is not only adds an option, but changes the default behavior so that comments are stripped out. I think this is okay to match the existing behavior in ROS 1.

I think it's worth mentioning the change of behavior in the commit message.

@dirk-thomas
Copy link
Copy Markdown
Member

changes the default behavior so that comments are stripped out.

I am not sure that is better default behavior. The comments often provide a lot of context. I would rather see them shown by default and let uses hide them if they don't mind.

@sloretz
Copy link
Copy Markdown
Contributor

sloretz commented Jun 8, 2020

I am not sure that is better default behavior. The comments often provide a lot of context.

I found it pretty difficult to understand geometry_msgs/msg/TwistStamped with comments: #524 (review) . The repeated comments added noise that made it difficult for my eyes to find the message fields.

@audrow
Copy link
Copy Markdown
Member Author

audrow commented Jun 8, 2020

I ran CI after Jacob's review. Here are the results.

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

@audrow
Copy link
Copy Markdown
Member Author

audrow commented Jun 8, 2020

I'm happy to make any changes depending on what we think the default behavior should be.

@dirk-thomas
Copy link
Copy Markdown
Member

I found it pretty difficult to understand geometry_msgs/msg/TwistStamped with comments: #524 (review) . The repeated comments added noise that made it difficult for my eyes to find the message fields.

And there are probably countless counter examples where without any comments the semantic is not obvious to the average user. That is why there certainly should be options to choose.

In your example a lot of the overhead comes from the fact that the comments are shown repeatedly for submessages. Maybe not showing comments for submessages would be a reasonable option or only showing it once per type?

@sloretz
Copy link
Copy Markdown
Contributor

sloretz commented Jun 8, 2020

And there are probably countless counter examples where without any comments the semantic is not obvious to the average user. That is why there certainly should be options to choose.

Agreed that the option should be there

In your example a lot of the overhead comes from the fact that the comments are shown repeatedly for submessages. Maybe not showing comments for submessages would be a reasonable option or only showing it once per type?

what that would look like:

$ ros2 interface show geometry_msgs/msg/TwistStamped
# A twist with reference coordinate frame and timestamp

std_msgs/Header header
	# Standard metadata for higher-level stamped data types.
	# This is generally used to communicate timestamped data
	# in a particular coordinate frame.

	# Two-integer timestamp that is expressed as seconds and nanoseconds.
	builtin_interfaces/Time stamp
		# Time indicates a specific point in time, relative to a clock's 0 point.

		# The seconds component, valid over all int32 values.
		int32 sec

		# The nanoseconds component, valid in the range [0, 10e9).
		uint32 nanosec

	# Transform frame with which this data is associated.
	string frame_id
Twist twist
	# This expresses velocity in free space broken into its linear and angular parts.

	Vector3  linear
		# This represents a vector in free space.

		# This is semantically different than a point.
		# A vector is always anchored at the origin.
		# When a transform is applied to a vector, only the rotational component is applied.

		float64 x
		float64 y
		float64 z
	Vector3  angular
		float64 x
		float64 y
		float64 z

It certainly helps, though there are still a lot of comments that might not help me understand the twist message, especially if I'm already familiar with the nested message (like std_msgs/msg/Header).

Maybe showing only the comments from the top level message by default would reduce the noise without losing the meaning? Presumably the top level message definition has enough comments to understand its semantics. Then the fields of the nested messages are there only to show how to access the data.

$ ros2 interface show geometry_msgs/msg/TwistStamped
# A twist with reference coordinate frame and timestamp

std_msgs/Header header
	builtin_interfaces/Time stamp
		int32 sec
		uint32 nanosec
	string frame_id
Twist twist
	Vector3  linear
		float64 x
		float64 y
		float64 z
	Vector3  angular
		float64 x
		float64 y
		float64 z

@dirk-thomas
Copy link
Copy Markdown
Member

Maybe showing only the comments from the top level message by default would reduce the noise without losing the meaning? Presumably the top level message definition has enough comments to understand its semantics.

👍

@audrow
Copy link
Copy Markdown
Member Author

audrow commented Jun 8, 2020

I can make it so only top level comments and whitespace are shown. Do we want to keep a --raw option to show the comments and whitespace for nested definitions?

@dirk-thomas
Copy link
Copy Markdown
Member

dirk-thomas commented Jun 8, 2020

Do we want to keep a --raw option to show the comments and whitespace for nested definitions?

👍 for having options to customize the output. Imo --raw doesn't convey what the option is supposed to do (just the fact that nested information is shown is everything but "raw"). Options like --all-comments / --no-comments seem much more intuitive.

Signed-off-by: Audrow <audrow.nash@gmail.com>
@audrow
Copy link
Copy Markdown
Member Author

audrow commented Jun 9, 2020

I've change interface show to use --all-comments and --no-comments. Below are some examples of printout.

No flags (top level comments included)
$ ros2 interface show geometry_msgs/msg/TwistStamped 
# A twist with reference coordinate frame and timestamp

std_msgs/Header header
        builtin_interfaces/Time stamp
                int32 sec
                uint32 nanosec
        string frame_id
Twist twist
        Vector3  linear
                float64 x
                float64 y
                float64 z
        Vector3  angular
                float64 x
                float64 y
                float64 z
No comments flag
$ ros2 interface show geometry_msgs/msg/TwistStamped --no-comments
std_msgs/Header header
        builtin_interfaces/Time stamp
                int32 sec
                uint32 nanosec
        string frame_id
Twist twist
        Vector3  linear
                float64 x
                float64 y
                float64 z
        Vector3  angular
                float64 x
                float64 y
                float64 z
All comments flag
$ ros2 interface show geometry_msgs/msg/TwistStamped --all-comments
# A twist with reference coordinate frame and timestamp

std_msgs/Header header
        # Standard metadata for higher-level stamped data types.
        # This is generally used to communicate timestamped data
        # in a particular coordinate frame.

        # Two-integer timestamp that is expressed as seconds and nanoseconds.
        builtin_interfaces/Time stamp
                # Time indicates a specific point in time, relative to a clock's 0 point.

                # The seconds component, valid over all int32 values.
                int32 sec

                # The nanoseconds component, valid in the range [0, 10e9).
                uint32 nanosec

        # Transform frame with which this data is associated.
        string frame_id
Twist twist
        # This expresses velocity in free space broken into its linear and angular parts.

        Vector3  linear
                # This represents a vector in free space.

                # This is semantically different than a point.
                # A vector is always anchored at the origin.
                # When a transform is applied to a vector, only the rotational component is applied.

                float64 x
                float64 y
                float64 z
        Vector3  angular
                # This represents a vector in free space.

                # This is semantically different than a point.
                # A vector is always anchored at the origin.
                # When a transform is applied to a vector, only the rotational component is applied.

                float64 x
                float64 y
                float64 z
Error message with no comments and all comments flag
$ ros2 interface show geometry_msgs/msg/TwistStamped --all-comments --no-comments 
Cannot use the flags '--all-comments' and '--no-comments' at the same time

@audrow audrow requested a review from jacobperron June 9, 2020 18:06
@audrow audrow requested a review from dirk-thomas June 9, 2020 19:07
Signed-off-by: Audrow <audrow.nash@gmail.com>
@audrow audrow force-pushed the audrow/toggle-comments-v2 branch from edc783f to 011cc77 Compare June 9, 2020 19:10
Copy link
Copy Markdown
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM, one suggestion

Co-authored-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Audrow <audrow.nash@gmail.com>
@audrow audrow force-pushed the audrow/toggle-comments-v2 branch from 46e3565 to 04c77b4 Compare June 9, 2020 22:34
@audrow
Copy link
Copy Markdown
Member Author

audrow commented Jun 9, 2020

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

Copy link
Copy Markdown
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

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

Beside some minor nitpicks.

Signed-off-by: Audrow <audrow.nash@gmail.com>
@audrow audrow merged commit 8e331ad into master Jun 10, 2020
@delete-merged-branch delete-merged-branch bot deleted the audrow/toggle-comments-v2 branch June 10, 2020 16:25
@audrow
Copy link
Copy Markdown
Member Author

audrow commented Jun 10, 2020

@dirk-thomas @jacobperron @sloretz Thank you for your help and feedback! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants