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

how can I "shell programming" in launch file?

asked 2013-05-28 22:02:15 -0600

Mohsen Hk gravatar image

Hi! I alwasy run some command in terminal like:

sudo chmod 777 /dev/USB0
sudo chmod 777 /dev/ACM0

but how can i do this in launch file, when i ask roslaunch expamle.launch it call this shell programming for once?

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
9

answered 2013-05-29 05:38:58 -0600

ahendrix gravatar image

You should really configure your system so that you don't have to manually modify device permissions on startup.

For serial devices on most Linux systems, that usually just means adding yourself to the proper group that has access to the serial device, or modifying the udev rules.

You can verify which group has access to the devices by doing ls -l /dev/ttyACM0 /dev/ttyUSB0 ; then add yourself to that group. For example, on Ubuntu the group is dialout, so you would do:

sudo usermod -a -G dialout USER
edit flag offensive delete link more

Comments

Please note that you need to log-out and log-in again (or reboot your pc) for this changes to take efffect! After that, it works like a charm here...

koenlek gravatar image koenlek  ( 2014-04-24 01:22:41 -0600 )edit
1

answered 2013-05-28 22:40:57 -0600

DamienJadeDuff gravatar image

updated 2014-04-17 19:55:58 -0600

Put these commands into an executable shell script (let's call it yourscript.sh) somewhere inside the package directory (let's call the package yourpackage) and then reference that script inside your launch file (e.g. example.launch):

<node name="nodename" pkg="yourpackage" type="yourscript.sh">
edit flag offensive delete link more

Comments

1

Actually roslaunch direct_path_to_.launch_fileis possible. See roslaunch -h ;-)

felix k gravatar image felix k  ( 2013-05-28 23:11:30 -0600 )edit
1

@Mohsen Keep in mind that this 'script node' is started with all others in parallel. So while usually the chmods will be done before any node even starts thinking about those /devs, the worst case might be that every other node has started (and perhaps crashed) before the first chmod is called

felix k gravatar image felix k  ( 2013-05-28 23:19:53 -0600 )edit
1
  • For sudo, you'd need to enter password. From the command, it seems you should set that up with udev. For the devices you use, it might also be sufficient to do adduser &lt;USER&gt; dialout.
dornhege gravatar image dornhege  ( 2013-05-29 02:15:14 -0600 )edit

When I use the above <node pkg="hast" type="yourScript.sh" name="yourScript"/> I get an error: ERROR: cannot launch node of type [hast/yourScript.sh]: Cannot locate node of type [yourScript.sh] in package [hast]. Is an entry to the CMakeLists file necessary?

benabruzzo gravatar image benabruzzo  ( 2014-04-14 07:45:53 -0600 )edit

Is the script executable?

dornhege gravatar image dornhege  ( 2014-04-15 04:21:42 -0600 )edit

Fixed the answer, thanks felix k. My answer is not a good one anyway. ;)

DamienJadeDuff gravatar image DamienJadeDuff  ( 2014-04-17 19:56:30 -0600 )edit
0

answered 2014-04-24 02:26:06 -0600

koenlek gravatar image

I agree with ahendrix answer: you should add yourself to the dialout group: it is most convenient and proper in my opinion.

For those that search for a way to run scripts or delay, see my answer here: http://answers.ros.org/question/51474...

edit flag offensive delete link more
0

answered 2013-05-29 05:20:12 -0600

Bill Smart gravatar image

Similar to the other answer, but the other way round. Create a shell script that sets your permissions (as described above), but make the last line of this script

roslaunch example.launch

Then just run the shell script.

edit flag offensive delete link more

Comments

...but, you should really implement the solution in Austin's answer, since that's the Right Thing to do.

Bill Smart gravatar image Bill Smart  ( 2013-05-29 05:45:32 -0600 )edit

Question Tools

Stats

Asked: 2013-05-28 22:02:15 -0600

Seen: 4,723 times

Last updated: Apr 24 '14