ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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.

Thanks.

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

Comments

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

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

How can this be done?

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

2 Answers

Sort by ยป oldest newest most voted
8

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

Comments

2

Thank you, I needed to rebooting.

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

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

Question Tools

1 follower

Stats

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

Seen: 5,075 times

Last updated: Aug 08 '14