Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 475

Creating an array/list of existing message type without defining custom message type?

$
0
0
Is there a way to create an array of an existing message type without defining another message type? As a use-case, say you have many `.bag` files, each with a username. You compile them into a summary bag file and would like all unique usernames in a `metadata` topic for convenience. Is there any way to accomplish something like this without a custom message type? users = get_unique_users() # a function returns a list of strings: [user1, user2, ..., userN] outbag = rosbag.Bag('/path/to/file.bag', 'w') outbag.write('/metadata/unique_users', std_msgs.msg.String(users)) It seems that an array of an existing message is such a simple extension that I'd figure such a mechanism exists. My current approach was to create a new package, `std_msgs_array` with: $ rosmsg show std_msgs_array/StringArray string[] data $ rosmsg show std_msgs_array/Float64Array float64[] data Is this expected or am I overlooking something? I do note the following from the [ROS Wiki](http://wiki.ros.org/std_msgs): >...it's usually "better" (in the sense of making the code easier to understand, etc.) when developers use or create non-generic message types Perhaps the intention is to force more project-specific message creation rather than relying on built-in, canned examples. This use-case might be somewhat fringe where I truly am looking for a "throwaway"; all I care about is getting a list of very basic values into the output `.bag` vs. something like sensor data specific to a more complicated process.

Viewing all articles
Browse latest Browse all 475

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>