Get the ros version installed using python code
Hello,
May I know which python package to used to find the ros version name and the detailed version number installed in my linux box.
TIA
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hello,
May I know which python package to used to find the ros version name and the detailed version number installed in my linux box.
TIA
I have found the version numbers just by looking at the ros_master's 'package.xml' and 'common.h' in the roscpp package.
That is exactly how rosversion -d
does it. See here:
mm = ManifestManager(PACKAGE_FILE)
path = mm.get_path(args.package)
package_manifest = os.path.join(path, 'package.xml')
if os.path.exists(package_manifest):
from xml.etree.ElementTree import ElementTree
try:
root = ElementTree(None, package_manifest)
version = root.findtext('version')
except Exception:
pass
an ugly way to grep the version name is to create a subprocess
pipe with the rosversion -d
(or rosversion pkg_name
for package version) command:
new_proc = subprocess.Popen(["rosversion", "-d"], stdout=subprocess.PIPE)
version_str = new_proc.communicate()[0]
Asked: 2019-10-16 15:25:14 -0500
Seen: 1,237 times
Last updated: Oct 17 '19
Autoware.ai 1.12.0 core planning
Why I can't launch robot in RViz after following a tutorial? Cant find launch file
rosbag to npz or h5 conversion
unable to plot or print anything from python script in ROS
getting various error (exit code -11, -6, bad_alloc) trying to use RPLIDAR code
How to project LiDAR point cloud (3D) onto the 2D image?
ROS_INFO can't print a ROS message?
Are you specifically restricted to python or is bash OK?
And are you assuming you have sourced the setup file or not?
yes i'm trying to understand only in python and I have sourced setup.bash file. I have found the version numbers just by looking at the ros_master's 'package.xml' and 'common.h' in the roscpp package. But I wanted to just use the information in my python application.
If you know what files theyre in, you can easily use python to crawl those files and extract the versions