Determine path to executable
I want to determine the absolute path to a binary I built. With rospack find
I can get the path to the package itself. However, finding the path to the executable is much harder: In the devel workspace it usually is in <workspace>/devel/lib/<project>
but when the package is deployed and installed to ${CATKIN_PACKAGE_SHARE_DESTINATION}
it is located directly in <install prefix>/<project>/
.
In both cases I can run that binary with rosrun <package> <binary>
but I did not find a way to get the corresponding path.
Is there a portable way to get the absolute path to a binary?
I can think of a "portable" way for this.. Why would you want to to this? Maybe there is another workaround for your problem!?
Portable here means "working for both development workspaces as well as installed packages." I do not loke workarounds where I have to add if/else clauses at every place where I want to get the absolute path to my binary.
Still, want do you intent to do with the path? Usually you do not need to know the path as rosrun and roslaunch do locate the file for you!
I want to run the binary by using the absolute path. I have to run the binary as quickly as possible as we measure the elapsed time of certains tasks. For that reason I want to avoid rosrun as it traverses the whole filesystem (I assume via
rospack find
, which can be relatively slow).catkin_find
uses a similar logic as tools likerospack
. It also needs to crawl the filesystem.Ok, thanks. Yes,
catkin_find
works for me, but only if I sourced all devel workspaces, while rosrun apparently finds its packages viaROS_PACKAGE_PATH
.