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.
How about you try to open the ports in .bashrc file ?
How can this be done?