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

How to get versions in package.xml from roscpp codes

asked 2016-04-14 17:14:22 -0500

okku gravatar image

Hi. I would like to know if there is a way to get versions inside roscpp codes. I want to print out the software version of node when it is launched, automatically referring manifest file. Any hints, comments are welcomed. Thanks in advance.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-04-24 22:36:51 -0500

ahendrix gravatar image

updated 2016-04-24 22:37:13 -0500

Buried deep in the catkin documentation there is a note that after calling catkin_pacakge(), the package version is available as a cmake variable that is named after your package: <packagename>_VERSION

You could make this available to C++ code using the add_definitions cmake command, like:

    # any arguments to catkin_package here


This uses the -D option to the compiler, which is equivalent to a #define.

You could use the version in your code as a string, for example:

ROS_INFO("Package version is %s", mypackage_VERSION); // replace mypackage with your package name
edit flag offensive delete link more


Cool! This is what I wanted. Worked perfectly on my ROS Indigo environment.

okku gravatar image okku  ( 2016-04-25 07:10:45 -0500 )edit

answered 2016-04-18 03:41:41 -0500

bluking gravatar image

You can use node handler to get the information of launch file, so you can add version information to your launch file.

edit flag offensive delete link more


It'll be much helpful, if you can read versions directly from package.xml, so that you don't have to write same version number to both xml and launch file. But thank you for information.

okku gravatar image okku  ( 2016-04-22 16:50:16 -0500 )edit

answered 2016-04-24 23:12:24 -0500

130s gravatar image

Another way to get the version defined in package.xml is to do the same/similar as rospack does. Example can be seen in this PR. It parses vector instance that contains info retrieved from parsed package.xml. Not intuitive nor convenient at all, but it's also C++.

edit flag offensive delete link more


For my study, thank you.

okku gravatar image okku  ( 2016-04-25 07:09:39 -0500 )edit

Question Tools


Asked: 2016-04-14 17:14:22 -0500

Seen: 1,380 times

Last updated: Apr 24 '16