0
$\begingroup$

Rosanswers logo

Hi,

is there a way (possibly in Python) to call the command line command rosmsg show from code, passing as an argument the name of the message/service and getting an object representing the message/the class with the message structure? I know that some commands can be called from rospy (as rostopic list, for example), but I can't find how to run rosmsg.


Originally posted by McKracken82 on ROS Answers with karma: 73 on 2016-12-05

Post score: 1


Original comments

Comment by NEngelhard on 2016-12-05:
What do you really want to achieve? This sounds like an xy-problem

Comment by McKracken82 on 2016-12-05:
I need to build instances of all the ros messages and services in a KB, so I need to understand which are all the messages/services being published, and which re their structures in terms of submessages/primitive types.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The command line tool calls a single function (https://github.com/ros/ros_comm/blob/6a0672c0189024e38bfe51d917dea148f76fccf7/tools/rosmsg/scripts/rosmsg#L34-L35) which you can call directly in Python.

You could also call any API which is using behind this directly, e.g. rosmsg_cmd_show (https://github.com/ros/ros_comm/blob/6a0672c0189024e38bfe51d917dea148f76fccf7/tools/rosmsg/src/rosmsg/__init__.py#L745).


Originally posted by Dirk Thomas with karma: 16276 on 2016-12-05

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by McKracken82 on 2016-12-06:
Great, that was exactly what I was searching for, although I thought messages were managed in a more object-oriented like structure. Anyway, that worked perfectly. Thanks!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.