0
$\begingroup$

Rosanswers logo

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?


Originally posted by nemesis on ROS Answers with karma: 237 on 2015-06-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I searched for your package name and found this:

https://github.com/Kinovarobotics/jaco-ros/blob/master/jaco_demo/nodes/jaco_demo/joint_angle_workout.py

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/WritingServiceClient%28c%2B%2B%29

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


Originally posted by cyborg-x1 with karma: 1376 on 2015-06-29

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by nemesis on 2015-07-28:
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"

Comment by cyborg-x1 on 2015-07-29:
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/WritingServiceClient%28c%2B%2B%29

Comment by nemesis on 2015-07-30:
Oh ok. Thank you so much for your help!

Comment by cyborg-x1 on 2015-07-31:
You're Welcome ;-)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.