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

Is using stringstream a recommended option for executing "rosrun" command upon execution of a C++ code?

asked 2015-06-29 15:48:23 -0500

nemesis gravatar image


I am trying to work on a project with some pre-existing code. The original author used stringstream to execute rosrun commands. Here is part of that code -

stringstream rosrun;
rosrun<<"rosrun jaco_demo jaco "<<table[i][0]<<" "<<table[i][1]<<" "<<table[i][2]<<" "<<table[i][3]<<" "<<table[i][4]<<" "<<table[i][5];

Where the "table" is just angular input to the Jaco Manipulator.

I wanted to know if the above is recommended as per ROS or not. I am going through nodes, topics, publishers, subscribers, messages and such. The above doesn't seem the best possible way to me for some reason though.

What would you recommend I could do here?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-29 16:05:38 -0500

updated 2015-06-29 16:06:16 -0500

I searched for your package name and found this:

Is it that node?

Seems to just send some actions to another node.

I guess the better way would be to use a client and call the service directly instead of calling that script with cpp.

According to itself, it is """A helper program to test cartesian goals for the JACO and MICO arms."""

edit flag offensive delete link more


The script I have posted above is required because it's part of a bigger set of commands. So the above gets called, followed by something else, and loops for example. I wish to know if calling it off using stringstream is good enough or something better can be done which is more "ROS-like"

nemesis gravatar image nemesis  ( 2015-07-28 13:45:22 -0500 )edit

Yes as I wrote do it with calling the services inside your node directly their arguments. Check out the function code, its a script that calls the services. You can do that directly in your code without stringstreams:

cyborg-x1 gravatar image cyborg-x1  ( 2015-07-29 03:56:00 -0500 )edit

Oh ok. Thank you so much for your help!

nemesis gravatar image nemesis  ( 2015-07-30 13:47:49 -0500 )edit

You're Welcome ;-)

cyborg-x1 gravatar image cyborg-x1  ( 2015-07-31 03:28:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-29 15:48:23 -0500

Seen: 1,333 times

Last updated: Jun 29 '15