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

stdout to stdin pipe using launch-prefix?

asked 2017-09-19 13:44:32 -0600

lucasw gravatar image

updated 2020-11-21 12:17:21 -0600

I'd like to use launch-prefix to pipe the stdout of a program (netcat) to the stdin of a ros node.

It works fine when launched from rosrun:

netcat 10.0.0.10 8001 | rosrun foo stdin_to_msg.py

I can also copy the command line that roslaunch generates (determined by ps -aux | grep stdin_to_msg.py) and run that successfully, but when run in the launch file the stdout from netcat is sent to the stdout of the roslaunch terminal if output="screen" (or nowhere if not, or a log file?), and the node itself never starts.

<node name="stdin_to_msg" pkg="foo" type="stdin_to_msg.py"
    launch-prefix="netcat 10.0.0.10 8001 |" output="screen"/>

Probably I can wrap this in a bash script and run that from roslaunch, but I'm curious if there is an in-launch solution.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-09-19 20:07:11 -0600

tfoote gravatar image

For what you're trying to do it would require roslaunch to do string concatenation and then execute it in bash. For using subprocesses that's generally not recommended due to potential security vulnerabilities. It instead is directly calling the executables and appending arguments directly.

If you do want to do the piping and other bashisms writing your stuff into a bash script is what I would recommend.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-09-19 13:44:32 -0600

Seen: 1,064 times

Last updated: Sep 19 '17