[ros-users] catkin support in python rospkg
Brian Wightman
brian.j.wightman at nasa.gov
Thu Jan 17 20:59:46 UTC 2013
In rosbuild I was able to use rospkg to grab all of the [cflags, lflags]
exports out of a given package's manifest. Is there a plan to add this
functionality for catkin packages?
My use-case may sound a bit odd:
I have been using scons rather than cmake to build packages. The rospkg
manifest.xml parsing makes this rather painless (20 lines of python to
collect all the build flags). Now with the "exports" buried in cmake
files, I don't have a convenient way to access them.
In particular, I have code that forwards ROS messages between systems
with separate roscore instances. I have to compile in a
publisher/subscriber call for each message type so I've found it
convenient to auto-generate the HPP/CPP files from a list of
message-containing packages (std_msgs, sensor_msgs, etc.) using Python
and rospkg.
If anyone's curious, here's the scons build code I've been using:
import os, rospkg
def load_ros_deps(env):
pkg_name = os.path.basename(Dir('.').srcnode().abspath)
depends = []
for d in map(repr, rospkg.RosPack().get_manifest(pkg_name).depends):
depends.append(d)
# load exports
manifest = rospkg.RosPack().get_manifest(d)
for f in [j for j in [manifest.get_export('cpp', i) for i in ['cflags', 'lflags']] if j]:
allf = f[0].split('`')
for conf in allf[1::2]:
env.ParseConfig(conf)
env.MergeFlags(env.ParseFlags(' '.join(allf[0::2])))
pkg_path = os.path.dirname(manifest.filename)
msg_path = os.path.join(pkg_path, 'msg_gen', 'cpp', 'include')
if os.path.exists(msg_path):
env.MergeFlags(env.ParseFlags('-I{}'.format(msg_path)))
env = Environment(
ENV = {'PYTHONPATH': os.environ['PYTHONPATH'], # allow us to call rosboost-cfg
'PKG_CONFIG_PATH': os.environ['PKG_CONFIG_PATH']},
...
)
Certainly I can achieve the same thing with CMake, but I find scons to
be much nicer to work with.
Thanks,
Brian Wightman
More information about the ros-users
mailing list