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

running bash in a launch file

asked 2012-08-31 09:56:55 -0500

DocSmiley gravatar image

I have a robot with 2 identical cameras that I need to distinguish between at runtime. The only thing that tells me which is which is the serial number and which of the two ports they appear on is random.

Not a problem. I have a script that will check that for me and will return 0 or 1 depending on which camera it detects on which port. I have also tried it with 'true' and 'false'

I'm trying to use this in my launch file so that when the robot starts up it auto detect and configure the ports.

<param if = "$bash (find uvc_camera)" name = "left/device" type = "string" value = "/dev/video1"/>

When I run this I get:

Invalid <node> tag: $bash (find uvc_camera) is not a 'bool' type.

The page says:

"All tags support if and unless attributes, which include or exclude a tag based on the evaluation of a value. "1" and "true" are considered true values. "0" and "false" are considered false values. Other values will error. "

Has anyone tried to do something similar and if so how do you get ROS to recognize the bool?

Ros Electric, Ubuntu 11.10

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-08-31 11:43:37 -0500

jbohren gravatar image

updated 2012-08-31 12:06:13 -0500

So, while all nodes can have guard attributes ("if" and "unless"), you can't execute arbitrary code inside of roslaunch xml attributes. That's why what you're trying isn't working. Also, this is a feature, not a bug. If people could execute arbitrary stuff in launchfiles, the roslaunch semantics would go out the window. Then light turns to dark, life to death, forever.

deleted terrible idea that should never influence anyone

Do you think you could incorporate the magic in "" into uvc_camera and post a patch that gets the camera via UID defined in a ros parameter?

You could do this:

<param name="device" command="$(find uvc_camera)/"/>

And make "" output the full device path.

edit flag offensive delete link more


Honestly, the whole setup is sufficiently hacky that I'm not sure I could do that.

DocSmiley gravatar image DocSmiley  ( 2012-08-31 11:50:11 -0500 )edit

Yeah, I don't know what I was thinking.

jbohren gravatar image jbohren  ( 2012-08-31 12:08:19 -0500 )edit

I tried what you've suggested but the command= just gives me errors in the ending with OSError: [Errno 13] Permission denied. I tried using value but that just gives me the filepath for

DocSmiley gravatar image DocSmiley  ( 2012-09-03 03:15:48 -0500 )edit

What's the contents of, and what are the file permissions? I tried this with my own bash script, and it worked for me.

jbohren gravatar image jbohren  ( 2012-09-04 04:16:14 -0500 )edit

Have you done chmod +x

Hippomormor gravatar image Hippomormor  ( 2016-11-22 13:31:48 -0500 )edit

answered 2012-09-02 15:56:27 -0500

weiin gravatar image

updated 2012-09-02 15:56:50 -0500

Not quite sure how your cameras are connected, but I'm guessing since you have a script to get the serial number, you could do a udev rule instead. You can create a symlink for each camera eg /dev/camera/camera_id and your launch param just uses this symlink.

eg for PR2 Hokuyo:

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


Asked: 2012-08-31 09:56:55 -0500

Seen: 3,143 times

Last updated: Sep 02 '12