Ask Your Question
0

sending messages containing not predefined types

asked 2012-12-13 02:51:13 -0500

ubisum gravatar image

updated 2012-12-13 02:51:32 -0500

Hello everyone.
I took a look at how custom messages can be designed in ROS and I realized that they can just include fields of predefined types (for instance, integers and strings).
Instead, I have two active nodes needing to communicate with each other. One of them, produces a list of objects belonging to a class that I have defined. This list should be sent to the other node but I guess it's not possible using standard ROS messages.
Could you suggest a way to bypass the problem, maybe using possible definitions of ROS messages?

Thanks for help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-12-13 03:53:40 -0500

Lorenz gravatar image

updated 2012-12-13 04:22:34 -0500

Custom messages can contain other (custom and predefined) messages. That's a required and widely used feature in ROS.

Example:

Message MyCustomMessage in package foo:

string name
geometry_msgs/PoseStamped pose

Message ObjectList:

 foo/MyCustomMessage[] objects
edit flag offensive delete link more

Comments

hi, thanks for answer. just to be sure: you are telling me that I can have a field of superclass Object[] in my custom message? It would be amazing. Why this possibility is not shown here: http://www.ros.org/wiki/msg ?

ubisum gravatar imageubisum ( 2012-12-13 04:10:16 -0500 )edit

Not really a "superclass", more a "containment" relation. One message can contain fields defined by other messages. I agree that the wiki should explain it explicitly. Maybe open a defect ticket for the wiki.

joq gravatar imagejoq ( 2012-12-13 04:18:33 -0500 )edit

Maybe Object was not the best choice for the example. You could replace object here by MyCustomMsgType.

dornhege gravatar imagedornhege ( 2012-12-13 04:21:38 -0500 )edit

ok, I knew about encapsulation of message. Anyway, I guess that the most encapsulated message in the hierarchy has to contain simple types listed in wiki guide. so, for trying to understand better, if I have an object List<Node>, where Node is a class defined by me, how should a message appear...

ubisum gravatar imageubisum ( 2012-12-13 04:25:55 -0500 )edit

... to contain that list? thanks for your support.

ubisum gravatar imageubisum ( 2012-12-13 04:26:34 -0500 )edit

mypkg/Node[] nodes

dornhege gravatar imagedornhege ( 2012-12-13 04:38:21 -0500 )edit

ok.i created a message in a file:

int id
scan_node[] sc_nodes
odom_node[] od_nodes

i saved it as measurement.msg in my pachage's directory msg I uncommented rosbuild_genmsg() in CMakeLists file and I got this error:...

ubisum gravatar imageubisum ( 2012-12-14 03:32:21 -0500 )edit

... IOError: [Errno 2] No such file or directory: '/home/ubisum/fuerte_workspace/beginner/msg/int.msg'
what happened?

ubisum gravatar imageubisum ( 2012-12-14 03:35:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-12-13 02:51:13 -0500

Seen: 711 times

Last updated: Dec 13 '12