ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

Rosrun as super user

asked 2014-08-08 04:35:57 -0500

trc123 gravatar image

updated 2014-08-08 05:09:43 -0500

Hello, I have some code in my ros node (within a catkin workspace) that requires super user privilege in order to access some serial ports. How can this be done as sudo does not work with rosrun.


Edit: This is using the admin account:

$groups ros
ros : ros adm dialout cdrom sudo dip plugdev lpadmin sambashare
edit retag flag offensive close merge delete


How about you try to open the ports in .bashrc file ?

sai gravatar imagesai ( 2014-08-08 04:37:21 -0500 )edit

How can this be done?

trc123 gravatar imagetrc123 ( 2014-08-08 04:43:00 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-08-08 04:47:48 -0500

gvdhoorn gravatar image

updated 2014-08-08 05:19:38 -0500

You should really not use sudo with rosrun. It leads to all sorts of nastiness with permissions.

For serial ports (and access to other hardware through /dev/xxx) you just need to give the relevant user (most likely your user) access to the device file (fi: /dev/ttyS0). This is not ROS specific.

See How do I allow a non-default user to use serial device ttyUSB0? on the Ubuntu stack-exchange for instance.

For ROS specific answers: google: linux serial ports udev access, which gives you:

Edit: and just for completeness (and for the lazy), a quote from the first answer to the question on the Ubuntu stack-exchange:

As you've noticed, the /dev/ttyUSB0 device has the group of dialout. All you need to do is add the second user to the dialout group:

sudo adduser USERNAME dialout

Note: you need to log out and back in for your user groups to be reloaded.

edit flag offensive delete link more



Thank you, I needed to rebooting.

trc123 gravatar imagetrc123 ( 2014-08-08 05:22:40 -0500 )edit

answered 2014-08-08 04:45:43 -0500

AFAIK the best way is to change (privilege) mode with udev rules, so that maybe every user can use this serial devices.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-08 04:35:57 -0500

Seen: 1,419 times

Last updated: Aug 08 '14