[ros-users] rosmsg and rossrv prototype

Ken Conley kwc at willowgarage.com
Wed Nov 2 16:28:00 UTC 2011

On Tue, Nov 1, 2011 at 6:01 AM, Thibault Kruse <kruset at in.tum.de> wrote:
> Hi,
> When using rostopic pub or rosservice call I often find it difficult to get
> the YAML right quickly, and a bit tedious as well.
> I therefore implemented a function for
> $ rosmsg prototype
> $ rossrv prototype
> that work similar to rosmsg show and rossrv show, except that yaml is
> returned that can be used for rostopic pub / rosservice call.
> Examples:
> $ rosmsg prototype sensor_msgs/PointCloud
> "{channels: [{name: '', values: []}], header: {frame_id: '', seq: 0, stamp:
> {nsecs: 0,\
>      secs: 0}}, points: [{x: 0.0, y: 0.0, z: 0.0}]}"
> $ rossrv prototype gazebo/SetModelConfiguration
> "{joint_names: [''], joint_positions: [0.0], model_name: '',
> test_urdf_param_name: ''}"
> $ rosmsg prototype tf/tfMessage
> "{transforms: [{child_frame_id: '', header: {frame_id: '', seq: 0, stamp:
> {nsecs: 0,\
>          secs: 0}}, transform: {rotation: {w: 0.0, x: 0.0, y: 0.0, z: 0.0},
> translation: {\
>          x: 0.0, y: 0.0, z: 0.0}}}]}"
> The key here was that the output can be copy/pasted as input to rostopic and
> rosservice.
> I already made a ticket for that enhancement here:
> https://code.ros.org/trac/ros/ticket/3732
> but given it is an API change I'd first like to know who thinks this would
> be useful. Note that this could then also be used for tab completion.

I'm definitely for such a feature, though, like Felix, I'm not sure
they belong with rosmsg/rossrv as there is a bit of a abstraction loss
there; either that, or rosmsg/srv need a first-class notion of the
YAML form of messages.  Right now the YAML form is implicit and the
code APIs are generally marked for internal use only.

Back in the day I pushed for this with 'bagy' [1], but was nixed as
feedback from the mailing list was that a first-class YAML
representation was a useful hack, but not first-class (though it was
not argued with the support of the particular use case above).

[1]: https://code.ros.org/gf/project/ros/mailman/?_forum_action=ForumMessageBrowse&thread_id=43661&action=ListThreads&mailman_id=8

Also, personally I use the multi-line input for command-line args,
which greatly simplifies the YAML, and perhaps the 'prototype' feature
could educate users about that as well.  Basically, you can use the
'rostopic echo' output form as a prototype of a 'rostopic pub'

e.g. if the rostopic 'echo' output is:

linear: 2.0
angular: 0.0

Then the rostopic 'pub' input can be:

$ rostopic pub /cmd_vel turtlesim/Velocity """
> linear: 2.0
> angular: 1.0
> """

This form is much easier to deal with when having msgs that contain msgs.

 - Ken

> My other concern is with the code quality of my patch, attached to the
> ticket at:
> https://code.ros.org/trac/ros/attachment/ticket/3732/0002-protoype-command.patch
> There are a lot of python introspection and roslib.message and yaml dumping
> bits that seem a bit unelegant to me, but I would not know better.
> I marked the spots with TODO comments in the patch.
> I'd be happy if python experts on either of those areas would have a look at
> the patch and improve it if possible.
> I am not sure whether this overlaps with rosh bagy functionality.
> Also it is a bit of a pity that some values are not well initialized, in
> particular Qauternions and header times. If anyone has a great idea of how
> to do this cleanly, that could be great.
> cheers,
>  Thibault
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users

More information about the ros-users mailing list