Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This can be done using the roslaunch launch-prefix option in the node tag. For example, if you user has passwordless sudo enabled, you could try:

<node pkg="my_pkg" type="my_node" name="my_super_node" launch-prefix="sudo"/>

If you don't want to set up passwordless sudo, and your node doesn't change very often, you could try setting the setuid bit on it, so that it runs as root even if started by a non-root user. The only trouble with this is that you'll have to reset the permissions whenever your node changes, and it generally won't be deployable through debs, and it will only work for compiled nodes; not for scripts.

cd devel/lib/my_pkg     # cd to the directory with your node
chown root:root my_node # change ownship to root
chmod a+rx my_node      # set as executable by all
chmod u+s my_node       # set the setuid bit

Note that both of these methods will unset LD_LIBRARY_PATH before executing your node (it's a security feature of glibc). This means that your node will either need to be statically compiled, or you'll need to turn on RPATH during the compilation process, so that the library search path is included in your executable rather than relying on the environment to be set up correctly.