Lua: fixing broken rttros.find_rospack (please read if you use it!)


the lua rttros.find_rospack function is failing with fuerte and newer
when the rttlua-gnulinux binary is running with elevated privileges
(e.g. setcap). This is because in that case the linux kernel unsets
LD_LIBRARY_PATH for security reasson, which in turn leads to rospack
not finding which is in a non-standard location. Argh...

The solution is to determine the package path using RTT's rtt_rospack
service (instead of calling os.execute("rospack find ...")). This
works fine, but has the drawback that rttros no longer is independent
of rtt. I can't imagine this really being a problem for anyone, but if
it is, speak up now.

The new version looks as follows:

local rtt_rospack_find=false
function find_rospack(package)
if not rtt_rospack_find then
if not (rtt and rttlib) then
error("find_rospack: not an rttlua _or_ rttlib not loaded.")
depl = rttlib.findpeer("deployer") or rttlib.findpeer("Deployer")
if not depl then error("find_rospack: failed to find a deployer") end
local res = rtt_rospack_find(package)
if res~="" then return res else return false end

The updated version can be found in my git repo: