ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You know that 'rostopic pub' has this functionality, so your first step should be to check it's code.

It is implemented in rostopic [Line 1707]. It's python so that there has to be a way to fill a message from such a string representation. The user input is stored in pub_args, so the next function to check is argv_publish, which leads to publish_message [L 1651], there, we find _fillMessageArgs [L. 1687], which then uses the final 'genpy.message.fill_message_args(msg, pub_args, keys=keys)' to fill the message. So the search continues to genpy.message and we finally find:

def fill_message_args(msg, msg_args, keys={}):
    """
    Populate message with specified args. Args are assumed to be a
    list of arguments from a command-line YAML parser. See
    http://www.ros.org/wiki/ROS/YAMLCommandLine for specification on
    how messages are filled. (...)

This should be the function you are looking for.

You know that 'rostopic pub' has this functionality, so your first step should be to check it's its code.

It is implemented in rostopic [Line 1707]. It's python so that there has to be a way to fill a message from such a string representation. The user input is stored in pub_args, so the next function to check is argv_publish, which leads to publish_message [L 1651], there, we find _fillMessageArgs [L. 1687], which then uses the final 'genpy.message.fill_message_args(msg, pub_args, keys=keys)' to fill the message. So the search continues to genpy.message and we finally find:

def fill_message_args(msg, msg_args, keys={}):
    """
    Populate message with specified args. Args are assumed to be a
    list of arguments from a command-line YAML parser. See
    http://www.ros.org/wiki/ROS/YAMLCommandLine for specification on
    how messages are filled. (...)

This should be the function you are looking for. for.