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

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

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

nemesis gravatar image

Hello,

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 joint_angle_workout.py jaco "<<table[i][0]<<" "<<table[i][1]<<" "<<table[i][2]<<" "<<table[i][3]<<" "<<table[i][4]<<" "<<table[i][5];
system(rosrun.str().c_str());
rosrun.str("");

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
1

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

updated 2015-06-29 16:06:16 -0600

I searched for your package name and found this:

https://github.com/Kinovarobotics/jac...

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.

http://wiki.ros.org/ROS/Tutorials/Wri...

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

edit flag offensive delete link more

Comments

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 -0600 )edit
1

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: http://wiki.ros.org/ROS/Tutorials/Wri...

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

Oh ok. Thank you so much for your help!

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

You're Welcome ;-)

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

Question Tools

1 follower

Stats

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

Seen: 1,423 times

Last updated: Jun 29 '15