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

rosrun inside a script

asked 2018-06-24 23:59:17 -0500

lr101095 gravatar image

updated 2018-06-25 00:20:26 -0500

ros kinetic, ubuntu 16.04, intera 5.2 for a sawyer simulation, gazebo 7,

I want to be able to run a python script from an already running python script, and i'm not sure if this is possible and if what i've read already explains what i'm looking for.


rosrun pkg

inside, i want to run

What is the equivalent of rosrun inside a python script?

Since i'm asking about this, i might as well ask, how could i do the same inside a C++ script?

Any information is much appreciated.

Thanks in advance.

~ Luke

edit retag flag offensive close merge delete


Why would you want to do this?

jayess gravatar image jayess  ( 2018-06-25 00:20:05 -0500 )edit

@jayess i have an inverse kinematics script that determines a required pose of a sawyer arm. so after the pose is achieved, i want a separate script to take over which is written independently of the IK script to be called.

lr101095 gravatar image lr101095  ( 2018-06-25 00:22:20 -0500 )edit

Not sure if starting a node inside another one is the correct way to solve your issue, but you can have a look to python subprocess

GuillaumeB gravatar image GuillaumeB  ( 2018-06-25 09:23:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-25 00:32:21 -0500

jayess gravatar image

updated 2018-06-25 00:33:45 -0500

I think that there's a "ROS way" to do this (if there is such a thing), or at least a couple of ROS ways. Instead of having your node start another node, why not just use topics, services, or actions?

For example, you can have the node that's solving the inverse kinematics (IK node) publish its status on a topic and the node that takes over subscribing to that topic. When the IK node publishes that it's task is complete, the next node gets the message and takes over.

This way will give you some extra flexibility in that you change swap out nodes and remap topics etc.

edit flag offensive delete link more


I've thought about doing something like that, but i was hoping there was a simpler way to go about it. I'll see if i can manage to use what you suggested and i'll let you know how it goes

lr101095 gravatar image lr101095  ( 2018-06-25 02:27:37 -0500 )edit

I would actually recommend using services in this case: the IK task is probably self-contained (solve for a given EEF pose) and the control flow of the caller should be blocked by the callee (ie: caller should wait for completion). That is what services do. Actions would be more complex.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-25 03:18:26 -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: 2018-06-24 23:59:17 -0500

Seen: 107 times

Last updated: Jun 25 '18